Results 31 to 40 of 69
-
05-23-2011, 02:21 PM #31
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
More great news!
I have now, using the following script, managed to initiate and UP or DOWN pulse from just 2 buttons. Previously, we had to use 3, with the third button controlling the UPDOWN_Pin Output. Now, however, this is done automatically upon pressing the button.
This proves that an UP/DOWN count can be initiated immediately upon being commanded to do so, without needing to set the UP/DOWN Pin through some other instruction.
Code:
Code:Var 0 Value 0 { &Out = 1 &UPDOWN_Pin = 1 // count down CALL &Pulses 2 // correct for first OFF/ON pulse at startup } Var 99 name Trigger3 Link IOCARD_SW Input 18 Type P { IF &Trigger3 = 1 { &UPDOWN_Pin = 1 CALL &Pulses 10 } } Var 98 name Trigger4 Link IOCARD_SW Input 23 Type P { IF &Trigger4 = 1 { &UPDOWN_Pin = 0 CALL &Pulses 10 } } Var 1 name Pulses link SUBRUTINE // parameter is number of pulses ... { &Out = 0 &PulseUp = DELAY &Pulses 9 // 50 msec for a half pulse } Var 3 name Out Link IOCARD_OUT Output 29 // Pulse Pin Var 11 name PulseUp { L0 = &PulseUp IF L0 > 0 { &Out = 1 &Finish = DELAY L0 9 // 50 msec for the other half of the pulse } } Var 12 name Finish { L0 = &Finish IF L0 > 0 { IF L0 > 1 { L0 = L0 - 1 CALL &Pulses L0 // recursive subroutine call } ELSE { &PulseUp = 0 // make responsive for another series of pulses. &Finish = 0 // make responsive for another series of pulses. } } } Var 55, name UPDOWN_Pin, Link IOCARD_OUT, Output 21 // Count UP or DOWN selector Pin Var 84, name RangeFlag, Link IOCARD_OUT, Output 17 // Range Flag
Jack
-
05-23-2011, 03:39 PM #32
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Jack,
Understood. Just change in Var 0:
Code:&UPDOWN_Pin = 1 // count down
Code:&UPDOWN_Pin = 1 // count up
Regards,
Nico
P.S. Some people even state that it is better not to comment at all. They claim that it is better to have no comment then a wrong comment...Last edited by kiek; 05-23-2011 at 03:41 PM.
-
05-23-2011, 03:59 PM #33
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
All done! What's next on the agenda?
Jack
-
05-25-2011, 11:52 AM #34
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
What should I do next? Should I just try and implement the (new) pulse code into the full script, or should I do some more testing (ie: one step at a time) before I run the full thing?
Kindest regards,
Jack
-
05-25-2011, 12:23 PM #35
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Jack,
I would first run a test script with just the NewDistance offset (so no Pulses routine at all).
Fly to, over and past a VOR and write the NewDistance value to a 3 digit display.
This will give you information upon which you can base the Control algorithm
regards,
Nico
-
05-25-2011, 12:42 PM #36
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
I have tried that, watching the value of the VOR1 DME change according to offset $0300.
It does indeed work perfectly, so no problems with this offset.
Regards,
Jack
-
05-25-2011, 01:21 PM #37
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Jack,
If you are sure about the values coming from NewDistance then try the complete Control script from posts #13 and #14, adapted with the 'inverted Pulses code' and the Var 0 code of post #31
regards,
Nico
-
05-25-2011, 02:05 PM #38
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
How is this:
Code:Var 0 Value 0 { &Out = 1 &CurrentD = 0 &Control = 0 &Control = TIMER 1 0 100 // control is called each second &UPDOWN_Pin = 1 // count up CALL &Pulses 1 // correct for first OFF/ON pulse at startup } Var 100 name Control Link SUBRUTINE { L0 = &NewDistance - &CurrentD IF L0 <> 0 { &UPDOWN_Pin = 1 // Ensure HSI counts UP IF L0 > 9 { L0 = 9 // no more then 9 pulses per second &CurrentD = &CurrentD + 9 } ELSE { &CurrentD = &NewDistance } } ELSE { &UPDOWN_Pin = 0 // We don't want to count up here! L0 = L0 * -1 IF L0 > 9 { L0 = 9 // no more then 9 pulses per second &CurrentD = &CurrentD - 9 } ELSE { &CurrentD = &NewDistance } } CALL &Pulses L0 } Var 1, name CurrentD Var 2, name UPDOWN_Pin, Link IOCARD_OUT, Output 21 // Count UP or DOWN selector Pin Var 4, name Out, Link IOCARD_OUT, Output 29 // Pulse Pin Var 5, name NewDistance, Link FSUIPC_IN, Offset $0300, Length 2 // FSUIPC VOR1 DME Input Source Var 43 name Pulses link SUBRUTINE // parameter is number of pulses ... { &Out = 0 &PulseUp = DELAY &Pulses 9 // 50 msec for a half pulse } Var 11 name PulseUp { L0 = &PulseUp IF L0 > 0 { &Out = 1 &Finish = DELAY L0 9 // 50 msec for the other half of the pulse } } Var 12 name Finish { L0 = &Finish IF L0 > 0 { IF L0 > 1 { L0 = L0 - 1 CALL &Pulses L0 // recursive subroutine call } ELSE { &PulseUp = 0 // make responsive for another series of pulses. &Finish = 0 // make responsive for another series of pulses. } } } Var 84, name RangeFlag, Link IOCARD_OUT, Output 17 // Range Flag
Kindest regards,
Jack
-
05-25-2011, 04:45 PM #39
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
I have tested the new pulses script.
Firstly, for some reason, &pulses must now only be called ONCE instead of TWICE at startup.
This is the exact script I am using:
Code:Var 0 Value 0 { &Out = 1 &CurrentD = 0 &Control = 0 &Control = TIMER 1 0 100 // control is called each second &UPDOWN_Pin = 1 // count up CALL &Pulses 1 // correct for first OFF/ON pulse at startup } Var 100 name Control Link SUBRUTINE { L0 = &NewDistance - &CurrentD IF L0 <> 0 { &UPDOWN_Pin = 1 // Ensure HSI counts UP IF L0 > 9 { L0 = 9 // no more then 9 pulses per second &CurrentD = &CurrentD + 9 } ELSE { &CurrentD = &NewDistance } } ELSE { &UPDOWN_Pin = 0 // We don't want to count up here! L0 = L0 * -1 IF L0 > 9 { L0 = 9 // no more then 9 pulses per second &CurrentD = &CurrentD - 9 } ELSE { &CurrentD = &NewDistance } } CALL &Pulses L0 } Var 1, name CurrentD Var 2, name UPDOWN_Pin, Link IOCARD_OUT, Output 21 // Count UP or DOWN selector Pin Var 4, name Out, Link IOCARD_OUT, Output 29 // Pulse Pin Var 5, name NewDistance, Link FSUIPC_IN, Offset $0300, Length 2 // FSUIPC VOR1 DME Input Source Var 43 name Pulses link SUBRUTINE // parameter is number of pulses ... { &Out = 0 &PulseUp = DELAY &Pulses 9 // 50 msec for a half pulse } Var 11 name PulseUp { L0 = &PulseUp IF L0 > 0 { &Out = 1 &Finish = DELAY L0 9 // 50 msec for the other half of the pulse } } Var 12 name Finish { L0 = &Finish IF L0 > 0 { IF L0 > 1 { L0 = L0 - 1 CALL &Pulses L0 // recursive subroutine call } ELSE { &PulseUp = 0 // make responsive for another series of pulses. &Finish = 0 // make responsive for another series of pulses. } } } Var 84, name RangeFlag, Link IOCARD_OUT, Output 17 // Range Flag
For some reason, after setting a VOR station that is 1.6 miles away (16 pulses), the HSI only went up to 0.9 (9 pulses). Also, when I tuned a non-existant VOR station (in other words, "0" miles away), the script did not count down. So, to summarize, the problems are:
- Script does not count up enough
- Script does not count down at all
The NewDistance variable changes value accordingly, but the rest of the script does not function correctly. It looks fine to myself, and I cannot see what particular bit is casuing the issue.
Just to reiterate, it is no longer a pulsing issue - That works fine. It is the calculation to calculate the number of pulses.
Regards,
Jack
-
05-25-2011, 05:33 PM #40
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Jack,
Two problems:
You miss a test on L0 > 0 in Var 100.
The pulse correction in Var 0 must be done before calling control. Maybe you need 2 again now...
Here is the updated script, please test again:
Code:Var 0 Value 0 { &Out = 1 &CurrentD = 0 &UPDOWN_Pin = 1 // count up CALL &Pulses 2 // correct for two OFF/ON pulse at startup &Control = 0 &Control = TIMER 1 0 100 // control is called each second } Var 100 name Control Link SUBRUTINE { L0 = &NewDistance - &CurrentD IF L0 <> 0 { IF L0 > 0 { &UPDOWN_Pin = 1 // Ensure HSI counts UP IF L0 > 9 { L0 = 9 // no more then 9 pulses per second &CurrentD = &CurrentD + 9 } ELSE { &CurrentD = &NewDistance } } ELSE { &UPDOWN_Pin = 0 // We don't want to count up here! L0 = L0 * -1 IF L0 > 9 { L0 = 9 // no more then 9 pulses per second &CurrentD = &CurrentD - 9 } ELSE { &CurrentD = &NewDistance } } CALL &Pulses L0 } } Var 1, name CurrentD Var 2, name UPDOWN_Pin, Link IOCARD_OUT, Output 21 // Count UP or DOWN selector Pin Var 4, name Out, Link IOCARD_OUT, Output 29 // Pulse Pin Var 5, name NewDistance, Link FSUIPC_IN, Offset $0300, Length 2 // FSUIPC VOR1 DME Input Source Var 43 name Pulses link SUBRUTINE // parameter is number of pulses ... { &Out = 0 &PulseUp = DELAY &Pulses 9 // 50 msec for a half pulse } Var 11 name PulseUp { L0 = &PulseUp IF L0 > 0 { &Out = 1 &Finish = DELAY L0 9 // 50 msec for the other half of the pulse } } Var 12 name Finish { L0 = &Finish IF L0 > 0 { IF L0 > 1 { L0 = L0 - 1 CALL &Pulses L0 // recursive subroutine call } ELSE { &PulseUp = 0 // make responsive for another series of pulses. &Finish = 0 // make responsive for another series of pulses. } } } Var 84, name RangeFlag, Link IOCARD_OUT, Output 17 // Range Flag
NicoLast edited by kiek; 05-25-2011 at 05:36 PM.
Looking for fun companions for travels and adventures? Authentic Ladies Premier Сasual Dating
Top-notch Сasual Dating -...