PDA

View Full Version : Sioc Codeing help



iwik
11-18-2016, 12:20 AM
Hi all,
Hope someone can help me correct the following code. Tried everything i understand but no
luck.
What i am trying to do is to have the output to a servo(fuel gauge) read zero when battery
switch is OFF. Here is my code.


Var 0010, name Batswstate, Link FSUIPC_IN, Offset $3102, Length 1 // MASTER BATTERY OFF =0
Var 012, name Fuel, Link FSUIPC_IN, Offset $0B94, Length 4 // Right Tank Percentage

{
IF V010 = 0
{
V014 = 0
}


L0 = &Fuel / 8388608
IF L0 < 0.25
{
L0 = L2 * 1023
V014 = L1 + 60
}
ELSE
{
V014 = L0 * 1023
}
}
Var 014, Link USB_SERVOS, Output 2, PosL 0, PosC 512, PosR 1000, Type 2


Thanks
Regards
Les

hyamesto
11-18-2016, 08:00 PM
Les:
With the USB SERVO, the value = 0 is for disconnect servo. (stays in place)
The value depends of the servo to mark 0 in instrumentīs scale.
Try another number (as i see in the SIOC code, must be in the range of 1 to 60)

[
IF V010 = 0
[
V014 = 60 // or value to zero the instrumentīs scale
]

Regards.
Horacio.

iwik
11-18-2016, 11:19 PM
Hi Horacio,
Nice to hear from you and thanks for replying. I tried your suggestion and had no luck.
So i changed the code around as follows


Var 0010, name Batswstate, Link FSUIPC_IN, Offset $3102, Length 1 // MASTER BATTERY OFF =0

Var 0012, name Fuel, Link FSUIPC_IN, Offset $0B94, Length 4 // Right Tank Percentage
{
L0 = &Fuel / 8388608
IF L0 < 0.25
{

L0 = L2 * 1023
V0014 = L1 + 60
}
ELSE
{
V0014 = L0 * 1023
}
IF &Batswstate = 0
{
V0014 = 10
}
}

Var 0014, Link USB_SERVOS, Output 2, PosL 0, PosC 512, PosR 0


Now it works BUT only when the engine is running, which shows in IOCPconsole
the fuel decreasing.
From my reading on Nico's site he says that " when a variable changes the script
in Curly brackets following is executed" obviously my understanding is wrong.
Cause according to my script its only executed if the fuel quantity is changing.So how does one get a process executed when this varaible
cant change as in my case fuel quantity.
Im utterly confused and no wonder why i can never get much to work .
Anyway your comments and ideas would be appreciated.
Thanks again
Regards
les

hyamesto
11-19-2016, 01:38 AM
Les:
Some lines in your code are wrong.

L0 = &Fuel / 8388608
IF L0 < 0.25
{
L0 = L2 * 1023
V0014 = L1 + 60
........


Where is L2 ??????


Anyway, try this way, working on my setup.



Var 0010, name Batswstate, Link FSUIPC_IN, Offset $3102, Length 1 // MASTER BATTERY OFF =0{
L0 = &Fuel / 8388608
IF &Batswstate = 0
{
V0014 = 10
}
ELSE
{
IF L0 < 0.25
{
L1 = L0 * 1023
V0014 = L1 + 60
}
ELSE
{
V0014 = L0 * 1023
}
}
}


Var 0012, name Fuel, Link FSUIPC_IN, Offset $0B94, Length 4 // Right Tank Percentage


Var 0014, Link USB_SERVOS, Output 2, PosL 0, PosC 512, PosR 1023




The values of V0014 are from your code....
Sure, there is another way to programming (using subroutines to check Batt status), but i have not sufficient information of your setup.
Regards.
Horacio.

iwik
11-19-2016, 03:37 AM
Big Thanks Horacio,
I have yet to try it out on the real gauges but testing SIOC it seems it works
fine.
Will let you know tomorrow when i integrate it with the rest of the code.
Take Care my friend
Regards
Les

kiek
11-19-2016, 04:37 PM
Hi Guys,

Here a SIOC best practice:

If you want to respond to changes in two other variables, you should put your script in a subroutine and call that subroutine from each of these two variable, like this:



Var 10 name Batswstate Link FSUIPC_IN Offset $3102 Length 1 // MASTER BATTERY OFF =0
{
CALL DoSomething
}


Var 12, name Fuel Link FSUIPC_IN Offset $0B94 Length 4 // Right Tank Percentage
{
CALL DoSomething
}

Var 9000 Link SUBRUTINE name DoSomething
{
// here the SIOC code that uses Batswstate and Fuel to calculate the output to the Servo
}


Kind regards.
Nico Kaan SIOC / How to program (http://www.lekseecon.nl/howto.html)

iwik
11-19-2016, 11:05 PM
Hi Nico,
Thanks for your comments and appreciate your guidance and i try to use your procedure when i can and will experiment so i can increase my skill level with sioc.


Horacio: Everything worked like a dream, so thanks again.

Kindest Regards
Les
P.S Had a wee go using Nico's advice and it worked great. I have stored that imformation for later

hyamesto
11-20-2016, 12:19 AM
Nico: Thatīs the way.... Thanks
Les: Youīre welcome.
Keep in touch.
Regards.
Horacio.