Cosmik42

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

Recommended Posts

5 hours ago, Toastie said:

That is a little harsh 

Sincere apology if it came out that way!

Actually reading @Kalahari134, I realize that he is talking about a physical controller, which I missed when I replied.

Here is my plan: create some kind of manual controller screen dedicated to manually interact with all the pre-prepared scenarios.

Would it achieve what you are asking @Kalahari134?

 

Share this post


Link to post
Share on other sites

Essentially I'd have a physical control panel, a hardware one (whether of the interlocked lever frame that someone made in a thread a few years back or a panel with buttons) and these would output both to signals on the layout (purely for the benefit of viewers) and an output that informs the software when a signal is cleared.

In its simplest (but rather expensive) incarnation, this might involve the back of the frame or panel displaying a colour when a route is set and a colour sensor recognising this. In a more complex system, one which may be beyond my electrical expertise but much cheaper than dozens of colour sensors and PUP Hubs, it might be possible to feed the route-setting status directly into the computer through USB devices (I suppose that is what some on here are getting at with their talk of Arduinos).

Edited by Kalahari134

Share this post


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

Essentially I'd have a physical control panel, a hardware one (whether of the interlocked lever frame that someone made in a thread a few years back or a panel with buttons) and these would output both to signals on the layout (purely for the benefit of viewers) and an output that informs the software when a signal is cleared.

Sounds amazing, but without such hardware myself, there is no way I can integrate such a dream hardware :)

Share this post


Link to post
Share on other sites
1 minute ago, Cosmik42 said:

Come join and vote!

As someone who does not have a FB account, how could I?

Share this post


Link to post
Share on other sites

I wish there was polling option in this forum. Many of them support this feature but I can't seem to find it here.

Here is the menu to vote for:

* Interactive map (14 votes so far)
* Android version (13 votes so far)
* iOS version (5 votes so far)
* Mac/Linux version (4 votes so far)
* WeDo 2.0 support (4 votes so far)
* 4DBrix support (2 votes so far)
* BuWizz support (1 vote so far)

Also, don't hesitate to mention if you have other ideas!

Edited by Cosmik42

Share this post


Link to post
Share on other sites

It would be really great, you could choose more colors. The sensor also recognizes black, blue and cyan (green) as far as I could see. I also think it would be great if it were possible to enter the distance manually, not just <3, <7, <30 and >30. Then it might be enough to implement only the "<".

A question: When exactly does the event of a sensor fire in your implementation? Only if the color/distance actually changes? Or every time the sensor measures the selected color/distance? In other words: Does the event "Change Color To Yellow" fire even if yellow was already detected?

Everything else is almost perfect. Many thanks for your work.

Share this post


Link to post
Share on other sites
Just now, mawe said:

The sensor also recognizes black, blue and cyan (green) as far as I could see.

I can add more color, but at least with my sensor, these color were not reliably detected. Meaning that for exemple a dark grey is detected as blue, sometime. The colors I picked were the one I could 100% of the time correctly identify. But I can add these other colors. 

Just now, mawe said:

I also think it would be great if it were possible to enter the distance manually, not just <3, <7, <30 a

It's a good point and a definitive => must do!

 

Just now, mawe said:

A question: When exactly does the event of a sensor fire in your implementation?

This is a very good question. I trigger only when the color is found AND the distance to the sensor is very close. The reason again is reliabilty. When nothing is very close to the sensor, it picks up almost random colors from its camera.

Finally, there is a 1.5s cool-down before another color event can trigger, to avoid too many shot of the same event at once.

Edited by Cosmik42

Share this post


Link to post
Share on other sites

Hi,

There are some small issues I found when testing:

WeDo Tilt sensor  is recognized but doesn't do anything (show log)

Trigger on other colors (already mentioned)

 

Get properties of Hub like

. MAC-Address

. Battery (in Volt)

. type

. FW-version

 

Is there a chance to reset all Variables?

Normally this is done at program start, but there is no real "program start"

Background: to prevent from retriggering I set Hub[x].State[y] to specific values, but of course they all should be reseted to have a defined state when starting trains

 

Get properties of the port, like

. color

. IsRunning

. IsStopped

. device connected

 

.RampExecuting

and so on

 

Select specific MAC–Addresses only

 

Select a specific path to get the program saved and load (now it's always the application path) or at least remember the last

 

Clicking EDIT always opens a new window, even if already opened

The Code windows have no names to distinguish

 

Is there a chance to display the line number in case of error?

Edited by Lok24

Share this post


Link to post
Share on other sites

I just ran some tests on my sbrick+ and a distance sensor. I wanted the train to drive slowly when it was tight and fast when there was enough space.
I only get values between 2 (near) and 9 (far) from the sensor.
With the "Sensor Event" I couldn't achieve this because a value less than 3 is also a value less than 7 and so on.  With "ExecuteCode" I could not evaluate the value of the sensor, here I could have easily realized a "between".
How should I proceed here? Is it possible to realize this?

 

Edited by mawe

Share this post


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

WeDo Tilt sensor  is recognized but doesn't do anything (show log)

Do you have an usage scenario for the tilt? As mentionned earlier, I don't own one, but can't seem to justify buying one.

3 hours ago, Lok24 said:

Get properties of Hub like

. MAC-Address

. Battery (in Volt)

. type

. FW-version

What scenario for these properties too? I can easily exposed them anyway.

Otherwise it's a pretty solid list. Will see what I can do.

1 hour ago, mawe said:

I just ran some tests on my sbrick+ and a distance sensor. I wanted the train to drive slowly when it was tight and fast when there was enough space.
I only get values between 2 (near) and 9 (far) from the sensor.
With the "Sensor Event" I couldn't achieve this because a value less than 3 is also a value less than 7 and so on.  With "ExecuteCode" I could not evaluate the value of the sensor, here I could have easily realized a "between".
How should I proceed here? Is it possible to realize this?

Yes, indeed. The best here would be for me to expose the distance, so that you trigger no matter what the distance, then use the actual distance value to do what you want on your motor speed for example.
Will look into it.

Share this post


Link to post
Share on other sites

Hi,

sorry, please don't missunderstand, my posting was in no way a "ToDo" list but some things I noticed when testing your project.

11 hours ago, Cosmik42 said:

What scenario for these properties too? I can easily exposed them anyway.

 

for example:

I run a motor with a speed of 70, but distance covered depends on batterylevel.

So you could add same factor to correct this, same is for the starting value for the ramp command.

I did that on my layout driven by a RaspPi and some SBrick last year shown on different conventions.

Of course it takes some testing with the factor :wink:

Share this post


Link to post
Share on other sites
Just now, Lok24 said:

for example:

I run a motor with a speed of 70, but distance covered depends on batterylevel.

So you could add same factor to correct this, same is for the starting value for the ramp command.

I did that on my layout driven by a RaspPi and some SBrick last year shown on different conventions.

Of course it takes some testing with the factor :wink:

Oh that makes total sense as I am running into similar issue on my 'self-driving module' where speed are hard-coded per section, and low battery trains kinda suffer there :)

Share this post


Link to post
Share on other sites

Hi,

for my project red keep (game of thrones) I used 4 EV3 and 16 Motors.
The Red Keep was moved in a certain programmed  circle.
Shutting down of one EV3 in the middle of a circle would have crashed everything.

So within the main programm  every cirle always started with

vmin = 6.3;
for each EV3 in EV3list
if EV3.Batterylevel < vmin then call emergencyStop
Next

"emergencyStop" was then used to stop all communication servers and clients on all slaves and master

With your project you run into the same scenario, I fear: if a Hub with sensors fails....

 

 

 

 

 

Share this post


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

With your project you run into the same scenario, I fear: if a Hub with sensors fails....

Definitely. I like the logic you have implemented for your project and will do something similar!

As a matter of fact, sensors via SBrick start to act funny as soon as the battery is 3/4 empty. Weird, out of bound values.

Edited by Cosmik42

Share this post


Link to post
Share on other sites
25 minutes ago, Cosmik42 said:

As a matter of fact, sensors via SBrick start to act funny as soon as the batter is 3/4 empty. Weird, out of bound values.

Hum, I have two SBrick, same firmware-version, same hardware-version.
One reports the batterys-level in volt, the other doesn't (always 0). Spooky.

Is there a resaon why you give it % instead of real value?
100% of 9V (battery) is different from 100% of 7.2V (accu) whereas the min voltage for the processor is always the same.

 

By the way, how is the syntax to access
Hub[0].Stop("A") or ther methods of hub in the "Global code"
 

I changed already

public void MyGlobalFunction()

into

static void MyGlobalFunction()

Or is this a pretty silly question for an C# - expert, which I'm definitely not?

 

Edited by Lok24

Share this post


Link to post
Share on other sites
On 1/24/2019 at 3:52 PM, Cosmik42 said:

Also, don't hesitate to mention if you have other ideas!

Have my vote for a Linux version.

And keep the underlying framework flexible so adding other hardware is easy. I'm working on a simple hardware platform to drive two motors and a bunch of LEDs for cheap via USB+9V, which I will use to run all the track switches and signals on our layout.

Share this post


Link to post
Share on other sites
22 minutes ago, Lok24 said:

Is there a resaon why you give it % instead of real value?
100% of 9V (battery) is different from 100% of 7.2V (accu) whereas the min voltage for the processor is always the same.

It's a fair question - Battery Level on my phone and all consumer devices are in % - so I kept that norm. But I agree that I cannot guess the type of battery plugged to it, so showing volt makes more sense. 

 

23 minutes ago, Lok24 said:

By the way, how is the syntax to access
Hub[0].Stop("A") or ther methods of hub in the "Global code"
 

I changed already


public void MyGlobalFunction()

into


static void MyGlobalFunction()

You need to pass the object inside your function.
So you function will look like this

static void MyGlobalFunction(Hub train)
{
	train.Stop("A");
}

And then inside your script you can call it like this

MyGlobalFunction(Hub[0]);

 

Share this post


Link to post
Share on other sites

Nice. I'll try this!

Thank you for your patience and the helpful answers.

To Voltage: perhaps both?

.BattLevelV
.BattLevelP

 

 

Share this post


Link to post
Share on other sites
11 minutes ago, treczoks said:

I'm working on a simple hardware platform to drive two motors and a bunch of LEDs for cheap via USB+9V

Did you custom build this hardware or is it something I can buy? If I can find it, I could add support for it.
And my architecture is based on the very clean one of @Mr Hobbles. So adding new hardware is quite simple which is why I am proposing to add BuWizz, WeDo 2.0, but also 4D Brix and maybe yours! 

Share this post


Link to post
Share on other sites
On 1/7/2019 at 7:39 PM, Cosmik42 said:

My current bluetooth dongle cannot take more than 5 BLE connected at once

I have the same problem. Which dongle do you use? Can I use more than one dongle at a time?

Edited by mawe

Share this post


Link to post
Share on other sites
Just now, mawe said:
On 1/7/2019 at 7:39 PM, Cosmik42 said:

My current bluetooth dongle cannot take more than 5 BLE connected at once

I have the same problem. Which dongle do you use? Can I use more than one dongle at a time?

I bought this one:

https://www.amazon.de/dp/B007MKMJGO/ref=pe_3044161_185740101_TE_item

I can connect to 12 hubs with it.

Share this post


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

It's a fair question - Battery Level on my phone and all consumer devices are in % - so I kept that norm. But I agree that I cannot guess the type of battery plugged to it, so showing volt makes more sense.

This raises a question:

Does the Hub or whatever BLE device you are playing with report the actual battery voltage? On generic consumer devices reporting "%" values, these are "%ages of capacity", not voltage. An alkaline battery showing 1.0 V under some very minor load (i.e. a volt meter) is almost dead. It can't deliver any significant current. Same holds true for rechargeables but at individual voltage levels. An NiMH cell with nominal 1.2 V fully charged voltage reading (it is more than that) is doing fine at 1.0 V clamp voltage under load.

When the % reading should make any sense, one would need to know a) what type of battery is at work and b) what are their individual voltage/max. power (roughly U*Imax) characteristics.

All I am saying is that 1.0 V for alkaline when free running is close to 0% capacity when under load.

All the best,
Thorsten          

Share this post


Link to post
Share on other sites
16 minutes ago, Toastie said:

This raises a question:

Does the Hub or whatever BLE device you are playing with report the actual battery voltage? On generic consumer devices reporting "%" values, these are "%ages of capacity", not voltage. An alkaline battery showing 1.0 V under some very minor load (i.e. a volt meter) is almost dead. It can't deliver any significant current. Same holds true for rechargeables but at individual voltage levels. An NiMH cell with nominal 1.2 V fully charged voltage reading (it is more than that) is doing fine at 1.0 V clamp voltage under load.

When the % reading should make any sense, one would need to know a) what type of battery is at work and b) what are their individual voltage/max. power (roughly U*Imax) characteristics.

All I am saying is that 1.0 V for alkaline when free running is close to 0% capacity when under load.

All the best,
Thorsten          

The Boost Hub, PUP Hub, and PUP Remote all report both. It provides both voltage and battery level as a percentage.

Its not exposed what algorithm they use to calculate the percentage but I’ll assume this is the number they use to display the battery level in the official apps.

 

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   1 member