Page 1 of 1

Help Scripts SIOC

Posted: Fri Feb 10, 2023 7:08 pm
by Rafape
Hi from Madrid (Spain).

Let's see if someone who knows more than me can open my eyes. Programming sioc I know the basics switches and leds. I have copied two old codes that I found on the forums. With one I burned a servo because I don't understand the operations very well. I would like to understand the steps to follow. The code that works for me and not very well since the servos are jumping is this: (Thanks to Brian W. ;))

// ************************************************ ****************************
// * Config_SIOC ver 4.5 - By Manuel Velez - www.opencockpits.com
// ************************************************ ****************************
// * FileName : BRAKES_BRIANW.txt
// * Date : 7/24/2018


Var 0801, name SERVO_AcuPre, Link USB_SERVOS, Device 3, Output 1, PosL 200, PosC 478, PosR 804, Type 1 // ACCU PRESSURE
Var 0802, name TXRX_ACC, Link FSUIPC_INOUT, Offset $73A7, Length 1
{
L0 = &TXRX_ACC
L0 = L0 * 1
L0 = L0 * 1.8
L0 = L0 + 200
&SERVO_AcuPre = L0
}

According to the Opencockpits USB Servos card the range goes from 0 to 1023. According to Jean Luc's Offset (Triple Brake Indicator ACCU Pressure (0-255))

Could someone who knows how to program explain to me the reason for these calculations and where does multiply by 1 come from, then multiply by 1.8, then add 200, etc?

I have seen all the opencockpits videos, tutorials, forums, but I have not found anything on how and why to structure the code. Or if you know something where it is explained with examples to see what kind of information is needed to get to program something other than switches and leds.

Immensely grateful, regards, Rafa.

With a lot of effort, design, machining and time, this has been my job ;)

Re: Help Scripts SIOC

Posted: Wed Feb 15, 2023 8:33 am
by iwik
Hi,
I will do the best i can from memory.You can ignore the x 1. The 1.8 scales up the 0 to 255 to the range the servos use. I think the 200is just an offset. What you are supposed to do is connect your gauge with servo up to O/C servo card and run Servo test program. Adjusting the slider and note the values from 0 to Full scale.The 1.8 here just scales up the value from the sim to the workable range of the servo. You fiddle the value of 1.8 and 200 to get the gauge to follow what happens in fmGS.
Hope this helps,i have used this code and it works well.If i have made some errors please correct them.

Re: Help Scripts SIOC

Posted: Wed Feb 15, 2023 5:00 pm
by Rafape
Thank's Iwik.

From what I've tried to understand:

Var 0802, name SERVO_PressL, Link USB_SERVOS, Device 3, Output 2, PosL 200, PosC 512, PosR 804, Type 1 // Pressure L

Var 0805, name TXRX_PressL, Link FSUIPC_INOUT, Offset $73A8, Length 1
{
L0 = &TXRX_PressL
L0 = L0 * -1
L0 = L0 * 1.7
L0 = L0 + 200
&SERVO_PressL = L0
}

L0 = &TXRX_PressL (Value taken from the simulator, right?)
L0 = L0 * 1.7 (We multiply by 1.7 that I get from dividing 1023/604)
L0 = L0 + 200 (The limit of the minimum?)
&SERVO_PressL = L0 (The result)

L0 = L0 * -1 (Made the servo rotate backwards)

It works, but the servos are jumping, it doesn't have a continuous movement.

Anyway, thanks for your answer ;)