How to make script for Tiller
Posted: Tue Mar 21, 2017 8:12 pm
This a little info about getting a Steering Tiller in operation.
The script code here is now included in the latest OCP4NGX script code.
Well, I don't have a steering tiller myself, but I guess this isn't too difficult.
By reading the servo card manual, and examining some other scripts, I think you would know the solution.
There's always a program example in the Opencockpits manuals.
In the specific manual, there are two examples. One for the servos and one for the analog inputs. By combining some code of both examples, you would have the solution.
So we need some code to read the analog input:
Var 001, name tiller_pot, Link USB_ANALOGIC, Device 2, Input 1, posL 0, posC 128, posR 255
Now you say that you get values between 55 and 203 with the center at 128. To make use of the complete analog input range 0-255, we need to change our code a little bit:
Var 001, name tiller_pot, Link USB_ANALOGIC, Device 2, Input 1, posL 55, posC 128, posR 203
After changing this, the value that comes from the analog input will go from 0 to 255 and no longer from 55 to 203 which give you a better resolution to control the tiller.
By entering the range of your potentiometer, sioc will calculate the full range from 0-255.
In SIOC monitor the value from the potentiometer will still be 55-203 because this is the raw data, but once you use the analog input in a variable, you can see the used value in the IOCP monitor.
Ok, now we also need some code to send data to an FSUIPC offset:
The offset for the steering tiller is 3BC4
Var 002, name tiller_offset, Link FSUIPC_OUT, Offset $3BC4, Length 2
Ok, now that we've got the code for the analog input and the FSUIPC offset, we need to make a complete code that sends the analog input to the FSUIPC offset:
Var 001, name tiller_pot, Link USB_ANALOGIC, Device 2, Input 1, posL 55, posC 128, posR 203
{
&tiller_offset = &tiller_pot
}
Var 002, name tiller_offset, Link FSUIPC_OUT, Offset $3BC4, Length 2
By adding the code "&tiller_offset = &tiller_pot", the value that comes from the analog input will be send to the FSUIPC offset everytime that the potentiometer has been moved.
Now run your flight sim, start sioc and open FSUIPC. Go to Axis Assignment and move the tiller. Select "Send direct to FSUIPC calibration",
enable the first action and from the list, select "Steering tiller". Now go to "Joystick calibration", page 9 and there calibrate the steering tiller.
That's all I guess.
I just tried this with a spare servo card and potentiometer and it seems to work here.
The script code here is now included in the latest OCP4NGX script code.
Well, I don't have a steering tiller myself, but I guess this isn't too difficult.
By reading the servo card manual, and examining some other scripts, I think you would know the solution.
There's always a program example in the Opencockpits manuals.
In the specific manual, there are two examples. One for the servos and one for the analog inputs. By combining some code of both examples, you would have the solution.
So we need some code to read the analog input:
Var 001, name tiller_pot, Link USB_ANALOGIC, Device 2, Input 1, posL 0, posC 128, posR 255
Now you say that you get values between 55 and 203 with the center at 128. To make use of the complete analog input range 0-255, we need to change our code a little bit:
Var 001, name tiller_pot, Link USB_ANALOGIC, Device 2, Input 1, posL 55, posC 128, posR 203
After changing this, the value that comes from the analog input will go from 0 to 255 and no longer from 55 to 203 which give you a better resolution to control the tiller.
By entering the range of your potentiometer, sioc will calculate the full range from 0-255.
In SIOC monitor the value from the potentiometer will still be 55-203 because this is the raw data, but once you use the analog input in a variable, you can see the used value in the IOCP monitor.
Ok, now we also need some code to send data to an FSUIPC offset:
The offset for the steering tiller is 3BC4
Var 002, name tiller_offset, Link FSUIPC_OUT, Offset $3BC4, Length 2
Ok, now that we've got the code for the analog input and the FSUIPC offset, we need to make a complete code that sends the analog input to the FSUIPC offset:
Var 001, name tiller_pot, Link USB_ANALOGIC, Device 2, Input 1, posL 55, posC 128, posR 203
{
&tiller_offset = &tiller_pot
}
Var 002, name tiller_offset, Link FSUIPC_OUT, Offset $3BC4, Length 2
By adding the code "&tiller_offset = &tiller_pot", the value that comes from the analog input will be send to the FSUIPC offset everytime that the potentiometer has been moved.
Now run your flight sim, start sioc and open FSUIPC. Go to Axis Assignment and move the tiller. Select "Send direct to FSUIPC calibration",
enable the first action and from the list, select "Steering tiller". Now go to "Joystick calibration", page 9 and there calibrate the steering tiller.
That's all I guess.
I just tried this with a spare servo card and potentiometer and it seems to work here.