Page 1 of 1

SetOutputState direct command turn ratio not working

Posted: 04 Jan 2012, 17:49
by ejvaughan
Hey guys. I have a question about the turn ratio parameter for the SetOutputState direct command. I understand what it is supposed to do--that is, set the speed of a motor relative to the speed of the motor to which it is synchronized--but it does not seem to be working for me. Here is my code (Objective-C):

Code: Select all

[anNXT setOutputState:kNXTMotorB
                            power:75 
                             mode:kNXTMotorOn 
                   regulationMode:kNXTRegulationModeMotorSync 
                        turnRatio:100
                         runState:kNXTMotorRunStateRunning 
                       tachoLimit:0];
            [anNXT setOutputState:kNXTMotorC
                            power:75 
                             mode:kNXTMotorOn
                   regulationMode:kNXTRegulationModeMotorSync
                        turnRatio:0
                         runState:kNXTMotorRunStateRunning
                       tachoLimit:0];
Unfortunately, this does not effect any sort of turning. Calls to GetOutputState for both motors (B and C) reveal that their turn ratios are correctly set to 100 and 0, respectively. So I do not understand why this isn't working. I am using the enhanced NXC/NBC firmware, v. 1.31. Any help would be appreciated.

Re: SetOutputState direct command turn ratio not working

Posted: 04 Jan 2012, 21:29
by afanofosc
Your Mode needs to include the OUT_MODE_REGULATED bit. MOTORON+BRAKE+REGULATED is probably your best bet.

John Hansen

Re: SetOutputState direct command turn ratio not working

Posted: 05 Jan 2012, 01:12
by linusa
Also, you have to send two identical packets, one to each motor. In your example, turnRatio:100 should be set both times. Movement will only start with the 2nd packet.

If you get strange results with multiple commands, make sure to reset BlockTachoCount of both motors and turn off both motors between calls (pairs of calls) to SetOutputState.

Re: SetOutputState direct command turn ratio not working

Posted: 05 Jan 2012, 01:23
by afanofosc
If you are using the enhanced NBC/NXC firmware you can use a single direct command for this and so long as you only have 2 motors connected you can do it via a single command with the standard firmware as well (I am pretty sure). 0xFF means all ports with the standard firmware. I'm not 100% certain what happens when you set 3 motors on and regulated with sync and a turn ratio. My guess is it would sync A and B but I could be wrong.

With the enhanced NBC/NXC firmware you can pass 3 for AB, 4 for AC, 5 for BC, and 6 for ABC or you can pass 0xFC for AB, 0xFD for AC, and 0xFE for BC.

Gosh I never realized that there was so much more to the enhanced NBC/NXC firmware in addition to support for multi-dimensional arrays! And it's 100% compatible with the standard NXT firmware too.

John Hansen