Jump to content

Recommended Posts

Posted
2 hours ago, Gunners TekZone said:

So this time I am sticking with a single Int-A and an RCX Serial tower.  Here are some observations...

- No "Save As" option.  I must remember to change the name of my saved program after the fact.

- A saved program doesn't retain and reconnect device connections... This one had me doing a bunch of troubleshooting before realising that all the device allocations in my test program were listed "No RCX" and "No Lego B", thus requiring the manual reconnection and assignment of all devices in the program.  Or doing such device connection (presumably in correct order?) prior to reloading a saved program.

- On a wim, I tried having two RCX's online at the same time... Half expecting them to just be recognised as a single unit (for simple in-coming commands at least).  But as soon as I turn the 2nd one on, the program stops running, and will not restart without turning off (any one) of the "extra" RCX bricks.  Now, I was using the "While Rcx1 alive?" loop, so that might be a factor?

I am guessing that in order to have multiple RCX bricks running, one needs a dedicated IR tower for each?  It has been a long time since I messed with these little yellow bricks, but I thought these had some form of internal ID and could run multiples on a single tower?

Hello @Gunners TekZone, glad to see you back testing!

- No Save As.  Indeed, for now I wanted to keep it VERY simple.  But I take good note of that...

- A saved program doesn't retain and reconnect device connections.  But the Name is retained as long as you connect your device BEFORE loading your saved code. 

As fas as I know, there are no UNIQUE ids for connections and Chrome does not provide the "Com" port number used...  I've heard they might give more flexibility in a future version of the web serial api...
Anyway, for now, the procedure is, you need to connect to a device to use its Auto generated Device Name in Lego Blocks.  For RCX, actually, the Brick does not have to be powered really but the IR tower has to be connected.
I still have a note to improve eventually the Device Naming and connect etc.
But again, for now, it is VERY simple, Device Name are generated when you connect them, and the Device you select in Lego Blocks are retained in the saved files...  But if you load your file when no device connected, the blocs will select no device...

It may become difficult if you have many devices, so you may have to take notes LegoB1 is COM19, Rcx1 is COM5, LegoB2 is COM12 etc... 

I tried having two RCX's online at the same time:  I do not think 2 RCX with the same IR Tower can work... in parallel...  I cannot test as I have only one but I do not see the gain...  However, 2 IR tower, opposite direction, might work independantly.  The MSG instruction trick here is the best I think.

 

Thank you very much for your observations and suggestions.  Always VERY appreciated!


 

Posted
6 hours ago, Bliss said:

added a FOOTER and the version should now be: Version: 2026-03-29-1947

It does work with the "installed" version :steve:

8 hours ago, Bliss said:

When you drag a function block into the code area

Wait... What code area ? *huh*

Posted (edited)
7 hours ago, Bliss said:

I do not think 2 RCX with the same IR Tower can work... in parallel...  I cannot test as I have only one but I do not see the gain

Once I removed the RCX1 Alive? constraints, then YES multiple RCX bricks DO work (So far three of them, 2x 1.0 and 1x 2.0,  all working as one)... At least as for testing outputs only (I haven't tested inputs yet, but probably the same).    As for gain, well perhaps when needing to do many of the same thing.  Eg. multiple track switching, lighting, etc or other motorized applications where one brick is not close enough (and without resorting to long leeds), or doesn't have enough needed outputs?  Or a form of simple choreographed dance with multiple little yellow wheeled "bugs" on the floor :pir_tong2:   I duno... I just like options :innocent2:  (Granted, the IR tower range and angle becomes the limitation)

Edited by Gunners TekZone
Posted
18 minutes ago, Gunners TekZone said:

Once I removed the RCX1 Alive? constraints, then YES multiple RCX bricks DO work (So far tree of them, 2x 1.0 and 1x 2.0,  all working as one)

@Gunners TekZone

Wait: "All working as one" means that all three RCX' turn their outputs on, when the program says ouput_X on (with no ID), right?

According to https://www.mralligator.com/rcx/opcodes.html#set_motor_on_off the RCX reply to an output_X on command is 0xD6/0xDE, which all three RCX' should send back.

@Bliss Does your program read back the RCX replies ("receipts"), which they emit after successful instruction submission? In my VB6 programs based on the IVPBrick COM Interface, this issue (arrival of multiple receipts from different RCX') did clog IR traffic. Also, LEGO software (e.g. ScriptEd) does not recognize the replies as they are not synched, and thus assumes something went wrong.

Which also means that all three RCX will emit their sensor data upon request at the same time, wouldn't they? I simply don't get how it should work otherwise. Interesting! 

Best
Thorsten

Posted (edited)
49 minutes ago, Toastie said:

Wait: "All working as one" means that all three RCX' turn their outputs on, when the program says ouput_X on (with no ID), right?

Yes.  AFAIK this was normal operation with other programs (it is with the IR Remote Control).  
You can just barely see the LCD indicators showing the Port A activation.  BTW, I am using a different Interface-B then the one shown in this pic.

2026-03-30-01.08.28.jpg?rlkey=fjbneszj4i

@BlissI did attempt to try a IF X OR Y input routine, to see if the RCX inputs act the same... But the RCX input block (or at least what looks like the closest match) will NOT connect??


2026-03-30-01.05.03.jpg?rlkey=6ucqug59y2

Edited by Gunners TekZone
Posted
38 minutes ago, Gunners TekZone said:

it is with the IR Remote Control

Yes, the IR remote does also not check for any reply, so it should turn on the respective output of any RCX/Scout in range.

My main point is that you can't directly control individual RCX' when there are more than one in IR range of one or more than one IR towers without running a messaging protocol between RCX' and computer. As far as I know. OK, and when pointing towers into different direction of course, so the RCX' do only see one signal source.

As said before, I have many RCX and Scouts doing work on my train layout. Each has an IR/RF transceiver on board, and my computer sends 2 byte messages into the ether, but only one of the PBricks will recognize its ID.

Best
Thorsten  

 

Posted (edited)
13 hours ago, Gunners TekZone said:

but I thought these had some form of internal ID and could run multiples on a single tower?

 

1 hour ago, Toastie said:

My main point is that you can't directly control individual RCX' when there are more than one in IR range of one or more than one IR towers without running a messaging protocol between RCX' and computer

Yes, I understood they can blindly all work the same.  But was wondering if they could be (eventually if not already) recognised and controlled individually in Blocky... Hence my roundabout query to @Bliss

However, I don't think he is able to look into this with only one RCX in his possession...

So I will not worry about it myself... I am just testing for the moment as I do not have a "real world" case to use this at the moment.  Alas... Too many other projects on back burners.  And anyhow, making a nicely complex setup is beyond my mental/physical focus *huh*   For now.

Edited by Gunners TekZone
Posted

@Gunners TekZone, @Toastie,

I do check for replies and even have three retries...  But after 3 retries, if I do not get any reply, well, I just send an error to the chrome console (Press F12 to see the console) and keep going...

I'll check if I display an error in the status window, might not do it at the moment.

But the thing is, I do not stop the program for this.

For the Rcx Input Value block, it does not return a boolean as I showed in a previous post, if the Input is configured as a touch sensor, it will return 0 or 1. 
See the example in post:

 

Posted

@Bliss

this is all simply amazing and incredibly nice work! The functions function :steve:

One more question regarding functions: Lets say I have this block:

400x108.jpg

which does what it should do, but only with the right variable block attached. Is the variable "Sensor_3" only passed to the function when it is explicitly attached to the function block? If so, what does the information "with: Sensor_3" in the function block mean?

11 minutes ago, Bliss said:

I do check for replies and even have three retries...  But after 3 retries, if I do not get any reply, well, I just send an error to the chrome console (Press F12 to see the console) and keep going...

Ah, I see! Nice! 

But how would the Blockly program cope with two contradicting data (lets say Sensor_1 on RCX1 says closed, Sensor_1 on RCX2 says open)?

I shall break out two fo my RCX and the serial tower ...

And finally: With all you really advanced programming knowledge, do you see any change of reviving the USB tower? It needs a 64bit driver ...

All the best
Thorsten  

Posted
17 minutes ago, Bliss said:

For the Rcx Input Value block, it does not return a boolean as I showed in a previous post, if the Input is configured as a touch sensor, it will return 0 or 1. 
See the example in post:

Ah, sorry, I had missed that (and probably many other) details during my groggy reading stages :innocent2:

Posted (edited)
3 hours ago, Toastie said:

@Bliss

this is all simply amazing and incredibly nice work! The functions function :steve:

One more question regarding functions: Lets say I have this block:

400x108.jpg

which does what it should do, but only with the right variable block attached. Is the variable "Sensor_3" only passed to the function when it is explicitly attached to the function block? If so, what does the information "with: Sensor_3" in the function block mean?

Ah, I see! Nice! 

But how would the Blockly program cope with two contradicting data (lets say Sensor_1 on RCX1 says closed, Sensor_1 on RCX2 says open)?

I shall break out two fo my RCX and the serial tower ...

And finally: With all you really advanced programming knowledge, do you see any change of reviving the USB tower? It needs a 64bit driver ...

All the best
Thorsten  

This function you gave in example, does not make a lot of sense though.

The input variable should be "Sensor", then when you call the function, you connect Sensor_3 to Sensor, and later in your code, you may call again you function but this time, Sensr_4 connects to Sensor...
Inside your function, you whould then only use "Sensor" variable.If you want to explictely use Sensor_3 inside the function, there is no need to use input variable...  just use Sensor_3 variable already available as a global anyway.

 

For the USB Tower, since I don't own one yet, I did not check what work has been done already to get it working on modern OS...

 

9 hours ago, Wapata said:

Wait... What code area ? *huh*

The code area, I mean the Blockly code area where you drag blocks from the toolbox to make you blockly program.

Edited by Bliss
Posted

@Gunners TekZone, @Toastie, @Wapata and all the others,

I added the "Save As" button.  The "clear" button has been replaced by a "New" button. (New Project).  Which will clear the area and put back the project name to default.

The last Folder used should be retain in a same session only.  If you close and open the lego blockly page, it will revert to default folder (Downloads) until you save as or load a project...

The save button will always now overwrite the same project file name.

I also added the "New Edits" detection since the last save and you will have an "unsaved changes exist" indicator (Black Dot) on the left of the file name.

When Unsaved edits exist, you will be asked for confirmation when you click on Load or New button...

Latest Version: 2026-03-30-1212

Posted (edited)
2 hours ago, Bliss said:

The input variable should be "Sensor", then when you call the function, you connect Sensor_3 to Sensor, and later in your code, you may call again you function but this time, Sensr_4 connects to Sensor...
Inside your function, you whould then only use "Sensor" variable.If you want to explictely use Sensor_3 inside the function, there is no need to use input variable...  just use Sensor_3 variable already available as a global anyway.

I see.

Does that mean though that in your example "Sensor" is local to the function? If the definition of the input to a function becomes automatically global, then the inputs to a function are not needed at all, as one can simply define the variables outside the function, right? Here is an example, where I use "Sensor" as a global variable; the same for "OutputFwd" and "OutputRev", which I use as text/integer variables. Variables can take on any format, right? Float, integer, string, etc?

Furthermore, I believe you mentioned somewhere, that when using the output commands "LEGO B1 out" with a variable other than given in the drop-down list (A-H), you have to use output numbers either as such or formatted as string, e.g., output A = "1", B = "2", or simply 1 and 2 as integers, and so on, right? At least it works that way in the code below: The first two calls to ChangeOutputs work, the third does not:  

640x544.jpg

Best
Thorsten

Edited by Toastie
Posted (edited)

@Toastie

Quote

Does that mean though that in your example "Sensor" is local to the function?

No, I don't think so.  The Sensor variable appears in the variable category, so it must be global.
Don't forget that the basic of blockly is to make it easy for children.
But still, doing it this way makes the program neat...

 

Quote

Furthermore, I believe you mentioned somewhere, that when using the output commands "LEGO B1 out" with a variable other than given in the drop-down list (A-H), you have to use output numbers either as such or formatted as string, e.g., output A = "1", B = "2", or simply 1 and 2 as integers, and so on, right? At least it works that way in the code below: The first two calls to ChangeOutputs work, the third does not:  

I'm suprised that  "3", "7" is working... As I said, they made it very simple so you don't need to think about conversion etc...
You cannot use a Text directly in the Set Output ON block.  But using a variable before might do the conversion internally of text number into number...  But it will not convert a Letter to a number.

However, if you still want to assign output port letters to your OutFwd and OutRev variable, you can still use the "Constant" variable that I provide for you to use anywhere in your program.

They are in the Lego B -> Output Single Port Category at the top.

chrome_gWV4W7K6KR.png

 

Edited by Bliss
Posted
3 minutes ago, Bliss said:

Don't forget that the basic of blockly is to make it easy for children.

I need to ask my 8 years old child to help me then... :sweet:

Or check if there is Blockly tutorials in english or in french, i thing i'm missing some beginners tips.

Posted (edited)
13 minutes ago, Wapata said:

i thing i'm missing some beginners tips

Initially I thought the same, but just trying things out really helps.

I also like the "it looks prettier" very much!

Best
Thorsten   

18 minutes ago, Bliss said:

Don't forget that the basic of blockly is to make it easy for children.
But still, doing it this way makes the program neat...

Absolutely! I love it.

I did not know that Blockly was also designed for children! That makes absolutely sense then. Of course, type definition and conversion is somewhat elaborate. However, on super computers such as the C64, TI99/4, the Sinclairs or even on an original XT, integer math really speeds things up. I guess, this is far less of an issue today ... good to know. 

I have no problem at all with all variables being global - you simply have to pay attention. In addition, you are providing powerful blocks, so that messing around with variables and such is much easier.

Thank you very much for the clarification - it renders things much more comfortable.

Best wishes
Thorsten 

Edited by Toastie
Posted

I just noticed that if you take too long to create a variable with its Dialog window, or using the confirm diablog window , it actually blocks the background programs and eventually, the Lego Interface disconnects.

As soon as we connect a Lego Interface B, it starts reading continuously the 19 bytes streams...

So this is interrupted by those modal dialog window...

I'll try to find a fix for this and let you know.

 

Posted
6 minutes ago, Bliss said:

I just noticed that if you take too long to create a variable with its Dialog window, or using the confirm diablog window , it actually blocks the background programs and eventually, the Lego Interface disconnects.

Well it is absolute >luxury< that it works as it works right now! 

When I stop my programs (in QBasic :pir_laugh2:) to just take a brief look at the code, the Interface disconnects and of course has to be reinitialized every time! So I consider any arbitrary disconnect as absolutely normal, and I am every time surprised that it does not anyway.

Best
Thorsten 

@Bliss

It does look much prettier - and works.

640x1129.jpg

Best
Thorsten

Posted

@Toastie,

I think you'll have your Blockly Expert Certificate very soon ;-)  You're progressing fast!

You will become our Blockly teacher and teach to Wapata!  Do you speak French?  (I do as I'm french canadian if you didn't notice my accent in my writing lol)

 

The new version should fix the blocking dialog window problem now.  (I replaced the built in prompts and confirm dialog with new custom ones)

Version: 2026-03-30-1519

Posted

@Bliss

Nope, it is the other way around! You are the creator of these tools and thus of course the teacher!

Spoiler

With regard to Canadians/Canada: Research wise, we do collaborate with quite diverse Canadian groups. All these people are extremely friendly, forthcoming, and always helpful. This includes people I regard as role models (senior researchers at SCIEX in Toronto, they are providing us with rather expensive research equipment, and we try to get some of their issues into the clear - seems to work), PIs at UBC, and so on. Some of my graduate researchers did spend some time at UBC campuses, in Kelowna ...

Accent wise I am out. I am from Northern Germany. Make it almost South Denmark ;) When we lived in Southern California, some students told me that I "sound" like an Australian ...

French? Oh, that reminds me ... ( @Wapata I AM SORRY!) - almost 50 years ago :innocent2:, the school system in Germany radically changed. High school students were allowed to wildly choose their preferences, at age 14 or 15 - for me, it was Chemistry, Physics, Philosophy, and Art, with Political Science as a filler. Thrown out: French, English ...

For some reason, your visual Blockly interface connects with my brain. I don't know why, as I love BASIC, VB6, some "applied C++". NXT's visual wiring system (NI's LabView based) also worked for me, but it sooner than later always crashed miserably when I was trying to run more complex programs.

Inline declaration of variables (a NO GO in informatics), automatic variable type conversions (a NO GO in informatics), functions = subroutines = procedures (a NO, OK, we know), THAT is my world. The reason is: My programs are at best "scripts making it work". I don't do real programming. I do use tools others provide, and try to get away with. So far, it worked ;) At least taking a look at divers programming environments gives you a glimpse of what is possible and be what is so "common".

Well, you have encouraged me to try this route (and you know I was reluctant) - and you were right!

All the best
Thorsten 

    

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...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...