Results 1 to 10 of 69
-
05-18-2011, 01:22 PM #1
HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi everyone,
Whilst I have, for now, gotten the flags and course pointer on my HSI to work (there's still the remaining motors left though!), I'm currently working on a logic for the HSI pulse counter.
Basically, my HSI display works like a heartbeat. I have an "engage pin" connected to the display, and when 5V is going to this pin, I send pulses (ON/OFF/ON/OFF) to the display.
Each routine of OFF/ON/OFF counts as one pulse, and counts the display up by 1.
Previously, I have been using Nico's LED blink script to simulate this, executed by a button press.
Obviously, I cannot rely on this alone, as in FSX, this value is changed by the disstance from the VOR1 station (tuned).
My friend Mikael Stockfors has very kindly designed a logic for the range display, which certainly looks like it could work. Please analyse the logic (NOTE, is is NOT formatted to work with SIOC yet, it is just a visual draft to show how things work):
Code:"VAR 1, name CurrentDistance" "VAR 2, name NewDistance, LINK (FSUIPC output source)" { L0 = NewDistance - CurrentDistance; IF L0 > 0 THEN { Set output to make counter count UP; // Pulses make the counter go UP NoPulses = L0; } ELSE { Set output to make counter cound DOWN; // Same technique, except the pulses count DOWN, due to an // extra pin which can change the UP to a DOWN count NoPulses = L0 } Send NoPulses to the range display; // One pulse = 1 digit count CurrentDistance = NewDistance; }
Kindest regards,
Jack
-
Post Thanks / Like - 1 Thanks, 0 Likes, 0 Dislikes737NUT thanked for this post
-
05-18-2011, 05:14 PM #2
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Jack,
What is the "length" of one pulse? I mean, how many milli seconds do you need for each cycle? Or in other words: the time between two ON's ?
Nico
-
05-18-2011, 05:31 PM #3
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
I think 100 milli-secs would do (that's 10 pulses per second).
Kindest regards,
Jack
-
05-18-2011, 05:50 PM #4
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Jack,
I have not checked this code, i'm not sure whether SIOC allows recursive calls of subroutines, but I don't see why not.
The idea is to call the subroutine Pulses with the number of pulses that you want to send.
Code:Var 100 name Main { &Out = 0 L0 = 3 // 3 is just an example CALL &Pulses L0 // generate L0 number of pulses } Var 1 name Pulses link SUBRUTINE // parameter is number of pulses ... { &Out = 1 &PulseDown = DELAY &Pulses 5 // 50 msec for a half pulse } Var 2 name PulseDown { L0 = &PulseDown IF L0 > 0 { &Out = 0 &Finish = DELAY L0 5 // 50 msec for the other half of the pulse } } Var 3 name Finish { L0 = &Finish IF L0 > 0 { IF L0 > 1 { L0 = L0 - 1 CALL &Pulses L0 // recursive subroutine call } ELSE { &PulseDown = 0 // make responsive for another series of pulses. &Finish = 0 // make responsive for another series of pulses. } } } Var 4 name Out link ... pulse train here
regards,
NicoLast edited by kiek; 05-19-2011 at 03:14 PM.
-
05-18-2011, 05:58 PM #5
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
That is superb! Thanks so much! Thanks for helping me out at such short notice; it is really fantastic =).
It is 11:00PM here, so I shall double-check the code tomorrow. However, I have read through it and can understand how it works. The line "L0 = 3"; as you say 3 is an example. As "3" could theoretically be any number, wouldn't it be better to make L0 equal to another variable specifically designed for the pulse value (ie L0 = X, where X is the number of pulses).
Thank you so much, I am so grateful for your help.
Regards,
Jack
-
05-19-2011, 02:36 AM #6
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Jack,
Like I said, L0 = 3 is just an example. L0 = &NoPulses is also possible.
If this subroutine works you should also be careful not to call it too often because sending a large number of pulses would take some time.
Maybe you should use the endless timer approach. In the control routine you check the NewDistance - CurrentDistance and act accordingly. If the number of pulses to be sent is too much for the control cycle period, you maximise the amount to what is possible and take care of the rest in the next control cycle.
regards,
NicoLast edited by kiek; 05-19-2011 at 06:21 AM.
-
05-19-2011, 12:58 PM #7
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
I shall consider the endless timer approach should we need to use it for the range display in the future.
I have now taken your script, replaced "3" with NoPulses.
Firstly, this is the script that calculates NoPulses (all finished now):
Code:Var 1, name CurrentDistance Var 4, name NoPulses Var 3, name UP_Pin, Link IOCARDS_OUT, Output X Var 5, name DOWN_Pin, Link IOCARDS_OUT, Output X Var 2, name NewDistance, Link FSUIPC_IN, Offset $0300, Length 2 // FSUIPC VOR1 DME Input Source { L0 = NewDistance - CurrentDistance IF L0 > 0 THEN { &DOWN_Pin = 0 // Ensure down pin is OFF &UP_Pin = 1 // Pulses make the counter go UP NoPulses = L0 } ELSE { &UP_Pin = 0 // We don't want to count up here! &DOWN_Pin = 1// ...But we need to count down, so DOWN pin is ON &NoPulses = L0 * -1 } CurrentDistance = NewDistance }
This is your script, adapted slightly to work with the above:
Code:Var 100 name Main { &Out = 0 L0 = NoPulses // 3 is just an example CALL &Pulses L0 // generate L0 number of pulses } Var 1 name Pulses link SUBROUTINE // parameter is number of pulses ... { &Out = 1 &PulseDown = DELAY &Pulses 5 // 50 msec for a half pulse } Var 2 name PulseDown { L0 = &PulseDown IF L0 > 0 { &Out = 0 &Finish = DELAY &PulseDown 5 // 50 msec for the other half of the pulse } } Var 3 name Finish { L0 = &Finish IF L0 > 0 { IF L0 > 1 { L0 = L0 - 1 CALL &Pulses L0 // recursive subroutine call } ELSE { &PulseDown = 0 // make responsive for another series of pulses. &Finish = 0 // make responsive for another series of pulses. } } } Var 4, name &Out, Link IOCARDS_OUT, Output X
So, as it stands, can you see any obvious errors? I just use the first to calculate the pulses, and your script to send them.
At the moment, the script(s) don't cater for when you loose the VOR1 signal or something else like that happens; but that's okay for now, it's just a test.
Thanks very much for your time.
Kindest regards,
Jack
-
05-19-2011, 01:35 PM #8
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Jack,
I think it is better to integrate the two scripts.
We need a Var 0 with some initialisations, and in the NewDistance var we have to call the Pulses subroutine.
In this example there is no need for a NoPulses variable.
Maybe you should test this first. I'm not sure about the value in FSUIPC offset 0x0300, the documentation says nm * 10 ...
Let's see what happens.
Code:Var 0 Value 0 { &Out = 0 &CurrentDistance = 0 // ?? } Var 1, name CurrentDistance Var 2, name UP_Pin, Link IOCARDS_OUT, Output X Var 3, name DOWN_Pin, Link IOCARDS_OUT, Output X Var 4, name &Out, Link IOCARDS_OUT, Output X Var 5, name NewDistance, Link FSUIPC_IN, Offset $0300, Length 2 // FSUIPC VOR1 DME Input Source { L0 = &NewDistance - &CurrentDistance &CurrentDistance = &NewDistance IF L0 <> 0 { IF L0 > 0 { &DOWN_Pin = 0 // Ensure down pin is OFF &UP_Pin = 1 // Pulses make the counter go UP } ELSE { &UP_Pin = 0 // We don't want to count up here! &DOWN_Pin = 1 // ...But we need to count down, so DOWN pin is ON L0 = L0 * -1 } CALL &Pulses L0 } } Var 10 name Pulses link SUBRUTINE // parameter is number of pulses ... { &Out = 1 &PulseDown = DELAY &Pulses 5 // 50 msec for a half pulse } Var 11 name PulseDown { L0 = &PulseDown IF L0 > 0 { &Out = 0 &Finish = DELAY L0 5 // 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 { &PulseDown = 0 // make responsive for another series of pulses. &Finish = 0 // make responsive for another series of pulses. } } }
Last edited by kiek; 05-19-2011 at 03:15 PM.
-
05-19-2011, 01:50 PM #9
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Jack,
Here is the endless timer approach.
I believe this script is much more robust.
Code:Var 0 Value 0 { &Out = 0 &CurrentDistance = 0 &Control = 0 &Control = TIMER 1 0 100 // control is called each second } Var 100 name Control Link SUBRUTINE { L0 = NewDistance - CurrentDistance IF L0 <> 0 { IF L0 > 0 { &DOWN_Pin = 0 // Ensure down pin is OFF &UP_Pin = 1 // Pulses make the counter go UP IF L0 > 9 { L0 = 9 // no more then 9 pulses per second &CurrentDistance = &CurrentDistance + 9 } ELSE { &CurrentDistance = &NewDistance } } ELSE { &UP_Pin = 0 // We don't want to count up here! &DOWN_Pin = 1 // ...But we need to count down, so DOWN pin is ON L0 = L0 * -1 IF L0 > 9 { L0 = 9 // no more then 9 pulses per second &CurrentDistance = &CurrentDistance - 9 } ELSE { &CurrentDistance = &NewDistance } } CALL &Pulses L0 } } Var 1, name CurrentDistance Var 2, name UP_Pin, Link IOCARDS_OUT, Output X Var 3, name DOWN_Pin, Link IOCARDS_OUT, Output X Var 4, name Out, Link IOCARDS_OUT, Output X Var 5, name NewDistance, Link FSUIPC_IN, Offset $0300, Length 2 // FSUIPC VOR1 DME Input Source Var 10 name Pulses link SUBRUTINE // parameter is number of pulses ... { &Out = 1 &PulseDown = DELAY &Pulses 5 // 50 msec for a half pulse } Var 11 name PulseDown { L0 = &PulseDown IF L0 > 0 { &Out = 0 &Finish = DELAY L0 5 // 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 { &PulseDown = 0 // make responsive for another series of pulses. &Finish = 0 // make responsive for another series of pulses. } } }
Last edited by kiek; 05-19-2011 at 03:14 PM.
-
05-19-2011, 02:11 PM #10
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
Thanks so much for your help, I'll try the endless timer script (hopefully tonight).
About the Offset * 10...
At first, I thought I'd have to divide this offset by 10 to use it "sensibly". However, it turns out the the range display on the HSI as a dot between the 3rd and 4th digits (like a decimal point).
So, therefore, if I'm 33.3nm away from the station, FSUIPC/SIOC will recognised this as "333" nm, and send 333 pulses. The HSI will then read 333, but because of the DP, it will actually read "33.3".
See what I mean? Or is it better to leave this out?
Regards,
Jack
Looking for fun companions for travels and adventures? Authentic Ladies Premier Сasual Dating
Top-notch Сasual Dating -...