Mats's blog

Rotary encoders using Gray code

Mats's picture

Servos often use potentiometers to measure the position. That works fine if you have a good quality potentiometer. A different alternative is to use an optical or mechanical decoder. You can find examples of 3D printed rotary encoders here:

It's made in two variants.

Natural encoded ( i.e. simply using binary form where a hole represents 1 and no hole = 0). 

Gray code. Gray code has the advanage that only one bit changes for each step of the rotation.

Install problems on 1843

Mats's picture
If you try to install MRL on later versions you will get this type of error and the logfile will fill up very quickly. 
My logfile went to 1.5 G in just a few seconds.
16:45:23.670 [webgui] INFO c.m.f.Service [] subscribe [python/p
ublishState ---> webgui/onState]
16:45:23.795 [New I/O worker #7] INFO c.m.s.WebGui [] POST /api/m
16:45:23.796 [New I/O worker #7] INFO c.m.f.Service [] subscrib

Using a phone for sound input

Mats's picture


A very nice way to use MRL from the phone is to use the webgui. But you must have access to a WiFi network for this to work. ( Not really. But you must be able to reach the host where MRL is running from your phone, could be anywhere in the world ).

1. Make sure that your instance of MRL running with the WebSpeechRecognition and the WebGui started. For example you can use this script. It starts a chatbot. with sound input and output. You don't need any servos or anything else to make this work So you can try it without any extra hardware: 

Using RemoteAdapter to connect two MRL instances

Mats's picture


Today I continued testing RemoteAdapter to be able to connect two MRL instances executing on the two Rapberry PI computers that I have. 


Uploading MRLComm to the Arduino

Mats's picture

A short video showing how to upload MRLComm.ino to the Arduino using the Arduino IDE.

It is also possible to upload it using the WebGui, but I prefer to do it this way, since it's easier to understand what's happening.

A little video that explains about i2c and the different devices that can be used in MRL

Mats's picture

I have been working on adding support for i2c to MyRobotLab during the spring and a bit of the summer.

So what is i2c ?

It's a very simple 2 wire addressable serial protocol. So you can, in theory, connect up to 126 different devices on the same 2 wires. You can find many different devices that use the i2c protocol. For example servodrivers, ad converters, gyro accelerometers, power measuring devices, LCD and OLED screens, temperature measuring devices, real time clocks and so on.

i2c interface and Arduino

Mats's picture


We had a lot of fun yesterday working together on MRLComm and Arduino. Four people ( Grog, kwatters, camality and me ) working on the same sourcecode, discussing different options and ways to make the software better and add some more functionallity.

Sometimes we think in different ways, and sometimes its difficult to explain in a short shoutbox. So creating a post to describe something that is a bit larger is necessary. So thats what I'm doing now to explain the way I think about the i2c interface and the device drivers. Any comments are welcome. 

Software reset in Arduino

Mats's picture


To avoid runaway tasks in MRLComm if MRL is closed, this code could be exected when MRLComm detects that the contact with MRL has been lost.

void(* resetFunc) (void) = 0;  // Define the reset function at address 0

resetFunc();  // Call the reset 
It will then end up in the initial setup() and reinitiate. So all pins will be reste to their initial state and the communicaiton will go into it's initial state.