Jack
I do not believe that SIOC cannot do maths :)
In your code here
L0 = &Pot * 2.83
L0 = &Pot - 621.86
&Calc = L0 * -1
Change to
Try
L0 = &Pot * 2.83
L0 = L0 - 621.86
&Calc = L0 * -1
Regards
David
Printable View
Jack
I do not believe that SIOC cannot do maths :)
In your code here
L0 = &Pot * 2.83
L0 = &Pot - 621.86
&Calc = L0 * -1
Change to
Try
L0 = &Pot * 2.83
L0 = L0 - 621.86
&Calc = L0 * -1
Regards
David
Hi David,
Still no luck.
What do you make of this though (IOCPConsole Log):
I know it's alot to read, but it is pretty much the same thing repeated.Code:5=183 - GS
58=171 - Pot
58=172 - Pot
5=178 - GS
5=174 - GS
5=170 - GS
100=56 - seconds of FS time (0 - 59)
5=165 - GS
5=161 - GS
5=157 - GS
5=153 - GS
100=57 - seconds of FS time (0 - 59)
5=149 - GS
5=145 - GS
5=141 - GS
100=58 - seconds of FS time (0 - 59)
5=138 - GS
100=59 - seconds of FS time (0 - 59)
100=0 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=1 - seconds of FS time (0 - 59)
100=2 - seconds of FS time (0 - 59)
100=3 - seconds of FS time (0 - 59)
100=4 - seconds of FS time (0 - 59)
100=5 - seconds of FS time (0 - 59)
58=171 - Pot
100=6 - seconds of FS time (0 - 59)
30=138 - Calc
31=-147 - Calc2
1=128 - Motor_1
58=172 - Pot
100=7 - seconds of FS time (0 - 59)
30=135 - Calc
31=-151 - Calc2
1=250 - Motor_1
100=8 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=9 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=10 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=11 - seconds of FS time (0 - 59)
100=12 - seconds of FS time (0 - 59)
100=13 - seconds of FS time (0 - 59)
100=14 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=15 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=16 - seconds of FS time (0 - 59)
58=171 - Pot
100=17 - seconds of FS time (0 - 59)
30=138 - Calc
31=-147 - Calc2
1=128 - Motor_1
58=172 - Pot
100=18 - seconds of FS time (0 - 59)
30=135 - Calc
31=-151 - Calc2
1=250 - Motor_1
100=19 - seconds of FS time (0 - 59)
100=20 - seconds of FS time (0 - 59)
100=21 - seconds of FS time (0 - 59)
100=22 - seconds of FS time (0 - 59)
100=23 - seconds of FS time (0 - 59)
100=24 - seconds of FS time (0 - 59)
100=25 - seconds of FS time (0 - 59)
100=26 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=27 - seconds of FS time (0 - 59)
100=28 - seconds of FS time (0 - 59)
100=29 - seconds of FS time (0 - 59)
100=30 - seconds of FS time (0 - 59)
100=31 - seconds of FS time (0 - 59)
100=32 - seconds of FS time (0 - 59)
100=33 - seconds of FS time (0 - 59)
100=34 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=35 - seconds of FS time (0 - 59)
100=36 - seconds of FS time (0 - 59)
100=37 - seconds of FS time (0 - 59)
100=38 - seconds of FS time (0 - 59)
100=39 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=40 - seconds of FS time (0 - 59)
58=171 - Pot
100=41 - seconds of FS time (0 - 59)
30=138 - Calc
31=-147 - Calc2
1=128 - Motor_1
58=172 - Pot
100=42 - seconds of FS time (0 - 59)
30=135 - Calc
31=-151 - Calc2
1=250 - Motor_1
100=43 - seconds of FS time (0 - 59)
100=44 - seconds of FS time (0 - 59)
100=45 - seconds of FS time (0 - 59)
100=46 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
58=171 - Pot
58=172 - Pot
58=171 - Pot
58=172 - Pot
100=47 - seconds of FS time (0 - 59)
100=48 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
58=171 - Pot
58=172 - Pot
100=49 - seconds of FS time (0 - 59)
100=50 - seconds of FS time (0 - 59)
100=51 - seconds of FS time (0 - 59)
100=52 - seconds of FS time (0 - 59)
100=53 - seconds of FS time (0 - 59)
100=54 - seconds of FS time (0 - 59)
100=55 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
58=171 - Pot
58=172 - Pot
100=56 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=57 - seconds of FS time (0 - 59)
100=58 - seconds of FS time (0 - 59)
100=59 - seconds of FS time (0 - 59)
100=0 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=1 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=2 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=3 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=4 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
58=171 - Pot
58=172 - Pot
58=171 - Pot
58=172 - Pot
100=5 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=6 - seconds of FS time (0 - 59)
100=7 - seconds of FS time (0 - 59)
100=8 - seconds of FS time (0 - 59)
100=9 - seconds of FS time (0 - 59)
100=10 - seconds of FS time (0 - 59)
100=11 - seconds of FS time (0 - 59)
100=12 - seconds of FS time (0 - 59)
100=13 - seconds of FS time (0 - 59)
100=14 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
58=171 - Pot
58=172 - Pot
100=15 - seconds of FS time (0 - 59)
100=16 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=17 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
100=18 - seconds of FS time (0 - 59)
5=139 - GS
100=19 - seconds of FS time (0 - 59)
5=140 - GS
5=141 - GS
100=20 - seconds of FS time (0 - 59)
5=142 - GS
5=143 - GS
100=21 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
5=144 - GS
5=145 - GS
100=22 - seconds of FS time (0 - 59)
5=146 - GS
5=147 - GS
5=148 - GS
100=23 - seconds of FS time (0 - 59)
5=149 - GS
5=150 - GS
100=24 - seconds of FS time (0 - 59)
5=151 - GS
5=152 - GS
5=153 - GS
100=25 - seconds of FS time (0 - 59)
5=154 - GS
5=155 - GS
100=26 - seconds of FS time (0 - 59)
5=156 - GS
5=157 - GS
100=27 - seconds of FS time (0 - 59)
5=158 - GS
5=159 - GS
5=160 - GS
5=161 - GS
100=28 - seconds of FS time (0 - 59)
58=171 - Pot
5=162 - GS
58=172 - Pot
5=163 - GS
5=164 - GS
100=29 - seconds of FS time (0 - 59)
5=165 - GS
5=166 - GS
5=167 - GS
100=30 - seconds of FS time (0 - 59)
5=168 - GS
5=169 - GS
5=171 - GS
100=31 - seconds of FS time (0 - 59)
5=172 - GS
5=173 - GS
5=174 - GS
100=32 - seconds of FS time (0 - 59)
58=171 - Pot
58=172 - Pot
5=175 - GS
5=176 - GS
5=178 - GS
100=33 - seconds of FS time (0 - 59)
5=179 - GS
5=180 - GS
5=181 - GS
100=34 - seconds of FS time (0 - 59)
5=183 - GS
5=184 - GS
5=185 - GS
100=35 - seconds of FS time (0 - 59)
5=187 - GS
58=171 - Pot
58=172 - Pot
58=171 - Pot
58=172 - Pot
58=171 - Pot
58=172 - Pot
As you can see, as GS changes value, and as FS seconds (time) go on, the Calc and Position Subroutines are not called at all.
Apart from the "Calcs" near the top, it is never called anywhere else. Why?
Regards,
Jack
Jack
Can we deal with one thing at a time. What happened when you made the correction to your code presumably that solved the "incorrect calculation" ie you got the correct value for &calc? If not then what did you get?
Regards
David
Hi David,
Yes, as you can see we now get:
Pot = 171
Calc = 138
As it should be. We get a weird, useless Calc2 value, but this is because 171 Pot is NOT in Calc2's range, so it can't calculate it properly.
Jack
Hi David,
Interestingly, I called the subroutines (the calculating ones) from the GS offset itself.
Weirdly, the Calc and Calc2 variables were only called at random times. According to the script, they should be called every time GS changes value; of which tyey certainly do not.Code:// *****************************************************************************
// * Config_SIOC ver 3.7B1 - By Manolo Vélez - www.opencockpits.com
// *****************************************************************************
// * FileName : Glideslope.txt
// * Date : 6/10/2011
Var 0100, Link FSUIPC_IN, Offset $023A, Length 1 // seconds of FS time (0 - 59)
{
CALL &Position // Call our variables that control the moto
CALL &Position2
}
Var 0005, name GS, Link FSUIPC_IN, Offset $0C49, Length 1 // FSUIPC GS Source
{
CALL &Value_Calc
CALL &Value_Calc2
}
Var 0030, name Calc // Calculation holding variable
Var 0031, name Calc2 // Calculation holding variable (2nd)
Var 0058, name Pot, Link USB_ANALOGIC, Input 2, PosL 0, PosC 127, PosR 250 // Potentiometer
Var 0003, name Value_Calc, Link SUBRUTINE // Provides a scale between GS and Pot
{
L0 = &Pot * 2.83
L0 = L0 - 621.86
L0 = L0 * -1
&Calc = ROUND L0
}
Var 0001, name Motor_1, Link USB_DCMOTOR, Output 1 // Motor
Var 0002, name Position, Link SUBRUTINE // The Calculations for driving the motor
{
IF &GS >= 138
{
IF &GS <= 254
{
IF &Calc > &GS
{
&Motor_1 = 120
}
ELSE
{
IF &GS >= 138
{
IF &GS <= 254
{
IF &Calc < &GS
{
&Motor_1 = 250
}
ELSE
{
IF &GS >= 138
{
IF &GS <= 254
{
IF &Calc = &GS
{
&Motor_1 = 128
}
}
}
}
}
}
}
}
}
}
Var 0009, name Position2, Link SUBRUTINE // The Calculations for driving the motor (
{
IF &GS >= 0
{
IF &GS <= 119
{
IF &Calc2 > &GS
{
&Motor_1 = 120
}
ELSE
{
IF &GS >= 0
{
IF &GS <= 119
{
IF &Calc2 < &GS
{
&Motor_1 = 250
}
ELSE
{
IF &GS >= 0
{
IF &GS <= 119
{
IF &Calc2 = &GS
{
&Motor_1 = 128
}
}
}
}
}
}
}
}
}
}
Var 0561, name Value_Calc2, Link SUBRUTINE // Provides a scale between GS and Pot
{
L0 = &Pot * 3.6
L0 = L0 - 468.2
L0 = L0 * -1
&Calc2 = ROUND L0
}
Regards,
Jack
Jack
Try removing the var 100 timing routine and see what happens. I strongly counsel you to reduce the code to smaller sections eg bracket out the second cals/position routines and get that working - then add other sections building upon a sound base. If you keep changing the logic flow then you will lose track and reference points.
Regards
David
HI David,
If I remove the Var 100 routine what will be there to call the subroutines?
Also, I'm not sure whart you mean regarding the "reduce coding".
Jack
Jack
I mean simplifying your code to get the basic building blocks working and then progress. You do not need the timer routine to check movement against the glideslope - do you? Also get calc 1 working first before introducing calc2. This avoids potential cross corruption and makes troubleshooting easier. This is basic programming :)
Regards
David
Do you mean just checking the values of the Calc variables against the GS one? Nothing to do with the position vars?
Jack
Hi Jack,
Please be more precise in your wording ....
In programming Subroutines are called but Variables are assigned values...
So Calc and Calc2 are not 'called', but may get a new value when Value_Calc and Value_Calc2 subroutines are called.
I think the log file only shows variables that have been assigned a NEW value!
The fact that you do not see Calc and Calc2 anymore in the log tell us that they have not changed since...
regards,
Nico