Jump to content
THIS IS THE TEST SITE OF EUROBRICKS!
THIS IS THE TEST SITE OF EUROBRICKS!

Featured Replies

10 hours ago, Gunners TekZone said:

I am looking forward to testing your legob.py script!!

this driver does not require the pythonnet (no need to import clr) nor the legoClassB dll...

But it is not guaranteed to work on win 7...

I like python, but from one version to another, they may change the name of properties and method and makes your program not working...

Edited by Bliss

Not a problem.  I like what you have done so far with the .net Script, for it's apparent compatibility, stability and multi-device use.

I will treat this raw Python version as a separate entity in testing and operation.

Edited by Gunners TekZone

I cannot include images anymore in my posts since few days...

But in the command codes from this link: https://www.blockcad.net/dacta/,

Quote

3p	00110ppp		Turn output port off.
3P	00111ppp		Turn output port off.

the first 3p 00110ppp will coast to stop a motor (free wheel)

3P 00111ppp will brake stop a motor

Edited by Bliss

58 minutes ago, Bliss said:

I cannot include images anymore in my posts since few days...

Where are your images hosted?

Best,
Thorsten

4 hours ago, Toastie said:

Where are your images hosted?

Best,
Thorsten

Well, I often just copy / paste from my screen capture software...  or I'll save as a GIF on my pc...

Usually it will tell me that the image too big...  But now it just tells it encountered a problem ...

Best not to copy/paste images directly into a post.  Eurobricks doesn't "host" images and has a limited allowance for attachments. 

That was how I ran into issues on my prior account.  As when someone's quote includes your image, you can delete the original, but not from the quote.  However, it still counts toward your attachment allowance.

I use the "Insert other media" button and "insert image from URL" option... Using a link from my public folder on Dropbox.

Edited by Gunners TekZone

@Bliss

Yes, as @Gunners TekZone said, EB does not host images. The small attachment "allowance" is more or less for stuff you put on your "account".

I am very happy with bricksafe.com. Uploading pictures is per drag and drop from your computer. Then just hover over an image, right click copy url, paste into EB post and the picture appears (you can also have just the link inserted). If the picture is too large, double click it and adjust the size to your needs.

Best,
Thorsten

Thank you both.  I removed images from some of my previous posts...

Next time I'm going to use bricksafe or other mean.

 

@Gunners TekZone, @Ax4478, and for who might be interested.

I got an RCX brick few days ago with its Serial IR Tower and I managed to find in this forum and google some information.

The following link seems to be the most complete to explain the serial protocol and list all opcodes etc...

https://www.mralligator.com/rcx/

So I started to make a Python driver and right now I have a draft version that takes care of only output commands (Not all yet but some interesting ones).
I will refresh the following link as I add features and fix errors that you may find :-)

link for LegoRcx.py python driver for RCX brick serial communication.

Note that this is not for the USB version.  Only the serial RS-232 IR Tower.

You can use the shell in Thonny IDE or any other shell like the one that comes with python.  I personally use Thonny.

Copy the LegoRcx.py in your working folder (that you navigate to in the Files left pane of Thonny for ex).

Then in the Shell:

>>> from LegoRcx import RCX
>>> rcx=RCX("COM1")  # use the com port for you IR Tower
>>> rcx.snd(1) # should play BEEP BEEP
>>> rcx.mot(rcx.A).on()  # run motor on output A
>>> rcx.mot(rcx.A + rcx.B + rcx.C).on()  # run motors A, B, C
>>> rcx.mot(rxc.B + rcx.C).off()  # stop motors B and C (Brake)
>>> rcx.mot(rcx.A).float()  # coast to stop motor A
>>> rcx.mot(rcx.A).on()
>>> rcx.mot(rcx.A).r()  # Set reverse direction.
>>> rcx.mot(rcx.A).f()  # Set forward direction.
>>> rcx.mot(rcx.A).flip()  # flip direction.
>>> rcx.mot(rcx.A).pow(0)  # Set speed to minimum  pow(7) is the Maximum

>>> rcx.prg(5)  # Set program #5  (can use 1 to 5)

>>> rcx.close()  # Shutdown serial communication and any threads gracefully.

About the prg method, since I have no program in the brick yet, I can see the program number changing but I do not know of it will actually run the program too.  I have not seen a Run program command in the list of opcodes.
However I saw commands to start tasks...  I do not yet know the structure of the programming of the RCX...


I guess I should post further development for the RCX Python driver in another forum thread?
Maybe this one?  

 

Edited by Bliss

33 minutes ago, Bliss said:

I guess I should post further development fo the RCX Python driver in another forum thread?
Maybe this one?  

That is a good idea!... But due to the Python programming language (and the length of that older topic) I recommend you copy your last post and start a fresh topic for this new RCX/Python mashup, as @Toastie recently did for his BASIC one.

Edited by Gunners TekZone

3 minutes ago, Gunners TekZone said:

What firmware did you load onto the RCX?  Or is it just using the base ROM (which does nothing in my tests).

 

I loaded the firmware firm0332.lgo.

I think remote commands do not work without a firmware.

 

 

Just finishing loading it now... It has been awhile since I used any of mine :)  Looking forward to this!!

WORKS NICE!

Edited by Gunners TekZone

1 hour ago, Bliss said:

I guess I should post further development for the RCX Python driver in another forum thread?

@Bliss

I think, this thread is for 9751 - and RCX stuff should certainly go into another thread. I also believe this topic deserves its own thread! We should not further derail this one.

However, before doing so, you should define your goal first. You are saying, you want to create an RCX Python "driver". Is it that? Or do you want to add another programming language/environment (Python) as interface to load (LEGO) byte codes into the RCX? Or do you want to integrate RCX features into your 9751 control program?

I am asking, because when you use that LEGO 332 firmware, you are essentially sending LEGO byte codes to the RCX, and that one then interprets the list of byte codes that it received (and acknowledged) via its IR interface. But this is not really a driver, is it? The H8 microcontroller inside the RCX then does what these can accomplish.

Now, there are at least two rather powerful comprehensive programming environments for the RCX that have "C-like" programming structures: NQC within the BricXCC IDE and RobotC. The former produces native LEGO byte codes and was developed by Dave Baum, the latter relies on a custom firmware made by Dick Swan. Back in the days, I was in contact with both. In the beginning, NQC was "extended" to match with the new byte codes, Dick's firmware provided, but then RobotC came into play. I have about 10 RCX (and 5 SCOUTs) programmed in both "languages". Both environments run on modern (Win11) machines without any problem (as per install) - but naturally only with the serial IR tower, as there is no USB driver for the USB tower (freely) available.

RobotC's firmware is about 10–100 times faster than all LEGO's firmwares. It is available on the net for free with ample of documentation. Since long there is no further development of RobotC for the RCX, but both IDEs are rather mature and "flawless" in terms of reliability. The speed of RobotC allowed me to program even a PID algorithm (running as a separate task) controlling the power delivered to train motors to achieve more or less constant speed, when the load changes (friction etc.)

Let me know if you want some program examples ("multi" tasking etc.) or other resources, I am happy to share!

Best,
Thorsten

2 hours ago, Toastie said:

@Bliss

Now, there are at least two rather powerful comprehensive programming environments for the RCX that have "C-like" programming structures: NQC within the BricXCC IDE and RobotC. The former produces native LEGO byte codes and was developed by Dave Baum, the latter relies on a custom firmware made by Dick Swan. Back in the days, I was in contact with both. In the beginning, NQC was "extended" to match with the new byte codes, Dick's firmware provided, but then RobotC came into play. I have about 10 RCX (and 5 SCOUTs) programmed in both "languages". Both environments run on modern (Win11) machines without any problem (as per install) - but naturally only with the serial IR tower, as there is no USB driver for the USB tower (freely) available.

 

Hi @Toastie - I use this version of nqc which comes with USB tower support, without a requirement for a seperate driver install (at least on macOS, which is what I use). You may find it useful. https://github.com/BrickBot/nqc

Hi @Mr Hobbles

Holy cow! How on Earth could I have missed that? My goodness. I updated BricxCC regularly (back then until 2011) just to learning now, the NQC was not necessarily updated within that package as well - I thought it was. Stupid me.

However, I guess the missing 64bit driver for Windows remains an issue using the USB tower on my computer - at least I believe so. I never found a suitable 64bit driver for that tower other than building my own using NI software - but that miserably failed, partly also because I was unsure about permission to do so. I gave up on that many years ago.

EDIT Wait: You are saying it works without additional driver? Ohh, I shall try that!

Thank you very much for that link!!!

All the best,
Thorsten

 

Edited by Toastie

@Mr Hobbles,

no, just tried, NQC can't find a USB or serial port - device manager tells me that the tower does not have any driver. I guess, on Windows, it simply wants a 64 bit driver for the tower. But that is OK; I have the USB tower running on my Toshiba 1998 laptop and the serial tower on my Win11/64bit laptop.

Best,
Thorsten

Edited by Toastie

@Toastie

Thanks for feedback on that matter.

Is it a driver? maybe more a communication gateway? 

Right now I just want make a dumb interface with the RCX like the Lego Interface B is.  So sending through communication commands to activates outputs basically.
For the moment, I do not read any acknowledgement from the RCX but I will probably add this feature, not for the acknowledgement for the commands Python sends when we want to activate outputs but to ask for the status of RCX inputs like we do for Interface B.

The basic goal to achieve is allowing interactions between multiple old serial lego interfaces and also interaction with the external world using ethernet (MQTT as an exemple).

Example:
- A master Python program running on a PC that has many serial ports and have ethernet connectivity and integrates MQTT client "driver" as well as Lego Interface B serial driver and RCX "serial driver" and maybe more (web server etc).
- An IKEA zigbee button might send a signal to your smart home hub like Home Assistant that has MQTT broker addon installed.
- an automation in the smart home hub could then send a special MQTT topics that your python main program has subscribed to.
- Upon receiving the MQTT topic, the Main program could then start some sequence of events that is:
- Send commands to RCX1 to activate a sound, then change the position of a lego train switch by sending a command to activate output A of RCX1, and then start a lego Train by sending a command to Lego Interface B #1 to activate its output # H.
- Python main program train sequence may wait for a light sensor to be received from Lego Interface B # 2 and than ask the RCX 1 to activate output #2 (antoher train switch or a light ).

The Python main program could also ask an RCX to activate an RCX Program that would have been previously loaded into the RCX memory with Brickx / nqc.

So for now it is really to make python act like a mindstorm remote control for RCX at some point.  But eventually with more features...
I have no intent to make another RCX language.

This 332 firmware is interesting as it allows to send/receive data with the RCX and also to run programs executing on the RCX (programs writen with nqc from brickx or writen with original lego software)...

Many questions remains for me that I will answer through more testing/reading/from other member's help:
If there is a program running on the RCX, does it still listen to Remote serial commands (can we still sens motor commands)? 
Is it possible to stop a program remotely?  (haven't seen yet an opcode to stop a running program, but I saw stop task...)
Does RobotC firmwares allow the same serial communication protocol than 332 firmware? 

 

Maybe the best, would be to create a thread titled: Using python as a hub to communicate with old lego interfaces (RCX, Lego Interface B, and maybe more?)
Then, we could talk about Lego Interface B, RCX etc and even maybe other "Driver" in the future provided by others like Interface A etc...  (That I do not own unfortunately)

EDIT:
I just created:

 

 

Edited by Bliss

On 1/8/2025 at 11:48 PM, Gunners TekZone said:

I am still probably a week away from getting my third one, but it is at least in Canada now :)

Alas... My 3rd Interface-B arrived, but was also DOA...

I guess having only two working Interface-Bs will have to do... 1st world problems :D

Edited by Gunners TekZone
Belatedly realised most of my post wasn't relevant to this topic. Tee hee hee opps

2 hours ago, Gunners TekZone said:

My 3rd Interface-B arrived, but was also DOA...

Oh NO! Merde (EB's Watch Your Language Police or WYLP has never caught it - in contast to shyt with i :pir-tongue:)

But you are an expert in fixing Interface B's! Totally dead does not mean totally dead - so much for the logic - but that could be a power supply/regulator failure ... cross my fingers!

All the best,
Thorsten

On 1/15/2025 at 5:54 AM, Toastie said:

But you are an expert in fixing Interface B's! Totally dead does not mean totally dead

Hah... Thanks.  It does seem to be a looming "profession".

The 1st one was a simple resistor bypass in the device's Serial Transmission circuit.  But this 2nd one is not so simple... Something is really wrong in the circuit. 

But I was just able to prove a way to make it work again :pir-triumph: So a little bypass and transplant surgery is in order 

But gotta wait until I am feeling well enough for the delicate soldering.  And I think I will open up a new topic to document the repairs for others, as I am thinking this might be a more common issue in "dead" interface-B's that power up, but don't function. 

I'll drop a link here when that happens.

Edited by Gunners TekZone

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.
Sponsored Links