Cosmik42

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

Recommended Posts

20 hours ago, Toastie said:

Answer #3 seems to go along that line: Link

Yes, i think here is the answer.

I ordered another adapter mentioned by @Cosmik42. If it does not work i'll maybe try an internal Bluetooth adapter (PCIe).

I also found this link where some Lego - Buetooth related stuff is described. SBrick is selling the mentiond adapter.

 

3 hours ago, Cosmik42 said:

It's why I offer you that you can change the current hard-coded value of a Partial 5 to trigger a color, to the partial of your liking

Pease do so. Is it possible to set the Value of partial corresponding to the color of interest?

Does the sensor recognize colors better if you use light? @Lok24 Did you try that?

 

Edited by mawe

Share this post


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

(BTW: white isn't a color too, but works brilliant, due to reflecting)

Hee hee, I love this.

Oh, white is regarded as color - as in a mix of colors. Black though is "nothing". When there are reflections, black is not black but the color reflected by the surface - which is not black …

:wink: 

Share this post


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

Does the sensor recognize colors better if you use light? @Lok24 Did you try that?

@Lok24 I'd try using some white light and see if it changes the results. Also perhaps slight change of angle to help with reflections.

Share this post


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

BTW, I confirm EV3 is the next device being integrated! Started tonight and I am half way through

Now we are talking business. Simply because this means integration of really >intelligent< bricks. That is my world - as in "distributed intelligence"

So far the whole BLE stuff means to me: Report to the client and the client tells the server what to do. OK, WeDo hubs may be different, I have not the faintest idea, I don't have one, but only stupid "Hubs No.4". So there is a furious amount of wireless traffic to do "the works". This is very nice, but not how things work today: There is mostly at least a bit of intelligence in the servers. If not an unbelievable amount. With an EV3, NXT, or RCX - a lot. Sure, the RCX is nothing compared to the EV3, but so much better than any Hub.No4.  

And: BT integrations of EV3 is fine - but then NXT should be in reach as well! Both are talking plain vanilla BT over serial protocol, right?

I know that the EV3 is the latest and hottest in Mindstorms, but just because of that it means next to >nothing< to me. I'll get one anytime soon, (just to have them all - the LEGO PBricks that is). The NXT though talks to a HiTechnic (formerly fully TLG supported) IR Link "sensor". That in turn talks the RC Train, PF, and RCX protocol. In other words, the moment an NXT is supported, you can control all your PF and RC trains as well. There is one downside: The IR link range is 50 cm or so.

However: Here I described how to mod original PF-IR into PF-RF. The latter is very simple OOK direct 1:1 IR protocol translation. Runs on 433 MHz and will not interfere with any BT/BLE communication (and Here is described how the NXT controls PF as well as RC trains).

So from that perspective, @Cosmik42's software is not only serving all the BT (NXT, EV3) and BLE (PuP stuff) peripherals, but the whole shoo bang (PF, RC, RCX, Scout, MicroScout).

And this is what I call the idea of LEGO. Not only brick-wise, but also electronic stuff wise.

That would be so cool - this is my ultimate goal. I have 4.5V/12V trains equipped with PF receivers hooked up to RF, 9V trains, RC trains, and now BLE (PuP) trains. My point is: TLG makes a >fuss> about all that backward compatibility with regard to their ABS bricks. And that IS amazing. I have my 323 train from 1964 still here. It is like that. 

But with regard to doing the same with any electronic devices, TLG >miserably failed<. IMHO only of course.

All the best,
Thorsten

  

     

Share this post


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

Now we are talking business. Simply because this means integration of really >intelligent< bricks. That is my world - as in "distributed intelligence"

...snip...

I myself was never interested in NXT/EV3 as TLG got stupid with their motors/sensors. They look like alien appendages rather than Lego elements, and I found hard to integrate into existing MOC's without them looking silly or taking up too much space. RCX on the other hand was ideal, but sadly it was never updated for PF/anything else, so it lays behind as my ideal Mindstorms implementation so far.

This is why I was excited to see that Lego intends to use the new Powered UP/Power Functions 2.0 connectors for Mindstorms, as described here:

https://education.lego.com/en-us/support/wedo-2/faqs

Quote

What does that mean for the existing plug systems on other Power Function and MINDSTORMS products? Will they also be changed?
Yes, eventually we will convert to the new plug system after a transition period. The exact timing of this transition has not been determined.

They confirm the new connectors will be used on Mindstorms, but give no timeframe. Fair enough. But this (hopefully) means that all Powered UP/WeDo 2.0/Boost motors and sensors should be usable on future Mindstorms products, and vice versa (Similarly to how we have the Boost motor usable on WeDo 2.0).

So, I think Lego does indeed intend to create a "unified future" where Mindstorms, Control+, Boost, Powered UP, WeDo, etc all use the same devices, connectors and protocols. I definitely have my hopes up for the future. The Lego Power Functions 2.0 future. :)

This is how Lego describes the WeDo 2.0 hub (The "Smarthub 2 I/O") in the linked FAQ (I've bolded relevant parts):

Quote

What is the Smarthub 2 I/O?
An electronic system based building brick that is part of the LEGO Power Functions (LPF) 2.0, a new technology platform for LEGO Education. 

- It has built-in Bluetooth low energy to wirelessly connect to the control software/App. 
- It is powered from a battery source, either two AA batteries or a rechargeable battery pack. 
- It has two I/O ports to connect to external motors, sensors, or any new component belonging to the LPF 2.0 system. 
- It has a build in RGB light surface that can show up to 10 different colors that be controlled by the software/App. Colors include: none, pink, purple, blue, sky blue, teal, green, yellow, orange, red, and white.

 

Edited by Mr Hobbles

Share this post


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

BTW, I confirm EV3 is the next device being integrated! Started tonight and I am half way through!

I'm excited :moar:

Imagine being able to display text on the EV3 brick (nice back-lit screen) - it could be built into a train station as a "display board".

Audio would also be possible *oh2*

  • Colour sensors
  • Touch sensors - great for "detecting" the end of a rail yard "parking spot"
  • Ultrasonic distance sensors
  • This list goes on for a while so I'll stop now :grin:
1 hour ago, Mr Hobbles said:

They look like alien appendages rather than Lego elements, and I found hard to integrate into existing MOC's without them looking silly or taking up too much space

I have the same problem, but they will be great to operate switch points for example :laugh:

3 hours ago, Toastie said:

The NXT though talks to a HiTechnic (formerly fully TLG supported) IR Link "sensor"

Oh yeah @Toastie I totally forgot about these! I have a couple of them somewhere - this would be SO excellent being able to then control IR gear. Perhaps even turn on the TV :laugh:

Share this post


Link to post
Share on other sites

It is totally possible to integrate NXT as well via Bluetooth. Issue is I don't own one. Will see how easy to find one.

Share this post


Link to post
Share on other sites
12 hours ago, mawe said:

Pease do so. Is it possible to set the Value of partial corresponding to the color of interest?

Does the sensor recognize colors better if you use light? @Lok24 Did you try that?

 

There is no light, and it must independent from light.  Sensor always says "BLACK" when it ist black, there's no problem with that.

Share this post


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

There is no light, and it must independent from light.  Sensor always says "BLACK" when it ist black, there's no problem with that.

Then the only way to solve your problem is to let the black color trigger with a lower partial value. I will cook you up something.

Share this post


Link to post
Share on other sites

Hi, seems to me so.

What about your setup, is it possible for you get "black" triggered in any test condition? (which here is just a black tile and the sensor)

If not so, in the moment it's a little bit useless to add all these colors to the event-dropbox if they never trigger

With my EV3 I often use the RGB-values to define the colors myself.

BTW: V.09 shows still 0.8 in the "propetries" menu...

Share this post


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

What about your setup, is it possible for you get "black" triggered in any test condition? (which here is just a black tile and the sensor)

No point making a hard-coded case for Black. Let's offer the option to all colors.

15 minutes ago, Lok24 said:

BTW: V.09 shows still 0.8 in the "propetries" menu...

It was fixed the same night. You were just too fast to download it :p

Thanks for the feedback though.

Share this post


Link to post
Share on other sites

Hi,

i used that technique for a layout I had shown on two conventions for totally four days, no problems at all.

The sound comes from Windows Media Player, which I called from your global code.

Share this post


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

The sound comes from Windows Media Player, which I called from your global code.

I love you really use every bit of possibility from this. Well done!

Share this post


Link to post
Share on other sites

Here is the event for the RED(!) tiles on the track:

LOG writes to console
STOP stops the engine
START(dir) starts the engine in desired direction
PLAY(sound) plays a sound
SETMOTOR(s,100) starts motor for s = Signal, waits a moment and stops
IF (CHECK(2,1)) means: two red tiles in step 1 of the complete show.


countevent(Hub[0],Hub[1]);

if (check(2,1))  // Zurück auf 1
{
log("Halt am Signal, Zurück auf Gleis 1");
Stop();
Wait(1000);
setmotor(w,-100); Wait(mt);setmotor(w,0);
Wait(1000);
Start(1);

}
if (check(2,2)) // vowärts bis Signal
{
log("Halt auf Gleis 1, Vowärts bis Signal");
Stop();
Wait(2000);
setmotor(k,100); Wait(mt*2);setmotor(k,0);
play (pfeife);
Wait(2000);
Start(-1);
setmotor(k,-100); Wait(mt*2);setmotor(k,0);
}

So it's only one routine doing that all and some global commands
(There is one additional on the Handheld "Power" to start the whole thing)


 

 

Edited by Lok24

Share this post


Link to post
Share on other sites

Hey @Cosmik42 - this project just keeps getting better and better. EV3 integration will be awesome in terms of the possibilities it offers!

 

Btw - did you hear anything back from the Pfx Brick guys?

Share this post


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

Btw - did you hear anything back from the Pfx Brick guys?

Sadly I did not. So I would love to take you up on your offer in order to integrate this hardware.

Share this post


Link to post
Share on other sites

That’s a shame. It would ultimately help them sell their brick system.

No problem though - I will get one of my kits sent over to you this week

Share this post


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

That’s a shame. It would ultimately help them sell their brick system.

Once we have support for this I'll be buying some for sure :wink: loving the idea of 3rd party lights 

Share this post


Link to post
Share on other sites

Hi, here is the complete idea of implementig sounds which are called form the events i.e. with "CALL(bell);" :

public static string [] sound = { // Filenames
"xxx",
"Bell",
"Hupe",
"bue",
"Trillerpfeife",
};

public const int bell = 1;
public const int hupe = 2;
public const int bue = 3;
public const int pfeife = 4;

public const string path = "E:\\Daten\\Lego\\Boost - PU - SBrick\\PoweredUp\\LegoTrainProject\\Sounds\\";

// ----play----------------------------
static void play(int so)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
string fn = path + sound[so] +".wav";
player.SoundLocation = fn;
player.Play();
}

 

Share this post


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

Hi, here is the complete idea of implementig sounds which are called form the events i.e. with "CALL(bell);" :

Great! Do you mind if I include it in the default Global Code?

Share this post


Link to post
Share on other sites

It's not that mysterious ... sure you can do if your like.
But it's only some kind of workaround, cause it plays only one sound at a time.

BTW:

Why isn't it possible to use WAIT(1000); in global code?
Must be something with the different threads I assume....

 

Share this post


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

It's not that mysterious

But you've opened the door to a new dimension. Imagine what is possible with this ingenious idea. Everything. Any external program can be integrated with it.

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.