Altitude Encoder Converter - Serial to Parallel Gray Code

mrburnette

Senior Member
I have a friend whose project for the past 15 years has been to build his own airplane. In his case, this is an Europa. The project in the past couple of years has taken shape to be recognizable as an airplane and on a recent visit, the Rotax engine was mounted. Now there is a need to interface a Dynon with the transponder.

My friend tried to build the ATmega based serial to parallel-Gray code converter here: http://www.mail2600.com/EncoderConverter/EncoderConverter.html but the world has changed a lots since the article was published in 2004 and the author was unable to find his notes on the project- especially the fuses and bootloader specifics. The project was built and programmed, but it did not work. So, I was asked to convert the ATmega to a PICAXE design.

Below is the prototype code I have written. I runs in the simulator and performs as expected. It has not been tested outside the simulator and even then it has not been fully tested. There will be required changes, I feel certain, to the serial input routine and perhaps some performance improvements, etc.

UPDATE 20120402- Runs on real hardware and decodes in lab. Dynon tests maybe this weekend. Now 08M2 @9600 BAUD is simulating Dynon and just looping through altitude table,

The Dynon EMS-D10 outputs a serial data stream at 9600 BAUD for connecting a transponder (new transponders accept serial, but old ones are generally parallel-input, active LOW. The format is "ALT" (space) and a 5 digit blocked number or a (minus sign) plus a 4 digit blocked number. Lines are carriage return ended. Examples:
ALT 12000
ALT -0010

Gray code can be managed on an "X" PICAXE with the instruction set, but the original article used a lookup table: I saw no reason to get into nasty bit-shifting. This PICAXE BASIC code is written for the 18M2 chip and I used the TABLE for storing the read-only information. My thinking is that the EEPROM may be useful to configure the final program... such things as Inverted/non-Inverted parallel Gray code, serial console echo on/off, and maybe input polarity as well as output polarity and BAUD. Right now, the program is dumb but is being posted only to demonstrate brute-force table lookup and the concept of split/concatenated tables; that is, the positive data is in the table and the negative data is also in the table but two separate routines manage the lookups.

I cannot answer aviation questions. I can respond to the concept in this code and my brute-force implementation. The code is not elegant... just something written for a friend who is an aspiring PICAXE programmer who needed a little push to get him off the ground (no pun.) :D

- Ray



View attachment 10921

View attachment 10919
 
Top