SetOutputState direct command turn ratio not working

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
ejvaughan
Posts: 10
Joined: 13 Jun 2011, 02:38

SetOutputState direct command turn ratio not working

Post 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.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: SetOutputState direct command turn ratio not working

Post by afanofosc »

Your Mode needs to include the OUT_MODE_REGULATED bit. MOTORON+BRAKE+REGULATED is probably your best bet.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
linusa
Posts: 228
Joined: 16 Oct 2010, 11:44
Location: Aachen, Germany
Contact:

Re: SetOutputState direct command turn ratio not working

Post 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.
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
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: SetOutputState direct command turn ratio not working

Post 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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests