Cosmik42

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

Recommended Posts

On 9/1/2019 at 12:12 PM, Didicas said:

In any case after starting they show color red and distance 15. This is only changing if I touch with my finger the sensor, already in a distance of 1 cm nothing happens (1cm = currently the distance where the train is passing).
After I am touching the distance changes from 15 to 1 and stays at 1 even if I remove my finger.
If I touch the second sensor then the second sensor changes from 15 to 1 and only then the first sensor changes from 1 to 15. Again these values stay after removing the finger.

I have to touch again the first sensor for any changes and so on...

Are you simply looking at the display on screen? If so, it does not necesseraly refresh in real time.

However, try to create an event trigger and see if the event is captured there.

9 hours ago, Nivst said:

I've recently purchased a couple of Color & Distance sensors (88007) to mount under my trains for plate/tile color detection to automate my layout and for shows.

This setup works consistently using the PoweredUp mobile app, but when porting the exact same logic to The Brick Automation Project the color detection of white and yellow pieces drops below the threshold, causing the program to miss the triggers.

Red is detected with very high certainty 100% of the time.

Tested under different light setups and surfaces.

Any tips? 

Maybe my software is too strict in detection to avoid false positive. I will give it a look tonight.

Share this post


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

Are you simply looking at the display on screen? If so, it does not necesseraly refresh in real time.

However, try to create an event trigger and see if the event is captured there.

Maybe my software is too strict in detection to avoid false positive. I will give it a look tonight.

Yes I checked only the display. But I absolutely had not the impression that it is a refresh issue.
Specialy because it was reacting when I touch the sensor (so my finger was touching at the sensor), but it was not reacting anymore at a distance of 1 cm or 2 cm where the train was passing.

Anyhow I will try to create a trigger event like you say and let you know.

Unfortunatelly I am on a trip this week. I took some lego devices in my laguage to test already today evening, but I forgot that my laptop is working with WIN 7 (where the Train project doesn't run)
So I cannot continue testing before next weekend or during next week.

Are you not able to reproduce my issue? At your side the sensor 88807 is running fine with one of the powered up hubs?

Share this post


Link to post
Share on other sites

Hi @Cosmik42  and all,

this weekend I was at Bricking Bavaria in Fürth (D) with more than 200 exhibitors.

We had a sniffer which showed over 60 BT devices near my desk.....
So I used the limitation of addresses, which really works fine!

Here's my example:

------------------------------

Smart Hub No 1 (V100)
- 90842B063B73

HandSet
A434F1CE5C45

BOOST_MOVE_HUB
- 1653AF77C3 4

Smart Hub No 6
90842B10790A

technic-Hub
90842B4A0971

SBrick
780D048D2

-------------------------

As you see:

- You can add text and blank lines
-  MAC owned by me but not used momentarily are "disabled" by "- "
- leading zeros must be omitted (last entry, SBrick)

With 1.5. technic Hub is detected properly and sliders shown, train motor, light and boost sensor at technic hub work fine.

Thanks a lot, really helpful!

Edited by Lok24

Share this post


Link to post
Share on other sites
5 hours ago, Lok24 said:

Hi @Cosmik42  and all,

this weekend I was at Bricking Bavaria in Fürth (D) with more than 200 exhibitors.

We had a sniffer which showed over 60 BT devices near my desk.....
So I used the limitation of addresses, which really works fine!

Here's my example:

------------------------------

Smart Hub No 1 (V100)
- 90842B063B73

HandSet
A434F1CE5C45

BOOST_MOVE_HUB
- 1653AF77C3 4

Smart Hub No 6
90842B10790A

technic-Hub
90842B4A0971

SBrick
780D048D2

-------------------------

As you see:

- You can add text and blank lines
-  MAC owned by me but not used momentarily are "disabled" by "- "
- leading zeros must be omitted (last entry, SBrick)

With 1.5. technic Hub is detected properly and sliders shown, train motor, light and boost sensor at technic hub work fine.

Thanks a lot, really helpful!

Hello

Do I understand well that the wedo 2 distance sensors 45304 work with the new control+ technik hub without any problems?

So its better to use them for the moment instead of the new colour and distance sensors 88807? 

Share this post


Link to post
Share on other sites
On 9/9/2019 at 8:12 PM, Didicas said:

Yes I checked only the display. But I absolutely had not the impression that it is a refresh issue.
Specialy because it was reacting when I touch the sensor (so my finger was touching at the sensor), but it was not reacting anymore at a distance of 1 cm or 2 cm where the train was passing.

Anyhow I will try to create a trigger event like you say and let you know.

Unfortunatelly I am on a trip this week. I took some lego devices in my laguage to test already today evening, but I forgot that my laptop is working with WIN 7 (where the Train project doesn't run)
So I cannot continue testing before next weekend or during next week.

Are you not able to reproduce my issue? At your side the sensor 88807 is running fine with one of the powered up hubs?

I did a new test:

I placed a sensor 9583 (Wedo 1.0 Motion Sensor + SBrick) and 88807 (PuP new color and distance sensor + new control+ technik hub) next to each other and let a red train passing.

At the beginning the display shows:
Sensor 9583: Distance 5
Sensor 88807: Color None and Distance 15

Events trigger:
Sensor 9583: Distance is below 15
Sensor 88807: Distance is below 15 + color changed to red

I let the train passing the sensors.

Console:

All Sensor Events for Program #1 are active.

Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #2 triggered - Technic Hub on port A has a distance below 13
Event #1 triggered - SBrick R on port D has a distance below 5
Event #3 triggered - Technic Hub sensor detected RED
Event #2 triggered - Technic Hub on port A has a distance below 1
Event #1 triggered - SBrick R on port D has a distance below 0
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Sensor Events for Program 'Program #1' are stopped.

 

After the train passed the sensors:

Now display shows:
Sensor 9583: Distance 5
Sensor 88807: Color Red and Distance 1

But because the train is not next to the sensors anymore the colour should change to none and the distance to 15!

 

I let the train again passing the sensors:

Console:

Sensor Events for Program 'Program #1' are stopped.
All Sensor Events for Program #1 are active.
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #2 triggered - Technic Hub on port A has a distance below 13
Event #1 triggered - SBrick R on port D has a distance below 1
Event #3 triggered - Technic Hub sensor detected RED
Event #2 triggered - Technic Hub on port A has a distance below 13
Event #1 triggered - SBrick R on port D has a distance below 9
Sensor Events for Program 'Program #1' are stopped.


Display shows now after passing:
Sensor 9583: Distance 5
Sensor 88807: Color Red and Distance 1

But the sensor 88807 should should show now again show color none and distance 15 as the train has already passed the sensors.
Why is the distance of the Technik hub only below 13? I expect again something like below 1.

 

I hope this info helps you to detect the problem.

What about the sensor 45304 (Wedo 2.0). Is this sensor working without problems together with the control+ hub like the sensor 9583 together with the SBrick?

Thank you for your help.

 

Share this post


Link to post
Share on other sites
On 9/15/2019 at 1:35 PM, Didicas said:

I did a new test:

I placed a sensor 9583 (Wedo 1.0 Motion Sensor + SBrick) and 88807 (PuP new color and distance sensor + new control+ technik hub) next to each other and let a red train passing.

At the beginning the display shows:
Sensor 9583: Distance 5
Sensor 88807: Color None and Distance 15

Events trigger:
Sensor 9583: Distance is below 15
Sensor 88807: Distance is below 15 + color changed to red

I let the train passing the sensors.

Console:

All Sensor Events for Program #1 are active.

Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #2 triggered - Technic Hub on port A has a distance below 13
Event #1 triggered - SBrick R on port D has a distance below 5
Event #3 triggered - Technic Hub sensor detected RED
Event #2 triggered - Technic Hub on port A has a distance below 1
Event #1 triggered - SBrick R on port D has a distance below 0
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Sensor Events for Program 'Program #1' are stopped.

 

After the train passed the sensors:

Now display shows:
Sensor 9583: Distance 5
Sensor 88807: Color Red and Distance 1

But because the train is not next to the sensors anymore the colour should change to none and the distance to 15!

 

I let the train again passing the sensors:

Console:

Sensor Events for Program 'Program #1' are stopped.
All Sensor Events for Program #1 are active.
Event #1 triggered - SBrick R on port D has a distance below 5
Event #1 triggered - SBrick R on port D has a distance below 5
Event #2 triggered - Technic Hub on port A has a distance below 13
Event #1 triggered - SBrick R on port D has a distance below 1
Event #3 triggered - Technic Hub sensor detected RED
Event #2 triggered - Technic Hub on port A has a distance below 13
Event #1 triggered - SBrick R on port D has a distance below 9
Sensor Events for Program 'Program #1' are stopped.


Display shows now after passing:
Sensor 9583: Distance 5
Sensor 88807: Color Red and Distance 1

But the sensor 88807 should should show now again show color none and distance 15 as the train has already passed the sensors.
Why is the distance of the Technik hub only below 13? I expect again something like below 1.

 

I hope this info helps you to detect the problem.

What about the sensor 45304 (Wedo 2.0). Is this sensor working without problems together with the control+ hub like the sensor 9583 together with the SBrick?

Thank you for your help.

 

Is there anybody who can tell me if the wedo 2 sensor 45304 is the better option for the new technik control+ hub?
Or do I have to use the wedo hub 45301 if I use the sensor 45304? I suppose this combination is already in use by someone?

Share this post


Link to post
Share on other sites
On 9/9/2019 at 10:38 AM, Cosmik42 said:

Maybe my software is too strict in detection to avoid false positive. I will give it a look tonight.

Hey @Cosmik42 have you had a chance to look into this? :blush:

Share this post


Link to post
Share on other sites
On 9/19/2019 at 10:15 PM, Didicas said:

Is there anybody who can tell me if the wedo 2 sensor 45304 is the better option for the new technik control+ hub?
Or do I have to use the wedo hub 45301 if I use the sensor 45304? I suppose this combination is already in use by someone?

To keep you informed... in the meantime I included the technik hub control+ and the sensor 88807 with the selfdriving mode.

Until now it is working how it should be, so it seems to be just a display problem.

Share this post


Link to post
Share on other sites

Hi @Cosmik42

I love your project. Just one question, did anything ever come of the 4dbrix motors you received? I noticed they’re not mentioned ever since you got them. At this moment 4dbrix support is the main thing holding me back from using this software.

Share this post


Link to post
Share on other sites

Just wanted to update that I've used the BAP application with great success in our show yesterday!

I wasn't able to accomplish all the logic I wanted, but that's on my and my zero C# knowledge :)

Managed to get past the color detection issue I posted about by raising the tile one plate up and slowing the trains a bit, made for almost 100% correct detection.

The new feature of limiting the connection to only approved devices seems to work great, but after a while if I disconnect a component - to change batteries for example - the application isn't able to pick it back up, gotta close the app and reconnect everything.

Not sure if that's because of the app or the laptop BT.

Overall - THANK YOU @Cosmik42

Share this post


Link to post
Share on other sites
On 10/15/2019 at 2:42 PM, Kalindor71 said:

Hi Cosmik42,

Is there a way to obtain the source code for this program so I can extend it.

I believe @Cosmik42 is rather busy at the moment or maybe for long. You know, I also believe @Bartosz has voiced it very nicely, about 2 and 1/2 months ago - which is a long time span in the software developing "market":wink::

On 1/8/2019 at 9:02 PM, Bartosz said:

Some people would agonize over making it pretty/portable and never get to anything, whereas others would "just do it" :)

I guess just take care of releasing it before you get bored/go MIA (as it, unfortunately, often happens ;) ). My myself I do not own any PU hub yet, so I don't have any real interest in this software, but - just in case (and since I'm programmer as well:) )

Gone MIA - it really happens, often.

Plus, when I look at my truly dirty VB6 code I wrote for my own PuP device operation - just thinking about making it public or handing it over ... makes me blush.

Best wishes,
Thorsten

Share this post


Link to post
Share on other sites

Hi @Cosmik42,

I'm using BAP to control a monorail for a public display and I've encountered an issue. My configuration is as follows;

  • Hub one is an EV3 with NXT touch sensors connected
  • Hub two is an EV3 with NXT touch sensors connected
  • Hub three is an SBrick which powers train 1
  • Hub four is an SBrick which powers train 2

BAP will connect to all of the hubs successfully. However, when I have both of the EV3 hubs (i.e. one and two) connected, the moment one of the touch sensors is triggered, BAP exits straight away.

If I plug all the NXT touch sensors into a single EV3 hub and only connect one hub, the touch sensor triggering works as desired and the events and related code executes flawlessly.

I suspect some kind of bug exists in the situation of there being multiple EV3 hubs connected but I do not have any means of tracing what is happening. I believe that you only have one EV3, so getting you to diagnose the root cause of this issue could be a challenge. Is there any way to set some form of "debug" flag at run time in order to get a trace of the code as it executes? If that is not possible, do you have any suggestions as to how I can further trace the cause of the issue?

Regards,

David

 

Edited by djm
typo

Share this post


Link to post
Share on other sites

I'm having trouble grokking how to configure this software. All I want initially is my loco (PoweredUp hub, train motor, colour & distance sensor) to go forwards until it detects red,wait a few seconds, go backwards until it sees white, wait a few seconds, go forwards again, repeat.....

What I'm after next is two trains in a layout with three stations but the central one is a passing point. I can write the pseudo-code for it easily enough as I've had it working using NXT and PF control so I'm hoping I can write this one myself once I see how the first one works.

If someone would be kind enough to help an old man, I'd be very grateful.

Share this post


Link to post
Share on other sites

Hi @Snapshot

I think that can't be done without programming code.....

First you have two add to evens, one for red, one for white.
For each of of them you choose "Execute Code"

The two codes are below - they are very similar - and hopefully work....
I can't test them in the moment, no time.

Perhaps you gvive it a try, and then we discuss what they do and how to do even easier.

Please note: the white and red events have to correspond with the direction of the loco. So perhaps you have to change the two colored tiles or switch the 50 and -50 in the codes, last line.

if (Hub[0].State[0] == 1)
{
MainBoard.WriteLine("----> White");
Hub[0].State[0] = 0;
Hub[0].RampMotorSpeed("A",0,1000);
Wait(1200);
MainBoard.WriteLine("Wait");
Wait(5000);
MainBoard.WriteLine("Start");
Hub[0].RampMotorSpeed("A",0,50,1000);
}


if (Hub[0].State[0] == 0)
{
MainBoard.WriteLine("-----> Red");
Hub[0].State[0] = 1;
Hub[0].RampMotorSpeed("A",0,1000);
Wait(1200);
MainBoard.WriteLine("Wait");
Wait(5000);
MainBoard.WriteLine("Start");
Hub[0].RampMotorSpeed("A"0,-50,1000);
}

 

Edited by Lok24

Share this post


Link to post
Share on other sites

@Lok24

Many thanks for the fast response. It took me a while to work out but I finally got there and I pasted the appropriate bits of your code into each sensor event. When I try to run them from the code editor, White compiles correctly but Red gives the following syntax errors:

Compiling code ...
Compiling failed.
Error (CS1026): ) expected
Error (CS1002): ; expected
Error (CS1525): Invalid expression term ','
Error (CS1002): ; expected
Error (CS1525): Invalid expression term ','
Error (CS1002): ; expected
Error (CS1002): ; expected
Error (CS1525): Invalid expression term ')'

There's probably a single character typo in there which I'll hunt down once I'm on a larger screen than this little 13" laptop.

Thanks again

Jonathan

Share this post


Link to post
Share on other sites
4 hours ago, Lok24 said:

Hub[0].RampMotorSpeed("A"0,-50,1000);

The issue you have is here, delete the 0 after "A".

Share this post


Link to post
Share on other sites

I think it actually needs a comma inserted between the "A" and the 0, compared with the version in the first set of code, but I will check the syntax of the instruction. Thanks for spotting the faulty line.

Share this post


Link to post
Share on other sites

Hi all,

 

indeeed, sorry. The original program is more elegant, and I had to change it, but we can discuss this later.

As you see the both programms are nearly the same, and the first seems to be correct ;-)

In the second the line must of course be:

Hub[0].RampMotorSpeed("A",0,-50,1000);

That means accelerate motor on port A from 0 to -50 in 1000 milliseconds.

 

 

Edited by Lok24

Share this post


Link to post
Share on other sites

I'm testing on a very short length of track so I've changed the first RampMotorSpeed to a simple Stop and adjusted the second to 0,20,500 and 0,-20,500.

So the hub is detected by BAP when I turn it on, I Start Sensor Events and nothing happens. I can start the motor using the slider under Hubs but the sensor doesn't pick up the colour plates. What fundamental principle am I missing in how BAP works?

From a programming POV what initialises the state variable?

I'll be away for the rest of the day as I now have a 300km round trip to London to see my mother.

Share this post


Link to post
Share on other sites
18 minutes ago, Snapshot said:

I'm testing on a very short length of track so I've changed the first RampMotorSpeed to a simple Stop and adjusted the second to 0,20,500 and 0,-20,500.

 

I have only 6 tracks here to test, the tiles are only 2 Tracks apart

18 minutes ago, Snapshot said:

So the hub is detected by BAP when I turn it on, I Start Sensor Events and nothing happens. I can start the motor using the slider under Hubs but the sensor doesn't pick up the colour plates. What fundamental principle am I missing in how BAP works?

No, it doesn't anything, it waits for event.....

You should move the engine manually to one of the colored tiles in the track, that causes an event in BAP and starts the programm sequences.

Or you edit the event with

if (Hub[0].State[0] == 0)

(which is initialised to 0 during the code within BAP which you can't see)

and click on "run code"

 

Edited by Lok24

Share this post


Link to post
Share on other sites

On second look both versions shouldn't have worked, RampMotorSpeed should take 3 parameters - port, speed, duration.

Share this post


Link to post
Share on other sites
7 minutes ago, Nivst said:

On second look both versions shouldn't have worked, RampMotorSpeed should take 3 parameters - port, speed, duration. 

Correct, but I think it takes also 4 parameters: port, fromspeed, tospeed, duration.

Did you test the programm?

Edited by Lok24

Share this post


Link to post
Share on other sites
1 hour ago, Lok24 said:

Correct, but I think it takes also 4 parameters: port, fromspeed, tospeed, duration.

Did you test the programm?

Haven't tested, just remember (or think I do) what's listed in the help section.

Share this post


Link to post
Share on other sites

Hi,

yes, you are right, but there is beyond this a method with four parameters.

This is extremly useful, because with

Hub[0].RampMotorSpeed("A",20,50,1000);

you can set the first parameter  to start the engine immediatly without humming until motors turns.

In fact I use variables for that in the two sections

Hub[0].RampMotorSpeed("A",vs,vm,tx);

or 

Hub[0].RampMotorSpeed("A",vs*-1,vm*-1,tx);

I set them in the Global Code:

// Create your own constants!
public const int vs = 20;
public const int vm = 50;
public const int tx  = 1000;

 

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.