Cosmik42

Control all your Powered Up & Power Function (SBrick) devices with a single software

Recommended Posts

23 minutes ago, Walt White said:

I'm sure a more experienced programmer could do it in a more elegant and concise structure, but at least it seems to work.  Video and some notes are available.

Amazing! It operates soooo smoothly! Well done Walt!

Share this post


Link to post
Share on other sites
8 hours ago, Walt White said:

I figured out a way to do it with one big loop.  The Globals and Program code are close to 500 lines total and it is hard to follow.  The trick is how to manage the waiting that each train has to do while the other train continues to move and process the colored tiles in the track.

 

The "wait" can better be established in the evens, not in global code.

 

Share this post


Link to post
Share on other sites
On 3/21/2020 at 12:49 AM, TuxTown said:

I have a new layout, and now at some places with switches en sensors, the train stops only at a sensor when the loc has passed and the first train car is halfway passed. This derails the train when the switch gets adjusted. Before, and also now at other places in the track layout, the train already stopped when the loc was in front of a sensor. I search but as far as I know this is not and adjustable setting. What can make the difference?

 

A solution can be putting the sensor further away from the switch ofcourse. But thats hard with the small PU wires. Two tracks is the limit for me. Which brings me to another thing I noticed. I think I have the same switch motors as Cosmik42, namely this one: https://www.flickr.com/photos/skaako/albums/72157629455967364 However, on a picture in his manual thread, his motor is pointing away from the switch whereas in my case the motors are on the other side. In the curve of the switch, to get left and right oke in BAP. The direction of the motor is not adjustable in the software, is it?

 

(Like before, I'm using the self-driving module)

 

Hi @Cosmik42, do you by any change have a comment on this one? How did you operate this switchmotor pointing outside instead of inside the switch? As I now have a few sensors where the train needs 3 tracks to stop for some reason, I need to place the sensor a bit further away from the switch...

Share this post


Link to post
Share on other sites

O, now I see looking at the pictures in the thread"Lego Train - Full Layout Automation - A Break Down" you use left and right the other way around. I was looking from the side the train is coming from. You don't.  That means the only left question is what makes the difference in the time to stop the train at a sensor

Share this post


Link to post
Share on other sites

Problem solved. It seems a bit harder to detect train in a curve, compared with a straight track. I solved it with lifting the sensor one brick.

Share this post


Link to post
Share on other sites

Salut Cheatay, Apparement tu parles français, pourrais-tu me donnez qques conseils concernant le programme Ncontrole de 4dbrix.  J'ai pu enregistrer 2 hubs lego powered up, mais n'arrive pas à en enregistrer d'avantage, est-ce que tois tu as pu en enregistré (appairer) plus ? et impossible de les piloter, il me demande une licence, mais le site de 4dbrix ne fonctionne plus.

Sous "configure controller" est-ce un arduino que l'on peut relier en usb pour émettre des infras-rouge pour la gamme power function ?

As-tu du acheter une licence pour utiliser ce programme avec les hub lego ? Ou utilises-tu un autre programme ?

Merci d'avance pour tes réponses,

Cordialement, Nicolas

Share this post


Link to post
Share on other sites
Posted (edited)

When some of my hubs need fresh batteries, after swapping them the hub doesn't reconnect to BAP. I have the switch off the program, restart and enable all of my hubs again. Is that normal behaviour and if so, is it fixable?

Edited by TuxTown

Share this post


Link to post
Share on other sites

And did someone manage to operate 2 motors in one train via PowerUp / BAP? I now have two Power Functions motors with one hub in a Horizon Express. Would be nice to convert that to BAP, but PowerUp has no option to adjust two things to one hub port yet.

Share this post


Link to post
Share on other sites

Hi Cheatay, Apparently you speak French, could you give me some advice regarding the Ncontrole program from 4dbrix. I was able to register 2 lego powered up hubs, but can't save any more, have you been able to register (pair) more? and impossible to control them, it asks me for a license, but the 4dbrix site no longer works.

Under "configure controller" is it an arduino that can be connected by usb to emit infras-red for the power function range?

Did you have to buy a license to use this program with lego hubs? Or are you using another program?

Thank you in advance for your answers,
Best regard,

Nicolas

For tuxtown,

Yes you can use 2motor with 1hub, i do it for change the height with the rail. (Thé inconvénient is the battery used more quickly than you have 2hub. Or you Can have 2hub with the same color led.

Best regard,

Nicolas

Share this post


Link to post
Share on other sites

Hi Nicotornare, yes you can attach 2 motors to one hub. I however want to run one train with two motors. In that case BAP is only starting one motor (the deafult). So I cant use PowerUp and or BAP if I use tho motors in my double Horizon Express. Right now I have two Power Functions motors in it.

Share this post


Link to post
Share on other sites

Hi Tuxtown,

Yes you Can, you must cut the cable and After you Can put two motor on one wire A. With the bluetooth you use only A for two motor and B for light... (But you must modify the cables. You must to be "manually"

Second solution you must parameter the A and B for the same fonction in the same Time.

Best regard

Share this post


Link to post
Share on other sites
Posted (edited)

Aha, is there a wire scheme for that somewhere? For my PF motors I opened one motor to swap the wires (soldering / to reverse the direction) so as to have both wires coming through the middle gate in the loc baseplate. If I have to cut the PU wires anyway, maybe I can skip the soldering the motor part. And if I am going to cut the wires anyway, is it also possible to use a PF motor instead of a PU motor? My PF motors are becoming useless.

Edited by TuxTown

Share this post


Link to post
Share on other sites

Hi Cosmik42, in case you are around these days some open questions and some
new:

1)When some of my hubs need fresh batteries, after swapping them the hub
doesn't reconnect to BAP. I have the switch off the program, restart and
enable all of my hubs again. Is that normal behaviour and if so, is it
fixable?

2) "I still find it odd that in the self-driving module when you say a train
starts in section X it immediately says "going to section Y and leaving
section X", although the train doesn't have passed the end section sensor
for X. This makes it hard to start with more than 1 train, especially if a
train doesn't start at the beginning of a path. "
-> As a consequence, you have to make sure at the start that each train has
an  empty sector in front of the sector you give as a starting sector for
that train.  Fixing this problem would lower the number of sectors needed
for driving multiple trains.

3) it would be nice to able to log all events en triggers to a file. Makes
debugging / analysing BAP behaviour easier.

4) will there ever be a new version, or is 1.5 the final one?

 

Share this post


Link to post
Share on other sites

Hello … I would love to port your C# code to Python to allow it to run on other platforms. I am a Software Engineer with almost 40 years of experience. I am also willing to help you fix bugs or extend the current implementation.

Also, I love your layout that you used to demo your program (you have done an absolutely amazing job) and are wondering if you have the details. I would love to create one very similar to yours.

 

Thanks

 

Randy

Share this post


Link to post
Share on other sites

EV3 Connection Fail

Some months ago I noted that I was able to connect an EV3 to BAP but hadn't tested anything.  I'm ready to start testing now, and the connection fails.  I'm currently running Windows 10 Version 1903 Build 18362.720.

I figured out that my Bluetooth connection to the EV3 is running on COM4.  The EV3 pairs and connects to the laptop and shows the "<>" icons indicating a successful connection to the laptop.  I've added the EV3 MAC address to the BAP list of allowed devices and it failed, and I checked the box to allow BAP to connect to any device and it fails.  

What's odd is that when I tell BAP to connect via COM4, BAP spends about 15 seconds attempting, and then issues the "Could not connect" error message, and the connection to the EV3 is broken at the same instant.  The icon on the EV3 just shows "<".

Is anyone else connecting BAP to EV3?

Walt

Share this post


Link to post
Share on other sites
Posted (edited)

Wow, I can't believe how long this project has been going on and I only just stumbled across it. What an amazing piece of work. While I hope your CEO day job is a success, I can't help thinking there should be a viable enterprise in developing this software commercially.

My 6 year old son and I have been into Lego technic and PU/Boost since Boost launched. He also has PU trains. I wanted to offer Junior Lego League at his school so I persuaded themto get a couple of Wedo 2 sets, and then CoronaVirus put a stop to all that. Still I got another Wedo 2 set for us to use at home and can heartily recommend this set. The part selection and guided lessons make a great resource for teaching from basic to quite advanced level. 

Anyway, I read with excitement that Lego had updated the firmware in the hubs and that sensors now work with PU hubs as well as Boost. Why? Well one limitation of having one Wedo 2 set was only 2 ports making a 2 motor device with a sensor impossible. No problem, I'll use the PU hub in Wedo, nope, doesn't work, Wedo hubs only. No problem, I'll use Wedo hub and PU hub in PU app, nope, Wedo hub, not recongised. Jeez Lego, you make it hard to love you sometimes.

Trying then with the Boost hub and S2Bot with Scratch, gues what, S2Bot is STILL not updated since port renaming on Boost at last update.

We also have 2 sbrick pluses and I picked up about 6 sets of Wedo 1 hardware as lots of schools are selling this stuff on as their hardware changes (to Chrombooks) which can't run Wedo 1 software.

So imagine my joy upon finding your software. With 5 Boost move hubs, A batman PU hub and motors. A wedo 2 set and several PU hubs out of trains I think we're limited now only by our imagination, so looking forward to getting stuck in.

I have read all 29 pages of this thread (nothing like coming late to a project!) so I'm pretty sure this han't been touched on, which is surprising:

Why no support for USB connected Wedo 1 hubs? This alleviates a bunch of issues around battery supplied power, although (at least in Lego software) there's a max of 3 such hubs allowed. Using th Wedo 1 hubs for switches/fixed sensors seems the best solution with BLE duties reserved for mobile applications.

That's really my only minor criticism of your excellent work and I just wanted to thank you again for opening up even more possibilities for my son and I to explore.

Jim

Edited by BoilingFrog
omitted info

Share this post


Link to post
Share on other sites
Posted (edited)

Latest status of my Bypass Train Project:

YouTube video.

Details to follow over the summer.  Hint:  I'll try to simplify the C# code and probably test using WeDo version 1.0 sensors.

Walt

Edited by Walt White

Share this post


Link to post
Share on other sites

@Cosmik42 any chance we can see the new IR transmission capability soon?

Since the latest PoweredUp app version you can use the PU color/distance sensor to send IR commands to PF.

Share this post


Link to post
Share on other sites
21 hours ago, Walt White said:

Latest status of my Bypass Train Project:

YouTube video.

Wow !!! <3

21 hours ago, Nivst said:

@Cosmik42 any chance we can see the new IR transmission capability soon?

Since the latest PoweredUp app version you can use the PU color/distance sensor to send IR commands to PF.

Very hard for me to find any time for this project anymore. But I will try!

On 4/11/2020 at 6:41 AM, Walt White said:

EV3 Connection Fail

Do you still experience the issue?

On 4/23/2020 at 2:43 PM, BoilingFrog said:

Why no support for USB connected Wedo 1 hubs? This alleviates a bunch of issues around battery supplied power, although (at least in Lego software) there's a max of 3 such hubs allowed. Using th Wedo 1 hubs for switches/fixed sensors seems the best solution with BLE duties reserved for mobile applications.

Thanks for all the kind words. Happy this is useful for more people :)
I do not own the Wedo 1 hardware, which is why it was never implemented.

But beyond that, the whole mindset was a BLE centric thinking.

Share this post


Link to post
Share on other sites
On 4/6/2020 at 10:54 PM, TuxTown said:

1)When some of my hubs need fresh batteries, after swapping them the hub
doesn't reconnect to BAP. I have the switch off the program, restart and
enable all of my hubs again. Is that normal behaviour and if so, is it
fixable?

I am affraid this is a tricky one. Not sure I can fix it.

 

On 4/6/2020 at 10:54 PM, TuxTown said:

2) "I still find it odd that in the self-driving module when you say a train
starts in section X it immediately says "going to section Y and leaving
section X", although the train doesn't have passed the end section sensor
for X. This makes it hard to start with more than 1 train, especially if a
train doesn't start at the beginning of a path. "
-> As a consequence, you have to make sure at the start that each train has
an  empty sector in front of the sector you give as a starting sector for
that train.  Fixing this problem would lower the number of sectors needed
for driving multiple trains.

This module is certainly far from perfect. Rethinking train detection to actually know when a train leaves a section would be a huge improvement. For now it is assumed the train leaves the section within a certain timeframe.

 

On 4/6/2020 at 10:54 PM, TuxTown said:

3) it would be nice to able to log all events en triggers to a file. Makes
debugging / analysing BAP behaviour easier.

That should be doable!

 

On 4/6/2020 at 10:54 PM, TuxTown said:

4) will there ever be a new version, or is 1.5 the final one?

So very hard to say! :(

Share this post


Link to post
Share on other sites
21 hours ago, Cosmik42 said:

Do you still experience the issue?

Yes.  In a new project that successfully connects to an SBrick.  BAP does a long wait trying to connect to the EV3, issues the "could not connect" message, and the connection between my laptop and the EV3 is broken.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.