-
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;
}
My question is, how can I accurately control the number of pulses outputted by SIOC, and is there a better way than just using an LED blink script? EG, if I want 5 pulses, I just want to send 5 pulses straight to the display. Is there a better way to achieve this goal?
Kindest regards,
Jack
-
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
-
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
-
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
An alternative is the TIMER approach. One way or the other you need to build in wait periods in your script. In the example above I do that with the DELAY statement. Note that a SIOC program immediately continues with the statement after the DELAY statement (if present), that's why I needed three different Vars to send a pulse.
regards,
Nico
-
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
-
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,
Nico
-
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
}
Please note: The "Up" and "Down" pins are extra outputs that must be activated in order to provide a pulse. They receive no actual pulses themselves and don't do anything else.
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
Obviously, the "X"s in each script will be replaced with a correct working output number.
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
-
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.
}
}
}
Nico
-
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.
}
}
}
Nico
-
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
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Jack,
I understand. Leave it as it is.
Regards,
Nico
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Jack,
I have tested the Pulses Subrutine with a led. Works like a charm
Nico
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
Thanks so much for testing with an LED BTW.
I have good news! Whilst there are some problems, the HSI display works most of the time, accurately representing the distance (eg 1.6 nm appears as "16", but it's actually 1.6 because of the DP).
The problem was, that when the HSI counted to 16, I flew towards the VOR station. The value counted down, as it should, but stopped at 0.4. Then, when I flew over the VOR station, and the distance started to increase again, the HSI value remained stuck at 0.4nm.
One thing, I had to change the script slightly. The "UP" and "DOWN" Pins I mentioned are infact the same pin. +5V to the pin (ON) means that it counts up, whilst 0V (OFF) to the pin makes the display count down.
This is the script; identical, just for that minor change:
Code:
Var 0 Value 0
{
&Out = 0
&CurrentD = 0
&Control = 0
&Control = TIMER 1 0 100 // control is called each second
}
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 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 &PulseDown 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.
}
}
}
However, I am extremely impressed by your script. I am surprised I have got it working at all, so when FSX read 1.6, and the HSI read 1.6, I was very, very pleased.
One thing; when using the script, SIOC seems to activate output 28 (unrelated) when it is counting up. There is a RESET pin on the pulse meter, which, if tampered with, can seriously affect the pulse. Is it possible SIOC is accidently activating this output, just like 28?
Kindest regards,
Jack
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Jack,
We're making progress!
I see you have removed the IF L0 <> 0 test in Var 100.... that's not right, now if L0 = 0 you try to count down...
And no, it's not very likely that the SIOC script changes Output 28. That output is not mentioned at all, is it? Are you sure you have no short-circuits in your hardware?
regards,
Nico
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
I have changed the script back to the <>; so now it's the same just with that one alteration.
This is what I did this time:
- Started a flight
- Started SIOC
- VOR1 DME = Out of range
- I then tune 116:00, VOR1 DME = 1.6nm away
- The range counter went to 1.4
- I changed back to the "0" range frequency, it went down to 2 (or something like that; not 0)
Weirdly, this is what the IOCPConsole log states:
Code:
5=0 - New Distance
5 = 16 New Distance
5 = 15 New Distance
5 = 14 New Distance
... And so on, as I fly towards it.
As you can see, even though "New Distance" changes; no other var at all changes.
Regards,
Jack
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
To add to my last post, here is the full IOCPConsole Log:
Code:
5=9 - NewDistance
2=1 - UPDOWN_Pin
1=9 - CurrentD
10=9 - Pulses
11=9 - PulseDown
4=0 - Out
12=9 - Finish
10=8 - Pulses
4=1 - Out
11=8 - PulseDown
4=0 - Out
12=8 - Finish
10=7 - Pulses
4=1 - Out
11=7 - PulseDown
4=0 - Out
12=7 - Finish
10=6 - Pulses
4=1 - Out
11=6 - PulseDown
4=0 - Out
12=6 - Finish
10=5 - Pulses
4=1 - Out
11=5 - PulseDown
4=0 - Out
12=5 - Finish
10=4 - Pulses
4=1 - Out
11=4 - PulseDown
4=0 - Out
12=4 - Finish
10=3 - Pulses
4=1 - Out
11=3 - PulseDown
4=0 - Out
12=3 - Finish
10=2 - Pulses
4=1 - Out
11=2 - PulseDown
4=0 - Out
12=2 - Finish
10=1 - Pulses
4=1 - Out
11=1 - PulseDown
4=0 - Out
12=1 - Finish
11=0 - PulseDown
12=0 - Finish
2=0 - UPDOWN_Pin
10=0 - Pulses
4=1 - Out
5=8 - NewDistance
2=1 - UPDOWN_Pin
1=8 - CurrentD
10=-1 - Pulses
11=-1 - PulseDown
2=0 - UPDOWN_Pin
10=0 - Pulses
11=0 - PulseDown
5=7 - NewDistance
2=1 - UPDOWN_Pin
1=7 - CurrentD
10=-1 - Pulses
11=-1 - PulseDown
2=0 - UPDOWN_Pin
10=0 - Pulses
11=0 - PulseDown
5=6 - NewDistance
2=1 - UPDOWN_Pin
1=6 - CurrentD
10=-1 - Pulses
11=-1 - PulseDown
2=0 - UPDOWN_Pin
10=0 - Pulses
11=0 - PulseDown
5=0 - NewDistance
2=1 - UPDOWN_Pin
1=0 - CurrentD
10=-6 - Pulses
11=-6 - PulseDown
2=0 - UPDOWN_Pin
10=0 - Pulses
11=0 - PulseDown
5=6 - NewDistance
2=1 - UPDOWN_Pin
1=6 - CurrentD
10=6 - Pulses
11=6 - PulseDown
4=0 - Out
12=6 - Finish
10=5 - Pulses
4=1 - Out
11=5 - PulseDown
4=0 - Out
12=5 - Finish
10=4 - Pulses
4=1 - Out
11=4 - PulseDown
4=0 - Out
12=4 - Finish
10=3 - Pulses
4=1 - Out
11=3 - PulseDown
4=0 - Out
12=3 - Finish
10=2 - Pulses
4=1 - Out
11=2 - PulseDown
4=0 - Out
12=2 - Finish
10=1 - Pulses
4=1 - Out
11=1 - PulseDown
4=0 - Out
12=1 - Finish
11=0 - PulseDown
12=0 - Finish
2=0 - UPDOWN_Pin
10=0 - Pulses
4=1 - Out
5=5 - NewDistance
5=6 - NewDistance
5=7 - NewDistance
5=8 - NewDistance
Generally, the script did not give the correct values. Also, the last 5 lines are strange; distance changes but nothing else.
kindest regards,
Jack
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Jack,
I have no experience with IOCPConsole, never work with it.
I recommend to build it up from the ground up with small steps.
We know that the Pulses SUBRUTINE is ok.
So first make a script that sends say 5 pulses to your HSI and count UP, then do the same counting down. Check the correct working of that first.
If that's OK, do some tests with the NewDistance variable.
If that's ok bring in the control routine without the test about sending more then 9 pulses.
If that's ok maximise the number of pulses sent in a control cycle.
and so on...
Such an approach gives a lot more insight then "staring at a IOCPlog file...." ;-)
regards,
Nico
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
I'm so sorry; I couldn't quite understand that.
Do you mean a script with JUST the pulse subroutine on its own? Maybe linked to a pushbutton or something? Because that subroutine on its own doesn't do anything unless it's used with the other variables in the script.
Kindest regards,
Jack
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Jack,
Quote:
Originally Posted by
Boeing 747 Flyer
Do you mean a script with JUST the pulse subroutine on its own? Maybe linked to a pushbutton or something?
Yes indeed. Or called from Var 0.
And "connected" via Outputs to your HSI.
Like I did when I tested the Pulses subrutine with a led.
regards,
Nico
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
How is this:
Code:
Var 2 name Trigger Link IOCARD_IN Input 25
{
IF &Trigger = 1
{
CALL &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 3 name Out Link IOCARD_OUT Output 29 // Pulse Pin
Var 11 name PulseDown
{
L0 = &PulseDown
IF L0 > 0
{
&Out = 0
&Finish = DELAY &PulseDown 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.
}
}
}
I couldn't isolate the Pulses var because it relies on the "Pulsedown" var, which is further linked to the finish var.
Regards,
Jack
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Jack,
Almost correct...
- Your script lacks a parameter to the CALL of &Pulses ... You should write CALL &Pulses 5 or whatever the number you want to test.
- And you should add Up or Down counting in Var 2, before you call &Pulses.
BTW: Pulses, PulseDown and Finish belong together. You cannot and should not isolate Pulses.
regards,
Nico
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
I used the following script; using two different pushbuttons for counting UP and DOWN. Each button produced exactly 10 pulses.
Code:
Var 2 name Trigger Link IOCARD_SW Input 25
{
IF &Trigger = 1
{
&UPDOWN_Pin = 1
CALL &Pulses 10
}
}
Var 8 name Trigger2 Link IOCARD_SW Input 19
{
IF &Trigger2 = 1
{
&UPDOWN_Pin = 0
CALL &Pulses 10
}
}
Var 1 name Pulses link SUBRUTINE // parameter is number of pulses ...
{
&Out = 1
&PulseDown = DELAY &Pulses 5 // 50 msec for a half pulse
}
Var 3 name Out Link IOCARD_OUT Output 29 // Pulse Pin
Var 11 name PulseDown
{
L0 = &PulseDown
IF L0 > 0
{
&Out = 0
&Finish = DELAY &PulseDown 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.
}
}
}
Var 55, name UPDOWN_Pin, Link IOCARD_OUT, Output 21 // Count UP or DOWN selector Pin
I did the following test:
(Button X = UP, Y = DOWN)
- Pressed button X twice, HSI went to 20
- Press button Y once, HSI went to 11
- Pressed X once, went to 21
I reset the HSI using the reset pin.
- I pressed X once, went to 10
- Pressed Y once, went to 0
- Pressed X twice, went to 20
- Pressed Y once, went to 12
As you can see, it more or less goes up by exactly 10 each time. There is, however, a noticeable small margin of error counting down sometimes.
EDIT: After looking closely at the HSI display, I can confirm that when giving the first 10 pulses, the HSI display goes:
0000, 9999, 9998, 9999, 0000, 0001, 0002, 0003... Up to 0008
As you an see, the display goes DOWN by 2 values before counting 10 up... Which may explain the "lag" by 2 in pulses (explained in the above tests).
Also, I have found out that the display cannot be given two instructions at once. EG: If told to go up by 10 pulses, it MUST finish receiving 10 pulses before doing anything else. If told to go up by 10, and then 15, whilst it is still counting to 10, it will not go up by either 10 or 15 and get "confused".
Regards,
Jack
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
I tried the DME_Full script again and frequently replicated the same problem.
Although, after tuning a VOR station that was 1.6nm away, the HSI showed 16 (1.6); it would never count down.
This is what IOCPConsole shows, after changing from 16 -> 15 (I have written it in the format you prefer). The following is listed in chronological order, it just tells you the value of each var as time goes on. The following all happened in about 5 seconds.
- New Distance = 15
- UPDOWN Pin = 1 (so as if we're going to count up??? Why?)
- CurrentD = 15
- Pulses = -1
- PulseDown = -1
- UPDOWN Pin = 0 (that's better, we can count down now)
- Pulses = 0
- PulseDown = 0
END
My concern is that SIOC is trying to do all the pulsing BEFORE it sets the UPDOWN_Pin to 0. Obviously, it cannot count down until this is set properly. Also, why is the pulses value -1? We can't have a -1 pulse?
Regards,
Jack
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Jack,
Quote:
Originally Posted by
Boeing 747 Flyer
I tried the DME_Full script again and frequently replicated the same problem.
It's too early run the full script. Your basic test, sending pulses does not work correctly yet as you have reported in post #22.
First things first.
Nico
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Jack,
Quote:
Originally Posted by
Boeing 747 Flyer
As you an see, the display goes DOWN by 2 values before counting 10 up... Which may explain the "lag" by 2 in pulses (explained in the above tests).
You have to find out why this is. Maybe you need to build in some time between &UPDownPin = 1 and the Call of &Pulses?
Use 1 push button (Type P) to set the UPDOWN pin (according to the position of the button) . Use the other button to start the CALL of &Pulses 10
Quote:
Originally Posted by
Boeing 747 Flyer
Also, I have found out that the display cannot be given two instructions at once. EG: If told to go up by 10 pulses, it MUST finish receiving 10 pulses before doing anything else. If told to go up by 10, and then 15, whilst it is still counting to 10, it will not go up by either 10 or 15 and get "confused".
Good to know. In my control script this will not happen because it only generates a number of pulses per control cycle, either up or down. But maybe, see also my first comment, we need more delay.
Again: make this procedure (sending up/down pulses) 100% reliable before continuing...
regards,
Nico
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
I have now finally figured out how to get a consistent value "10" on the HSI every time, without an erraneous results.
Basically, the pulse must START on 5V, and end on 5V. For example to count from 0-10:
- ON, OFF, ON, OFF, ON, OFF, ON, OFF, ON, OFF, ON, OFF, ON, OFF, ON, OFF, ON, OFF, ON, OFF, ON,
That's 11 "ONs" and 10 "OFFs". Doing this sequence consistantly gets 10 values exactly each time. The identical logic applies for counting down; you must START with 5V and END with 5V (with 11 ons and 10 offs).
I cannot seem to get a consistent enough result starting with an OFF.
In other words, all pulses must start with ON, and end with ON. If a pulse is finished with OFF, and starts with ON, then this in itself counts as a pulse and will give one extra value we don't need.
PS: All information was recorded using the following script:
Code:
Var 99 name Trigger3 Link IOCARD_SW Input 18 Type P
{
IF &Trigger3 = 1
{
&UPDOWN_Pin = 1
}
}
Var 98 name Trigger4 Link IOCARD_SW Input 23 Type P
{
IF &Trigger4 = 1
{
&UPDOWN_Pin = 0
}
}
Var 2 name Trigger Link IOCARD_SW Input 25 Type P
{
IF &Trigger = 1
{
CALL &Pulses 10
}
}
Var 1 name Pulses link SUBRUTINE // parameter is number of pulses ...
{
&Out = 1
&PulseDown = DELAY &Pulses 9 // 50 msec for a half pulse
}
Var 3 name Out Link IOCARD_OUT Output 29 // Pulse Pin
Var 11 name PulseDown
{
L0 = &PulseDown
IF L0 > 0
{
&Out = 0
&Finish = DELAY &PulseDown 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
{
&PulseDown = 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
On its own, the script didn't work. So, I opened up controlador.exe and manually provided the pulses, and it worked exactly as described above.
Regards,
Jack
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Jack,
Good work.
I have changed the subrutine Pulses such that in 'rest' Out will be 1. Also added a Var 0 in order to be able to start with Out = 1
Code:
Var 0 Value 0
{
&Out = 1
}
Var 99 name Trigger3 Link IOCARD_SW Input 18 Type P
{
IF &Trigger3 = 1
{
&UPDOWN_Pin = 1
}
}
Var 98 name Trigger4 Link IOCARD_SW Input 23 Type P
{
IF &Trigger4 = 1
{
&UPDOWN_Pin = 0
}
}
Var 2 name Trigger Link IOCARD_SW Input 25 Type P
{
IF &Trigger = 1
{
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
Regards,
Nico
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
Great news! That script ensures that it goes up EXACTLY by 10 or down by 10 each time. The trick seems to be starting on 5V and ending on 5V.
There is just one problem. As you know, as SIOC is started it resets all outputs connected to the mastercard.
Var 0 turns the range display to 5V. So, in other words, the range display = 0 for a very, very short time, before var 0 sets it to 5V. This very short OFF/On sequence, even if it is for a billionth of a second, counts as a pulse, so the HSI display counts down one.
We need to get rid of this initial OFF/ON pulse.
Also, some more good news: the script even works when transitioning from an UP to a DOWN count EG: 10-20, then back down to 10 is no problem.
Regards,
Jack
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Jack,
Quote:
Originally Posted by
Boeing 747 Flyer
We need to get rid of this initial OFF/ON pulse.
Well, change Var 0 to this:
Code:
Var 0 Value 0
{
&Out = 1
&UPDOWN_Pin = 0 // count down
CALL &Pulses 1 // correct for first OFF/ON pulse at startup
}
regards,
Nico
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
Fantastic news! We have bypassed stage 1. All is working!
I did, however, have to change the script slightly. Firstly, the error was a DOWN pulse (it went from 0 to 9999) so the UPDOWN_Pin had to be 1. Secondly, and I don't know why, &Pulses must be called TWICE to compensate for the error:
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
}
}
Var 98 name Trigger4 Link IOCARD_SW Input 23 Type P
{
IF &Trigger4 = 1
{
&UPDOWN_Pin = 0
}
}
Var 2 name Trigger Link IOCARD_SW Input 25 Type P
{
IF &Trigger = 1
{
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
Anyway, I tested it many times, and no matter how hard I tried, I could not get the display to go wrong. It always count up or down 10; exactly how I wanted it.
Woohoo!
Jack
-
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
Kindest regards,
Jack
-
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
into
Code:
&UPDOWN_Pin = 1 // count up
Programmers often forget to update the commentary parts when they change their code.
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... ;-)
-
Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?
Hi Nico,
All done! What's next on the agenda?:D
Jack
-
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
-
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
-
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
-
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
-
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
If you can see anything wrong please tell me and I shall correct it right away.
Kindest regards,
Jack
-
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
The problem is not the pulsing script at all; it is the calculation for the pulses.
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
-
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
regards,
Nico