Jump to content
THIS IS THE TEST SITE OF EUROBRICKS! ×
THIS IS THE TEST SITE OF EUROBRICKS!

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


Recommended Posts

Posted (edited)
6 hours ago, Lok24 said:

Hi @nuno2500,

sorry, my fault....

use:


Hub[0].SetLEDColor(Port.Colors.BLUE);
Hub[1].SetLEDColor(Port.Colors.LBLUE);

And here are the colors:

 

Thank you so much. That is great. Is there any list of all the BAP commands. I call command to something like: "Hub[0].Stop("A);". I need to Invert motors using "Edit Code".  Thanks once again.

Edited by nuno2500
Forget something important
  • Replies 745
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted
24 minutes ago, nuno2500 said:

Thank you so much. That is great. Is there any list of all the BAP commands. I call command to something like: "Hub[0].Stop("A);". I need to Invert motors using "Edit Code".  Thanks once again.

Take a loot at the help menu, there's at least a partial list there.

 

Posted
12 minutes ago, Nivst said:

Take a loot at the help menu, there's at least a partial list there.

 

Yes, i have been reading those topics but i can´t find an invert motor command :(

Posted

Hi,

invert a second motor regarding the first?

Hub[0]. setmotorspeed("B", Hub[0]. getspeed("A")*-1)

"invert" relative to - what?

 

 

 

 

Posted (edited)
On 12/3/2019 at 10:48 AM, Lok24 said:

Hi,

invert a second motor regarding the first?

Hub[0]. setmotorspeed("B", Hub[0]. getspeed("A")*-1)

"invert" relative to - what?

 

 

 

 

Hello Lok24. Thanks again for your patience :) I need to do this: stop (or wait) a train motor and reverse the motor. There is the "INVERT" option but does not stops before invert the motion (motor). It is a straight and single railroad so i need to go and go back but i want the train to stop at the trainstations on both ends. I have only one motor.

Edited by nuno2500
Forget something important
Posted

Hi,

The invert option can have a drawback: the train passes the coloured plate, and when it comes back it inverts again. So I if you use setmotorspeed or equivalent, it will always go the right way.

 

Posted
1 minute ago, lego3057 said:

Hi,

The invert option can have a drawback: the train passes the coloured plate, and when it comes back it inverts again. So I if you use setmotorspeed or equivalent, it will always go the right way.

 

You can get around that by using the hub states as flags.

Posted (edited)

Ah, I see! A shuttle train!

in general SetMotorSpeed(50) is forward, and SetMotorSpeed(-50)  is backwards

Here is what you need if you have a sensor in the engine, you need two  events (detecting white and red ie.)

 

if (Hub[0].State[0] == 0)  
{
    Hub[0].State[0] = 1;       
    Hub[0].RampMotorSpeed("A",0,1000);
    Wait(3000);
    Hub[0].RampMotorSpeed("A",10,50,1000);
}


if (Hub[0].State[0] == 1)
{
    Hub[0].State[0] = 0;
    Hub[0].RampMotorSpeed("A",0,1000);
    Wait(3000);
    Hub[0].RampMotorSpeed("A",-10,-50,1000);
}

or without sensor, by time (3secs to run)

while (True)
{
    Hub[0].SetMotorSpeed("A",50);
    Wait(3000);
    Hub[0].Stop("A");
    Wait(1000);
    Hub[0].SetMotorSpeed("A",-50);
    Wait(3000);
    Hub[0].Stop("A");
    Wait(1000);
}

 

Edited by Lok24
Posted (edited)

Eureka :) Eureka :) Thanks for all the help. I found a very easy way to do it. Just have so set up "trigger cooldown" on Hub Editor, higher than the time that take to get na unwanted sensor event.

Here is my code (trigger cooldown=20000):



if(Hub[0].GetSpeed("A")>0)

{Hub[0].Stop("A");

Wait(15000);

Hub[0].SetMotorSpeed("A",-75);}

else if(Hub[0].GetSpeed("A")<0)

{Hub[0].Stop("A");

Wait(15000);

Hub[0].SetMotorSpeed("A",75);}

Edited by nuno2500
missing text
Posted

Does anyone know if it is possible (and how!) to access the rotation encoder of Control+ motors? I'm trying to create a movement sequence for the Liebherr...

Thanks in advance!

Posted

Hello. How get raw value from color sensor? trigger value 5 is not suitable. I calculated the values for determining the blue and black color that I can set in the Powered Up application, but this is not possible here. 

Using C# reflection I find event "ColorTriggered" on Hub type, but it send result color. I find private field Characteristic - Windows.Devices.Bluetooth.GenericAttributeProfile.GattCharacteristic has event "ValueChanged", if i got it right here can get raw color value, but subscribe to this event imposible becouse dont using Windows.Devices namespace.

  • 4 weeks later...
Posted

Hi people! 

Finaly got my (88007) color sensors and build them into my 2 trains. Tested them with the PU app, they work like a charm, missing a color tile once in 20 times?? Not sure about that, but not very often. Now I am ready to go to use BAP and the self driving module! Oh heck....the self driving module works with sensors for each section, not with sensors in trains and colorplated sections! 

Help!!! I don't know how to code from scratch! I do know how to read code and adjust it here and there though. Currently I have a testing track layout with basically two turning loops, connected by a piece of single track, The 2 switches will be automated by an Sbrick in the future, but are not there yet so the switches now work as dummies to split up the track. I'm using red tiles to mark sections and white tiles to stop the trains at stations. I'd like to automate the trains so they ride from section to section, stop for a few seconds at stations and ofcourse won't colide while doing that! Does anyone have a good and complete example (some good comments in it would be helpful!) how to automate my two trains? 

Posted
On 12/7/2019 at 5:44 PM, Philo said:

Does anyone know if it is possible (and how!) to access the rotation encoder of Control+ motors? I'm trying to create a movement sequence for the Liebherr...

Thanks in advance!

Hi @Philo, do you want to access that in your program or physically? If in software then check my code from BC2: https://github.com/imurvai/brickcontroller2/blob/master/BrickController2/BrickController2/DeviceManagement/ControlPlusDevice.cs

There's a method called SetupChannelForPortInformationAsync which instructs the hub to send port information notifications. This notification is handled in the OnCharacteristicChanged method where both the absolute and relative positions are calculated from the response.

Posted

Hi @imurvai, Actually I wanted to do that in software, but not get too deep in low level code... that's why I tried BC2. Since it seems that getting rotation encoder encoder is not yet available in BC2, I used external sensors on a PUP hub to have a minimum feedback about the position of the arm. But now that Technic hub is supported in Powered up app, I'll use that to make what I want (even though this app does have some stupid shortcomings, such as limited range in input/output fields!)

Posted
On 4/1/2019 at 7:58 PM, mawe said:
On 4/1/2019 at 7:58 PM, mawe said:

Hello @Cosmik42
I have two questions on the "Self-Driving Train Module".

Second: Is it possible to drive with two-way traffic in this mode? I have seen that you only provide an "End Section Detector", that could be a problem. Imagine an oval with two alternative routes:
Oval.JPG

 

On 4/2/2019 at 3:01 PM, Cosmik42 said:

 

This has always been in my mind, but I never found the time to make it happen.

It create some much more complex edge cases unfortunately.

 

I don't think it has to be that hard. You should start bij giving a section the possibility of an end and start switch and also give each section the possibility of a start and end section.

In this example, let's say section 0 is the halve circle on the left and we number our sections clockwise:

- Section 0: Starts with switch: 4l, 5r, Ends with switch: 1l, 2r

- Section 1: Previous section: 0, Next Section: 3

- Section 2: Previous section: 0, Next Section: 3

- Section 3: Starts with switch: 1l, 2r, Ends with switch: 4l, 5r

- Section 4: Previous section: 3, Next Section: 0

- Section 5: Previous section: 3, Next Section: 0

Now when a train goes counter clockwise, the program can take these settings and simply turn everything around. In start position you have to configure your train and tell in which section it starts and which direction. I'm not sure if you can make the program detect a turning loop (easy when 1 section is connected left and right to a switch, more difficult when there are multiple sections in the loop) but if you can, you might want to switch status from clockwise to counter clockwise while the train is in the turning loop.

I think it's easier too when you know in which section which train is and therefor you can keep history. Yellow train is in section 1 now and was in section 0 before this? Then it's going clockwise. Red train is in section 4 and was in section 0 before? Then it's going counter clockwise. And that needs a decision who is to enter section 3 first. ;-)

Keeping track of history of the train is easier with colordetection in sections I guess. I hope you find time to implement the colordetection on sections in the self driving module anyway, maybe let people choose between the 2 options in the program.   

Posted

I'm experimenting with BAP. Not sure whether besides the Wedo 2.0 distance sensor (works perfect) the normal BOOST distance plus color sensor are also supported? I get at the moment:

 

Hub HUB NO.4 is connected!
Port Connected: B of type BOOST_DISTANCE
HUB NO.4 lost bluetooth connection
HUB NO.4 lost bluetooth connection
HUB NO.4 lost bluetooth connection
HUB NO.4 lost bluetooth connection
HUB NO.4 lost bluetooth connection
HUB NO.4 lost bluetooth connection
New device found - Mac Address 90842B1012B6
Exception while connecting Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at LegoTrainProject.MainBoard.<TryToConnect>d__18.MoveNext() in C:\Users\Cosmik\Dropbox (Lucky Duck Games)\Private\LuckyDuck\The Lego Project\Source\LTP.Desktop\Main UI\MainBoard.cs:line 186
New device found - Mac Address 90842B1012B6
Error opening communication:Unreachable
New device found - Mac Address 90842B1012B6

 

Not sure if its related to those boost version of the sensor.

 

I' ve also got issues with a WeDo Hub endlessly trying to reconnect hanging the program. The author hasn't been seen on this forum for months, is it? I've already upgraded my hubs. I'll try another laptop now.

 

Posted (edited)

Ai, if you open a project on another laptop it sees the hubs as new hubs ;-(

 

On another laptop it seems more stable now. The boost sensors however (from the lego shop, 88007 i think) don't detect anythink it seems. Wedo sensors work excellent.

 

O wait: it looks like the debug shows detection. It just isn't indicated in the hub section of the gui, as is in the WeDo case.

Edited by TuxTown
Posted

Oke, obviously I have to rebuild  a few switch motor blocks to get left and right oke ;-) What to do with switches which doesn't split the track but merge two tracks? Only put an end-section sensor there?

Posted (edited)
On 1/4/2020 at 8:04 PM, Venderwel said:

Hi people! 

Finaly got my (88007) color sensors and build them into my 2 trains. Tested them with the PU app, they work like a charm, missing a color tile once in 20 times?? Not sure about that, but not very often. Now I am ready to go to use BAP and the self driving module! Oh heck....the self driving module works with sensors for each section, not with sensors in trains and colorplated sections! 

Help!!! I don't know how to code from scratch! I do know how to read code and adjust it here and there though. Currently I have a testing track layout with basically two turning loops, connected by a piece of single track, The 2 switches will be automated by an Sbrick in the future, but are not there yet so the switches now work as dummies to split up the track. I'm using red tiles to mark sections and white tiles to stop the trains at stations. I'd like to automate the trains so they ride from section to section, stop for a few seconds at stations and ofcourse won't colide while doing that! Does anyone have a good and complete example (some good comments in it would be helpful!) how to automate my two trains? 

Hi

I also have that problem with reading colors, from time to time. The main reason why the BAP protection only works with distance sensor is because the color sensor is not that reliable

 

12 hours ago, TuxTown said:

Oke, obviously I have to rebuild  a few switch motor blocks to get left and right oke ;-) What to do with switches which doesn't split the track but merge two tracks? Only put an end-section sensor there?

Yes, one sensor after the switch

 

 

Edited by lego3057
Posted
1 hour ago, lego3057 said:

Hi

I also have that problem with reading colors, from time to time. The main reason why the BAP protection only works with distance sensor is because the color sensor is not that reliable

 

 

I know that is why the project works with the distance sensor, but it would be nice if both would be possible, let the user decide what type they want to use: Wanna use color sensor? Okay, use type 2 of self driving module, but beaware..... You want to use distance sensor? Use type 1 of self driving module...etc

 

I'm not sure how @Cosmik42 thinks about it, or other frequent posters (like @Lok24) in this topic, but maybe it's a good idea to start a BAP wiki? I'm willing to volunteer in that, though I never made/started a wiki. But I think it can be very useful to have manuals there and code examples. 

 

Posted

 

I'm trying to operate two trains in the self-driving module. "Could not set Motor Speed to 40 for Green Train because no default port are setup", it says. How do II setup a default port? I have all motors in port A (trains as well as switch motors) and all sensors in port B

Posted

Newbee jumping in here:blush:

I believe I scanned many of the posts but I'm not sure of one basic thing--

Can this app control both the sbrick and the control+ hubs?

If so, this sounds like a wonderful tool to operate an entire diorama with one program.

If so, one more question - can it work on a laptop with a bluetooth dongle?

Thanx, Ed

Posted (edited)

Wow, i didn't know this one existed. A Hub with 4 ports can be handy. The welcome message of the program says with version 1.5 control+ hub implementation complete, including L+XL engines. SBrick is also supported (I don't have one).

Edited by TuxTown
Posted
3 hours ago, TuxTown said:

 

I'm trying to operate two trains in the self-driving module. "Could not set Motor Speed to 40 for Green Train because no default port are setup", it says. How do II setup a default port? I have all motors in port A (trains as well as switch motors) and all sensors in port B

 

I've gone through the whole tool. And through large portions of this thread. Not a clue as to why of how to set a default port ?! The train just rides, but doesn't change speed or stop for an occupied section.

 

Also still not clear what the power up colors are for. Al my hubs use green at te moment. What's the purpose of changing tot white or blue?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.

Announcements

  • THIS IS THE TEST SITE OF EUROBRICKS!

×
×
  • Create New...