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
Thanks! It appears I forgot to fix the same error we had in the LegoDemoB program... Here is the Fixed LegoScriptB program I also corrected the Example codes in my posts above. Some of them were not working because of some hidden characters ... -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
import time Lego1.ComPort="COM1" Lego1.StartLego() Lego2.ComPort="COM2" Lego2.StartLego() time.sleep(1) Lego2.SetPow[1] = 7 Lego2.SetDir[1] = False while not cancellationToken.IsCancellationRequested: if Lego1.InOn[1]: Lego2.SetOn[1] = True else: Lego2.SetOn[1] = False time.sleep(0.020) -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
I updated my previous post and the dropbox link because I forgot to include properties InTempC and InTempF... By the way, the password for the EXE standalone zip file is lego. If you use the Start Stop button to connect your Lego Interface B Box, you do not need to connect it in the script by using StartLego() method. (But you can do it also, It will see it is already started). Then, If you have a temp sensor on input 3, you can just write the following script and Run it: print("Temperature (C): ", Lego1.InTempC[3]) print("Temperature (F): ", Lego1.InTempF[3]) -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Hello all. Happy new year! Here is a Draft of my C# project that embed IronPython as an attempt to make a programming environment for the Lego Interface B. Dropbox link : LegoScriptB for Programming Lego Interface B. It is based on my previous LegoDemoB project except that I removed all Lego Box Command Buttons and Status information. However, I left the Serial Start Stop buttons so you can still use them but it is not necessary as you can start and stop lego box from the script textbox. Features: - You can connect and use up to three (3) lego interface B. You can use Lego1, Lego2, Lego3 Variables. - Upon exiting the software, the last script in the textbox is saved. - In this version, there is no way to save to and load from files. - For now, I use Notepad++ to save some scripts in one file that I copy paste the parts I need in the Script textbox... - You probably can use many Python modules (import), for now I just used import time in my examples. - I will provide a text file eventually with all the Methods and Properties of the Lego variable. - You do not need to install Python. The exe is supposed to include all dependant libraries. - If your script has errors, the output box does not give very detailed msg. For example, it you forget a ":" colon for while or if, it will only log "invalid syntax". I'm trying to find a way to have more detailed error messages. I would suggest you try smaller parts of your code as it grows... Usual mistakes are lowercase, uppercase, indents, missing colon... How to use: - Be careful, Python is case sensitive (Lego1, True, False, print, while, etc) - In python, Indentation if VERY important. - You may comment your script with "#" symbol followed by you comment. - You enter your script in the "Enter you Python Script Here:" textbox. - To execute the script, click "RUN Script" button. - The Run Script button will be disabled during the execution of you script program. - The "STOP Loop Scipt" button is provided to allow to gracefully end an infinite While Loop. (See Example) - The use of while loop is tricky as you can be stucked in an infinite loop. You will have to shut down the whole Software. Please always use "while not cancellationToken.IsCancellationRequested:" rather than "while True:" Lego Variable Methods: - StopLego() : Stop Serial Communication with Lego box. Same as the STOP Button. Ex.: Lego1.StopLego() - StartLego() : Start Serial Communication with the Lgo box. Same as the START Button. (You must have set a valid COM port prior to use this method) Ex. Lego1.StartLego() Lego Variable Properties: - ComPort : Read/Write (R/W) COM port. Ex.: Lego1.ComPort = "COM14" - SetOn[OutPortNo] : (R/W), Where OutPortNo = 1 to 8 representing Output A to H. Ex.: Lego1.SetON[1] = True # Activates Output A. Lego1.SetOn[1] = False # Deactivates (BRAKES) Output A. - SetFree[OutPortNo]: (R/W), Where OutPortNo = 1 to 8 representing Output A to H. Ex.: Lego1.SetFree[1] = True # to inform to Coast to Stop then on a second line: . Lego1.SetOn[1] = False # Deactivates (Coast to Stop) Output A. - SetDir[OutPortNo]: (R/W), Where OutPortNo = 1 to 8 representing Output A to H. Ex.: Lego1.SetDir[1] = False # Set the direction of output A to CCW I think. If set to True, it's the opposite direction. You should set this property before SetON... - SetPow[OutPortNo]: (R/W), Where OutPortNo = 1 to 8 representing Output A to H. Accepts values 0 to 7. Ex.: Lego1.SetPow[1] = 7 # Sets the max power to Output A. - IsRunning: (Read Only), Tells if the Lego Box Serial Communication has been established, the Stop Led Light on the lego box should be OFF. Ex.: if Lego1.IsRunning: print("Lego Box is Running") - InOn[InputPort): (RO), Input port range is 0 to 8. 0 is the status of the Lego Box Stop Button. 1 to 8 are the Input port number. Reports True or False and follow the Led light status. Can be used for many sensors. Ex: if Lego1.InOn[1]: print("Lego1 input 1 is ON") - InVal[InputPort): (RO), Input port range is 1 to 8. 10 bit Value of input port. Ex. if Lego1.InVal[1] > 100: print("Input 1 value > 100) - InRotCW[InputPort): (RO), Input port range is 5 to 8. Status of the last direction reported by the rotation sensor. True (CW?) or False(CCW?). Ex.: if Lego1.InRot[5]: print("Lego 1 Input 5 Rotation ClockWise") - InRot[InputPort): (RW), Input port range is 5 to 8. Rotation sensor Count. You can Read or Set this property. Ex. Lego1.InRot[5] = 0 # Resets input 5 rotation sensor count to 0. if Lego1.InRot[5] > 48: print("Lego1 Rot Sensor 5 made at least 3 turns") - InTempC[InputPort] and InTempF[InputPort]: (RO), Input port range 1 to 4. Read the Temperature Sensor valur in celsius and fahrenheit. print(Lego1.InTempF[3]) # prints temp sensor value at input port 3. Script Examples: The following script connects Lego1 to COM14 port and prints the IsRunning status in the Output Log Textbox. Then it sets the power to max (7) and activates 4 outputs A, B, C, D. It Waits 3 seconds, then it Deactivates the 4 same outputs. Script ends. import time Lego1.ComPort="COM14" Lego1.StartLego() time.sleep(1) print("Lego 1 Running: ", Lego1.IsRunning) Lego1.SetPow[1] = 7 Lego1.SetPow[2] = 7 Lego1.SetPow[3] = 7 Lego1.SetPow[4] = 7 Lego1.SetOn[1] = True Lego1.SetOn[2] = True Lego1.SetOn[3] = True Lego1.SetOn[4] = True time.sleep(3) Lego1.SetOn[1] = False Lego1.SetOn[2] = False Lego1.SetOn[3] = False Lego1.SetOn[4] = False The following scipts has a While loop using the cancellationToken to be able to exit the loop with the STOP Loop Script button. You have to connect a Touch sensor to Input #1. You may connect a motor to Output 1. When executing the script, Press once on the Touch Sensor. The motor (Output 1) will Run for 3.5 sec, then stop for 1.5 sec, Reverse the direction, then start again for 3.5 sec and do this in a loop until you press again the Touch sensor. import time print("Script Running") Lego1.ComPort="COM14" Lego1.StartLego() time.sleep(1) print("Lego 1 Running: ", Lego1.IsRunning) Lego1.SetPow[1] = 7 Lego1.SetDir[1] = False seq_en=False wait_en=False m1=False # m1 is a memory used to simulate a ONE SHOT over the Input 1 to avoid hunting effect... print("Sequence Disabled") while not cancellationToken.IsCancellationRequested: if Lego1.InOn[1]: if not m1: m1=True if not seq_en: ti=time.time() + 3.5 seq_en = True print("Sequence Enabled") else: seq_en= False print("Sequence Disabled") else: m1=False if seq_en: if not wait_en: if time.time()<ti: Lego1.SetOn[1] = True else: Lego1.SetOn[1] = False tw=time.time()+1.5 wait_en = True else: if time.time()>tw: Lego1.SetDir[1] = not Lego1.SetDir[1] ti=time.time() + 3.5 wait_en=False else: Lego1.SetOn[1] = False time.sleep(0.020) # 20ms scan time. Not mandatory but I thought it might help ressources. Anyway, legobox scantime is around 20-30 ms Lego1.SetOn[1] = False Simple Loop script to make output 1 follow input 1 import time Lego1.ComPort="COM14" Lego1.StartLego() time.sleep(1) Lego1.SetPow[1] = 7 Lego1.SetDir[1] = False while not cancellationToken.IsCancellationRequested: if Lego1.InOn[1]: Lego1.SetOn[1] = True else: Lego1.SetOn[1] = False time.sleep(0.020) Can be even simpler: import time Lego1.ComPort="COM14" Lego1.StartLego() time.sleep(1) Lego1.SetPow[1] = 7 Lego1.SetDir[1] = False while not cancellationToken.IsCancellationRequested: Lego1.SetOn[1] = Lego1.InOn[1] time.sleep(0.020) -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
I updated the LegoDemoB in Dropbox. Added automatic Com port list refesh on clicking the dropdown of the combobox. Added colored Start/Stop Lego Box Buttons. LegoDemoB Program Dropbox Link -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
@Gunners TekZone, I updated the dropbox. For the slider position vs start/stop of the lego box, after a stop, it will reset to max, but when starting again the box, the slider will come back to the last position but not if you activate an output, it will use this setting not the max like before. If it is preferable, i could also after a stop reset all slider to the max and keep the max when clicking the start again. I'm talking here about start/stop of the box in a same session. If the program is shutdown and re-executed, sliders will initialize at max. I also found another bug: If there is NO com port on the PC, the program do the ghost thing because there was of an error not displayed but shown in the windows log events. The program was initialzing with first com port, item 0 but there was no item. Now it is allowed to start the program without com port in the PC but the combo box does not refresh if you plug a serial usb adapter while the program is running. Have to restart the program... I guess would need a refresh com list button eventually... Bliss -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Good find. Will try to fix later on. Actually for this project, Controlling one box only would be enough as you found out that you can run more than one instance of the program allowing connecting to many lego interface B independly. So I do not intend to add a Lego 3, at least not now. (Maybe I should even remove the second Lego from this demo project... ) However, for my other project, yes, I can eventually allow more than 2... Thank you. -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Hello, you may check back the Dropbox link in my previous post. I "published" using Fodi addon to make sure the exe in the publish folder was really a standalone. Because sometime, If I copy this exe alone in another folder and try to execute, it will ghost. But if I copy the whole publish folder with all its content, then the exe opens the form fine... Thank you! -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Thank you. I just implemented those 3 items (Without calibration for the moment). Updated Dropbox LegoDemoB files Let me know. Bliss -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
So I did get this ghost behavior when I copied the exe to another directory on my computer. So I deleted ALL files and folders in my visual studio build bin folders and recompiled everything... I updated the Dropbox link above that I still include here: LegoDemoB recompiled files Thanks for your help. -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
I checked the visual studio project settings and it appears to be compiling for windows 7, win-x86... Maybe it does not do for 32 bits version I don't know. Did you right click on the exe file, properties, compatibility tab and force for windows 7? -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
@Gunners TekZone, I uploaded the files in dropbox: Dropbox link The EXE zip file is password protected . Pwd is lego (all lowercase letters) -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
When I click the same link I get: (See the name of the file) Might be a bug with Box.com... (Maybe you should clear your browser cache?) -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
I just tried to download the Exe file zipped alone and Chrome tells me there is a virus pfff... I'll check how I can make this program safe for everyone... I'll also check if I can compile the project so it run on Win7 +. (It is not set for win 10+). -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
i uploaded just the EXE file (Zipped at 61k) too. Lego Demo Program Folder. Exe zipped file password is : lego -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Are you sure you use the latest updated program? Cause I see "Lego Modbus Server" in the form Window Title bar which is an old project I did in the past and I changed the title few iterations back. Do not use the Lego Interface B dot Net Framework version as I do not update it anymore for the moment. It should look like this now: (Removed Imageas it was a copy paste...) -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
I uploaded again with some colors (Inputs) and some delimiting lines for clarity and also added A,B,C...H in the label for the outputs... Lego Demo Form in dot NET 8 -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Thank you for you feedback! As for the cw/ccw box, I think you confused with the Speed box. (I call this the speed but this is the amount used to increment the counter) cw/ccw is an indicator that shows the last direction of the rotation sensor. it is not the description of the followind box which is the speed. As for the Look, this is only a form to test the box, I did not want to put too much of effort to make it look like the real box. At least not for now. -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Thank you! Updated LegoDemo Program version Dot NET 8 This one should solve hopefully the First Attempt Connection fail and also the change of Com Port in the combobox while the Lego Box already running... Bliss -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Thank you for all your comments, recommandations and observations. I did not even notice we could run multiple instances of my Lego Demo Program :-) But actually, my ultimate goal, is to integrate some kind of basic language to allow the user to program logic interacting between inputs and outputs of more than one Lego Box. I will post a very preliminary version of this program that i'm working in parallel. It uses the same lego class engine but I removed all the buttons for now and provide just a textbox to enter a script and an output textbox to display results when applicable. This program will be a standalone exe. I was also thinking about making another program to control the Lego InterfaceB that would integrate an MQTT Client, i.e. some kind of Lego Gateway, so users could use Home Assistant and/or Node-Red (Home Automation) to program logics to interact between lego boxes on same PC (Program would allow 2-3 Legoboxes to run) and even between PCs with 2-3 lego boxes on each PC... About the Lego Demo progr., you said: Was there any error message in the textbox of the one that gets disconnected? Thank you again for your precious help. -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Thank you @Gunners TekZone for reporting the bugs. Indeed I did not test the opening of the second port while the first one was connected. (Even if I do not have a 2nd lego interface B, I have other com ports and just selecting one of them while one port was already in use, did give the same error.) So I think I found why and made the corrections. I updated the Projects: Updated Lego Demo Project in .Net Framework version. Updated Lego Demo Project in .Net *.0 version Bliss -
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 my Lego Demo windows app compiled with .net 8.0. Before it was .Net Framework 4.8... Here is the link for the whole souce and bin files... I tried to compile a standalone exe but not sure yet if really did... You should look at the exe in: folder LegoDemoB\bin\Release\net8.0-windows\publish\win-x86. Bliss -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Hello @Gunners TekZone, Thank you for your feedback. Congrats fixing your faulty Interface B!!! Hats off! When you say you rebooted, you rebooted you PC or the application only? At the top of my program windows form, you select the COM port and click on Start Lego. Under the Start/Stop Button there is a textbox that shows the status of the connection and initialization... Do you get any statut message in this little texbox after you click the Start Lego Button? Did you try the EXE file in the BIN folder directly or used the setup in the publish folder? I noticed that if I select the wrong COM port and click start lego it may hang eventually and the only way to get back to normal is to remove the USB RS232 adapter and reconnect it... I updated the link with an improved version (I think). I also used costura.fody to build a standalone exe that has supposedly all dependant libraries DLL etc. Use the EXE file in the ...LLEGOInterfaceB\LegoProject\bin\Debug\app.publish . UPDATED Lego Interface B Test Program Thank you again. Bliss -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Hello, I'd like to share with you a Visual Studio 2022 project I'm working on for the Lego Interface B. (I'm no professional programmer. Just doing this for fun) I have some ongoing projects for this great lego box but this one is an Upgrade (Including Performance Improvements) and merge of existing projects I did in the past for the Lego Interface B. (Originally, I did with VB.Net, now it is C# .net) I just saw my Lego Interface B few months ago getting dirt on a shelf and decided to get back to it :-) Here is the link to download this project: Lego Interface B Windows Test Form I already compiled it and you can find the .exe file in the Lego70909\LEGOInterfaceB\LegoProject\bin\Release folder. It should work directly if you have .Net Framework already installed. There is also a Publish folder with an installer that I did not tried. It is working on my home Computer (Windows 10) and I tested it on my job laptop which is Win 11. I had to resize the form though on the Win11 to see the Data Log textbox. The software is a form that shows Lego Intrerface B Inputs Status and have buttons to allow to control Outputs. There is no way yet to make some programming like activate a motor when a touch switch is ON etc... (this is on my to do list) Note that for the Outputs, there are a OFF and FREE buttons. OFF actually Stops and "BRAKEs" the motor, FREE will "Coast to Stop" the motor (FreeWheel). The form has a log window but it is not perfect as it might hang when there is to much lines in the text box... Also, The data is in Hexadecimal and sometime, would be better to Binary... Improvement on this maybe in next versions or I might get rid of this. One of the feature of this project is the use of multithreading and a Lego Class (Methods and Properties) that alows to create many instances of the Lego Box. This Test project has 2 tabs on the top named Lego1 and Lego2. So in theory, you can connect and run 2 Lego Interface B at the same time. I do not have 2 Lego Interfaces B to test this feature unfortunately. So I would appreciate if someone with 2 Lego Box could try this out and let me know how it goes. Thank you and Happy Holiday! -
Dacta Control Lab Software
Bliss replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Hello @Toastie, For Light Sensor, leftmost 10 bit are definitely the analog value, not the 12 rightmost bits... I noticed that bit 4.3, for light sensor, will go "1" when light is blocked (or not enough light) and go to "0" when light source not blocked. It looks like the interface use this bit to turn ON/OFF the input led. But it's more tricky than just blocking the light, if you block the light source slowly, this bit wont change. (or if you unblock slowly as well). Also, Bit 4.4 goes 1 for one scan after 4.3 changes from 0 to 1 or from 1 to 0. In short, if you have a part that moves slowly in front of the light source, bits 4.3 will stay 0. It might stay 1 if you moved fast enough to block the light (goes to 1) then move slowly out of the light source. If a long part goes fast, bit 4.3 will go to 1 and when the long part unblock the light, this bit will go to 0. 4.0 & 4.1 seems to go to 1 at the same time for one scan when something block, unblock the sensor (Must not be too far away). Original instruction says Light Sensor can be used to: - Count using a pulley wheel (Could be the use for the 4.0, 4.1 bits?), - Work as an electric eye. - Sort color (grey scale) Bit 4.2 of light sensor, for me, remains zero at the beginning and then after having a very bright light like a bright flashlight near the sensor and removing this bright light from the sensor, this bit will go to ONE. After that, it will reset to zero if I bring back the bright light near the sensor. Bit 4.0 goes to ONE for one scan at every change of state (0->1 or 1->0) of the bit 4.2. I'm not sure there is any use for this bit 4.2 really... Bits 4.5, I do not know yet if it is of some use. I'm still testing... About the 4.3 bit, It appears that this bit for the rotation sensor is also used the same way as for the light sensor. It toggles the interface input led (1=Led off, 0= led on). This bit changes every 1/8 turn. For the Rotation Sensor, the bit 4.4 goes 1 for one scan after 4.3 changes from 0 to 1 and from 1 to 0.