Cris Harrison
Published © CC BY-NC

NexGen Flight Simulator: Radio Interface

An Arduino-based radio interface for older radios including ARINC 410

IntermediateShowcase (no instructions)6,134
NexGen Flight Simulator: Radio Interface

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
C-3436A/ARN-30 Surplus Aircraft Radio Head
×1
Relay (generic)
This relay is Arduino ready
×1
Nylon Screws & Nuts 4-40
×1
Molex Right Angle Power Connector #15-24-4441
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Wire Wrap IC Socket -16 pin
×4
Wire Wrap Female DB-25
×2
SparkFun Snappable Protoboard
SparkFun Snappable Protoboard
×1

Software apps and online services

Arduino IDE
Arduino IDE
Python Scripting Language

Story

Read more

Schematics

C-3435A Wiring Spredsheet

Code

Python Test Script for C-3436 Radio Head

Python
This Test Script is run in a Linux Terminal Session. You must first find the USB port number "/dev/ttyACM0" with a program called lsusb.
import serial

ser = serial.Serial (
   port 	= '/dev/ttyACM0',
   baudrate 	= 115200,
   parity	= serial.PARITY_NONE,
   stopbits	= serial.STOPBITS_ONE,
   bytesize	= serial.EIGHTBITS,
   timeout	= 10
)

while True:
  print ( ser.readline())

ser.close ()

C-3436A.outline

Arduino
This is the code outline, I like to outline my code as its easier to understand later
radio outine
C-3436A.h
1. define pins arrays and inilize them. Fpin[] & Hpin[] and power and panel light
2. define what the pins will be.
   pinMode(F[n], PULLUP);
   pinMode(Plight, OUTPUT);
3. define data arrays frac[] & hund[] and power and panel light.
4. define alt data arrays frac[]0 & hund[]0 and power and panel light.
5. define and inialize the two look up arrays flu[]={} and hlu[]={}
6. define 4 test variables: ftest, htest, ftest0, htest0.

-----
void() {
void init()
}
-----
init.c
  void init()
does reads on the arrays F[] & H[] and variable Pwr 
and assigns them to frac0[], hund0[] and variable Pwr0
the values for ftest0, htest0 are calulated.
-----
FORMATS:

send_message() 
START BYTE  (0-7)   == FF
hund 4 bits (8-11)  == hlu(htest)
frac 4 bits (12-15) == flu(ftest)
switches: 
power (16) = pwr
unused (17-24)

recv_message()
START BYTE (0-7) == FF
COMMANDS (0-15):
1. Send Status Message
2. Set Plamp ON
3. Set Plamp OFF

-----
void loop()
   check for input: Serial.Read(ifavilable()){ decode(); }
   read all the fractions: frac[i] = Digital.Read(H[i]);
   read all the hundreds:  hund[i] = Digital.Read(H[i]);
   calulate the values:    ftest, Htest;
   if( ftest != ftest0 or htest != htest0 or pwr != pwr0 ) { 
       send message to RSS
       swap variables and arrays. frac0[] = frac[], hund0[] = hund[], pwr0 = pwr }
   else { do nothing };

C3436A.h

Arduino
This is my header file. It's used is to separate the variables from the code base.
/*
 * C-3436A.h
 *
 *  C. Harrison	Aug 21, 2014	Creation
 *
 */


// we need to list the digital input pins:

// Pin defs
// please note: arrays F[] & H[] are being indexed 1-5 
int F[]= { 0, 22, 23, 24, 25, 26 };
int H[]= { 0, 30, 31, 32, 33, 34 };

int powerpin = 20;
int dial_light = 40;
// now we need the variables & arrays

int frac[6];
int hund[6];
int frac0[6];
int hund0[6];
int pwr, pwr0;
int ftest, ftest0;
int htest, htest0;

C-3436A.ino

Arduino
This is the program I wrote to "test" the software. This software does not have my protocols for how the Arduino will talk and listen to the Radio Sub System in NexGenin place.
/*
 * C-3436A
 *
 *  C. Harrison	Aug 30, 2014	Creation
 *
 */

#include "C3436A.h"


void setup(){
  void modes();
  Serial.begin(19200);
  Serial.println("C-3436A awake");
  void init();
}


void loop(){
 int i;
 //  check for input: 
 while( Serial.available()) {
   char data = Serial.read();
   if( data == '!') {
     char cmd = Serial.read();
     char dat = Serial.read();
     char eol = Serial.read();
     if( cmd = 1 ) {
       // panel light}
       if( dat = 0 ) {
       digitalWrite( dial_light, LOW); }
       if( dat = 1 ) {
       digitalWrite( dial_light, HIGH); }
       }}
       
 
 //  read all the data
 for( i= 1; i <  6; i++ ) { 
   frac[i] = digitalRead( F[i]);   
   hund[i] = digitalRead( H[i]); }
   pwr     = digitalRead( powerpin );
 //  calulate the values:    ftest, Htest;
 int ftest, htest, ftest0, htest0, pwr, pwr0;
 
 ftest = decode_F(calc_F());
 htest = decode_H(calc_H());
 
 if( ftest != ftest0 or htest != htest0 or pwr != pwr0 ) {
   //send message to RSS
   swap();  }
 else { 
      ; }  // Do Nothing
}}

int decode_H( int data ){
  int code[][2] = {{13,0},{9,108},{11,109},{5,110},
               {27,111},{16,112},{30,113},{2,114},
               {23,115},{8,116},{28,117},{1,118},
               {7,119},{4,120},{24,121},{20,122},
               {6,123},{18,124},{17,125},{10,126}};
               
   for( int i= 0; i < 22; i++ ) {
      if( data == code[i][0]) {
        return code[i][1]; }
}}

int decode_F( int data ){
  int code[] = {20, 5, 8, 2, 16, 4, 1, 9, 10, 18 };
  
  for( int i= 0; i < 10; i++ ) {
      if( data == code[i]) {
        return i; }
}}

int calc_F(){
  int temp = ( F[22] + (F[21]*2) + (F[20]*4) + (F[8]*8) + (F[7]*16));
  return( temp );
}

int calc_H(){
  int temp = ( H[19] + (H[18]*2) + (H[17]*4) + (H[5]*8) + (H[4]*16));
  return( temp );
}

void swap(){
  for( int i = 1; i < 6; i++ ) {
    frac0[i] = frac[i];
    hund0[i] = hund[i]; }
    ftest0   = ftest;
    htest0   = htest;
    pwr0     = pwr;
}

void modes(){

pinMode( F[1], INPUT_PULLUP);
pinMode( F[2], INPUT_PULLUP);
pinMode( F[3], INPUT_PULLUP);
pinMode( F[4], INPUT_PULLUP);
pinMode( F[5], INPUT_PULLUP);

// hundreds array
pinMode(H[1], INPUT_PULLUP);
pinMode(H[2], INPUT_PULLUP);
pinMode(H[3], INPUT_PULLUP);
pinMode(H[4], INPUT_PULLUP);
pinMode(H[5], INPUT_PULLUP);

// Now we have to assign the power switch pin

pinMode( powerpin, INPUT_PULLUP);

// Now we have to assign  the digital output pins

pinMode(dial_light, OUTPUT);

}

// we need to read the first time so while in loop the test will not fail.
// read all the pins and put then in arrays
void init(){
	int i;

for( i=1; i< 7; i++){
    frac0[i] = digitalRead(F[i]);
    hund0[i] = digitalRead(H[i]); }
    ftest0   = decode_F(calc_F());
    htest0   = decode_H(calc_H());
    pwr      = digitalRead(powerpin); }

Credits

Cris Harrison

Cris Harrison

1 project • 3 followers

Comments