I'm trying to use 2 synchronized motors sending direct commands. I read the bluetooth documentation but I can not understand how regulation parameters works to synchronize motors.
Can any one help me?
Motor synchronization using Direct commands
Re: Motor synchronization using Direct commands
You prepare two parameter sets for SetOutputState, with all parameters exactly the same, except the motor. You use MODE_REGULATED, and REGMODE_SYNC. The motor on bit has to be 1 as usual, and the optional brake bit can be 1 (just use 1, you'll be fine). The RUNSTATE can as usually be RUNNING.
The "trick" is now to send the SetOutputState command to the first motor, and then to the second. Both motors will start running in sync.
It's best if both motors are turned off before (motor-on bit 0, runstate idle, regmode off, power 0), and if BlockTachoCount is reset (using ResetMotorPosition, set the "relative" parameter to true to reset BlockTachoCount).
Good explanations are found in the LEGO Mindstorms NXT "Executable File Specification" (see NXT homepage), and inside the NXC Guide PDF (see Output Module).
The "trick" is now to send the SetOutputState command to the first motor, and then to the second. Both motors will start running in sync.
It's best if both motors are turned off before (motor-on bit 0, runstate idle, regmode off, power 0), and if BlockTachoCount is reset (using ResetMotorPosition, set the "relative" parameter to true to reset BlockTachoCount).
Good explanations are found in the LEGO Mindstorms NXT "Executable File Specification" (see NXT homepage), and inside the NXC Guide PDF (see Output Module).
RWTH - Mindstorms NXT Toolbox for MATLAB
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
Re: Motor synchronization using Direct commands
With the enhanced NBC/NXC firmware you can do this with a single SetOutputState direct command rather than two separate ones. Just pass in one of these three combined motor constants and the enhanced NBC/NXC firmware will do the right thing.
In the standard firmware the SetOutputState direct command does accept the 0xFF value to mean "all motors". This may work if you are synchronizing A and B but C is not connected or if you are synchronizing B and C but A is not connected. I haven't tested this so I can't say for sure if it works correctly or not.
John Hansen
Code: Select all
#define OUT_AB 0x03
#define OUT_AC 0x04
#define OUT_BC 0x05
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Who is online
Users browsing this forum: No registered users and 2 guests