Lok24 Posted August 14, 2021 Posted August 14, 2021 (edited) Hi all, we all remember the discussion about the 10277 and how to control smoothly with a LEGO remote control. With the current beta release Pybricks provides the opportunity to connect the remote to a hub and load the control programm permanently into the hub. Brilliant, thanks to the Pybricks team. For those who need a ready to use application program for "Motor Control": here is my first approach for the city hub (see link below) No programming needed ! Some of the features: - Connect 1 or 2 motors of any kind to Port A and/or B - In the first section you find same parameters to customize the control You can use two profiles to set minimum speed maximum speed accelerate in steps of ... wait for next acceleration step(in ms) - You can set the rotation for each of the motors, i.e. opposite - Accelarates continously when holding button (or not, configure it) - Assign buttons to functions as you like - „Switch“ between Profil_A and Profil_B (ie. to move very slow) - Watchdog stops motors when loosing remote connection, or continues driving when connection is lost, you can reconnect the remote by pressing the green button - Set Color and brightness of Hub LEDs Please note: if you use any tacho motors (like boost or technic) it uses load control, so no slowing down or even stopping in curves when speed is slow or load to high. It's really awsome! Just have a try and let me know what you think about it, thanks. progams, installation and instructions (all in german) Edited August 6, 2022 by Lok24 Quote
zephyr1934 Posted August 14, 2021 Posted August 14, 2021 This sounds amazing (unfortunately for me it will be a while before I have time to try it out though) 1 hour ago, Lok24 said: - Set Color and brightness of Hub LEDs Such a simple concept and such a valuable addition if you do not like the hood/cab/etc of your loco glowing purple. Quote
Lok24 Posted August 14, 2021 Author Posted August 14, 2021 (edited) 13 minutes ago, zephyr1934 said: Such a simple concept and such a valuable addition if you do not like the hood/cab/etc of your loco glowing purple. That's the idea When starting it is blue, when loading i.E. red, but only with 30% brightness, if remote connected "Color.GREEN*10" or even "Color.GREEN*0", if connection is lost red again . Edited August 14, 2021 by Lok24 Quote
TekyTek Posted August 23, 2021 Posted August 23, 2021 @Lok24 I have just found your decoupler train mod using PF. Another great idea! https://www.eurobricks.com/forum/index.php?/forums/topic/114550-remote-decoupling-engine/ I like it a lot and I am thinking of building it using a PU wedo motor for the decoupler and a PU train motor in the front of the loco. If I use your PyBricks program to control the 2 motors will it work? I know it will discover both motors, but will it be able to run the decoupler from the “B” buttons and not think both motors are used to drive the train? Maybe you can advise which part of the code I need to change please? Cheers John. Quote
Lok24 Posted August 31, 2021 Author Posted August 31, 2021 (edited) Hi all, version 2.4 is available - Connect to a certain remote - show mode (slow or fast) by LED color New with Version 2.4 remoteName = "remote3" # connect this remote only "" connects to any remote LED_A = Color.GREEN * 0.3 # Remote Profil_A, color * brightnessLED_B = Color.RED * 0.5 # Remote Profil_B, color * brightness Edited August 6, 2022 by Lok24 Quote
Gimmick Posted August 31, 2021 Posted August 31, 2021 @Lok24 I don't realy get what remoteName does. Has every remote unique name? Oo If not, how should a name I set after the connection is established prevent a connection to an unwanted remote? :| Quote
Lok24 Posted September 1, 2021 Author Posted September 1, 2021 (edited) Hi, Every remote has a name. You can set this in different ways before(!) starting the program. With the Pybricks class remote (name=...) the remote connects to any remote with that name, if you have two with identical names any of them would do If you ommit name any would do. And if you choose the MAC-Address as name..... When developing this feature this paramer was called "address". Now it's the name. Edited September 1, 2021 by Lok24 Quote
Lok24 Posted September 24, 2021 Author Posted September 24, 2021 (edited) Hi all, just made some videos to show how smooth trains drive ( 1min) Speed is set to +5/-5 (in a range of 1-100) , 1 waggon is about 1kG, there is app. 60gr of ballast on the loco. Motor is just started and stopped via LEGO remote, no manual regulation at all up to sec. 50 in the video, then button is just pushed and hold, acceleration is automatically. Here's a switch (45 sec) Smooth! Edited September 24, 2021 by Lok24 Quote
Toastie Posted September 25, 2021 Posted September 25, 2021 On 9/24/2021 at 4:09 PM, Lok24 said: Smooth! PID rocks. Best Thorsten Quote
Toxic43 Posted October 29, 2021 Posted October 29, 2021 (edited) @Lok24 I have successfully flashed your program to a hub! The only issue now is I can't get a remote to pair with it. Both the hub and remote have new batteries and I could pair the remote before the firmware flash. I went back and flashed the Lego firmware again to be sure, and I could then pair the hub and remote again. I have since flashed pybricks with your program onto the hub again, taking care to follow the instructions. I still can't pair a remote with it. Any ideas what I am doing wrong? Great videos above by the way. I'm looking to have that level of control with my 10277. Also being able to use a remote without having to bang on full power all the time would be great! EDIT: OK, I have found a way to connect the hub to the remote, via a mobile phone Bluetooth pairing. Not exactly what I thought it would be. I was expecting to be able to pair the remote straight to the hub. I'm not sure if this is possible or if I'm missing something here. Ideally I'd like to not have to use a phone at all and be able to hand the remote and hub/loco to the kids so they can run the Croc without needing Daddy's phone! Edited October 29, 2021 by Toxic43 Quote
Lok24 Posted October 29, 2021 Author Posted October 29, 2021 (edited) @Toxic43, I have no idea what went wrong, sorry. When you open the program in beta.pybricks.code you have two lines that handle the behaviour of the remote: remoteTimeout =10 # hub waits x seconds for remote connect after starting hub remoteName = "" # connect this remote only You only have 10 seconds after starting the hub to connect, and there should be no "remoteName" entered to connect any remote Did you really run https://beta.pybricks.com/ ? Did you turn on "include current program" in the settings? Way sould be : Program starts with a red light, which turns off after 10 secs, unless you press green button on the remote within the 10 seconds. What color does Hub show when starting the program? Edited Aug 22: It's now available with code.pysbricks.com Edited August 6, 2022 by Lok24 Quote
Toxic43 Posted October 29, 2021 Posted October 29, 2021 1 hour ago, Lok24 said: @Toxic43, I have no idea what went wrong, sorry. When you open the program in beta.pybricks.code you have two lines that handle the behaviour of the remote: remoteTimeout =10 # hub waits x seconds for remote connect after starting hub remoteName = "" # connect this remote only You only have 10 seconds after starting the hub to connect, and there should be no "remoteName" entered to connect any remote Did you really run https://beta.pybricks.com/ ? Did you turn on "include current program" in the settings? Way sould be : Hubs starts with a red light, which turns off after 10 secs, unless you press green button on the remote within the 10 seconds. Thanks for the reply. I changed the 10 seconds to 20 to give the remote a bit more time to connect. I didn't enter anything for remotename. Definitely using the beta.pybricks.com address and "Include current program" was checked when I performed the firmware flash. The hub is stating up with a flashing deep blue light, not the white light of the remote, or the red you mentioned. The hub also isn't turning off after 10, or even 20 seconds even if I push the remote button or not. The remote turns off pretty quickly once it realises there is no hub to connect to, but the hub now sits there blinking intermittent blue flashes. I have to pull the batteries to switch off. If I flash the Lego firmware again it works fine and the remote connects right away. I can get the remote to connect on the Pybricks firmware, but as I said, it uses the mobile phone as a proxy so no direct connection. I don't know what is going wrong. Quote
Lok24 Posted October 29, 2021 Author Posted October 29, 2021 (edited) Hi, 30 minutes ago, Toxic43 said: I changed the 10 seconds to 20 to give the remote a bit more time to connect. if I remember correctly that's is an issue not fixed in pybricks, 10 is the maximum. Edit: yes, here it is: https://github.com/pybricks/support/issues/485 30 minutes ago, Toxic43 said: The hub is stating up with a flashing deep blue light, not the white light of the remote, or the red you mentioned. Thats correct, the Hub starts, but not the program. To start the program you have to press the Hub Button when flashing blue, LED turning to RED. And then press remote green button. Pressing the Hub button when program is running stops program, returning to flashing blue. And so on Edited October 29, 2021 by Lok24 Quote
Toxic43 Posted October 29, 2021 Posted October 29, 2021 Holy Cow! That fixed it! Thank you! A little bit of knowledge goes a long way! It was the second hub button press I wasn't picking up. Now I know that, how do I switch between profiles for the slower speed running? Quote
Lok24 Posted October 29, 2021 Author Posted October 29, 2021 (edited) Profile is switched as indicated in line 39 SWITCH = "CENTER" where "CENTER" is a reserved word in pybricks which means the green button, you can also use SWITCH = "B+" i.e. And it does't necessarily change the speed, but intended to have a different acceleration. Color of remote indicates the mode as set in lines 50/51 LED_A = Color.GREEN*0.3 # Remote Profil_A, color * brightness LED_B = Color.RED*0.5 # Remote Profil_B, color * brightness so it should turn from green to red. You can set the speed-buttons in 36-38 to "B", if you like Edited August 6, 2022 by Lok24 Quote
DarioD Posted December 5, 2021 Posted December 5, 2021 I wonder why I didn’t peek into the forum earlier? I would have solved a lot of problems with the 10277 remote control earlier. But in the end it's sweeter when you find a solution yourself. It takes longer, but the satisfaction is greater. :-) Quote
ejayb Posted December 11, 2021 Posted December 11, 2021 Lok, what do you think about the STOP function slowing the loco down to 0 at the same, or a similar, rate to the acceleration steps rather than an instant stop? Quote
Toastie Posted December 11, 2021 Posted December 11, 2021 (edited) @ejayb when you type "@Lok24" @Lok24 will get a notification that someone (= you ;)) were addressing him. Otherwise, he has to read all the messages to get hold of your inquiry. Which he will certainly do at some time, but this may speed up things a bit. I like the STOP function to stop any of my trains with full brake (= shortened outputs). I use power/speed = 0 to slow down my trains in the way you suggested. Sometimes things do go bad on a layout - you see it coming - and then the train slows down "realistically" but maybe not preventing damage ;) Just my thoughts. All the best, Thorsten Edited December 11, 2021 by Toastie Quote
Lok24 Posted December 12, 2021 Author Posted December 12, 2021 13 hours ago, ejayb said: Lok, what do you think about the STOP function slowing the loco down to 0 at the same, or a similar, rate to the acceleration steps rather than an instant stop? This can be done via the "-" button, "Stop" is for emergency case. Quote
ejayb Posted December 13, 2021 Posted December 13, 2021 (edited) Excuse me, it's been a while since I tried your script and my hub is currently running an automated loop for Christmas. As the PU remote only has buttons, do you just remember when you're at the 'last step' before 0 so you don't overshoot and send the loco in the other direction? In fact, changing the LED based on speed/power level could be useful. For example, the controller LED could be yellow for steps 1 and 2, the speed limit inside a yard, and then green above 2, for main line running. I realise that there is the profiles option but I'm not sure that really benefits this workflow. How do you use it? Edited December 13, 2021 by ejayb Quote
Lok24 Posted December 13, 2021 Author Posted December 13, 2021 (edited) 3 hours ago, ejayb said: In fact, changing the LED based on speed/power level could be useful. For example, the controller LED could be yellow for steps 1 and 2, the speed limit inside a yard, and then green above 2, for main line running. You can set this in lines 50/51 LED_A = Color.GREEN*0.3 # Remote Profil_A, color * brightness LED_B = Color.RED*0.5 # Remote Profil_B, color * brightness Edited December 13, 2021 by Lok24 Quote
ejayb Posted December 13, 2021 Posted December 13, 2021 Sorry, I meant that the colour should change automatically based on a specified speed/step. I’ll look at the code later and see if I can add it Quote
Lok24 Posted December 13, 2021 Author Posted December 13, 2021 3 minutes ago, ejayb said: Sorry, I meant that the colour should change automatically based on a specified speed/step. I’ll look at the code later and see if I can add it Sure. Speed is held global in v, look at line 200 function "drive", this is where motors are controlled Just add some if (v> 6) : remote.light.on(....) Quote
Lok24 Posted December 30, 2021 Author Posted December 30, 2021 Hi all, please note: V 2.5 cannot be compiled any more, Use 2.6. instead (which does exactly the same) or change line 251 in line 2.5 tospeed_limit, acceleration_limit, torque_limit = Motor(port).control.limits() Quote
BatteryPoweredBricks Posted August 4, 2022 Posted August 4, 2022 Hi @Lok24 I've said it before but thanks for sharing this program! I use it for as many of my Lego trains as I can. When you have time could you post or edit the original post with an updated link to the latest version here? I've seen at least one YouTube video that links to this thread but none of the links here seem to work. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.