NXT Virtual Subtractor
Simple software solution that allows to control two independent motors as if they were connected by a subtractor.
Datasheet:
Completion date: 27/10/2012
Power: electric (NXT brick)
Language: ROBOTC
Bricks: 1
Motors: 2 x NXT motor
Sensors: none
I’m a big fan of controlling NXT-powered models with a control pad, especially in analog mode, with joysticks and speed control. I was looking for a way to easily control two independent propulsion motors, such as left/right motor in the tracked vehicles. Usually the control can be made easy mechanically, using a subtractor, but sometimes there is no space for it, or the propulsion system is under too much stress to use pieces such as differentials. I found a purely software solution that uses just one pad’s joystick to control two independent propulsion motors just as if they were connected with a subtractor, even though the subtractor is not there. The main advantage of this solution is that it enables analog speed control in all possible directions’ combinations.
Virtual subtractor program:
#include "JoystickDriver.c"
task main()
{
bMotorReflected[motorA] = false;
bMotorReflected[motorB] = false;
while(true)
{
getJoystickSettings(joystick);
motor[motorA] = 0;
motor[motorB] = 0;
if (joystick.joy1_y1 != -6)
{
motor[motorA] = joystick.joy1_y1 / 1.28;
motor[motorB] = joystick.joy1_y1 / 1.28;
if (joystick.joy1_x1 != -5)
{
motor[motorA] = (joystick.joy1_y1 + joystick.joy1_x1) / 2.56;
motor[motorB] = (joystick.joy1_y1 - joystick.joy1_x1) / 2.56;
}
}
else if (joystick.joy1_x1 != -5)
{
motor[motorA] = joystick.joy1_x1 / 1.28;
motor[motorB] = joystick.joy1_x1 / -1.28;
}
nxtDisplayCenteredTextLine(0, "BATTERY: %3.1fV", nImmediateBatteryLevel / (float) 1000);
nxtDisplayTextLine(2, "Y1: %d", joystick.joy1_y1);
nxtDisplayTextLine(3, "X1: %d", joystick.joy1_x1);
}
}
@EV3fan
I don’t know ev3 software.
Is it possible to control a robot with a programm written in the ev3 software running on it via such a gamepad? I don’t have any idea how to code in robotc, you know.
to me that’s the most precise tank steering possible – great work, especially programming
Oke
@Lennart
I suggest you type “robotc” into Google and click the first link you get.
Where can you buy/download that?
@Lennart robotC
What kind of software do you use?
@Sariel
Ok thanks! See my site for nxt & PF creations!
Nxt45.wordpress.com
@Nxt45
Well, it works for me.
@Sariel
I downloaded robotC 3.05 and it did not work it just came up with errors.
@NXT45
Obviously, that’s why it’s not called 3.05 anymore.
@Sariel
Is ther any differenc between 3.05 and 3.51?
@Sariel
Thanks!
@NXT45
3.05
Hi! What kind of RobotC is this? 3.54?
@Marcky
There’s a pre-made driver for it in the ROBOTC.
I hope this is not a stupid question with an obvious answer, but how do you interface the joystick with the NXT unit?
Witam. Chciałem powiedzieć, że zamiast pada zawsze możesz wykorzystać układ sterowany żyroskopem 😉 na warsztatach z robotyki zbudowaliśmy platformę na gąsienicach sterowaną właśnie dwoma “pilotami” z żyroskopami. Gąsienice są sterowane niezależnie, każda ma swój silnik. Zamieszczam filmik ze sprawozdaniem z tych warsztatów. Czasem widać na rękach dwa “piloty” oraz tą platformę. Mogę też poszukać i wysłać na maila kilka zdjęć tej konstrukcji. http://youtu.be/aCSrWavjhVM?t=5m4s