AForge.NET

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

NXT Motors Sync

The forum is to discuss topics related to robotics, like building robot, controlling it, its software and hardware, etc.

NXT Motors Sync

Postby TheOneRing » Mon Jan 18, 2010 10:52 am

Hi,
I'm currently trying to use the Synced mode with turn ratio but actually it doesn't work.
In all tutorials you have to set the motor state for AB or BC together with sync activated but actually AForge seems not to support this, am I doing something wrong?

What is the correct way of syncing two motors? Can you please give me a small example.


PS: oops wrong toppic please move to AForge.NET Framework
TheOneRing
 
Posts: 6
Joined: Mon Jan 18, 2010 10:46 am

Re: NXT Motors Sync

Postby andrew.kirillov » Mon Jan 18, 2010 11:26 am

Hello,

Don't have my NXT here at this moment, so can not try. As far as I remember from the time I was playing with NXT, one motor should be set first to Sync regulation mode and the another one should be set to Speed. When you set first motor to Sync, nothing happens. But when set second motor to Speed, both should start moving.

Unfortunately there is no much details given by Lego about their Bluetooth API, so many things should be discovered or searched on the Internet.
With best regards,
Andrew


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

Re: NXT Motors Sync

Postby TheOneRing » Mon Jan 18, 2010 11:49 am

Thanks for the quick reply.
Actually I ported your c# code in some parts to c++,
so my code look a bit different but all in all works in the same way.

So here is my code for setting the motor state:

MotorState motorstateB;
motorstateB.Power=-js.y*100.0/Joystick::maxY;
motorstateB.Mode=On;
motorstateB.Regulation=Sync;
motorstateB.TurnRatio=js.x*100.0/Joystick::maxX;
motorstateB.RunState=Running;
motorstateB.TachoLimit=0;

MotorState motorstateC(motorstateB);
motorstateC.Regulation=Speed;

ns->setMotorState(B,motorstateB);
ns->setMotorState(C,motorstateC);

I'm trying to remote control the nxt with my gamepad.
Solutions like setting different power levls for setting the directions are working but the turn ratio doesn't work at all.

Any Ideas?
TheOneRing
 
Posts: 6
Joined: Mon Jan 18, 2010 10:46 am

Re: NXT Motors Sync

Postby andrew.kirillov » Mon Jan 18, 2010 11:57 am

Not sure about details of your implementations ... But here is one thing I've spotted in your code, which may be a bit wrong ...

Motors' mode is a bit field, so you may need doing something like this:
Code: Select all
motorstateB.Mode=On | Regulated;

Otherwise I think your regulation settings are ignored.
With best regards,
Andrew


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

Re: NXT Motors Sync

Postby TheOneRing » Mon Jan 18, 2010 12:59 pm

Hi thank's
motorstateB.Mode=On | Regulated; worked but now it reacts a bit strange. It changes the directions while driving forward. ^^
But one problem is solved thank you :D
TheOneRing
 
Posts: 6
Joined: Mon Jan 18, 2010 10:46 am

Re: NXT Motors Sync

Postby TheOneRing » Mon Jan 18, 2010 4:01 pm

Hi,
in my code the gempad state is read every 220ms and send to the nxt now ith seems like the nxt switches the left and the right motor every interval, and thats the reason why it cant drive an any direction I want it to.
Code: Select all
   motorstate.Mode=On|Regulated;
    motorstate.Regulation=Sync;
    motorstate.RunState=Running;
    motorstate.TachoLimit=0;
    motorstate.TurnRatio=js.x*100.0/Joystick::maxX;
    motorstate.Power=-js.y*100.0/Joystick::maxY;
    ns->setMotorState(B,motorstate);
    ns->setMotorState(C,motorstate);


Greetings
TheOneRing
TheOneRing
 
Posts: 6
Joined: Mon Jan 18, 2010 10:46 am

Re: NXT Motors Sync

Postby TheOneRing » Mon Jan 18, 2010 4:35 pm

Just tried one in speed mode one in syc mode, but the result was the the synced one did nothing and the speed one was working
TheOneRing
 
Posts: 6
Joined: Mon Jan 18, 2010 10:46 am

Re: NXT Motors Sync

Postby andrew.kirillov » Mon Jan 18, 2010 8:14 pm

Hmmm ... I do remember that somehow I managed to start both motors rotate simultaneously using Sync mode ... But I also remember there were some issues with it.

As for my Lego bots I decided to skip with Sync and just send two command one after another. Bluetooth is not so slow, so you should not see motion issues with this approach.

It will be interesting to hear if you find some solution or not. In the meantime I will try it with my Lego when I have a moment.
With best regards,
Andrew


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

Re: NXT Motors Sync

Postby TheOneRing » Tue Jan 19, 2010 7:43 pm

Hi, i simplified the moving capabilities now its only possible to move in one direction at once, but I left the possibility to implement a smooth turning if I can solve the sync issue.

But the work f my fellow students is quite interesting for you I think ^^ the pended some hours more in their project.

Here is a movie


and here is the link to the web page (only German) http://www.dkohler.ch/nxtRubik/.
TheOneRing
 
Posts: 6
Joined: Mon Jan 18, 2010 10:46 am

Re: NXT Motors Sync

Postby Piero » Wed Dec 22, 2010 8:46 am

Hi, what is the exact syntax to move forward a NXT? I have to use sync regulation in one motor and speed in the other or i can move one motor before the other without sinc regulation?
Thanks!
Piero
 
Posts: 19
Joined: Mon Dec 13, 2010 3:52 pm



Next

Return to Robotics

cron