I am confusing "OnFwdReg"
Posted: 14 Jun 2012, 22:03
Hi
I am starting with NXC. I have a code but I am confusing, so I have reduced my code to minimun.
I will show ..
this code work fine, but If I change the main task to
program do nothing !!! For me it is suppose that Wheels run in oposite direction!!!! (Robot should spin oposite than before)
another test ... If I change main task to ...
or ....
It runs fine too !!!
So why programn dont work when I try to Spin ACW (AnticlockWise) only ????
thanks in advance and sorry for my english!
I am starting with NXC. I have a code but I am confusing, so I have reduced my code to minimun.
I will show ..
Code: Select all
#define SPIN_SPEED 50
// NXT Port aliases
#define WHEELS OUT_BC
#define LEFT_WHEEL OUT_B
#define RIGHT_WHEEL OUT_C
#define CW 1 // clockwise
#define ACW -1 // anticlockwise
void Spin(short dir)
{
// Gira hacia el lado de "dir"
// Usar CW o ACW
NumOut(0, LCD_LINE4, dir);
NumOut(0, LCD_LINE5, sign(dir));
/*
OnFwdReg(LEFT_WHEEL, -sign(dir)*SPIN_SPEED, OUT_REGMODE_IDLE );
OnFwdReg(RIGHT_WHEEL, sign(dir)*SPIN_SPEED, OUT_REGMODE_IDLE );
*/
OnFwdReg(LEFT_WHEEL, dir*10, OUT_REGMODE_IDLE );
OnFwdReg(RIGHT_WHEEL, -dir*10, OUT_REGMODE_IDLE );
}
task main()
{
Spin(CW);
Wait(3000);
}
Code: Select all
task main()
{
Spin(ACW);
Wait(3000);
}
another test ... If I change main task to ...
Code: Select all
task main()
{
Spin(CW);
Wait(3000);
Spin(ACW);
Wait(3000);
}
Code: Select all
Spin(ACW);
Wait(3000);
Spin(CW);
Wait(3000);
So why programn dont work when I try to Spin ACW (AnticlockWise) only ????
thanks in advance and sorry for my english!