Results 21 to 30 of 55
-
06-10-2011, 04:38 PM #21
- Join Date
- Jul 2013
- Posts
- 917
Re: Scaling Localiser and Glideslope Needles for HSI
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
-
06-10-2011, 05:05 PM #22
Re: Scaling Localiser and Glideslope Needles for HSI
Hi David,
Still no luck.
What do you make of this though (IOCPConsole Log):
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
-
06-10-2011, 05:19 PM #23
- Join Date
- Jul 2013
- Posts
- 917
Re: Scaling Localiser and Glideslope Needles for HSI
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
-
06-10-2011, 05:56 PM #24
Re: Scaling Localiser and Glideslope Needles for HSI
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
-
06-10-2011, 06:53 PM #25
Re: Scaling Localiser and Glideslope Needles for HSI
Hi David,
Interestingly, I called the subroutines (the calculating ones) from the GS offset itself.
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
-
06-11-2011, 04:24 AM #26
- Join Date
- Jul 2013
- Posts
- 917
Re: Scaling Localiser and Glideslope Needles for HSI
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
-
06-11-2011, 06:30 AM #27
Re: Scaling Localiser and Glideslope Needles for HSI
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
-
06-11-2011, 06:39 AM #28
- Join Date
- Jul 2013
- Posts
- 917
Re: Scaling Localiser and Glideslope Needles for HSI
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
-
06-11-2011, 10:40 AM #29
Re: Scaling Localiser and Glideslope Needles for HSI
Do you mean just checking the values of the Calc variables against the GS one? Nothing to do with the position vars?
Jack
-
06-11-2011, 11:20 AM #30
Re: Scaling Localiser and Glideslope Needles for HSI
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,
NicoLast edited by kiek; 06-11-2011 at 11:44 AM.
Beautiful Womans in your town for night
B_34 TOGA takeoff