Results 1 to 7 of 7
Thread: Sioc Code Frustration
-
06-27-2011, 03:00 PM #1
- Join Date
- Jan 2007
- Location
- NEW ZEALAND
- Posts
- 899
Sioc Code Frustration
Hi All,
Im battling again, it seems to be a never ending battle for me. Read all docs, been to Nico
site but my code dont do what i want. The simple stuff is ok but when i have to do
anything slightly diff all goes wrong. It seems to me this sioc is not what it appears.
Heres my problem.
Im driving an Analogue meter from the Servo card via a PWM to Dc converter. AS the
first 25% of the scale is non linear i have to add an offset for this first 25%.
Here is my Code:
Var 1002,name Fuel Link FSUIPC_IN,Offset $0b7c,Length 4
{
L0 = v1002 / 8388608
L2 = L0 * 100
IF L2 < 25
{
CALL V100
}
ELSE
V1000 = L0 * 1023
}
VAR 100,Link SUBRUTINE
{
L1 = L0 * 1023
V1000 = L1 + 70
}
Var 1000,Link USB_SERVOS,Output 2,Posl 0,Posc 512,Posr 1023,Type 2
If i select 20% fuel in FSX then it just carries out the statement after ELSE.
I thought that after an IF statement(L2 < 25) the Code following in the Curly Brackets
would be executed. In my case its not, ive tried everything but no success.
Apparently this if statement is not what it appears.
Can someone please help.
Thanks
Les
-
06-27-2011, 04:13 PM #2
- Join Date
- Jul 2013
- Posts
- 917
Re: Sioc Code Frustration
Les
Are you sure that section of conditional code is not being run. The reason I ask is that you appear to be using L0 in two variable sections of code. You cannot carry across a local variable value from one section to another - that is why they are local. This will give you strange results Perhaps you could call the subroutine passing the L0 (not sure?). Simplest answer is to have a new variable defined to replace the instances where you have used L0
As always I stand to be corrected
Regards
David
-
06-27-2011, 05:46 PM #3
Re: Sioc Code Frustration
Hi Les,
David is right.
This statement:
Code:L1 = L0 * 1023
Nico
BTW: wrap CODE tags around your code, will make your posts a lot more readable (see the numbersign icon above in this editor)
-
06-27-2011, 08:18 PM #4
Re: Sioc Code Frustration
Hello iwik
A small change and the code should logically work though not as you may expect.
Unsure what you try to achieve because it seems that the "servo" value will
have an overlapping region.
I would have split the gauge/meter in two sections - each with its own scaling factor
or maybe just lower the multiplier in the line:
L1 = L0 * 1023
Code:Var 1002,name Fuel Link FSUIPC_IN,Offset $0b7c,Length 4 { L0 = v1002 / 8388608 L2 = L0 * 100 IF L2 < 25 { L1 = L0 * 1023 V1000 = L1 + 70 } ELSE { V1000 = L0 * 1023 } } Var 1000,Link USB_SERVOS,Output 2,Posl 0,Posc 512,Posr 1023,Type 2
-
06-28-2011, 02:39 PM #5
- Join Date
- Jan 2007
- Location
- NEW ZEALAND
- Posts
- 899
Re: Sioc Code Frustration
Hi and Thanks all.
David- Learnt something new, meaning of Local variables.
Kiek- Will do code with tags in future, always wondered how others were getting that format.
Per-Eirk- i think i lost my way big time. Your comments helped a lot, put me back on track and made my code simpler. Works well now.
Les
-
06-28-2011, 03:03 PM #6
Re: Sioc Code Frustration
Hi,
Here some information about Local or Internal Variables in SIOC.
regards,
NMico
-
06-29-2011, 02:42 PM #7
- Join Date
- Jan 2007
- Location
- NEW ZEALAND
- Posts
- 899
Re: Sioc Code Frustration
Thanks Nico,
I was aware of those varaibles but unsure of when and how they can be used. I find i have to trip myself up before it sinks in. I quite often visit your page
for clarification.
Regards
Les
18yo GIRLS GIRL LS-MODEL FILES CLOUD WEBSITE: OPEN IN AN ANONYMOUS BROWSER (the link does not work...
Offsets for Trottle