SC PASCAL: PROGRAMMING THE FLAPS LEVER USING POTENTIOMETERS
We have a flaps lever that moves a 10koms potentiometer. We connect this pot to a board able to read that pot (Main USB or Servos USB). Then we can check the value of the pot in the different positions of the lever.
In this example, the values for the different positions are:
Flaps |
Pot value |
0 |
40 |
1 |
130 |
2 |
230 |
5 |
324 |
10 |
454 |
15 |
559 |
25 |
673 |
30 |
764 |
40 |
857 |
We can work with these values in different ways. For example we can calculate the value of the pot in the middle of two consecutive positions:
| Flaps |
Middle value |
| 0-1 |
85 |
| 1-2 |
180 |
| 2-5 |
277 |
| 5-10 |
389 |
| 10-15 |
506 |
| 15-25 |
616 |
| 25-30 |
718 |
| 30-40 |
810 |
If the pot value is bigger than 389 but lower than 506 means that the lever is in the 10º position.
We are going to use an *.INI file as follows:
[Main]
Main1=SIMIO000210
[MainADCs]
Lever1=1
Lever2=2
EjeSplr=3
EjeFlap=4
[Flaps]
Flaps01=85
Flaps12=180
Flaps25=277
Flaps510=389
Flaps1015=506
Flaps1525=616
Flaps2530=718
Flaps3040=810
where we define the name of the SimIO board, in which ADC is the pot connected, and the middle values that we calculated before.
When we move the flaps lever, we have to read the values of the pot, so we will write our code in the OnADCChange() section. Once read, we have to do something with this info. In this case we have to update the value of the lever position IOCP variable (IOCP variable 326) accordingly.
IOCP variable 326 have these values:
| Flaps |
IOCP variable |
| 0 |
0 |
| 1 |
2048 |
| 2 |
4096 |
| 5 |
6144 |
| 10 |
8192 |
| 15 |
10240 |
| 25 |
12288 |
| 30 |
14336 |
| 40 |
16384 |
These values can be get using the software Offset Monitor included in the IOCP Server Suite.

IOCP variable has to be registered at OnIOCPConnect() section.
And finally, at MAIN section, we read the values fro the *.INI file, and enable the flaps pot ADC.
Script is as follows:
PROGRAM Flaps;
const
OFFSET_FLAPLEVER_POS=326; //0 2048 4096 6144 8192 10240 12288 14336 16384
var
Main1:string;
Flaps01:integer;
Flaps12:integer;
Flaps25:integer;
Flaps510:integer;
Flaps1015:integer;
Flaps1525:integer;
Flaps2530:integer;
Flaps3040:integer;
ejeflap:integer;
//BOARDS EVENTs
procedure OnADCChange(sn:string;nadc:byte;value:integer);
begin
if nadc=ejeflap then begin
if (value<Flaps01) then WriteIOCP(1,OFFSET_FLAPLEVER_POS,0) else
if ((value>(Flaps01)) and (value<(Flaps12))) then WriteIOCP(1,OFFSET_FLAPLEVER_POS,2048) else
if ((value>(Flaps12)) and (value<(Flaps25))) then WriteIOCP(1,OFFSET_FLAPLEVER_POS,4096) else
if ((value>(Flaps25)) and (value<(Flaps510))) then WriteIOCP(1,OFFSET_FLAPLEVER_POS,6144) else
if ((value>(Flaps510)) and (value<(Flaps1015))) then WriteIOCP(1,OFFSET_FLAPLEVER_POS,8192) else
if ((value>(Flaps1015)) and (value<(Flaps1525))) then WriteIOCP(1,OFFSET_FLAPLEVER_POS,10240) else
if ((value>(Flaps1525)) and (value<(Flaps2530))) then WriteIOCP(1,OFFSET_FLAPLEVER_POS,12288) else
if ((value>(Flaps2530)) and (value<(Flaps3040))) then WriteIOCP(1,OFFSET_FLAPLEVER_POS,14336) else
if ((value>(Flaps3040))) then WriteIOCP(1,OFFSET_FLAPLEVER_POS,16384) end;
end;
//IOCP EVENTs
procedure OnIOCPConnect(socket:byte);
begin
RegIOCPOffset(1,OFFSET_FLAPLEVER_POS);SYNC;
end;
//MAIN
Begin
Main1:=readinifile('Throttle.ini','Main','Main1');
ejeflap:=readinifile('Throttle.ini','MainADCs','EjeFlap');
Flaps01:=readinifile('Throttle.ini','Flaps','Flaps01');
Flaps12:=readinifile('Throttle.ini','Flaps','Flaps12');
Flaps25:=readinifile('Throttle.ini','Flaps','Flaps25');
Flaps510:=readinifile('Throttle.ini','Flaps','Flaps510');
Flaps1015:=readinifile('Throttle.ini','Flaps','Flaps1015');
Flaps1525:=readinifile('Throttle.ini','Flaps','Flaps1525');
Flaps2530:=readinifile('Throttle.ini','Flaps','Flaps2530');
Flaps3040:=readinifile('Throttle.ini','Flaps','Flaps3040');
EnableADCChannel(Main1, ejeflap, 1, 30); //Flaps pot
End.