User Manual - Programming With SC-Pascal Vol II - Rev1.1
User Manual - Programming With SC-Pascal Vol II - Rev1.1
User Manual
SC-MAN-SCP-E-11-0011
LOG
INDEX
1 Definitions and acronyms ..........................................................................................................................3
1.1 Definitions .........................................................................................................................................3
1.2 Acronyms ..........................................................................................................................................3
2 Related documentation .............................................................................................................................4
3 Purpose of this document .........................................................................................................................4
4 Programming a Display (OUTPUT) .............................................................................................................4
4.1 How to program a display output using IOCP? .................................................................................5
4.2 How to program a display output using FSUIPC? .............................................................................7
5 Programming an encoder (INPUT).............................................................................................................8
5.1 How to program an encoder using IOCP? .......................................................................................11
5.2 How to program an encoder using FSUIPC? ...................................................................................12
1 Functions for HARDWARE-SIMULATOR syncronization ..........................................................................15
6 More Practical Examples with INPUTS ....................................................................................................16
6.1 Programming a PushButton ............................................................................................................17
6.2 Programming a Rotary Input...........................................................................................................18
7 Programming an Analog Input (Potentiometer) .....................................................................................20
7.1 How to program a pot using IOCP?.................................................................................................22
7.2 How to program a pot using FSUIPC? .............................................................................................24
8 Programming a Servo (OUTPUT) .............................................................................................................25
8.1 ScaledUnPot Function .....................................................................................................................27
8.2 How to program a servo output using IOCP? .................................................................................27
8.3 How to program a servo output using FSUIPC? ..............................................................................29
9 Examples ..................................................................................................................................................31
1.1 DEFINITIONS
Item Definition
Backlight Lighting which illuminates the letters, lines or other features of a panel from the
inside or back of the module.
Switch and Hub Device A device for connecting many Ethernet cables. For use when you want to connect
many Ethernet devices to a single computer.
SC Pascal A programming language and a high level editor/compiler. All script provided by
Sismo are programmed in this language. There are manuals for learning this
language on our website. You can also download the program from our website.
Crossed Ethernet Cable A type of Ethernet cable used to connect a module directly to a computer.
Standard Ethernet Cable If you are using a standard Ethernet cable, you should connect the module to a
Hub/Switch or to your Router (and not directly to the computer)
Mother – Daughter Master – Slave board
Ethernet Local area network data transfer protocol. An alternative to USB.
IOCP Input/output completion port (IOCP) is an API for performing multiple
simultaneous asynchronous input/output operations in Windows NT.
FSUIPC Flight Simulator Universal Inter-Process Communication. For controlling
asynchronous input/output operations in flight simulation.
UDP A protocol within the TCP/IP protocol suite
DHCP Dynamic Host Configuration Protocol, A protocol that provides a means to
dynamically allocate IP addresses to computers on a local area network. To be
deactivated or the IP addresses will change!
Script A program which controls the SC-MB and allows the user to assign the functions of
one of the Plug&Fly Modules (AFT, FWD, etc.) to the Motherboard.
Add-on Company ProSim, iFLy, PMDG. They are companies which interface the hardware with the
flight simulation software.
Autosense a feature found in network adapters that allows them to automatically recognize
the current local network's speed and adjust its own setting accordingly
Plug&Fly Modules Require no building or skills in electronics. They are fully equipped to be installed
on your simulator. They are the FWD, AFT, MIP, Pedestal, MCP and EFIS.
1.2 ACRONYMS
Item Definitions
PCB Printed Circuit Board.
GND Ground – Return path for electric current in a circuit
PRM Plug Ready Module
2 RELATED DOCUMENTATION
The intention of this document is to describe the environment of the editor/compiler SC-Pascal and the
enough steps to make the realization of scripts according to the needs of the fans of the Flight Simulation
and other applications.
To manage a display as the MCP has, the first thing to do is connect the Displays to the SIMCARD. A display
works very similar as an OUTPUTS-led already explained in the chapter 7 of this manual.
Once the display is connected to the card, we must check the corresponding display number, because the
card can manage a total number of 96 outputs.
As an example, we have connected 3 displays to
the card at display Nº1, Nº2 and Nº3. Click with
the mouse on the serial number of the Simcard
at SC-Pascal (e.g. SC-MMB0000) and at the SC-
PASCAL TEST DISPLAY window, go to DISPLAYS
and click with mouse on the displays 1, 2 & 3. If
the led turns to green light and displays are
switch on, the connection DISPLAY <-> Simcard
will be right.
As a result, we can begin to program with SC-Pascal high level
language!
For programming an output, either leds or displays; the Procedure OnFSUIPCChange is used if we use
FSUIPC protocol, but we must use the Procedure OnIOCPChange when using the IOCP protocol, both
protocols already studied along this manual. The following shows examples:
The function WriteDigitEth will be used to write the desired values in the displays for both; IOCP and
FSUIPC protocols. See the parameters of the function:
WriteDigitEth('Serial Number of the SIMCARD', Nº of the first display to be written, Value to be written,
‘Pad Value, Total number of displays to be written, Nº of the display with decimal point (0->without
decimal point; 2->el 2nd digit is with decimal point), brightness (0->OFF; 15->ON));
Example1; WriteDigitEth('SC-MMB0000',1,59,’0’,3,0,15); //It writes the value 59 at 3 displays. The first
display, which will be written, is the display Nº1 connected to the Simcard SC-MMB0000. It also fills out
with the '0' character to the third display without any value. It has no decimal point and has the
maximum brightness (score 059)
Example2; WriteDigitEth('SC-MMB0000',5,8,’0’,4,1,15); //It writes the value 8 at 4 displays. The first
display, which will be written, is the display Nº5 connected to the Simcard SC-MMB0000. It also fills out
with the '0' character to the forth display without any value. It has decimal point at the first digit and has
the maximum brightness (score 0008.)
Example3; WriteDigitEth('SC-MMB0000',10,359,’0’,5,3,15); //It writes the value 359 at 5 displays. The first
display, which will be written, is the display Nº10 connected to the Simcard SC-MMB0000. It also fills out
with the '0' character to the fifth display without any value. It has decimal point at the third digit and has
the maximum brightness (score 003.59)
Example4; WriteDigitEth('SC-MMB0000',15,359,’ ’,4,0,15); //It writes the value 359 at 4 displays. The first
display, which will be written, is the display Nº15 connected to the Simcard SC-MMB0000. It also fills out
with the ' ' character to the forth display without any value (that is to say that nothing is written). It has
not decimal point and has the maximum brightness (score 359)
Example5; WriteDigitEth('SC-MMB0000',21,Value,’0’,3,0,15); //It writes the value Value at 3 displays. The
first display, which will be written, is the display Nº21 connected to the Simcard SC-MMB0000. It also fills
out with the '0' character to the third display without any value (that is to say that nothing is written). It
has not decimal point and has the maximum brightness
Note: the score of the example 5 depends of the value which is read in the Procedure OnIOCPChange when
using IOCP protocol or, in the Procedure OnFSUIPCChange if FSUIPC is used.
Following the example of the displays connected to the Simcard; the IOCP offsets for a specific Simulator (in
this example to the default FSX aircraft) are the next ones:
Course OBS CAP => offset 43; ALTITUDE => offset 107;
The first thing to do is register the offsets 43 y 107 (use socket 0).
Subsequently, we need to edit the Procedure OnIOCPChange:
- Use a “debug” in order to know the taken values by both offsets.
- If any value of the offsets changes (e.g., from 0 to 1, 2, 3…), we must write the value in the display
according to the new value that the offset took which corresponds to the Simulator. In this way,
Display and Simulator will be synchronized. The following function is used to make it possible when
using IOCP: WriteDigitEth (see chapter 7).
- We use the "case" clause: if one of the previous registered offsets (43:, 107:, …), which are included
into the "case", change, the statement given after the colon will be done (:WriteDigitEth...):
case offset of
43:WriteDigitEth('SC-MMB0000', 1, value, '0', 3, 0, 15);
107:WriteDigitEth('SC-MMB0000', 4, value, '0', 5, 0, 15);
End;
Thus, the value taken by the offset of the Simulator is sent to the Displays through IOCP.
Following the example of the displays connected to the Simcard; the FSUIPC offsets for a specific Simulator
(in this example to FS9 using PMDG) are the next ones:
Course OBS CAP => offset $0C4E; (size 2) ALTITUDE => offset $622E; (size 2)
The first thing to do is register the offsets $0C4E y $622E.
Subsequently, we need to edit the Procedure OnFsuipcChange:
- Use a “debug” in order to know the taken values by both offsets.
- If any value of the offsets changes (e.g., from 0 to 1, 2, 3 …), we must write the value in the display
according to the new value that the offset took which corresponds to the Simulator. In this way,
Display and Simulator will be synchronized. The following function is used to make it possible when
using FSUIPC: WriteDigitEth (see chapter 7).
- We use the "case" clause: if one of the previous registered offsets ($0C4E:, $622E: …), which are
included into the "case", change, the statement given after the colon will be done
(:WriteDigitEth...):
case offset of
$0C4E:WriteDigitEth('SC-MMB0000', 1, value, '0', 3, 0, 15);
$622E:WriteDigitEth('SC-MMB0000', 4, value, '0', 5, 0, 15);
End;
Thus, the value taken by the offset of the Simulator is sent to the Displays through FSUIPC:
As an example, we have connected an encoder to the card at input Nº1 and Nº2. Click with the mouse on
the serial number of the Simcard at SC-Pascal (e.g. SC-MMB0000) and move the connected encoder in
order to test on the SC -PASCAL TEST (INPUTS) window that the Input Nº1 and Nº2 changes from red
(active) to grey colour (inactive). If we can get that and the test works as it was explained, the connection
Encoder <-> Simcard will be right.
As a result, we can begin to program with SC-Pascal high level language!
SetEncVel(); is the first function which must be added. This function must be inside of the Procedure Main.
A value between 0 and 100 must be written inside the brackets of the funcion:
0 -> it means that the encoder speed is minimal and the displays speed is slow when changing the value of
the digits.
100-> it means that the encoder speed is maximal and the displays speed is fast when changing the value of
the digits.
The user can change the value of this function in order to find the desired speed.
SetEncVel (Value for encoder speed);
// 0 -> low speed
//100 -> high speed
To send data from an encoder to the Simulator, both with FSUIPC and IOCP and for any type of Simulator,
we use the next event:
Procedure OnEncoderChange (encId:integer; value:integer);
We can read what encoder has been moved and its value if this event is used, that is, Procedure
OnEncoderChange is run each time we change the status of an encoder.
Next, it is shown through examples:
Suppose you have connected to the card the following encoders:
Course OBS CAP => input Nº1, input Nº2;
ALTITUDE => input Nº3, input Nº4;
1.1 Programming with SC-Pascal Vol II
SCP
User Manual SC-MAN-SCP-E-11-0011 9 / 31
User Manual - Programming with SC-Pascal Vol II - Rev1.1
Flight Simulators Solutions
www.sismo-soluciones.com
Each encoder, which is connected to the card, must be registered in order the script can check
automatically which each encoder is being moved and in this way to decrease / increase the value each
time you move it left/right respectively. The encoders must be registered with the following statement:
RegEncoder (‘’, Serial Number of the Simcard, pin INPUT 1, pin INPUT 2, Lower Value, Upper Value,
Recursiveness, Initial Value, Encoder Type, Speed Type);
//Registering Encoders
Cada encoder conectado debe ser registrado. El primer encoder que se registre tendrá la Identidad encID =
0, el segundo será encId = 1, y así sucesivamente, pero esto lo comprobaremos mejor en el ejemplo.
Para mejorar la comprensión, algunos de los parámetros de esta función se explican a continuación:
- Lower Value: is the smallest value that can get an encoder, for example, for the CAP OBS Course is
1.
- Upper Value: is the largest value that can get an encoder, for example, for the OBS Course CAP
would be 360.
- Recursiveness
0 -> when the encoder reaches the "upper value" does not continue increasing its value, it stays at
that “upper value”: for example, it can not continue adding digits when the value 360 is reached
(the same applies to the "lower value").
1 -> when the encoder reaches the " upper value" continues with the "lower value": for example,
after to reach 360, if we increase the encoder again it takes the value 1 until you get again to reach
360 and so on in a cyclical way (it also happens in opposite direction of movement, ie, if it reaches
the "lower value" continues with the "upper value").
- Initial Value: is the initial value taken by the encoder. If this value is 100, and the encoder is moved
for the first time to the right, it will take the value 101.
- Encoder Type
true -> if the encoder is ½ cicle type, as E33, E37, ALPS ECII,..
- Speed Type
true -> the encoder speed will be the speed specified inside the SetencVel function.
false -> encoder speed will be the speed by default, that is to say speed 0.
// An encoder is registered. Due that it is the first encoder registered, its identity will be encID = 0. It is connected to the card SC-
MMB0000 on pins 9 and 10, and the lower value that can take is 1 and the upper is 360. It is a recursive encoder and its initial
value is 100. Furthermore, the encoder is 1/ cycle type and the speed is set at the SetEncVel function.
Following the example of the encoders connected to the Simcard; the IOCP offsets for a specific Simulator
(in this example to FSX by Default) are the next ones:
Course OBS CAP => offset 43;
ALTITUDE => offset 107;
The first thing to do is register the offsets 43 y 107 (use socket 0) and add the SetEncVel (30); function into
the Procedure Main.
Subsequently, we need to edit the Procedure OnEncoderChange:
- Use a “debug” in order to know the taken values by the encoder connected to the card and check
which identity has the encoder moved.
- If the value of an encoder changes (e.g., from 100 to 101), we must write the new value in the
corresponding offset of the Simulator in order the Simulator can interpret it. In this way, Encoder
and Simulator will be synchronized. The following function is used to make it possible when using
IOCP: WriteIOCP (see chapter 6).
- We use the "case" clause: if one of the encoders already registered with a specific identity -encId-
(0:, 1:, ...), which are included into the "case", change, the statement given after the colon will be
done (:WriteIOCP ...):
case encId of
0: WriteIOCP (0, 43, value);
1: WriteIOCP (0, 107, value*100);
End;
Note 1: See that the SetEncVel function is into the Procedure Main and the register of the encoders is made into the Procedure
OnIOCPConnect.
Note 2: See that the initial value of the encoder is estimated by reading the value that the Simulator has in their respective offsets
for each encoder using the ReadIOCP function (explained in Chapter 7). Both encoders are normal cycle type.
Note 3: See that the value of the encoder ALTITUDE is multipliedby 100 in order to be synchronized with FSX 737 by default offset.
Thus, the value taken by the Encoder is sent to the Simulator through IOCP.
Following the example of the encoders connected to the Simcard; the FSUIPC offsets for a specific
Simulator (in this example to FSX/FS9 using Project Magenta) are the next ones:
Course OBS CAP => $0C4E (size 2)
ALTITUDE => $540A (size 2)
The first thing to do is register the offsets $0C4E and $540A, and add the SetEncVel (30); function into the
Procedure Main.
Subsequently, we need to edit the Procedure OnEncoderChange:
- Use a “debug” in order to know the taken values by the encoder connected to the card and check
which identity has the encoder moved.
- If the value of an encoder changes (e.g., from 100 to 101), we must write the new value in the
corresponding offset of the Simulator in order the Simulator can interpret it. In this way, Encoder
and Simulator will be synchronized. The following function is used to make it possible when using
FSUIPC: WriteFSUIPC (see chapter 6).
- We use the "case" clause: if one of the encoders already registered with a specific identity -encId-
(0:, 1:, ...), which are included into the "case", change, the statement given after the colon will be
done (:WriteFSUIPC ...):
case encId of
0: WriteFSUIPC ($0C4E, 2, value);
1: WriteFSUIPC ($540A, 2, value);
End;
Note 1: See that the SetEncVel function is into the Procedure Main and the register of the encoders is made into the Procedure
OnFSUIPCConnect.
Note 2: See that the initial value of the encoder is estimated by reading the value that the Simulator has in their respective offsets
for each encoder using the ReadFSUIPC function (explained in Chapter 7). Both encoders are normal cycle type.
Note 3: See that there are 2 types of offsets for the encoder ALTITUDE, the first one is for Reading values from the Simulator and the
other one is for writing in the Simulator the values that the encoder takes.
Thus, the value taken by the Encoder is sent to the Simulator through FSUIPC.
The functions to be used for synchronizing and initializing Hardware-Simulator with the same values are 2:
- Syncrosoftware;
- Syncrohardware;
A continuación se muestra el orden más lógico para realizar la inicialización del script y dos ejemplos, para
IOCP y FSUIPC:
In case we are programming with IOCP, these two functions are always located on the Procedure
OnIOCPConnect. If the protocol used is FSUIPC, they will be placed in the Procedure OnFSUIPCConnect.
Both functions must be located after registration of encoders and offsets, as well as after the StartEvents;
function.
Below, the logical order to initialize the script is shown with two examples, for IOCP & FSUIPC:
1. Registering the offsets
2. Registering the encoders
3. Startevents; // Begin the events once the offsets were registered
4. Syncrosoftware;
5. Syncrohardware;
e.g. IOCP
e.g. FSUIPC
Chapter 6 already showed how to program any type of INPUT, and in particular, an example of
programming a 2-position switch was seen for both IOCP and FSUIPC protocols.
The Chapter 6 also explained the event to use: Procedure OnInputChange, with which we can read what
input has been active/ inactive and the value it takes each time a change of value is made, that is, each time
we change the status of an input.
Moreover, the functions, which we can use to write in the simulator, were explained, either through IOCP
(WriteIOCP) or via FSUIPC (WriteFsuipc).
And finally, the useful functions for using in programming inputs were shown, such as, setBit (used to
change the value of a particular bit of an offset) and sendKey (used to send a key to the simulator, e.g. the
key 'k').
This chapter does not increase the theoretic knowledge for the inputs programming. That is because all the
functions and the method of programming have already been sufficiently explained, but the programmer
experience will be increased based on more examples of inputs programs such as programming
Pushbuttons (1 single input) and rotaries (more than 2 inputs).
e.g. IOCP
See the logic which was used for programming. Also see the use of global constants as well as the use of the if statement to
program the 3 pushbuttons for the Flight Simulator By Default:
e.g. FSUIPC
See the logic which was used for programming. Also see the use of global constants and variables as well as the use of the if
statement to program the 2 pushbuttons for Project Magenta:
e.g. IOCP
See the logic which was used for programming. Also see the use of global constants as well as the use of the if statement to
program the 1 rotary owith 3 positions for FSX using L4SC-Ovhd:
e.g. FSUIPC
See the logic which was used for programming. Also see the use of global constants and variables as well as the use of the if
statement to program the 1 rotary owith 4 positions for PmSystems from Project Magenta:
Additionally, you can add up to a total of 21 analog inputs through extension cards for potentiometers.
As an example, we have connected a pot to the card at the analog input Nº1. Click with the mouse on the
serial number of the Simcard at SC-Pascal (e.g. SC-MMB0000) and enable the ACTIVATE ADC1 tag for the
pot Nº1 in order to test on the SC -PASCAL TEST window that when the pot (ADC1) is moved, its value
changes from 0 (minimal value that the pot takes) to 1023 (maximal value that the pot takes). If we can get
that and the test works as it was explained, the connection Pot <-> Simcard will be right.
As a result, we can begin to program with SC-Pascal high level language!
EnabledADC is the first functions that we must add. This function enables the activation of the analog
inputs and should be placed immediately after to the function StartEvents; and after the registration of
offsets.
Its structure is:
EnabledADC (‘Serial Number of the Simcard’, ‘1111111111111111’);
Example1; EnabledADC ('SC-MMB0000', ‘1111111111111111’);
To send data from a potentiometer to the Simulator both FSUIPC and IOCP and with any type of Simulator,
the following event is used:
Procedure OnADCChange (boardId:ansistring; nadc:integer; value:integer);
When moving the pot, this procedure will read the Simcard which manage the pot (boardId) and the value
that the pot takes (value), that is, each time we change the status of a potentiometer the Procedure
OnADCChange is activated, indicating also the value that takes the pot (value) when it is turned and the
corresponding analog input number (nadc) on the card (boardId).
See the following examples:
Suppose you have connected to the card the following pots (their function is to modify the brightness of
the DU’s screens):
OUTBD DU BRT=> ADC Nº1;
INBD DU BRT => ADC Nº2;
If we move the potentiometer, which was connected to AI1 on the card (OUTBD DU BRT), the Procedure
OnADCChange will read the nadc = 1, and the pot which was connected to the AI2 on the card (INBD DU
BRT) will read the nadc = 2.
Following the example of the brightness potentiometers connected to the Simcard; the IOCP offsets for a
specific Simulator (in this example to FSX by Default + ORION) are the next ones:
The first thing to do is register the offsets 3505 y 3826 (use socket 0) and add the EnabledADC; function
into the Procedure Main.
Subsequently, we need to edit the Procedure OnADCChange:
- Use a “debug” in order to know the taken values by the pots connected to the card and check
which pot is the moved one by you in a concrete moment.
- If the value of an encoder changes (e.g., from 471 to 472), we must write the new value in the
corresponding offset of the Simulator in order the Simulator can interpret it. In this way, Pot and
Simulator will be synchronized. The following function is used to make it possible when using IOCP:
WriteIOCP (see chapter 6).
- We use the "case" clause: if one of the pots (nadc) already connected to the card (boardId), which
are included into the "case", change, the statement given after the colon will be done (:WriteIOCP
...):
Note 1: See that the EnabledADC function and the register of the encoders are made into the Procedure OnIOCPConnect.
Note 2: We have connected 2 potentiometers on the Simcard Analog inputs 1 and 2 respectively. Here we can see a very useful way
of using analog inputs connected: the method is based on a set of global constants which must be written prior to the Procedure
Main (called at random: ADC_BRIGHT_PFD_CAP and ADC_BRIGHT_ND_CAP) and then, use them inside the script.
Note 3: See the logic which was used for programming. Also see the use of global constants as well as the use of the case nadc…
statement to program the 2 pots:
Thus, the value taken by each Pot is sent to the Simulator through IOCP.
See the following example:
Suppose you have connected to the card the following pots (their function is to modify the CAB of the FWD-
OVH):
ADC_CONT_CAB=> ADC Nº1;
ADC_FWD_CAB=> ADC Nº2;
ADC_AFT_CAB=> ADC Nº3;
If we move the potentiometer, which was connected to AI1 on the card (ADC_CONT_CAB), the Procedure
OnADCChange will read the nadc = 1, the pot which was connected to the AI2 on the card (ADC_FWD_CAB)
will read the nadc = 2 and the pot which was connected to the AI3 on the card (ADC_FWD_CAB) will read
the nadc = 3.
Following the same example of the 3 potentiometers connected to the Simcard; the FSUIPC offsets for a
specific Simulator (in this example to FSX/FS9 using PmSystems) are the next ones:
ADC_CONT_CAB=> offset $5670; (size 1) ADC_FWD_CAB=> offset $5671; (size 1)
ADC_AFT_CAB=> offset $5672; (size 1)
After StartEvents; function, the first thing to do is register the offsets $5670, $5671 and $5672 (size 1) and
add the EnabledADC; function into the Procedure Main.
Subsequently, we need to edit the Procedure OnADCChange:
- Use a “debug” in order to know the taken values by the pots connected to the card and check
which pot is the moved one by you in a concrete moment.
- If the value of an encoder changes (e.g., from 471 to 472), we must write the new value in the
corresponding offset of the Simulator in order the Simulator can interpret it. In this way, Pot and
Simulator will be synchronized. The following function is used to make it possible when using
FSUIPC: WriteFsuipc (see chapter 6).
- We use the "case" clause: if one of the pots (nadc) already connected to the card (boardId), which
are included into the "case", change, the statement given after the colon will be done
(:WriteFsuipc...):
Note 1: See that the EnabledADC function and the register of the encoders are made into the Procedure OnFsuipcConnect.
Note 2: We have connected 3 potentiometers on the Simcard Analog inputs 1, 2 and 3 respectively. Here we can see a very useful
way of using analog inputs connected: the method is based on a set of global constants which must be written prior to the
Procedure Main (called at random: ADC_CONT_CAB, ADC_FWD_CAB and ADC_AFT_CAB CAP) and then, use them inside
the script.
Note 3: See the logic which was used for programming. Also see the use of global constants as well as the use of the case nadc…
statement to program the 3 pots:
To manage a servo-gauge as the MIP has (Flaps or HBP) and also FWD-OVH or AFT-OVH, the first thing to do
is connect the servo to the corresponding SIMCARD for controlling them.
A servo works very similar as an OUTPUTS-led already explained in the chapter 7 of this manual. Once the
servo is connected to the card, we must check the corresponding Servo number, because the Simcard-
Servos can manage a total number of 16 outputs.
As an example, we have connected 2 servos to
the Simcard-Servo at servo Nº1 and Nº2. Click
with the mouse on the serial number of the
Simcard at SC-Pascal (e.g. SC-MMB0000-SERVO)
and at the SC-PASCAL TEST SERVO window,
enable the Activate Servo 1 and Activate Servo 2
tags, and move the bar of the servo checking that
they takes values from 0 (minimal value) to 254
(maximal value). At the same time the servo
needle must also be moved. If this effect is well
done, the connection SERVO <-> Simcard will be
right.
ActivateServo is the first functions that we must add. This function enables the activation of the servos and
should be placed immediately after to the function StartEvents; and also after the registration of offsets.
Its structure is:
ActivateServo (‘Serial Number of the Simcard-Servo’, Number of the Servo Output);
Example1; ActivateServo ('SC-MMB0000-SERVO',1);
//Activate the Servo connected to the position 1 of the Simcard SC-MMB0000-SERVO
Example2; ActivateServo ('SC-MMB0000-SERVO',13);
//Activate the Servo connected to the position 13 of the Simcard SC-MMB000-SERVO
For programming an output, either leds, displays or servos; the Procedure OnFSUIPCChange is used if we
use FSUIPC protocol, but we must use the Procedure OnIOCPChange when using the IOCP protocol, both
protocols already studied along this manual. The following shows examples:
Suppose you have connected to the card the following servos:
SERVO FUEL TEMP => servo Nº1;
SERVO EGT => servo Nº2;
The function to be used to write the desired values on the servos is the same for both the IOCP protocol
and FSUIPC. Here the details of the parameters of the function SendServo:
SendServo('Serial Number of the Simcard Servo, Nº of the Servo Output, Value to be sent to the Servo (0-
>minimal; 254->maximal));
Example1; SendServo ('SC-MMB0000-SERVO', 1, 0);
//It sends the value = 0 (minimal value) to the servo connected to the position 1 of the Simcard SC-
MMB0000-SERVO
Example2; SendServo ('SC-MMB0000-SERVO', 2, 254);
//It sends the value = 254 (maximal value) to the servo connected to the position 2 of the Simcard SC-
MMB0000-SERVO
Example3; SendServo ('SC-MMB0000-SERVO', 3, 77);
//It sends value = 77 to the servo connected at position 3 of the SC-MMB000-SERVO
Example4; SendServo ('SC-MMB0000-SERVO', 4, iVal);
//Envía el valor que posee la variable iVal al servo conectado en la posición 4 de la Simcard SC-
MMB0000-SERVO. Para poder usar iVal, previamente debe de ser declarada como variable de nombre
“iVal”
//It sends the value that contacins the variable iVal to the servo connected to the position 4 of the
Simcard SC-MMB0000-SERVO. Previously, a variable named “iVal” must be declared if we want to use it
along the script
Before proceeding with programming servos and examples, we should know how to use ScaledUnPot
function which will allow us to simplify programming when we want to program and control a servo-gauge.
The structure of this function, for its use in programming servos or any other application that the user
wants, is:
ScaledUnPot ('Value, Initial Interval 1 Value, Final Interval 1 Value, Initial Interval 2 Value, Final Interval 2
Value);
Let's look at an example:
If we have a range of values between 1- 10, and we choose the value 5. For a range between 1- 20, the
value represented by 5 is equal to 10, and the value represented by 2 would be 4. In SC-Pascal would be as
follows:
E.g.1: iVal := ScaledUnPot (5, 1, 10, 1, 20); // The result ,saved and kept in iVal, is 10
E.g.2: iVal := ScaledUnPot (2, 1, 10, 1, 20); // The result ,saved and kept in iVal, is 4
E.g.3: iVal := ScaledUnPot (2, 1, 10, 1, 100); // The result ,saved and kept in iVal, is 20
E.g.3: iVal := ScaledUnPot (3, 1, 10, 1, 40); // The result ,saved and kept in iVal, is 12
Following the same example of the servos connected to the Simcard; the IOCP offsets for a specific
Simulator (in this example to FSX using L4SC-Ovh) are the next ones:
SERVO FUEL TEMP => offset 61; (range of values that the offset takes: from -50 to 50)
SERVO EGT => offset 52; (range of values that the offset takes: from 0 to 1100)
The first thing to do is register the offsets 61 y 52 (use socket 1).
Subsequently, we need to edit the Procedure OnIOCPChange:
- Use a “debug” in order to know the taken values by both offsets and also the values taken by the
iVal variable, which must be previously created to keep the resultant value of the ScaledUnPot
function.
- If any value of the offsets changes (e.g., from 0 to 1, 2, 3…), we must write in the servo-output
according to this new value that the offset took from the Simulator. In this way, Servo-Output and
Simulator will be synchronized. The function used is SendServo (already seen).
- We use the "case" clause: if one of the previous registered offsets (52:, 61, …) which are included
into the "case", change, the statement given after the colon will be done (:SendServo...):
Note 1: See that the ActivateServo function and the register of the encoders are made into the Procedure OnIOCPConnect.
Note 2: We have connected 2 servos on the Simcard Servo 1 and 2 respectively. Here we can see a very useful way of using servo-
instruments connected: the method is based on a set of global constants which must be written prior to the Procedure Main (called
at random: SERVO_FUEL_TEMP and SERVO_EGT) and then, use them inside the script.
Note 3: See the logic which was used for programming. Also see the use of ScaledUnPot function and the variable iVal for keeping
values.
Posición EGT 0
Posición EGT 11
In this case, the range of values taken by the servo EGT would be 32 for the minimum (EGT 0) and 223 for
the maximum position (EGT 11). And therefore, the values of the constants of the script should be:
GaugeEGT_0 = 32;
GaugeEGT_11 = 223;
Note 5: The valuesof the first interval of the ScaledUnPot function are identified and defined by the offset 61
and 52 respectively. This information must be provided by the software or addon to use.
Following the same example of the servos connected to the Simcard; the FSUIPC offsets for a specific
Simulator (in this example to FSX/FS9 using PmSystems by Project Magenta) are the next ones:
SERVO FUEL TEMP => offset $56B6; (range of values that the offset takes: from 25 to 1225)
SERVO EGT => offset $5604; (range of values that the offset takes: from 4 to 11000)
The first thing to do is register the offsets $56B6 y $5604 (size 2).
Subsequently, we need to edit the Procedure OnFsuipcChange:
- Use a “debug” in order to know the taken values by both offsets and also the values taken by the
iVal variable, which must be previously created to keep the resultant value of the ScaledUnPot
function.
- If any value of the offsets changes (e.g., from 0 to 1, 2, 3…), we must write in the servo-output
according to this new value that the offset took from the Simulator. In this way, Servo-Output and
Simulator will be synchronized. The function used is SendServo (already seen).
- We use the "case" clause: if one of the previous registered offsets ($56B6:, $5604, …) which are
included into the "case", change, the statement given after the colon will be done (:SendServo...):
Note 1: See that the ActivateServo function and the register of the encoders are made into the Procedure OnFSUIPCConnect.
Note 2: We have connected 2 servos on the Simcard Servo 1 and 2 respectively. Here we can see a very useful way of using servo-
instruments connected: the method is based on a set of global constants which must be written prior to the Procedure Main (called
at random: SERVO_FUEL_TEMP and SERVO_EGT) and then, use them inside the script.
Note 3: See the logic which was used for programming. Also see the use of ScaledUnPot function and the variable iVal for keeping
values.
Note 4: See the creation of constants (GaugeFuelTempM50, GaugeFuelTemp50, GaugeEGT_0 and GaugeEGT_11). These constants
keep the value which each servo-gauge takes at its respective positions (initial position and final position) along its trace. These
positions can be checked at SC-Pascal TEST when moving the state bar of each servo and looking the values taken by the needle of
each servo.
These values must be noted for each servo. Let’s see an example for the SERVO EGT:
Posición EGT 0
Posición EGT 11
In this case, the range of values taken by the servo EGT would be 32 for the minimum (EGT 0) and 223 for
the maximum position (EGT 11). And therefore, the values of the constants of the script should be:
GaugeEGT_0 = 32;
GaugeEGT_11 = 223;
Note 5: The values of the first interval of the ScaledUnPot function are identified and defined by the offset $56B6 y $5604
respectively. This information must be provided by the software or addon to use.
9 EXAMPLES
The user can find all the full examples in the scripts folder for FSUIPC and IOCP which are available in the
download area of Sismo Soluciones web.
END OF DOCUMENT