10-23-2008 04:37 AM
HI,
I have a joystick input which i have calibrated so that it is giving me an output of -10 to +10 at the extremes of the joystick's x axis.
From this i have an output into a case structure with 3 cases.
At the moment if the output is positive it moves a hydraulic tray (simulating a wing) upwards. (and keeps going up until it reaches the top)
if the output is negative it moves the hydraulic tray downwards (and keeps going until it reaches the floor)
and if the output is zero it turns the hydraulic pump off.
My problem i have realised is that if i move the joystick completely to the left (output of -10) the tray goes down as expected, but to move the tray up again i have to take the joystick past zero (output>0), whereas in fact it should start to go up as soon as i move the joystick slightly left (output>-10).
So i guess what i mean is i need it to move up as soon as the output of -10 to +10 increases.
What is the simplest way to do this? Is it inserting a simple formula node with a for statement in? If so what is the syntax for it because i'm not a programmer at all. I'm guessing i need some kind of:
for ??? (while the vi is running)
if(input(n) > input(n-1))
output = case 1;
else if (input(n) < input(n-1))
output = case 2;
else output = case 3;
I basically want to know exactly what to write in the formula node if anyone can help??
Regards,
Kieran
10-23-2008 07:30 AM - edited 10-23-2008 07:32 AM
desired logic without code node. When using compare like this, always use and integer as comparing a DBL with a DBL does not work, the numbers are almost the same but never quite exactly the same at the n..th significant digit.