Академический Документы
Профессиональный Документы
Культура Документы
#$%&%"st 'ut that interface is a one way connection(. )hat I mean is that the Po*eys can send commands to xPlane +ut at the moment it is very difficult to send info from xPlane to the PoKeys card. In a nutshell ...the PoKeys is the ideal solution ,in my mind- for switches, +uttons, potentiometers, etc. (,rumor is that PoKeys is developing a plug-in for xPlane.o what if I want my home-made coc*pit to display /av# 0re1uency 2ow would I +uild an interface that shows when my landing gear is down 2ow would I +uild a 0laps indicator 2opefully I can explain in this +asic tutorial. 3n4oy, 5arc
Unlike the PoKeys card, the Teensy2 needs pro rammin . !on"t et scared, the #rduino lan ua e is not that difficult. The $oard is %&'( cheap and can $e purchased here: http://www.p)rc.com/teensy/ 'emem$er that * was ravin a$out the PoKeys +ustomer ,erviceThey even replied to me on a ,unday. /ell customer service on the Teensy card is P00' or non1e2istin . 3at least in my e2perience4 * received one defective card and send twice an email. *"ve $een waitin for 56 days since the last email and still no reply...
1. First Example:
Display Nav1 frequency on an LCD Display Flap Position on an LCD Display Elevator trim on a second LCD
+ontrary to popular $elief, you can hookup more than one 7+! to the Teensy.
Spaghetti
Pin 5D 3Aackli ht4 of the 7+! is normally connected to +D%olt. * connected a 9=6 0hm resistor in series 3226 0hm will work to4 This reduces the $ri htness $ut most importantly the current draw. Pin E 3+ontrast4 is connected via a 56K potentiometer. *f you do not see a readout F tweak the pot.
WARN N! F"R #AT "WNER$ #AT$ lo%e Teensy boards. The more &ires' the more fun they tend to ha%e &ith it.
Jinclude K7iCuid+rystal.hL // most devices $elon to a cate ory. *n order to access the 3code4 parameters for that device, the appropriate li$rary has to $e loaded. K7iCuid+rystal.hL is the li$rary for <!99=>6 compati$le 7+!"s 7iCuid+rystal lcd5352, 55, D, 9, E, 24M 7iCuid+rystal lcd2352, 56, D, 9, E, 24M //7i$raryBame Bame0f7+!3', pinJ, &na$le pinJ, !9 pinJ, !D pinJ, !: pinJ, != pinJ4 //Bote that $oth 7+!"s use the same pins e2cept for the &na$le pin. Gli ht,im*nte er BavGreCuency<NM //,end1an1*nte er1from12Plane 2Plane1parameter 3in this case the Bav5 GreCuency4 Gli ht,im*nte er GlapsM //,end1an1*nte er1from12Plane 2Plane1parameter 3in this case the Glaps Position4 Gli ht,imGloat Trim&lvM //,end1a1Gloat%alue1from12Plane 2Plane1parameter 3in this case the &levation Trim4 dou$le dBavM //!eclare a dou$le 3used for formattin the GreCuency4 int iTrimM //!eclare an *nte er 3used for formattin the Trim Position4 void setup34 O //&ach code 3called sketch4 has to have a setup BavGreCuency<N H ;plane'ef3Psim/cockpit2/radios/actuators/nav5QfreCuencyQhNP4M //!eclare the Bav5 GreCuency !ata'ef 2Plane !ata'ef"s can $e found:http://www.2sCuawk$o2.net/2psdk/docs/!ata'efs.html BavGreCuency<N.on+han e3updateQlcd4M // update the 7+! when ;1Plane chan es //on+han e tells the software to only update the 7+! when there is a chan e in freCuency. This is ood practice as we do not want to kill our frame1rate. Thus when there is a chan e in freCuency, the software will )ump to the IupdateQ7+!R su$routine Glaps H ;Plane'ef 3Psim/fli htmodel/controls/win 5lQfla5defP4M //!eclare the Plap GreCuency !ata'ef Glaps.on+han e3updateQlcd4M //on+han e tells the software to only update the 7+! when there is a chan e in flap position. This is ood practice as we do not want to kill our frame1rate. Thus when there is a chan e in flap position, the software will )ump to the IupdateQ7+!R su$routine Trim&lv H ;Plane'ef 3Psim/fli htmodel/controls/elvQtrimP4M //!eclare the &levator Trim !ata'ef lcd5.$e in35:, 24M //!eclare the Type of 7+! 3num$er1of1characters , num$er1of1te2t1lines4 lcd5.print3PB#%5P4M //!isplay IB#%5R on the top row of the first 7+! lcd5.set+ursor36,54M
//Sove the cursor on the first 7+! to the second line 3character1position, line1position4. The top line is 6 lcd5.print3PG7#P,P4M //!isplay IG7#P,R on the $ottom row of the first 7+! lcd2.$e in35:, 24M //!eclare the Type of 7+! for the second one 3num$er1of1characters , num$er1of1te2t1lines4 lcd2.print3PT'*SP4M //!isplay IT'*SR on the top row of the second 7+! T void loop34 O //start the loop Gli ht,im.update34M // Beeds to $e there to et 2Plane data lcd2.set+ursor3:, 64M /Sove the cursor on the second 7+! to the first line, :th position 3character1position, line1position4. iTrim H Trim&lv U 566M //Gormat the &levator Trim !ata send from 2Plane. The !ata is a Float and will look like per e2ample 16.66259D:E9 That would $e very difficult to read. ,o we multiply the !ata with 566. Bow the result is 12.59D:E9 #s we declared iTrim as an Integer in the $e innin of the code, the actual display will show 12 lcd2.print3iTrim4M //!isplay the &levator Trim !ata to the top row of the second 7+! lcd2.print3P P4M //!isplay some $lank characters 3to erase previous data4 T void updateQlcd3lon val4 O //,tart the updateQlcd su$routine dBav H BavGreCuency<N M //7oad the 2Plane Bav5 GreCuency in the Double, called dB#% //The 2Plane Bav5 GreCuency is an inte er and would display as per e2ample 55E>D lcd5.set+ursor3:, 64M /Sove the cursor on the first 7+! to the first line, :th position 3character1position, line1position4. lcd5.print3dBav /5664M //!isplay the Bav5 GreCuency $ut divide it $y 566. Thus the !isplay will read 55E.>D lcd5.set+ursor3:, 54M /Sove the cursor on the first 7+! to the second line, :th position 3character1position, line1position4. lcd5.print3Glaps4M //!isplay the Glaps Position lcd5.print3P P4M //!isplay some $lank characters 3to erase previous data4 T
void setup34 O BavGreCuency<N H ;Plane'ef3Psim/cockpit2/radios/actuators/nav5QfreCuencyQhNP4M BavGreCuency<N.on+han e3updateQlcd4M // update the 7+! when ;1Plane chan es Glaps H ;Plane'ef 3Psim/fli htmodel/controls/win 5lQfla5defP4M Glaps.on+han e3updateQlcd4M Trim&lv H ;Plane'ef 3Psim/fli htmodel/controls/elvQtrimP4M //Trim&lv.on+han e3updateQlcd4M lcd5.$e in35:, 24M lcd5.print3PB#%5P4M lcd5.set+ursor36,54M lcd5.print3PG7#P,P4M lcd2.$e in35:, 24M lcd2.print3PT'*SP4M T void loop34 O Gli ht,im.update34M lcd2.set+ursor3:, 64M iTrim H Trim&lv U 566M lcd2.print3iTrim4M lcd2.print3P P4M //lcd2.print35?E, A(T&4M T void updateQlcd3lon val4 O dBav H BavGreCuency<N M lcd5.set+ursor3:, 64M lcd5.print3dBav /5664M lcd5.set+ursor3:, 54M lcd5.print3Glaps4M lcd5.print3P P4M M T
3.3 C'((ECT + P'TE(T%',ETEint potentiometerPin H EM int pot%al H 6M void setup34O O void loop34T pot%al H analo 'ead3potentiometerPin4 ,erial.println3pot%al4M T
ith a P'TE(T%',ETE-
void loop34T pot%al H analo 'ead3potentiometerPin4 ,erial.println3pot%al4M analo /rite3ledPin, pot%al/94M //convert 6X562E to 6X2DD T
ith a P'TE(T%',ETE-
void setup34O myservo.attach3?4M O void loop34 O potPos H analo 'ead3potpin4M potPos H map3potPos, 6, 562E, 6 ,5>64M // scale value myservo.write3potPos4M delay35D4M T
(ou can test the Teensy followin the instructions $elow. http://www.p)rc.com/teensy/firstQuse.html Note: My Teensy did not ha e a !ush"button as !i#tured in their instru#tions$ I had to !ush a !a!er#li! in the tiny hole$ %&' you tested your Teensy$ I theory you #ould start !rogra((ing but the Teensy )oader is *inda bare"bones' not ery +le,ible and does not !ro(!t +or errors in the #ode$ So -e need so(e (ore so+t-are$'
20 !ownload the #rduino software here: http://arduino.cc/en/Sain/,oftware *nstall the #rduino you )ust downloaded 3and remem$er the path.4 Al(ost done but no- -e ha e to (a*e the Arduino so+t-are #o(!atible -ith the Teensy$ 30 !ownload Teensyduino here: htt!:..---$!/r#$#o(.teensy.td0do-nload$ht(l *nstall Teensyduino. 3it will ask for the #rduino path4 90 *n order to interface with ;plane, you need to install the Teensy Plu in. This Plu in is $rilliant and * did not see any si nificant frame1rate loss $y usin it. The Plu in can $e downloaded here: http://www.p)rc.com/teensy/Teensy+ontrolsQ5.6.Nip &2tract the 1i! and copy it to ;1Plane"s 'esources/plu ins folder. 80 'un #rduino. :0 *f the installation worked you should see (our Teensy $oard under Tools L Aoards ,elect your Teensy Aoard
<0 0pen the $link e2ample in Gile L &2amples L Teensy L U,AQGli ht,im L AlinkTransponder. =0 +lick PUploadP to pro ram your Teensy $oard. 140 'un ;1Plane. The 7&! should $link.
:. Future Tutorials.
* am still awaitin some parts 3from +hina4 The ne2t tutorial3s4 should include: Auildin an interface for analo ue au es usin the Teensy 3per e2ample Glap Position @au e4 Auildin an interface for !i ital +olour !isplays. There are Cuite a few cheap cell phone displays availa$le on the internet. The oal 3or dream4 is to raphically confi ure them so they will mimic the <,*, GS,, <U!, etc.