AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

LEGO NXT: What does BRAKE flag really do?

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

LEGO NXT: What does BRAKE flag really do?

Postby one_eddie » Tue May 03, 2011 10:45 am

I made few tests

1: ON+REGULATED+SPEED+BRAKE
2: ON_REGULATED+SYNC+BRAKE
3: 1 without BRAKE set
4: 2 without BRAKE set

In tests 1 and 2 the brake flag did not changed anything. The motors (robot) behaves same (coasting). Any ideas what might be wrong?
one_eddie
 
Posts: 25
Joined: Tue Mar 29, 2011 2:59 pm
Location: Poland

Re: LEGO NXT: What does BRAKE flag really do?

Postby cheelio » Sun May 08, 2011 1:43 pm

Hey,
I can feel your pain....
I was also suffering with the same frustrations....
It took me some time to figure it out, but now I finally understand how braking works.
Main thing to keep in mind that you will always have to set power to 0 when doing a brake.
Mode has to be either ON+BRAKE for doing just the brake
or ON+BRAKE+REGULATED (with regulationmode set to speed) to keep the motor fixed at the braking point...
cheelio
 
Posts: 1
Joined: Sun May 08, 2011 1:33 pm

Re: LEGO NXT: What does BRAKE flag really do?

Postby mrbencowell » Sat May 14, 2011 4:40 pm

Hi there,

Eddie I've been following your posts as I've had a very similar issue to you. I've been trying to get control of two motors to move as in-sync in possible however I had absolutely no luck. In desperation I also tried MindSqualls although as Andrew has mentioned in other posts aforge is pretty much just sending bytes to the Lego. I suspect my issues aren't with aforge but with my understanding of how and in what order to control the motors. Digging into both MindSqualls and Aforge code there didn't seem to be much difference at all in the motor classes and methods.

To try and get my head around things I've setup a custom form to be able to set everything on the Motors manually so I can check the effects. It does seem very random at times .. quite often the motors emit a high pitched whistle which I'm guessing is something to do with sync or applying the brake but I'm not quite sure.

I can't get Turn Ratio to do anything at all, likewise Sync seems to cause the motors to run forever rather than respect the Tacho limits which leads me to think there's a bit more to getting control of these motors than is immediately apparent. If anyone can give me any pointers how to successfully sync motors I'd be MOST appreciative.

cheers
ben
User avatar
mrbencowell
 
Posts: 17
Joined: Sat May 14, 2011 4:29 pm

Re: LEGO NXT: What does BRAKE flag really do?

Postby one_eddie » Sun May 15, 2011 7:44 pm

Hi, please send the code to test and describe the behavior of the robot that occurs on your side. I'll try to check it out, maybe we can find a solution.
Did you tired to report this to LEGO support? Maybe there's a bug in the firmware (communication protocol implementation).
one_eddie
 
Posts: 25
Joined: Tue Mar 29, 2011 2:59 pm
Location: Poland

Re: LEGO NXT: What does BRAKE flag really do?

Postby mrbencowell » Sun May 15, 2011 10:47 pm

I'll send over the code tomorrow,

Reading around on the net today I'm starting to suspect that the direct lego commands work in a very different way to NXT-G etc, it seems that they may by pass the PID controller on the NXT (although I could have this completely wrong, information is hard to come by !).

Here's a link I've come across, which seems to back this up :

http://forums.ni.com/t5/LabVIEW-Educati ... d-p/909110

However there seem to be lots of people out there happily using various libraries which are all based upon Direct Commands. Aforge seems to be the only current c# solution out there with a community discussing it's use, mindsqualls hasn't been updated in 4 years, , whilst the site for NXT# has been down for a while now so I'm guessing it's also a dead project.

I'm beginning to think that if I want good synced control of motors I'm going to have to run either a NXT-G or Robot-C program on the brick and then send Bluetooth commands out of C# to trigger motors as required. Sigh .. I should have known it wouldn't be simple !.
User avatar
mrbencowell
 
Posts: 17
Joined: Sat May 14, 2011 4:29 pm

Re: LEGO NXT: What does BRAKE flag really do?

Postby mrbencowell » Sun May 15, 2011 11:12 pm

To expand on my post above, my suspicion is that when NXT-G syncs the motors it's doing something far cleverer than just sending direct commands, I suspect it's monitoring and anticipating motor position and constantly setting and reseting the motors as required, however direct commands alone aren't enough to keep motors synced or regulated.

I could be completely wrong about this, I was hoping to post on the NXTstep forum to ask for some NXT expert opinions but registration is currently closed.

More links and reading on Direct Commands :

http://forums.ni.com/t5/LabVIEW-Educati ... 687/page/2
http://www.mindstorms.rwth-aachen.de/tr ... torControl
User avatar
mrbencowell
 
Posts: 17
Joined: Sat May 14, 2011 4:29 pm

Re: LEGO NXT: What does BRAKE flag really do?

Postby andrew.kirillov » Mon May 16, 2011 9:05 am

Hello,

It is really nice to see we got a group of people finally who is trying to contribute to solving this motors’ related issue. Will also spend some time with my NXT to see if anything could be done. However the issue seem to be not that that simple and potentially the fix may not be possible within the Bluetooth API. Anyway, it is nice we got the brainstorming and sharing of the information.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3451
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: LEGO NXT: What does BRAKE flag really do?

Postby mrbencowell » Mon May 16, 2011 9:38 am

Thanks Andrew,

I agree it really does take a community of people banging their heads to try and get to the bottom of this stuff. Whilst its frustrating having to piece together various bits of information found on the web to get to the bottom of how to correctly use Sync and braking using direct commands, it's also part of the nerdy joy in all of this I guess.

As I say I'm going to look into this further this week, I intend to have a gui control that's giving me real time feedback to the various tacho counter properties, I suspect the use and reseting of these at the correct times it's part of the secret, and the reason why some of us are getting motor's reversing and zeroing in on positions before they start to rotate in sync.

If everyone else can also post their findings here that'd be very helpful.

All the best,
Ben

ps : Andrew congrats on a great library .. it's been invaluable on my project.
User avatar
mrbencowell
 
Posts: 17
Joined: Sat May 14, 2011 4:29 pm

Re: LEGO NXT: What does BRAKE flag really do?

Postby one_eddie » Mon May 16, 2011 10:10 am

Hi Ben, you wrote:
mrbencowell wrote:It does seem very random at times .. quite often the motors emit a high pitched whistle which I'm guessing is something to do with sync or applying the brake but I'm not quite sure.


I found this which seems to describe your scenario.

Sending commands ¶
When we want the motor to execute a movement, we simply send the correct string to the according mailbox. The motor for the specified port must be idle, i.e. it can't be carrying out any other movement commands at the time when the new command arrives. If this should happen, the NXT will indicate this erroneous user behavior by a signal (high and low beep) and will drop (ignore) the message.
Source: http://www.mindstorms.rwth-aachen.de/tr ... torControl


Simple approach as a workaround you should always check current state before changing it to another I quess.
one_eddie
 
Posts: 25
Joined: Tue Mar 29, 2011 2:59 pm
Location: Poland

Re: LEGO NXT: What does BRAKE flag really do?

Postby mrbencowell » Mon May 16, 2011 10:32 am

Great thanks Eddie, that does sound like the noise I'm hearing .. it's strange that it comes from the motors though ! .. I'll look into this.

I'm pretty new to C# so I'm trying to figure out how to create or work with events so I can keep a constant monitor on the motors, I'm guessing that Bluetooth delay will be an issue but it'd be exceptionally useful to have close to realtime feedback on the motor's current position.
User avatar
mrbencowell
 
Posts: 17
Joined: Sat May 14, 2011 4:29 pm



Next

Return to AForge.NET Framework