Hello!
I have FEZ Panda II and Drive Motor Shield. I need to control two motors(one for steering, one for move)
I’'ve used this code: http://www.tinyclr.com/codeshare/entry/194
but don’t understand how I can set different values for different motors
FEZ_Shields.DCMotorDriver.MoveRamp(100, 100, 20);
this command sets values for two motors, not for each other separately
hey @ bublik, welcome to the forums.
You’re correct, the MoveRamp and Move functions in the driver you showed sets two PWM signals at once.
If you look at the core of what they do, the Move function has two code blocks. Here’s one:
if (speed1 < 0)
{
_dir1.Write(true);
_pwm1.Set(1000, (byte)(100 - Math.Abs(speed1)));
}
else
{
_dir1.Write(false);
_pwm1.Set(1000, (byte)(speed1));
}
So all it does is figure out how to set the PWM parameters based on the input speed.
For you, where you want to control one or the other signal, I can see two approaches.
First option, just keep a variable that holds both speeds, and only change that variable; when you need to change one of the motors, set the required variable to it’s new value and then call the Move or MoveRamp. That should have the desired effect.
Second option, create new functions Move1 and Move2 and instead of having a code block inside Move() for each motor you can just unravel that into there.
Hope those options make sense!