Bliss
Eurobricks Citizen-
Posts
107 -
Joined
-
Last visited
Content Type
Profiles
Forums
Gallery
Everything posted by Bliss
-
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Hello @AJB2K3, I do have a Lego interface B that I try sometimes to "interface" with it using modern technology :-) I did some VB Net, C# try out in the past. But if you want to do Control Logics that have outputs and inputs interacting together, it is not that simple. Blocky based programming may be more appropiate though... I was planning to try interfacing the Lego Interface B with an ESP 8266 or better, ESP32. ESP32 is cheap and has WIFI, Bluetooth, UART (Serial) etc... So I decided to go ahead after your posts :-) I have a M5Stack Core2 (ESP32 and M5Stack have UIFlow programming IDE that uses blocky) and I have many ESP32 Dev Board as well. So I started with an ESP32 Dev Board and flashed it with the latest MicroPython Binary. I'm using Thonny as an IDE but I guess there are many others good IDE. Since ESP32 UART is TTL and Lego Interface B is RS232, you need to get a RS232 to TTL converter module (MAX3232): Like this ONE. The cable I use is a straight DB9 to DB9, not nul modem in this case. Between a PC and the Lego Interface, I needed a null modem cable... About your code and my experience with the Serial Protocol of the Interface B: - Before writing the lego start string to the serial port, I empty the read buffer. - after sending the lego start string I check the read buffer until there are at least 31 bytes available because the successful started string reply has 31 characters long. You may implement a timeout to make things better. - After Lego has sent the "###Just a bit off the block!$$$" started string, it will start to fill the RS232 read buffer with 19bytes long block of data. (You should not "Flush" the read (or write) buffer.at this point..) # MicroPython code for ESP32 import machine from machine import UART uart = UART(1, baudrate=9600, tx=17, rx=16) uart.init(9600, bits=8, parity=None, stop=1, txbuf=256, rxbuf=1000) uart.read() uart.write(b'p\0###Do you byte, when I knock?$$$') while uart.any()<31: pass LegoReply=uart.read(31) if LegoReply==b'###Just a bit off the block!$$$': print('Lego STARTED') - If there are no glitches on your serial link, your code could just wait until Read buffer has at least 19 bytes than you read the 19 bytes, treat them and loop... while True: if uart.any()>=19: LegoReply=uart.read(19) print(LegoReply) - To be full proof, It would be better to program some validation, like the checksum of the 19 bytes that should be "FF" hex (0xFF or \xFF) If checksum not good, then discard first byte and read another one to make it 19 byte again and recheck the checksum. Loop if necessary. To check the sum: IF (sum(LegoReply) & 0xFF == 255). (& 0xFF: Sum will be 2 bytes long but only first byte is needed to be check against 255 (FF hex)) - Some lego lab docs says the block of 19 bytes always starts with "\x00\x00" so you could also seach the block of 19 bytes for ""\x00\x00"", if not at position 0, then, read the missing number of bytes out of the serial. For example, if you read 19 bytes, but "\x00\x00" is at position 3, discard the first 3 bytes and read 3 more bytes. - Unfortunately, lego lab docs do not always mention it clearly but the 19 bytes block does not always start with "\x00\x00". It can start with "\x10\x00" if the big red stop button is pushed on the interface while communicating. (Red led above the red button blinking fast). - Also, the second byte is not always \x00. In fact, every bit of this byte represent the status of output ports command. For ex.:, Sending command to activate Output A and C, the second read byte should be \x05 (00000101). So you will need more validation code here but this would make the process stronger. Hope this might help some... -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
@AJB2K3 Did you configure you serial communication correctly? I read somewhere: 9600 baudno flow controlno parityno modem control linesone stop bit8 bit data Yves -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
You may find some information on the net about alternative to the original software. For exemple: https://www.shamlian.net/projects/dacta/ (Provides Links and what seems to be a Dacta.zip that contains what seems to be some Python language stuff) The later URL has some interesting links about the reverse engineering of this interface. One of the links is from Anders Isaksson who also offers a little windows executable to test you interface which I recall having used successfully in the past: http://www.blockcad.net/dacta/ Another cool software to test your Interface B: https://www.lgauge.com/technic/LEGOInterfaceB/9751.htm I do have the RoboLab software that works on Windows 95 (And MAC) but it seems to be in french only. Other links of interest: https://www.dajlab.org/jcontrollab.html I also did play around on my own years ago with this interface and used the information provided by others to program some VB.Net stuff that you can still find here: https://app.box.com/shared/xc44rksi2h Yves -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Monivae, This 9751 works with older 9V sensors and motors. It is still worth if you have also a bunch of these 9V sensors and motors and have also recuperated the 9V power supply to power the 9751 unit. It is worth because this unit has 8 inputs and 8 outputs which makes it interesting if you have fixed projects requiring lots of motors, lights, sensors. You can even plug many to your computer to multiply to number of Inputs and Outputs. This unit communicate with a computer using serial port RS-232. So you need to buy USB-to-RS232 Converter for each 9751 you want to connect to your computer. The quantity of unit you can connect at the same time depends really how many USB port you have available. (I assumed you have newer computer that have no RS232 built-in port anymore). You also need a serial cable that you might also have been able to recuperate from the original unit. If you don't have the original serial cable, probably a standard null modem cable will do the job (Male DB9 plug at one end, female at the other end. May need sex changer). Once you have a unit connected to your computer and powered on, then you can use software provided here (Bricklab.zip) to test the Inputs and Outputs. You can also use this other software to test a 9751 unit: http://www.lgauge.com/technic/LEGOInterfaceB/9751.htm Once you managed to get it to work with the test software, let us know here and we can discuss further how you can make your OWN program that controls the inputs and outputs the way you want to... -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
I uploaded a new version of the Lego IntefaceB Modbus IO Server Gateway. https://app.box.com/shared/xc44rksi2h This version (V2) supports the use of TWO (2) InterfaceB on the same Modbus Server. I have only one InterfaceB so I did not test with 2 but I tested lego1 et lego2 independantly. This means you can program a PLC Application with OpenPLC that uses 2 Lego InterfaceB, i.e. twice as much Inputs and Outputs... -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
I played with VB.Net about 10 years ago to get connected to my Dacta 9751 InterfaceB... Was fun project... But still, the language is not a real "Automation Friendly" one like we have in industrial automation. I would have liked to be able to program this little baby using simple "Ladder" language. Then, while browsing the internet recently I found out the OpenPLC project and that gave me an Idea... The OpenPLC supports the 5 languages according to IEC 61311-3. - Ladder (the most popular I believe) - SFC (Sequential Function Chart, or Grafcet, the best for sequential process) - FBD (Function Bloc Diagram. Has it's strenght... for me it's more for analog process and calculation) - ST (Structured Text, as in C) - IL (Instruction List... I don't use this one really) The OpenPLC supports the Modbus TCP protocol to communicate with I/O's. Since there are some Modbus Library code freely available, I had the idea to make a Modbus IO server with the Lego InterfaceB. I did not used my VB.Net but rather re-used the C# .Net code provided by: http://www.lgauge.com/technic/LEGOInterfaceB/9751.htm I modified it, improved the reading perfomance by using a continuous thread and stripped some code a bit, and I integretated the EasyModbusTCP Library and here we have a Modbus IO Server (Slave) using the Interface B. I then used some Modbus tool, like a Modbus Client simulator (Modbus Master) like the one provided by Radzio to test it. Then, I Installed the OpenPLC software as per their very clear instructions on their website and managed to build quickly a ladder program using Interface B I/O's... And it's very very performing. very fast response time. If anyone interested, here is my source code. (Exe is in the Bin\Release folder.). Please, read the Readme file. https://app.box.com/s/f1rpaucw84nd24md1neuuj8is4vuqmv2 In a near future, I would like to make it work with more than one InterfaceB... -
I'm Yves from Montreal city, Quebec province in Canada. While I don't consider myself a true AFOL as I don't build big mocs, I still love legos and I love to find out the unlimited creative talent of others. I'm not into castle, themes etc. I'm more into buildings, vehicles, technics (I have many technic sets... not the recent ones). I've been working in the industrial Automation fields (PLC = Programmable Logic Controller) for 30 years and I also own few mindstorms sets :) But I did not really "played" much with them yet. I've been off of the scene for about 10 years but recently, I stumbled on my old Lego Interface B (9751 - 70909) and had an Idea. 10 years ago or so, I did some VB.Net project to control this old baby. Was OK, certainly better than nothing but still lacking of some friendly programming language like we have in Automation. Then I had an idea to revive the Interface B. I'm going to share in the proper section if I can find it :) Here's my old brickshelf gallery: http://www.brickshelf.com/cgi-bin/gallery.cgi?m=YvesLev
- 2 replies
-
- technics
- mindstorms
-
(and 3 more)
Tagged with: