In this guide I will show you how to control the Lego Dacta Interface B on an OSX 15.0.1 Sequoia based machine. This was not easy and gave me a few headaches to start.
This may look like a distraction but once I work out how to do it on a computer, I can order the RA232 module from M5Stack for the M5GO and attempt to control the interface from the M5GO.
Serial to RS232 Adapter and Driver.The biggest headache with this unit is that modern computers don't have RS232 ports anymore and so adapters are required. I picked up a cheep UGreen adapter off amazon, plugged it in and hit an issue.
The adapter uses the Prolific PL2303 adapter chip and while a driver come in the packet, modern devices don't have optical drives!
I went online, searched the inter webs and downloaded the driver, tried to install it and found it blocked by the system.
The solution (well sort off) was that a working driver is actually found in the App Store.
You need to install the driver package from here and then run the app to install the driver.
Once this is done the driver is still blocked. to unblock it you need to open the control panel and go to General.
Click on the Login and Extensions options and scroll down to the “Extensions“ section and then click on the “I” symbol next to Driver Extensions.
In this window you should find the PL2303 driver is available but not enabled. Click on the slider to enable the driver, click done to close the panel and then close all panels.
Next we need to find the port. Make sure you have the latest Python installed with PYSerial and open the terminal. Next type in the following command:
python -m serial.tools.list_ports
and hit return.
In the above screenshot you can see that the driver is enabled and detected as:
/dev/cu.PL2303G-USBtoUART24110
Programming in PythonNow that the driver is installed and working we can now start writing code to "poke" the Interface B. I started Using IDEL which is the REPL Shell which comes with a python install but changed to Thonny shortly after.
In order to start communicating with the Interface B we first need to initialise a serial connection. The code used requires access to the PYSerial Library which is normally preinstalled in Python.
First we import the library with:
import serial
And then we need to configure the port.
By default pyserial configures the communications port with the following setting:
9600bps, no parity, 1 stop bit
But doesn't pass the port name to use. To pass the port name which will be used with the above settings us the following code in Python.
ser = serial.Serial(port='/dev/cu.PL2303G-USBtoUART24110')
Next we need to wake up the Interface B by sending the following message in bytes:
ser.write(b'p\0###Do you byte, when I knock?$$$')
If everything is configured correctly then the red LED next to the "Stop" button will go out. This did not happen for me and it took me several day to realise that it was the cables pin connecting to the Interface B. I dug out some Male to Female Dupont jumpers out and connect between the cable and Interface B so that pins 2 and 3 are swapped over.
if the light goes out we can check the response by sending:
print(ser.read(31))
Which will return the response:
###Just a bit off the block!$$$
If you leave the interface for more then two seconds without sending or receiving the LED will come back on and the Interface B will have disconnected.
In order to stop this I created a loop with the following code:
while True:
ser.write(b'2')
time.sleep(1)
In order to read the Interface B we need to send:
print(ser.read(19))
Which will return:
x00\x00\xff\xc8\x00\x8c\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xf6
Each line will always start with x00\x00\xff.
Initial Test Results.I connected the various Lego sensors to the Interface B and received the following results from the set.read.
For the Light sensor, I received:
b'\x00\x00\xff\xc8\x95L\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\x00\x17U'
b'\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\x00\x04~'
With the sensor connected to input port 5,
b'\x00\x00\xff\xc8\x95L\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xa1'
b'\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xb7
Connected to input port 6,
b'\x00\x00\xff\xc8\x95L\xff\xc8\x00\x17\xff\xc8\xff\xcc\xff\xc8\xff\xccU'
b'\x00\x00\xff\xc8\xff\xcc\xff\xc8\x00\x04\xff\xc8\xff\xcc\xff\xc8\xff\xcc~'
Connected to input port 7 and,
b'\x00\x00\xff\xc8\x00W\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc+'
b'\x00\x00\xff\xc8\x00\x84\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xfe
connected to input port 8.
I removed the light sensor and connected the touch sensor to input port 1 and received:
b'\x00\x00\xff\xc8\x95L\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xa1'
b'\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xb7
Input port 2:
b'\x00\x00\xff\xc8\x95L\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xa1'
b'\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xb7
without pressing the button and:
b'\x00\x00\xff\xc8\x95L\xff\xc8\xff\xcc\n\xd0\xff\xcc\xff\xc8\xff\xcc\x8e'
b'\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\n\xc0\xff\xcc\xff\xc8\xff\xcc\xb4'
With the button pressed.
I replied then that the data buffer wasn't being flushed and so I added the functions to flush the code and reran the code receiving changing values as expected.
Reference pages.I wouldn't be here if it wasn't for the people who went through all this effort before me.
Special thanks go out to the Eurobrick community found here:
https://www.eurobricks.com/forum/index.php?/forums/topic/67665-dacta-control-lab-software/&page=12
The messages found here: http://www.blockcad.net/dacta/
Battery Powered brick Youtube channel here: https://www.youtube.com/@BatteryPoweredBricks
And the Gauge site found here: https://lgauge.com/article.php?article=technic/articles/LEGOInterfaceB
Contact Me.Due to Issues with code and researching functions, this part has taken a lot longer than the other parts. If you find this useful then there is more crossover guides coming. You can drop a Message in Hackster.io message box below of find me via the following links:
https://twitter.com/Cpt_J_Purcell
https://bsky.app/profile/jamespurcell.bsky.social
On Discord (if I ever work out how to share the profile!)https://mastodonapp.uk/@AdamBryant
And on the M5Stack Facebook group and community forum.
If you have some spare change you can now buy me a tea @ https://bmc.link/ajb2k35
Comments