PDA

View Full Version : Nico's Kaan NAV1 & Course example



samsail
01-19-2011, 02:57 AM
Hi to every one,

In the attached Nico’s Kaan NAV1 Radio example you can chance the frequencies in NAV1 Radio and in the NAV1 Course using 2 rotary switches ( one for Radio and one for Course)
Can same one give a help to modify the script such as to use only one rotary encoder for both function? A selector push button must be in use for the designed mode ( course or radio).
I want to use the example to modify the script for CRJ 700 radio panel which use only one Rotary Encoder and Push buttons for selecting the frequencies ( you can see the RadioPanel In the Default FSX CRJ 700 airplane).
Thanks in advance,
Cheers,

pdpo
01-19-2011, 04:56 AM
Hi there,

this is very simple,
what you need to do is set a variable depending on the pushbutton or even multiple pushbuttons to a value which indicates what
you are changing. Then in the body of the encoder you use the IF {} ELSE {} construction to check this value and to do the needed
rotary action on different targets

Greetz Peter

kiek
01-19-2011, 05:08 AM
////////////////////////////////////////////////////////////////////
//
// Generic FS9/X NAV1 (VOR1) Radio
// SIOC 3.5+ code for FSUIPC
// using FSUIPC offsets 0x0350 and 0x0C4E
//
// Version 1.0
// Jan 19, 2011
//
// Nico Kaan
// The Netherlands
// www.lekseecon.nl
//
// INCLUDES:
//
// Implementation of a NAV1 radio, consisting of
//
// 1 single rotary encoder controlling the frequency and course
// with a push button to switch between frequency and course
// and a push button to switch between high and low part of the frequency
// five 7-segment displays for the frequency
// - software controlled Decimal Point via an Output
// three 7-segment displays for the course
//
// CHANGE LOG:
//
// 1.0 First Release

Var 8600 name FI_NAV1Freq Link FSUIPC_IN Offset $0350 Length 2
{
L0 = FROMBCD &FI_NAV1Freq
&NAV1Freq = L0
&NAV1FreqHigh = DIV L0 100
&NAV1FreqLow = MOD L0 100
CALL &OutNAV1Freq // display new freq value
}

Var 8601 name FI_NAV1Crs Link FSUIPC_IN Offset $0C4E Length 2
{
&NAV1Crs = &FI_NAV1Crs
}

Var 8610 name NAV1FreqLow
Var 8611 name NAV1FreqHigh
Var 8612 name NAV1Freq

Var 8613 name CalcNAV1Freq Link SUBRUTINE
{
L0 = &NAV1FreqHigh * 100 // high * 100
&NAV1Freq = L0 + &NAV1FreqLow // + low
&FO_NAV1Freq = TOBCD &NAV1Freq // BCD value to panel
CALL &OutNAV1Freq // display new freq value
}

Var 8614 name NAV1Crs
{
CALL &OutNAV1Crs
}

Var 8620 name OutNAV1Freq Link SUBRUTINE
{
&D_NAV1Freq = &NAV1Freq + 10000 // to display + '1'
&O_NAV1DP = 1
}

Var 8621 name OutNAV1Crs Link SUBRUTINE
{
&D_NAV1Crs = &NAV1Crs
}

Var 8638 name Mode Link IOCARD_SW Input 35 Type P // push button
// 0 = FREQ, 1 = CRS

Var 8639 name FreqPart Link IOCARD_SW Input 34 Type P // push button
// 0 = LOW, 1 = HIGH

Var 8640 name RO_NAV1FC Link IOCARD_ENCODER Input 59 Aceleration 1 Type 2
{
L0 = &RO_NAV1FC
IF &Mode = 0
{
IF &FreqPart = 1
{
&NAV1FreqHigh = ROTATE 8 35 L0
}
ELSE
{
L0 = L0 * 5
&NAV1FreqLow = ROTATE 0 99 L0
}
CALL &CalcNAV1Freq
}
ELSE
{
&NAV1Crs = ROTATE 0 359 L0
&FO_NAV1Crs = &NAV1Crs
}
}

Var 8670 name D_NAV1Freq Link IOCARD_DISPLAY Digit 20 Numbers 5
Var 8671 name D_NAV1Crs Link IOCARD_DISPLAY Digit 25 Numbers 3

Var 8680 name O_NAV1DP Link IOCARD_OUT Output 96

Var 8698 name FO_NAV1Crs Link FSUIPC_OUT Offset $0C4E Length 2
Var 8699 name FO_NAV1Freq Link FSUIPC_OUT Offset $0350 Length 2
With compliments ... ;-)
Nico

nricky
01-19-2011, 08:12 AM
Hi Nico

I took your sioc code and changed it a bid. Your idea with a single encoder is to cool.

What I have done: took your code and changed it so in 1 Sioc file is the code for all the radios.

Now the transfer from freq. also works

COM1 Active VAR. 8800, COM1 Standby VAR. 8801, COM2 Active VAR. 8802, COM2 Standby VAR. 8803, NAV1 Active VAR. 8804, NAV1 Standby VAR. 8805, NAV2 Active VAR. 8806, NAV2 Standby VAR. 8807

The file can be downloaded from my page http://www.flight.nrick.net/SiocSoftware.html

Hope that someone can use the sioc file. The only thing that is missing is the transponder and the ADF.

Cheers Norbert

samsail
01-20-2011, 11:53 PM
:roll:I thank you all for the response, special Nico Kaan for the excellent example ( One rotary controlling two freguencies)
But now is the real challenge.
How can control the radio frequencies for a CRJ700 radio panel that it use, for all standby frequencies only one encoder with push button (Low-Hi freg. selection) four push buttons to swap and for buttons to select mode ( Com1-Com2-Nav1-Nav2)?
The attached example controls radio frequencies as above but you need to use four rotary encoders
Regards,

kiek
01-21-2011, 04:17 AM
Hi,

With so many good examples already available, I'll leave that as an exercise to the reader ;-)

Tip: start with making your script more readable by introducing names instead of numbers (http://www.lekseecon.nl/howto.html#names)

regards,
Nico

nricky
01-21-2011, 08:06 AM
Hi Nico

I find it easier to use numbers than names. As you saw it is part of your code. If it was not for your code it would have been not able for me to so my script.

Thanks for that.

Cheers Norbert

PS keep your examples coming. Maybe you can help me on my ADF

kiek
01-21-2011, 09:47 AM
I find it easier to use numbers than names.
Strange?! You are not a computer are you? ;-) ;-)

Using numbers is more prone to errors... and more difficult to comprehend....

Of course you always need a number for a variable in SIOC, but then attach a name to it, so you can refer to your variable by its name. That's what I've done in my code.

You are Norbert ... not social security number 12345678 in Germany ... ;-)

nricky
01-21-2011, 01:27 PM
You are Norbert ... not social security number 12345678 in Germany ... ;-)

You are to funny have tried it few times to work with names but no chance. But you are right, for other it is easier to figure out to understand the code.

Have you done a sioc for the adf with a single encoder and a transponder. I have spend a bit time on the code but with no sucess.

Cheers Norbert

samsail
01-22-2011, 01:30 AM
Hi Kiek and Norbert

Numbers or names doesn’t make any different to me because I’ m not able to write even one single line in sioc code.

What is the story then?

A few months ago I decided to make alive my youth dream to build my own cockpit.
I decided to build a CRJ700 cockpit because I believed that it will be easier instead of a B737/800. This was my big mistake.
Because there are not pre-made modules for CRJ700 I have to build everything by my own and the worst, I have to learn to write in sioc code.
I thing that I will never be able to do it, even if I’ll try very very hard, because I think, my mind has not this ability ( Can a doctor understand an car engineer?).

What I have done so far?

I have search all the available sioc examples and I have cut parts from them making things to work for the parts of my cockpit.
My big trouble is to modify your example Kiek, in order to control the Radio frequencies with one rotary encoder (as per the layout of a CRJ radio panel)
If in your example there was a control of NAV2 radio freg (FSUIPC Offset 3120) instead of NAV1Course, ( FSUIPC 0C4E) then maybe I will be able to copy and paste (Like a parrot) some lines in order to control even the COM1 and COM2 Freg

Kiek your knowledge and your help are very precious so I hope you will never deprive these to us.

For the friend Norbert I have in the attached an example for the ADF but it use two encoders. When Norbert you will modify it to work with one encoder with push button please send back a copy.

Regards
Samsail

nricky
01-22-2011, 02:56 AM
Hi Samsail

Tanks for the code, it suizid be done with a single encoder. But at the moment my time is very limited.

Writing sioc is not that hard. I always said to myself i can't learn it. I spend lots of money on other elektronics because sioc is so hard. Than one week I said now you have to learn how. Took lots of examples made Lots of mistakes, but now i am ok with it. And there are lots of people out there that will help you have problems.

Don't give up have lots of fun here.

Cheers Norbert

kiek
01-22-2011, 02:25 PM
Maybe you can help me on my ADF
That's already available at my website: SIOC code for ADF (http://www.lekseecon.nl/howto.html#gensioc)

regards,
Nico

nricky
01-23-2011, 07:33 AM
Hi Nico

Will have a look at it later. Thanks

Cheers Norbert

samsail
01-27-2011, 11:33 PM
Hi,
Here is my progress in SIOC code.

In the attached file “Radio NAV1 NAV2”
I wrote a script to control NAV1 And NAV2 Radio freq. using a single rotary encoder with push button for Hi and Low frequencies, plus two more push buttons, one to select NAV1 or NAV2 and one to Swap form standby mode to active mode.

I thank you Nico for your examples, these are a great help for me.

In the attached file “ Nico’s ADF1” I have try to modify your script for the ADF1 in case to use one rotary encoder with push a button, but it is not work.

Can you please Nico check this file for my mistakes?
I thank you in advance,
Yiannis

kiek
01-28-2011, 08:42 AM
Here a version in which I've corrected your mistakes ... Also check the input number of your PushButton
Nico


Var 8700 name X_ADF1High Link FSUIPC_INOUT Offset $034C Length 2
{
L0 = FROMBCD &X_ADF1High
IF &ADF1High <> L0 // block values coming from rotary
{
&ADF1High = L0
&ADF1HighR = DIV &ADF1High 10
CALL &CalcADF1LowR
CALL &CalcADF1Freq
}
}
Var 8701 name X_ADF1Low Link FSUIPC_INOUT Offset $0356 Length 2
{
IF &X_ADF1Low <> &ADF1Low // block values coming from rotary
{
&ADF1Low = &X_ADF1Low
CALL &CalcADF1LowR
CALL &CalcADF1Freq
}
}
Var 8710 name ADF1High // FSUIPC ADF value high: 3 digits
Var 8711 name ADF1Low // FSUIPC ADF value: 1 digit
var 8712 name ADF1Freq // total (needed for display): 4 digits
var 8713 name CalcADF1Freq Link Subrutine
{
L0 = &ADF1High * 10 // high * 10
&ADF1Freq = L0 + &ADF1Low // + decimal
CALL &OutADF1
}
Var 8720 name OutADF1 Link SUBRUTINE
{
&D_ADF1 = &ADF1Freq
&O_ADF1DP = 1
}
Var 8730 name ADF1HighR // higher TWO digits controlled by rotarie
Var 8731 name ADF1LowR // lower TWO digits controlled by rotarie
var 8732 name CalcADF1LowR Link Subrutine
{
L0 = MOD &ADF1High 10
L0 = L0 * 10
&ADF1LowR = L0 + &ADF1Low
}
var 8733 name CalcADF1High Link Subrutine
{
L0 = DIV &ADF1LowR 10
L1 = &ADF1HighR * 10
&ADF1High = L0 + L1
}

Var 8740 name PushButton link IOCARD_SW input 1 type P

Var 8744 name RO_ADF1 Link IOCARD_ENCODER Input 5 Aceleration 4 Type 2
{
L0 = &RO_ADF1 * -1 // change direction
IF &PushButton = 1
{
&ADF1HighR = ROTATE 20 99 L0
CALL &CalcADF1High
CALL &CalcADF1Freq
&X_ADF1High = TOBCD &ADF1High // higher 3 Digits in bcd to fsuipc
}
ELSE
{
L0 = L0 * 5 // in steps of 5
&ADF1LowR = ROTATE 0 99 L0
&ADF1Low = MOD &ADF1LowR 10
CALL &CalcADF1High
CALL &CalcADF1Freq
&X_ADF1Low = &ADF1Low // decimal digit to fsuipc
&X_ADF1High = TOBCD &ADF1High // higher 3 Digits in bcd to fsuipc
}
}

Var 8770 name D_ADF1 Link IOCARD_DISPLAY Device 1 Digit 16 Numbers 4
Var 8780 name O_ADF1DP Link IOCARD_OUT Device 1 Output 95

samsail
01-28-2011, 12:14 PM
I can’t find words to thank you for helping me with the Sioc scripts.

My ADF1 is operated now perfect.

My best regards
Yiannis


:D

kiek
01-28-2011, 12:40 PM
Hi Yiannis,
It was my pleasure. I hope more people will see how easy and powerful SIOC is. :-)
Have Fun!
Nico

mabderezai
02-03-2011, 02:42 AM
Hello fellow cockpit builders,
I am new to the hobby ... I just ordered a bunch of parts and I'll be putting together my own OC cards this week... yay! I'm building a LVLD 767 cockpit...
I have good experience in programming and working with hardware, and I have read the SIOC manuals and the bits of code that I have found online... still I am not following the programming language that well... for instance, the & sign is not talked about in the OC manual (or I in the manual I found) plus... how did you pickup this language? the code that was posted in this thread by Nico seemed simple, but I still couldn't follow... would it be possible if you explain a line by line for some of the more SIOC specific lines... I get the IF/ELSE parts :D and I'm shaky on the VAR parts, but totally confused on the CALL :roll: ...

By the way, great site Nico!

kiek
02-03-2011, 06:36 AM
Hi,

Welcome on board!

The & sign is just a syntactical symbol (not an operator). It indicates the compiler that the identifier following is the name of a variable. It was introduced to make parsing of the text by the compiler simple. Of course there are more user friendly ways to work with variable names, but SIOC is a very simple language. Do not compare it with C++ or Java, or languages like that.

With the CALL command you call a subroutine variable.

Since you have good experience in programming, it should not be very difficult for you to learn SIOC. Just keep on studying the howto examples at my website and practice by writing small scripts.
And do note that SIOC is an 'event driven scripting language', not a procedural language with a begin and an end, see this example of flow of control (http://www.lekseecon.nl/howto.html#flow).

Regards,
Nico