PDA

View Full Version : Transponder XPNDR



BuzziBi
04-07-2013, 06:37 AM
Hi there :D

I'm working on a new project. A Squawk kode transponder (XPNDR). I've been googling around a bit for ideas, and maby som of you have some.
The closest I came was a LUA script for FSUIPC.
Tuning the FSX radios with the numpad of your keyboard - Utilities - The AVSIM Community (http://forum.avsim.net/topic/335998-tuning-the-fsx-radios-with-the-numpad-of-your-keyboard/page__pid__1983771#entry1983771)
But then I thought: I've got GA panel installed on the computer running instruments.
This program have Keystroke for: Reset on all 4 digits, and Setting new code. (The LUA script actually did'nt have more functions than this for the xpndr. And you had to start/stopp the script form viewing it self on the FSX)
So the easyest thing might be useing keystrokes instead. Running the keystrokes from the instrument computer and the LCD from FSX on my main computer.

The FSX only provides me with these options, as I understand it:
XPNDR 1000_INC Increments first digit of transponder Shared Cockpit
XPNDR 100_INC Increments second digit of transponder Shared Cockpit
XPNDR 10_INC Increments third digit of transponder Shared Cockpit
XPNDR 1_INC Increments fourth digit of transponder Shared Cockpit
Do I need more?
There are quite a few more functions on the panel and I have made action button for them, but should I ignore the rest of the features?

I hav not tryed, but can I use a arduino on a second computer, using Fink2fs for programming the keys?
Will it still work, sending the keystrokes via Widefs on the network?

pictures of the build:

7699 7700 7698


Inputs vould be appreciated :)

JMeller
04-07-2013, 11:19 AM
Roy,
Very nice replication of AlliedSignal'sKT76C!!

I performed some research on the unit's functions and I see no reason you cannot have your panel emulate the real thing with all of the features I read (http://www.iaavionics.com/kt_76c.htm)it would do- button for button, knob for knob. Unless I am missing something, I see no reason why you couldn't run the LCD, buttons and rotary switch off of a single arduino connected to your main computer running FSX.

My guess is that when you press the button "5" the arduino will use the command xpdrLCD.setCharAt(2,'5') to set the changed xpdr code and will send the appropriate key command until the xpdr read from LinkFS reads the correct code ie., XPNDR 10_INC for "XX5X" until xpdrLCD==xpdrFSX? A different, but similar, approach will be needed for the VFR button("1200"), i.e., match "1XXX" before moving to the next digit for "12XX" if(xpdrFSX.charAt(0)=='1'){}else{XPNDR 1000_INC}

At any rate, that would be my approach. I'm not sure if I was of any help, but again - nice panel!
-James

BuzziBi
04-07-2013, 01:34 PM
Just a question to that JMeller. Doesn't one nead a keystroke to get FSX to change focus to the Transponder, before you can change the digits or change other settings?

JMeller
04-07-2013, 03:04 PM
The transponder (i.e. radio stack) doesn't need to have focus, however FSX must. This applies for all of the 'Keys' inputs.
That said, I believe Jim's Multi has strings for some default commands piped directly into SimConnect instead of emulating the keyboard. He will have to correct me if I'm mistaken.

Jim NZ
04-08-2013, 06:56 AM
Hi Roy ,, There's a couple of ways to look at this and I've seperated them out because what happens with my link2fs "keys" is quite different to what might happen with using your keyboard emulator.

With Link2fs "keys" ,,,
The keystroke will go to FSX weather it is in focus or not. i.e. you can be using (say) a flight planner and that is in focus but FSX is behind it in the screen ,, well the keystroke will still go to FSX.
All my programs need to be in the same computer as flight sim ,,, they don't work over widefs.
Controlling the transponder can only be done with incrementing a digit up or down ,, at the moment there is no direct input of the digit.
Incrementing the digits up or down is by using the codes in the list in the "keys" section ,, ie NTT1- and NTT1= etc etc


Now, using your keyboard emulator ,,,,
When the switch is "flicked" the keystroke will only go to the program that is in focus.
The one thing I don't know is if going thru a Lua/FSUIPC setup then will FSUIPC (if FSX is not in focus) catch it instead ,, I don't know ,,, try it and see ??

Yep ,, I agree with James (JMeller) you've made a great job of the radio unit Roy ,,, Nice.

Good luck in sorting things out ,,, Jim

BuzziBi
04-08-2013, 02:41 PM
Hey Jim.
Having done some thoroughly research today, in terms of how the transponder works in FSX.
(Maby I should done that first :D )
What I have found, is that you can not use other functions than setting the 4 digit code, you kan use the "CLR" to undo a digit input, and you can set the code 1200 when hitting the VFR button. The selector switch does'nt work in FSX, but I can program the arduino card to make it look like it works, viewing the selected mode on the LCD.
The IDT button is not working in the FSX and the ALT mode only shows the first 3 digits of the current altitude.
(I'm not sure, but I assume it calculates flight level in relation to QNH)
i.e. if the altitude is 12500 feet, the display will show 125 as a flight level. Inc. or dec. as the altitude changes.

Have been loocking at the Link2fs Multi today (Very good program by the way, I spesially liked the monitor! Good job guys!)
I am anxious how it will be programming the card to use buttons instead of rotary encoders to change the code.
I guess it all lies in the sketch.
Have some ideas that I will try when I finish soldering of the switches. I'll be back with info when I have tried me a bit.
That said, I have bought an Arduino Mega which I will try to program it all on. So I do not know if there is any difference in terms of programming the Uno cards. It will be exciting!
I also found an old laptops that I shall try the programming on. I got so much weird results on the laptop computer I use everyday, so I gave up using that one.

BuzziBi
04-15-2013, 12:13 PM
I think I've found a way to attack the problem.

Lot of failing but suddenly it loosend. :p
It was imposible to (for me! ) to make a sketch, to push buttons for printing 1, 2, 3, and so on with buttons, to set the code. This I blame FSX!
I gave up on LUA, this is Greek for me! And I'm to stupid to understand what JMeller tried to make me understand :D
I came across something interesting yesterday. I have flash'd the arduino card with new firmware, this way I can use it as a HID keyboard.
Interesting stuff here: Arduino USB HID Keyboard | MitchTech (http://mitchtech.net/arduino-usb-hid-keyboard/) ,
and her: Arduino - DFUProgramming8U2 (http://arduino.cc/en/Hacking/DFUProgramming8U2)
By using the arduino card on the computer running the instruments: GA Panel and GA Radio stack from Peix Software (http://www.peixsoft.com/) , I can now use inputs on the arduino, to send keystrokes, 0,1,2,3 and so on, to the radio stack. And IT WORKS :p
The Radio stack is now the link between FSX and Arduino, instead of Link2fs (sorry Jim)!
It was quite difficult to understand what drivers to be installed and when to load the sketch, the guids I found was a bit messy, but I succeeded at the end.
By figuring this out, I have opened new opportunities :cool:
Now it will be interesting to see what things you can combine in the Sketch.

No way I could find the right keyboard ID's on the internet but I managed to read it from the HID Usage Tables (http://www.usb.org/developers/devclass_docs/Hut1_11.pdf)
By using the ID's that I wanted from the HID Usage table (I have edited a list her on my homepage (http://samboere.com/upload/HID%20Usage%20Tables.htm)) i managed to make a working sketch.


/* Arduino USB Keyboard HID
* X,1,2,3,4,5,6,7 keys
*/

uint8_t buf[8] = {
0 }; /* Keyboard report buffer */

#define PIN_X 8 // Input X for calling the Radio Stack
#define PIN_0 9 // Input The zero digit to the 7 digit
#define PIN_1 10
#define PIN_2 11
#define PIN_3 12
#define PIN_4 13
#define PIN_5 14
#define PIN_6 15
#define PIN_7 16

int state = 1;

void setup()
{
Serial.begin(9600);
pinMode(PIN_X, INPUT);
pinMode(PIN_0, INPUT);
pinMode(PIN_1, INPUT);
pinMode(PIN_2, INPUT);
pinMode(PIN_3, INPUT);
pinMode(PIN_4, INPUT);
pinMode(PIN_5, INPUT);
pinMode(PIN_6, INPUT);
pinMode(PIN_7, INPUT);
// enable internal pull-ups
digitalWrite(PIN_X, 1);
digitalWrite(PIN_0, 1);
digitalWrite(PIN_1, 1);
digitalWrite(PIN_2, 1);
digitalWrite(PIN_3, 1);
digitalWrite(PIN_4, 1);
digitalWrite(PIN_5, 1);
digitalWrite(PIN_6, 1);
digitalWrite(PIN_7, 1);

delay(200);
}

void loop()
{
state = digitalRead(PIN_X);
if (state != 1) {
buf[2] = 27; // X key
Serial.write(buf, 8); // Send keypress
releaseKey();
delay (1000);
}

state = digitalRead(PIN_0);
if (state != 1) {
buf[2] = 39; // 0( Zero) key
Serial.write(buf, 8); // Send keypress
releaseKey();
delay (1000);
}

state = digitalRead(PIN_1);
if (state != 1) {
buf[2] = 30; // 1 key
Serial.write(buf, 8); // Send keypress
releaseKey();
delay (1000);
}

state = digitalRead(PIN_2);
if (state != 1) {
buf[2] = 31; // 2 key
Serial.write(buf, 8); // Send keypress
releaseKey();
delay (1000);
}

state = digitalRead(PIN_3);
if (state != 1) {
buf[2] = 32; // 3 key
Serial.write(buf, 8); // Send keypress
releaseKey();
delay (1000);
}

state = digitalRead(PIN_4);
if (state != 1) {
buf[2] = 33; // 4 key
Serial.write(buf, 8); // Send keypress
releaseKey();
delay (1000);
}

state = digitalRead(PIN_5);
if (state != 1) {
buf[2] = 34; // 5 key
Serial.write(buf, 8); // Send keypress
releaseKey();
delay (1000);
}

state = digitalRead(PIN_6);
if (state != 1) {
buf[2] = 35; // 6 key
Serial.write(buf, 8); // Send keypress
releaseKey();
delay (1000);
}

state = digitalRead(PIN_7);
if (state != 1) {
buf[2] = 36; // 7 key
Serial.write(buf, 8); // Send keypress
releaseKey();
delay (1000);
}
}

void releaseKey()
{
buf[0] = 0;
buf[2] = 0;
Serial.write(buf, 8); // Release key
}

BuzziBi
04-15-2013, 12:21 PM
The code shows up like this Serial.write(buf, :cool:; // Send keypress
It should be: Serial.write(buf, 8 ) ; // Send keypress without the spaces

BuzziBi
04-22-2013, 03:37 AM
The Mind Game Continues!

Ok, so I got a result! The problem would be, that I do not understand why!
I have determined: FSX has only 1, 10, 100 and 1,000 Inc / Dec.
With the use of external software (GA Radio Stack), I can enter the code (eg. VFR 1200) directly, using the: 1, 2, 0, and 0 keys.

I tried to log Simconnect traffic, but got so much data that I failed to understand the results.
If I use the logging feature in Fsuipc I can see what happens, when I enter the code in GA Radio Stack:

<this number="" are="" constant=""> <this number="" is="" constant="" except="" the="">
< on every input code > < code at the end (ie 1200) >
//EVENT: Cntrl= 65715 (0x000100b3), Param= 0 (0x00001200) XPNRD_SET;

(I tried to serialprint the //EVENT:......... through the arduino, but nothing happened! :cool: )

The result is not logged until all four digits are entered. Only then the code is sent to FSX and will be logged.

Does anyone have comments / suggestions on how this can be used to make anyting reasonable on the arduino card?

By the way, has anyone tried to control a 16x2 LCD with two different arduino cards?
I'm thinking: one can control eg "lcd.setCursor(0, 0);" with one card, and "lcd.setCursor(4, 0);" with the next card?
</this></this>