Cosmik42

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

Recommended Posts

On 3/10/2019 at 6:08 PM, Cheatay said:

 

 

SUPER COOL VIDEO !!! <3

7 hours ago, coinoperator said:

Hi,
I wonder if there is a way to get the Servo's under control with this software?
I did a try on it but excepr for far left or right the servo goes into some shaker mode in all other positions, even in zero.

What servos? From which technology?

Let me know if I can help.

Edited by Cosmik42

Share this post


Link to post
Share on other sites

First off, thank you for this awesome piece of software!

I hope the new batch of Technic sets with control+ will lower the price of motors and battery boxes so converting existing trains won't have such a high entry point.

Quick question I couldn't find an answer to is looping - how do you loop an instruction?

Share this post


Link to post
Share on other sites
V1.2 is out - 03/17/19
----------------------------
- BuWizz - Implementation
- Play Sound (WAV) from the Event section
 
17 hours ago, Nivst said:

Quick question I couldn't find an answer to is looping - how do you loop an instruction?

What scenario do you have in mind?

Edited by Cosmik42

Share this post


Link to post
Share on other sites

I think he means instructions like:

If [event or value = xx] then goto [line]
Or just a plain goto [line]

Calling subroutines would also be great.

But this is going BASIC a bit :sweet:

Edited by coinoperator

Share this post


Link to post
Share on other sites

Hi

language is C#, there is no "goto" like in BASIC :wink:
an example for a loop would be


for (int i = 0; i < 10; i++)
{
   Hub[0].setMotorSpeed("A",i*10);
}

And a subroutine is placed in "Global code"

static void startMotor(Hub X, int v)
{
   X.setMotorSpeed("A",v);
}

and called from events with
startMotor(Hub[0],25);

Share this post


Link to post
Share on other sites

It is a really great software ! I love it.

my preferred way to control trains @home is via physical buttons and remotes are not the best for this.

Do you think it could be possible for your soft to support input/output from MIDI devices ?

that would allow to use cheap studio device such Korg NanoKontrol2 or NanoKontrol Studio. I can imagine moving train with pots and having light feedback for switch positions, moving switch via button press.

that would be so great !

 

Share this post


Link to post
Share on other sites
On 3/21/2019 at 10:48 AM, moustic said:

It is a really great software ! I love it.

my preferred way to control trains @home is via physical buttons and remotes are not the best for this.

Do you think it could be possible for your soft to support input/output from MIDI devices ?

that would allow to use cheap studio device such Korg NanoKontrol2 or NanoKontrol Studio. I can imagine moving train with pots and having light feedback for switch positions, moving switch via button press.

that would be so great !

 

Wow! Never saw this kind of giant remote! :D

The issue is to find a documentation to connect to this kind of hardware that is often propretiary.

Share this post


Link to post
Share on other sites

Very interesting software!

It´s working with my PUP trains. At the beginning also my SBricks were working, suddenly I get always the error message "connected but discarding".

I  realy have no idea what I do different now except from one thing... I did a software update of the SBricks to version 25.

Can this cause the problem? But I have no idea how to downgrate?

What else can I try to do?

Thank you very much for your support!

 

Share this post


Link to post
Share on other sites

I had the idea to check if the SBricks are connected with windows... If I see screen shot below they are unpaired, so in my view it´s okay.

But what´s the problem?

 

339303291_screenshotI240319.JPG.6003802a02c47f529dd5ae15a3d9925b.JPG795720580_screenshotI240319.JPG.207d6f7b6ce6e04719b6a9ee3b9830c3.JPG

Share this post


Link to post
Share on other sites

Thank you very much for publishing this project. The mere fact that it exists has convinced me to choose the PU system as my platform for the trains, which made the price of starting out go down dramatically from trying to get my hands on PF or 9V components. I used this tool to connect to my trains and it worked immediately, so I am very happy. While I am waiting for more parts to arrive (Arduinos, 4DBrix switch controllers and trains) I will be using this to control the trains remotely.

Right now there is no API or other possibility to access the tool's functionality from an external program, am I correct? Since I will be using some custom parts (4DBrix switch motors with Arduinos) I want to be able to script against all my components, so will probably be writing my own custom code, and being able to use your tool as an intermediary would save a lot of time :p 

Share this post


Link to post
Share on other sites

Hi @Cosmik42,

You probably know the problem with two mirrored and coupled trains that the rear railcar has to go "backwards" for the whole train to go forwards (2 x 60197 or 2 x 10233).

Is it possible to "couple" two hubs in your software and address them like one, so that both do exactly the same, but in the other direction?
Or do I have to realize this as an event of one hub, which then controls the second hub?

Share this post


Link to post
Share on other sites
On 3/26/2019 at 5:03 PM, mawe said:

Hi @Cosmik42,

You probably know the problem with two mirrored and coupled trains that the rear railcar has to go "backwards" for the whole train to go forwards (2 x 60197 or 2 x 10233).

Is it possible to "couple" two hubs in your software and address them like one, so that both do exactly the same, but in the other direction?
Or do I have to realize this as an event of one hub, which then controls the second hub?

Unfortunately right now there is no way to 'link' two hubs through the UI.

The only way to control 2 hubs at the same time is through custom code triggered via a sequence or an event.

But it is quite easy to trigger such sequence via a remote control for exemple.

Share this post


Link to post
Share on other sites

Hi Cosmik42,

I love your software, I've now have a 24" touchscreen monitor to use to control my Lego layout. Thanks so much for creating this.

A couple of suggestions I'll put out there for your consideration:

I have a steam loco with a WeDo 2.0 motor on a Hub4 but it runs in reverse due to the gearing setup when commanded to run forward. Could there be a check box on the hub setup page to reverse the direction of the controls for motors?

When a motor is set up as a standard switch, could there be a similar check box to reverse the right and left action? Perhaps the right and left directions could be called straight and diverging. Also, could the buttons change color when pressed, so the last one pressed becomes green and the other changes to red and they maintain the colors when the focus changes away from those buttons? It would make it easy to see which way the switches are set. Could each switch have a user entered name rather than just naming the hub?

Would it be possible to allow repositioning the hubs on the screen, rather than having their position set by the order they are activated? Being able to arrange the hubs in two rows, for example one for locomotive controls and a second row for switch controls would be helpful.

For locomotive light controls, could the LED polarity change when the locomotive direction is changed? I'm thinking I could wire the front headlight LED's to be reversed polarity from the rear, so they would light in the direction of travel when the operating direction is set or I could use bi-color LED's that would change from white to red based on polarity. I've been taking the LEGO 88005 LED set and cutting off their LED's and adding my own 3mm ones that fit much easier.

Not being a programmer I don't know how much work this entails but I wanted to make the suggestions.

I've run up against a 12 hub limit on my Bluetooth adapter which is based on the same Broadcom chip that the one you posted uses. When I try to add a 13th, the connected ones all disconnect. I've searched for ways to have two adapters on one PC but haven't found any way to do that. Do you or anyone have a workaround to add more than 12 devices?

Thanks,
Dave G

Share this post


Link to post
Share on other sites
11 hours ago, bogieman said:

I love your software, I've now have a 24" touchscreen monitor to use to control my Lego layout. Thanks so much for creating this.

Super happy to read this!

11 hours ago, bogieman said:

I have a steam loco with a WeDo 2.0 motor on a Hub4 but it runs in reverse due to the gearing setup when commanded to run forward. Could there be a check box on the hub setup page to reverse the direction of the controls for motors?

 I have been thinking of this as well. Time to do it. Agreed!

Share this post


Link to post
Share on other sites
11 hours ago, bogieman said:

When a motor is set up as a standard switch, could there be a similar check box to reverse the right and left action? Perhaps the right and left directions could be called straight and diverging. Also, could the buttons change color when pressed, so the last one pressed becomes green and the other changes to red and they maintain the colors when the focus changes away from those buttons? It would make it easy to see which way the switches are set. Could each switch have a user entered name rather than just naming the hub?

It's true that the naming convention is not ideal. I like your idea of Straight vs Diverging. Doing another check box here is possible too.

13 hours ago, bogieman said:

When a motor is set up as a standard switch, could there be a similar check box to reverse the right and left action? Perhaps the right and left directions could be called straight and diverging. Also, could the buttons change color when pressed, so the last one pressed becomes green and the other changes to red and they maintain the colors when the focus changes away from those buttons? It would make it easy to see which way the switches are set. Could each switch have a user entered name rather than just naming the hub?

I like your idea of new naming. It is also possible to add such check box here.

13 hours ago, bogieman said:

Would it be possible to allow repositioning the hubs on the screen, rather than having their position set by the order they are activated? Being able to arrange the hubs in two rows, for example one for locomotive controls and a second row for switch controls would be helpful.

I would love this, but as it is programmed it will require some serious refactoring on my side. Not sure when this can be delivered.

13 hours ago, bogieman said:

For locomotive light controls, could the LED polarity change when the locomotive direction is changed? I'm thinking I could wire the front headlight LED's to be reversed polarity from the rear, so they would light in the direction of travel when the operating direction is set or I could use bi-color LED's that would change from white to red based on polarity. I've been taking the LEGO 88005 LED set and cutting off their LED's and adding my own 3mm ones that fit much easier.

I am not sure how to achieve this.

13 hours ago, bogieman said:

I've run up against a 12 hub limit on my Bluetooth adapter which is based on the same Broadcom chip that the one you posted uses. When I try to add a 13th, the connected ones all disconnect. I've searched for ways to have two adapters on one PC but haven't found any way to do that. Do you or anyone have a workaround to add more than 12 devices?

I think the ultimate solution is to have a built-in one. This way it can use the RAM of your computer and virtually no limit.

Share this post


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

I am not sure how to achieve this.

 

Thanks for the positive reply.

What I was thinking was to treat the LED as a motor and linked to the adjacent motor control so when the motor is commanded to go forward the light gets a forward full on motor signal and it would get a full reversed polarity motor signal when reverse of the propulsion motor is commanded. This would require splicing in to the Lego LED wires 1 & 2 between the plug and the little mid-cable junction box as that seems to light the LED's in one polarity regardless of the input to it, at least that's how I think it works. Hope that makes sense.

Share this post


Link to post
Share on other sites
15 minutes ago, bogieman said:

What I was thinking was to treat the LED as a motor and linked to the adjacent motor control so when the motor is commanded to go forward the light gets a forward full on motor signal and it would get a full reversed polarity motor signal when reverse of the propulsion motor is commanded. This would require splicing in to the Lego LED wires 1 & 2 between the plug and the little mid-cable junction box as that seems to light the LED's in one polarity regardless of the input to it, at least that's how I think it works. Hope that makes sense.

Actually you can already do it! Simply set your lights as motors and you can achieve this without further code from me.

Edited by Cosmik42

Share this post


Link to post
Share on other sites
17 minutes ago, bogieman said:

This would require splicing in to the Lego LED wires 1 & 2 between the plug and the little mid-cable junction box as that seems to light the LED's in one polarity regardless of the input to it, at least that's how I think it works. Hope that makes sense.

The little junction box is a little more than that: It features a bridge rectifer and some other components that allow the hub to see what is connected its ports: 

When you set the output to "motor" make sure that the LEDs don't see full reverse polarity as many of them don't like that very much.

(http://www.learningaboutelectronics.com/Articles/How-to-connect-a-protection-diode-in-a-circuit)

I believe one can also use two antiparallel LEDs - one for forward one for reverse current - and the one emitting will protect the one in reverse.

Best,
Thorsten 

On ‎3‎/‎27‎/‎2019 at 5:44 PM, Cosmik42 said:

Unfortunately right now there is no way to 'link' two hubs through the UI.

But it could may be done, right? Maybe a drop down list in the frame of the current hub with other hubs already connected to your BLE clients; then select one from that list; then use the slider.value change event to trigger the other one? (I am doing that in my software)

Best
Thorsten 

 

Share this post


Link to post
Share on other sites
2 hours ago, Toastie said:

the one emitting will protect the one in reverse

Nope it won't.

It just depends on the max. reverse voltage of the led and I have no idea wich led Lego has used for it.
most leds have no problem with a reverse voltage of 12volts however.

Share this post


Link to post
Share on other sites

Didn't know that - just recently slowly killed an entire (very cheap) LED string (which was supposed to run on a 2x1.5V battery pack) by replacing that with a dirt cheap "3V DC" (measured about 4 V) wall wart. When looking into that a little more, it turned out to be a wall wart with a considerable AC component on the DC voltage. All but one of the 20 LEDs died over about 1 month … which may then just mean they were even of worse quality than the bad wall wart:tongue: 

However, there seem to be quite some references out there that do not favor the 12V reversing voltage … maybe that is an how-much-you-spend-on-LED-thing? Or: The LEDs I have in my storage bins are more than 8 years old - and they are simply making better ones nowadays?

Interesting! Thanks for pointing that out. I guess I need a new order of LEDs!

Best
Thorsten

Share this post


Link to post
Share on other sites
On 3/27/2019 at 5:44 PM, Cosmik42 said:

But it is quite easy to trigger such sequence via a remote control for exemple.

You're right. It is very easy to do this:

Hub[0].SetMotorSpeed("A", Hub[0].GetSpeed("A")+10); 
Hub[0].SetMotorSpeed("B", -Hub[0].GetSpeed("A")); 

 

Share this post


Link to post
Share on other sites
On 3/28/2019 at 9:42 PM, Toastie said:

Didn't know that - just recently slowly killed an entire (very cheap) LED string (which was supposed to run on a 2x1.5V battery pack) by replacing that with a dirt cheap "3V DC" (measured about 4 V) wall wart. When looking into that a little more, it turned out to be a wall wart with a considerable AC component on the DC voltage. All but one of the 20 LEDs died over about 1 month … which may then just mean they were even of worse quality than the bad wall wart:tongue: 

However, there seem to be quite some references out there that do not favor the 12V reversing voltage … maybe that is an how-much-you-spend-on-LED-thing? Or: The LEDs I have in my storage bins are more than 8 years old - and they are simply making better ones nowadays?

supply

Best
Thorsten

It works a bit different than you mention

first,
leds are current dependant.
usually (for small medium power leds) the current should be approx. 10mA (milli Ampere) where 10 is just a guess and not accurate here
If you raise the voltage by 2 you will however also raise the current by 2 (just physics)

So your wallmart gave them about 25% too much, this just might have been too much
That this cheap supply was not stabiised means that it also brings an ac component into the circuit
this let have the leds slightly flicker, maybe invisible but it shouldn't destroy them
LEDS are Light Emiting Diodes
They give ligt but they are still diodes and will block a max. X voltage in reverse direction
To find out what X is just should read the datasheet

But whatever, this reverse V didn't destroy them

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.