Home
AN_260 IR Remote Control Implementation by Java D2XX
Contents
1. Terms Description IR Infrared LED Light Emitting Diodes OTG USB On The Go USB Universal Serial Bus 23 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited 7 Application Note q FTDI AN_260 IR Remote Control Implementation by Java D2XX A e Version 1 0 AN Chip Document Reference No FT_000901 Clearance No FTDI 370 Appendix B List of Tables amp Figures 8 3 List of Figures Figure 2 1 NEC IR Protocol ror et a eaa c dax Pied esau da du AER a ou rad ceed acd aa pP dT 3 Fig re 2 2 NEG IR Modul a rrr tire aes dante tke tX shades ern Dee ac IER M USA BU ceed CBE LR CU tua RR ERR 3 Figure 2 3 INEG IR CaM E uiii exe boredexe a i E a EE aiiiusiajn ae niic mura es MURUS RR UC ETE 3 Figur 2 4 Philips RG 5 IR Protocol iriiri cadidate sata ex E idelgemetaiteateneie Sua a REM ea E a RE daa 4 Figure 2 5 Philips RC 5 IR Modula sss eee mese ese sese senes 4 Figure 2 6 Philips RC 5 IR Carrier 2 recie sana Rire Rn Pd RR Re ie EE NK RR nd ARRA a RM RA RR 4 Figure 4 1 Typical USB to IR block diagram ssssssssssssee memes senes nnn nnns 6 Figure 4 2 A minimum USB to IR block diagram sssssssseeee mmn nnns 6 Figure 4 3 Schematic of IR LED module e eeieeseeee nennen kenn ununi dan hen RAN RA BA AERA E 6 Fig re 5 1 Java D2XX code OVerVieW ocesees es iiu ee teste sa dd ened ka ce Rak a ceda baa ck Rida da E Rx Ma De
2. To have 8 8us baud rate in my case 9600 x 16 153600 1 153600 6 5us So 8 8us 1 113636 36 100 us 1 625 16 if ftDevice setBaudRate 8000 128Khz if IftDevice setBaudRate 625 LLiOKkHz 16 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited Ea Application Note d FTDI AN_260 IR Remote Control Implementation by Java D2XX Chi Version 1 0 AN I Document Reference No FT 000901 Clearance No FTDI 370 LogInfo Set bit rate failed J ERR RR RRR KKK KK KKK if lftDevice setLatencyTimer byte 2 Set Latency time to 2ms LogInfo Set latency time failed f FERE ROR cR OR ee eek Reset if ftDevice setBitMode byte OxFE D2xxManager FT BITMODE RESET LogInfo Reset failed Sync Write also read back configure our port Set to SYNC BIT MODE if ftDevice setBitMode byte OxFE D2xxManager FT BITMODE SYNC BITBANG bit input bit 1 7 output LogInfo Set to SYNC bitbang failed else LogInfo SYNC bitbang going compareThread new CompareThread compareThread start return true return false class CompareThread extends Thread public void run int i ftDevice write DataOutBuffer 256 Sync write 256 bytes for i 0 i1 5000 i ftDevice write DataOutBuffer 256 Sync another 256 bytes ftDevice read DataInBuffer 256 Sync read 256 bytes ftDevic
3. FE Granhical I aunt activity main vml Figure 5 1 Java D2XX code overview buon Pes Figure 5 2 Java D2XX code Running Result 5 1 MainActivity java package com example nec ir xchips import android os Bundle import android app Activity import android content pm ActivityInfo import android text method ScrollingMovementMethod import android view Menu import android view View import android widget TextView public class MainActivity extends Activity private SetAsyncBitBang MyAsyncBitBang null public byte NECIRAddress new byte 8 public byte NECIRCommand new byte 8 Override public void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout activity main setRequestedOrientation ActivityInfo SCREEN ORIENTATION PORTRAIT TextView MyMessage TextView findViewById R id RecvData SFY Ff POA ello emet etbod Coorollingdovenepntletibod ge LLLA Ce QOL 7 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited Ea Application Note FTDI AN_260 IR Remote Control Implementation by Java D2XX A Chi Version 1 0 AN I Document Reference No FT 000901 Clearance No FTDI 370 IRSetBitMode j Override public boolean onCreateOptionsMenu Menu menu getMenuInflater inflate R menu activity main menu return true public void CleanTextView View view TextView GetMyDat
4. OR RR K K K K K K K K K K K K K Configure Baud rate Reference AN232BM 01 to set the baud rate To have 8 8us baud rate in my case 9600 x 16 153600 1 153600 6 5us So 8 8us 1 113636 36 100 us 1 625 16 if ftDevice setBaudRate 80e 128Khz if ftDevice setBaudRate 625 1 kHz LogInfo Set bit rate failed PERE ERERERER ER ERS if lftDevice setLatencyTimer byte 2 Set Latency time to 2ms LogInfo Set latency time failed f 55e oe o EERE E Reset if ftDevice setBitMode byte OxFE D2xxManager FT_BITMODE_RESET LogInfo Reset failed Sync Write also read back configure our port Set to SYNC BIT MODE if ftDevice setBitMode byte OxFE D2xxManager FT BITMODE SYNC BITBANG bit input bit 1 7 output LogInfo Set to SYNC bitbang failed else LogInfo SYNC bitbang going compareThread new CompareThread compareThread start return true return false class CompareThread extends Thread public void run int i ftDevice write DataOutBuffer 256 Sync write 256 bytes 15 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited a7 Application Note FTDI AN_260 IR Remote Control Implementation by Java D2XX m e Version 1 0 ON Chip Document Reference No FT 000901 Clearance No FTDI 370 for i 0 1 lt 5000 i ftDevice write DataOutBuffer 256 S
5. 0 Initial Release 2014 02 17 25 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited
6. Figure 7 4 27 6usec for Philips RC 5 RC 6 carrier Generated by MyAsyncBitBang cpp 19 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited 7 File Edit Vertical Horiz cq Trig Display Cursors Measure Masks Math MyScope Utilities 7 FTDI Chip Document Reference No FT_000901 Curs1 Pos Curs2 Pos Application Note AN_260 IR Remote Control Implementation by Java D2XX Version 1 0 Clearance No FTDI 370 Figure 7 5 9 2usec duty cycle for Philips RC 5 RC 6 carrier Generated by MyAsyncBitBang cpp DI FT Brog 5 Flash ROM File Devices Help d hi PF o Device Tree Property Value Device 0 Loc ID 0x112 co BitBeng_WR Ej FT EEPROM Ci BitBang_RD 5j Chip Details C2 Tristate Em H USB Device Descriptor c3 Tristate USB Config Descriptor USB String Descriptors Hardware Specific USB Suspend VBus RS485 Echo Suppress Property H Porta CBUS Signals gt Battery Charge Detect gt Invert RS232 Signals Depending on the package type the device has up to 6 PEWS ries independently configurable CBus pins Not all CBUS pins gt CO are available on every package type please check with the gt C1 device s corresponding data sheet gt C2 gt C3 4j IO Pins Device Outout Read EEPROM Device 0 Word 0000 8000 0304 1560 0010 00 Cz12 0000 0000 0010 0000 0000 0000 0000 0018 0
7. Implementation by Java D2XX Chi Version 1 0 AN I Document Reference No FT 000901 Clearance No FTDI 370 DataOutBuffer AddIdx AddOffset NECIROne i AddOffset End of NEC IR Address CmdOffset 0 NEC IR Command for j 0 j 8 j 8 bit of NECIRAddress put Address if nECIRCommand j 0 nECIRAddress j 0 for i 0 i NECIRZeroLen 3 i DataOutBuffer CmdIdx CmdOffset NECIRZero i CmdOffset else for i 0 i NECIROnelen 3 i DataOutBuffer CmdIdx4CmdOffset NECIROne i CmdOffset NEC IR Command Bar for j 0 j 8 j 8 bit of NECIRAddress put Address Bar if nECIRCommand j 0 nECIRAddress j 0 Address Bar for i 0 i NECIRZeroLen 3 i DataOutBuffer CmdIdx4CmdOffset NECIRZero i CmdOffset else for i 0 i NECIROnelen 3 i DataOutBuffer CmdIdx4CmdOffset NECIROne i CmdOffset End of NEC IR Command eek NEC IR Stop bit KKK OK OR KOK for i 0 i 3 NECIRStopLen i DataOutBuffer StopIdx i NECIRStopBit i for i20 i 1 i ftDevice write DataOutBuffer 7692 ftDevice close return true return false 12 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited EN Pm p mme FTDI Chip Application Note AN 260 IR Remote Control Implementation by Java D2XX Version 1 0 Docume
8. Philips RC 5 IR Protocol iet oret decoro texas non eode aepo De utoc dre aa ax Roe Deere ORe 3 2 3 Philips RC 6 IR PEOtOCOI iet ett EE vw ne USE XE ce eee e Ee E TaS 4 3 Hardware Requirement issiimti nennen nnns snis Eni ea skia EEEE sess ense tia assa ases ai TEn 5 3 1 Async BitBang Mode of FTDI DeViC S ccccssccccecessesesneaeeeeecesseseaaeaeeeeecesseseaaeseeeeseessnssaaeens 5 3 2 Sync BitBang Mode of FTDI DeVICES c cccccccecsssssssececececesseusaececececeeseaeaeseeeessseseaeaeeeeeess 5 4 Examiple GIF CUIE neser EEE ebaeeanateanatesepastenetebans dn by E redox ile E 6 4 1 Typical UART to IR block diagram ccccccccccecsssessssececececessesseaeseeeceseesesaeceeeesseeseesaeeeeeeesesees 6 4 2 A minimum hardware cost IR block diagram eene 6 4 3 SchetidtiCso tertio pt eet erm etur eet 6 5 Example Program Writing aite tote teta tlie a itane da oae a ka ru dedegs e Dodae irte inu kae 7 5 1 NET e nA 7 5 2 SetAsyncBitBang aV d iie deeds a desde Ux sees Dee yate duly eet o eua dee di ua das 8 6 Example application reading cccccccssceessssececsesseceesessececsessececsesaececeeaaeeecseaaeeeesesaeeecsesaeeeeeeaaes 13 6 1 Sample application to drive the IR reader ccccccsscssssscecececessesssaeceeececsssessaeeeeeessessesseaees 13 6 2 JAVA D2xx Sync BitBang Reader App ccccccecsesseceeeeecsssesseaeeeceescesseseaeeeceessesseauaeeeesessesees 14 7 Testing Resul
9. RR aaa 7 Figure 5 2 Java D2XX code Running Result sssssssssssssseseseeses eee meses senes nn nnns 7 Figure 6 1 IR Reader Test SetUp iere at tertk lx hn neun ERR RE RR Ene ngu de ERERKQU ARRA RARE EA ERE BRA RU MA 13 Figure 7 1 Measure the IR LED to GND ness nnn nhanh n ERR ERA AREA NANE A iaaiiai 18 Figure 7 2 Measure FT234XD TXD pin to GND ce Henne emen nnn nnn 18 Fig re 7 3 Measure the IR receiver oi ctccctictesiee itae teresa RR Ra ka CE VAR IR E ERR TEXTE RXRE DRIN oa YE MER WAT NER 19 Figure 7 4 27 6usec for Philips RC 5 RC 6 carrier Generated by MyAsyncBitBang cpp 19 Figure 7 5 9 2usec duty cycle for Philips RC 5 RC 6 carrier Generated by MyAsyncBitBang cpp 20 Figure 7 6 Set BitBang_WR on CO and BitBang_RD on C1 for a FT X chip ssssssssss 20 Figure 7 7 Generate 100 us wavefrom on C1 BitBang RD Z ssssssssessee nenne 21 24 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited 7 Application Note FTDI AN 260 IR Remote Control Implementation by Java D2XX Chip Version 1 0 Document Reference No FT_000901 Clearance No FTDI 370 s Appendix C Revision History Document Title AN 260 IR Remote Control Implementation by Java D2XX Document Reference No FT 000901 Clearance No FIDI 370 Product Page http www ftdichip com FTProducts htm Document Feedback Send Feedback Revision Changes Date 1
10. ftDevice null return false Product Page Document Feedback Kok K K ok K K OK 2K K oe K OK OK K OK configure our port Set to ASYNC BIT MODE if ftDevice setBitMode byte OxFF D2xxManager FT BITMODE ASYNC BITBANG LogInfo Set to ASYNC bitbang failed fi OR K K K K K K K K K K K K K K K Configure Baud rate Reference AN232BM 01 to set the baud rate To have 8 8us baud rate in my case 9600 x 16 153600 1 153600 6 5us So 1 113636 36 8 8us 113636 36 16 7102 27 if lftDevice setBaudRate 7102 LogInfo Set bit rate failed 8 8us J ERR RRR EK KKK KKK x Header ORK KK OK KOK for i 0 i lt NECIRHeaderLen i NECIRLeaderCode 3 i byte OxFF NECIRLeaderCode 3 i 1 byte xe NECIRLeaderCode 3 i 2 byte exe x x Space KK K K K K K K K K K OK K K K for i 0 i lt NECIRSpaceLen i F RRNECIROne d eeeex for i 0 1 lt 21 i NECIRSpace 3 i NECIRSpace 3 i 1 NECIRSpace 3 i 2 0 NECIROne 3 i byte exFF NECIROne 3 i 1 byte exe NECIROne 3 i 2 byte exe 10 Copyright 2014 Future Technology Devices International Limited zS Application Note FTDI AN_260 IR Remote Control Implementation by Java D2XX m e Version 1 0 ON Chip Document Reference No FT 000901 Clearance No FTDI 370 for i 22 i lt NECIROneLen i F NECIRZero ereee e for i 0 i lt 21 i NEC
11. 000 0000 0000 0000 0020 0000 0000 0000 0000 0 0028 0000 0030 00 0038 000 0040 S4FE SDAO 5000 0000 0048 oa S659 3951 4842 0000 0050 0 4400 4900 2403 4600 pose 2000 4200 6100 Ready Figure 7 6 Set BitBang WR on CO and BitBang_RD on Ci for a FT X chip Product Page Document Feedback 20 Copyright 2014 Future Technology Devices International Limited F Application Note FTDI AN_260 IR Remote Control Implementation by Java D2XX Chip Version 1 0 Document Reference No FT_000901 Clearance No FTDI 370 File Edit Vertical Horiz Acq Trig Display Cursors Measure Masks Math MyScope Utilities Help Upper Limit 1 0s Lower Limit 150 0ps Figure 7 7 Generate 100 us wavefrom on C1 BitBang_RD 21 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited 7289 FTDI 8 Contact Information Head Office Glasgow UK Future Technology Devices International Limited Unit 1 2 Seaward Place Centurion Business Park Glasgow G41 1HH United Kingdom Tel 44 0 141 429 2777 Fax 44 0 141 429 2758 E mail Sales E mail Support E mail General Enquiries sales1 Qftdichip com supporti Qftdichip com admini ftdichip com Branch Office Taipei Taiwan Future Technology Devices International Limited Taiwan 2F No 516 Sec 1 NeiHu Road Taipei 114 Taiwan R O C Tel 886 0 2 8797 1330 Fax 886 0 2 8751 9737 E ma
12. IROne 3 i NECIROne 3 i 1 NECIROne 3 i 2 0 NECIRZero 3 i byte OxFF NECIRZero 3 i 1 byte exe NECIRZero 3 i 2 byte exe for i 22 i NECIRZeroLen i NECIRZero 3 i NECIRZero 3 i 1 NECIRZero 3 i 2 0 NECIR Stop bit x x for i 0 i lt 21 i NECIRStopBit 3 i byte OxFF NECIRStopBit 3 i 1 byte xe NECIRStopBit 3 i 2 byte xe fill up the IR Leader Code for i 0 i lt 3 NECIRHeaderLen i fill up the NEC IR Space for i 0 i 3 NECIRSpaceLlen i c DataOutBuffer i NECIRLeaderCode i DataOutBuffer 3 NECIRHeaderLen i NECIRSpace i NEC IR Address for j 0 j 8 j 8 bit of NECIRAddress put Address if nECIRAddress j 0 nECIRAddress j 0 for i 0 i NECIRZeroLen 3 i DataOutBuffer AddIdx AddOffset NECIRZero i AddOffset else for i 0 i NECIROnelen 3 i DataOutBuffer AddIdx Add0ffset NECIROne i AddOffset NEC IR Address Bar for j20 j 8 j 8 bit of NECIRAddress put Address Bar if nECIRAddress j 0 nECIRAddress j 0 Address Bar for i 0 i NECIRZeroLen 3 i DataOutBuffer AddIdx AddOffset NECIRZero i AddOffset else for i 0 i NECIROnelen 3 i 11 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited 7 d Application Note FTDI AN_260 IR Remote Control
13. a TextView findViewById R id RecvData GetMyData setText NECIRAddress 0 0 NECIRAddress 1 0 NECIRAddress 2 0 NECIRAddress 3 0 NECIRAddress 4 0 NECIRAddress 5 0 NECIRAddress 6 0 NECIRAddress 7 0 NECIRCommand 1 NECIRCommand 1 1 NECIRCommand 2 0 NECIRCommand 3 1 NECIRCommand 4 1 NECIRCommand 5 NECIRCommand 6 1 NECIRCommand 7 0 MyAsyncBitBang Gen38KHzIR NECIRAddress NECIRCommand public void onMsgShow final String recvdata runOnUiThread new Runnable public void run TextView showstr TextView findViewById R id RecvData showstr append recvdata IDE private void IRSetBitMode MyAsyncBitBang new SetAsyncBitBang this 5 2 SetAsyncBitBang java package com example nec ir xchips import android app Activity import android content IntentFilter import android hardware usb UsbManager import com ftdi j2xx D2xxManager import com ftdi j2xx FT Device public class SetAsyncBitBang private Activity mContext private D2xxManager ftD2xx private FT Device ftDevice null null 8 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited iN PA py Se Chip 7A Application Note FTDI AN_260 IR Remote Control Implementation by Java D2XX Version 1 0 Document Reference No FT_000901 Clearance No FTDI 370 private byte DataOutBuffer new byte 7692 public static f
14. aken care to assure it is accurate this information is subject to customer confirmation and FTDI disclaims all liability for system designs and for any applications assistance provided by FTDI Use of FTDI devices in life support and or safety applications is entirely at the user s risk and the user agrees to defend indemnify and hold harmless FTDI from any and all damages claims suits or expense resulting from such use This document is subject to change without notice No freedom to use patents or other intellectual property rights is implied by the publication of this document Neither the whole nor any part of the information contained in or the product described in this document may be adapted or reproduced in any material or electronic form without the prior written consent of the copyright holder Future Technology Devices International Ltd Unit 1 2 Seaward Place Centurion Business Park Glasgow G41 1HH United Kingdom Scotland Registered Company Number SC136640 Product Page Document Feedback 22 Copyright 2014 Future Technology Devices International Limited FFA Application Note FTDI AN_260 IR Remote Control Implementation by Java D2XX Chip Version 1 0 Document Reference No FT_000901 Clearance No FTDI 370 pud Appendix A References 8 1 Document References AN 232R 01 for the FT232R and FT245R Bit Bang Modes AN 233 Java D2xx for Android API User Manual 8 2 Acronyms and Abbreviations
15. andle Oxff 0x01 Enable Async Bitbang mode BaudRate ftHandle BAUDRATE printf fail on initialize Async Bit bang mode Mn return fal se printf Async Bitbang mode initial successful Mn Product Page Document Feedback 13 Copyright 2014 Future Technology Devices International Limited T Application Note d FTDI AN_260 IR Remote Control Implementation by Java D2XX A Chi Version 1 0 AN I Document Reference No FT 000901 Clearance No FTDI 370 return true int _tmain int argc TCHAR argv iit 1543 FT HANDLE ftdiHandle ftStatus FT Open O amp ftdiHandle if Bitbang Initial ftdiHandle TRUE for j 0 j lt 6000 j Out 27 6 usec with 9 2usec duty cycle DataOutBuffer 3 j Oxff out 9 2usec high DataOutBuffer 3 j41 0x00 output 27 6 9 2 usec low DataOutBuffer 3 j 2 0x00 output 27 6 9 2 usec low for j 0 j 1000 j ftStatus FT Write ftdiHandle DataOutBuffer 18000 amp dwNumBytesSent printf Exit the loop now n FT Close ftdiHandle printf Closed the file handle M getch return 0 6 2 JAVA D2xx Sync BitBang Reader App An example to read IR signals continually on bit O of FT X chip Again MainActivity java is the main application while syncbitbang java controls the bitbang interface for reading the data MainActivity java package com example syncbitbang4ir import com ftdi j2xx D2xxManager import
16. com ftdi j2xx FT Device import android app Activity import android content IntentFilter import android hardware usb UsbManager public class SyncBitBang CompareThread compareThread private Activity mContext private D2xxManager ftD2xx null private FT Device ftDevice null public static final int TwoK 2 1024 private byte DataOutBuffer new byte TwoK private byte DataInBuffer new byte TwoK get data to this buffer public SyncBitBang Activity activity 14 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited T Application Note FTDI AN 260 IR Remote Control Implementation by Java D2XX 1 H Version 1 0 AN Chip Document Reference No FT 000901 Clearance No FTDI 370 mContext activity try ftD2xx D2xxManager getInstance mContext catch D2xxManager D2xxException ex IntentFilter filter new IntentFilter filter addAction UsbManager ACTION USB DEVICE DETACHED LogInfo ex getMessage public void LogInfo String val MainActivity mContext onMsgShow val n public boolean Gen128KHzIR int devCount ftD2xx createDeviceInfoList mContext LogInfo Inside of Gen128KHzIR function if devCount gt D2xxManager FtDeviceInfoListNode deviceList new D2xxManager FtDeviceInfoListNode devCount ftD2xx getDeviceInfolist devCount deviceList send data and loop back
17. ding in this application Set the baud rate to 625 The sample reate will be 1 625 16 100us The program will read IR signals every 100 us It is fast enough to sample NEC IR signals since stop bit is 560us Logic 0 is 1 12ms and Logic 1 is 2 25ms 5 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited a Application Note d FTDI AN_260 IR Remote Control Implementation by Java D2XX Chi Version 1 0 AN I Document Reference No FT 000901 Clearance No FTDI 370 4 Example Circuit 4 1 Typical UART to IR block diagram An Android FTDI TXD PAD m een USB to UART chip SITE connector DAE FT234XD NEC IR OutputEnoder Google Nexus 7 Encondar Figure 4 1 Typical USB to IR block diagram A typical IR design will take UART information from an MCU USB UART bridge in this diagram and buffer this data through a dedicated IR transmitter 4 2 A minimum hardware cost IR block diagram Ui I USB OTG Connecto An Android FTDI system with an OTG USB USB to UART chip IR LED COnNECLOT FT234XD or Module Google Nexus 7 other FT X chips Figure 4 2 A minimum USB to IR block diagram Using an FTDI chip in bitbang mode whereby a data stream is bit banged out on a pin to the IR module removes the dedicated IR encoder Encoding is done on the host tablet and bit banged on the FT234XD 4 3 Schematic Figure 4 3 Schematic of IR LED modul
18. e 6 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited 7 Application Note d FTDI AN_260 IR Remote Control Implementation by Java D2XX A Chi Version 1 0 ON I Document Reference No FT 000901 Clearance No FTDI 370 5 Example Program writing MainActivity java is the main program and SetAsyncBitBang java does the mode setting to async bitbang mode The button1 click event will call CleanTextView function Package Explorer 3 C B MainAct Rel J SetAsyncBitBang java IG activity main xml 23 m out xmins androide http schenas android con apk res android a http schemas android com tools roid layout widthe match parent oid layout heighte match parent gt gei 4 jS com example nec ir xchips MainActivity BA Android 4 1 2 BA Android Dependencies 4 8 src 4 i com example neciirxchips JJ MainActivity java D SetAsyncBitBang java 9 gen Generated Java File ide geid RecvData ch andri android layout android layout amp assets android layout marginTops 51dp amp bin android texte TextView gt a amp libs 4 go res drawable hdpi drawable Idpi drawable mdpi drawable xhdpi 4 9 layout lici activity mainxml a android texte Button gt mew values values v11 values v14 d AndroidManifest xml iB ic launcher web png E proguard project xt B project properties K RelativeLayout gt
19. e close 17 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited Application Note FTDI AN 260 IR Remote Control Implementation by Java D2XX y Chip Version 1 0 Document Reference No FT_000901 Clearance No FTDI 370 7 Testing Results File Edit Vertical Horiz Acq Trig Display Cursors Measure Masks Math MyScope Utilities Help Stopped ES Figure 7 1 Measure the IR LED to GND Address 0000_0000 LSB to MSB Address Bar 1111_1111 LSB to MSB Command 1101_1010 LSB to MSB Command Bar 0010_0101 LSB to MSB File Edit Vertical Horiz Acq Trig Display Cursors Measure Masks Math MyScope Utilities Help Tek Stopped Single Seq 6 Sep 13 Buttons Curs1 Pos 0 0s Curs2 Pos B E Ch1 1 04 Figure 7 2 Measure FT234XD TXD pin to GND 18 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited Application Note FTDI AN 260 IR Remote Control Implementation by Java D2XX y Chi Version 1 0 7 Chip Document Reference No FT 000901 Clearance No FTDI 370 Eile Edit Vertical Horiz cq Trig Display Cursors Measure Masks Math MyScope Utilities Help Stopped Single Curs1 Pos 8 2ms Curs2 Pos chi 1 0 Figure 7 3 Measure the IR receiver File Edit Vertical Horiz cq Trig Display Cursors Measure Masks Math MyScope Utilities Help Curs1 Pos 0 0s Curs2 Pos T i i i f E Ch1 1 04
20. ement The following hardware is required to test the IR transmitter on an Android platform An Android system with an OTG USB connector Google Nexus 7 in this application note An FTDI UMFT234XD module A NPN transistor BC817 in this application note An IR LED 1KQ and 10009 resistors 3 1 Async BitBang Mode of FTDI Devices Async BitBang Mode is able to set each pin independently as an input or an output The data rate is controlled by the baud rate generator New data is written when the baud rate clock ticks If no new data is written to the device the pins will hold the last written value This application uses only the TXD pin to generate IR LED signal eg 4 bytes of data are needed to send a data stream 0101 The clock for the BitBang mode is actually 16 times the baudrate A value of 9600 baud would transfer the data at 9600 x 16 153600 bytes per second or once every 6 5 uS Set the baud rate to 7102 to have 8 8 usec duty on cycle in this application note 3 2 Sync BitBang Mode of FTDI Devices Synchronous Bit Bang mode data will only be sent out if there is space in the device for data to be read from the pins This Synchronous Bit Bang mode will read the data bus pins first before it sends out the byte that has just been transmitted It is therefore 1 byte behind the output and so to read the inputs for the byte that you have just sent another byte must be sent AN 232R 01 Sync Bit Bang mode is used for IR signals rea
21. equency 38 kHz nd 26 4us In this application note Figure 2 3 NEC IR Carrier 2 2 Philips RC 5 IR Protocol Philips RC 5 IR features are listed below e 5 bit address and 6 bit command All bits have an equal length of 1 778ms Bi phase modulation also called Manchester coding Carrier frequency is 36KHz The duty cycle of carrier frequency is 25 to 33 3 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited 7 Application Note d FTDI AN_260 IR Remote Control Implementation by Java D2XX A Chi Version 1 0 ON I Document Reference No FT 000901 Clearance No FTDI 370 Carrier frequency 36 kHz T21 778ms Repetition time 113 792ms MSB LSB MSB LSB 24 889ms Source http users pandora be davshomepage Figure 2 4 Philips RC 5 IR Protocol 889 usec 889 usec 889 usec 889 use logical 1 Figure 2 5 Philips RC 5 IR Modula 37 6 uses In this application note Figure 2 6 Philips RC 5 IR Carrier 2 3 Philips RC 6 IR Protocol RC 6 signals are modulated on a 36 kHz carrier the same as RC 5 The duty cycle of this carrier has to be between 25 and 50 4 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited 7 Application Note FTDI AN 260 IR Remote Control Implementation by Java D2XX Chi Version 1 0 SS ip Document Reference No FT_000901 Clearance No FTDI 370 a d 3 Hardware Requir
22. il Sales E mail Support tw sales1 ftdichip com tw supporti ftdichip com Document Reference No FT 000901 E mail General Enquiries tw admini ftdichip com Web Site http ftdichip com Application Note AN_260 IR Remote Control Implementation by Java D2XX Version 1 0 Clearance No FTDI 370 Branch Office Tigard Oregon USA Future Technology Devices International Limited USA 7130 SW Fir Loop Tigard OR 97223 8160 USA Tel 1 503 547 0988 Fax 1 503 547 0987 E Mail Sales E Mail Support E Mail General Enquiries us salesQftdichip com us support Gftdichip com us admin ftdichip com Branch Office Shanghai China Future Technology Devices International Limited China Room 1103 No 666 West Huaihai Road Shanghai 200052 China Tel 86 21 62351596 Fax 86 21 62351595 E mail Sales E mail Support E mail General Enquiries cn sales ftdichip com cn support ftdichip com cn admin ftdichip com System and equipment manufacturers and designers are responsible to ensure that their systems and any Future Technology Devices International Ltd FTDI devices incorporated in their systems meet all applicable safety regulatory and system level performance requirements All application related information in this document including application descriptions suggested FTDI devices and other materials is provided for reference only While FTDI has t
23. inal int NECIRHeaderLen 341 private byte NECIRLeaderCode new byte 3 NECIRHeaderLen 9ms 26 4us 341 public static final int NECIRSpaceLen 170 private byte NECIRSpace new byte 3 NECIRSpaceLen 4 5m 26 4us 170 public static final int NECIROneLen 85 private byte NECIROne new byte 3 NECIROneLen 2 25m 26 4us 85 public static final int NECIRZeroLen 42 private byte NECIRZero new byte 3 NECIRZeroLen 1 12m 26 4us 42 public static final int AddIdx 3 NECIRHeaderLen NECIRSpaceLen 1533 public static final int CmdIdx 3 NECIRHeaderLen NECIRSpaceLen 8 NECIROneLen NECIRZeroLen the index to point the command length 4581 public static final int NECIRStopLen 21 private byte NECIRStopBit new byte 3 NECIRStopLen iA 560u 26 4us 21 public static final int StopIdx 3 NECIRHeaderLen NECIRSpaceL en 2 8 NECIROneLen NECIRZeroLen 7629 public SetAsyncBitBang Activity activity mContext activity try ftD2xx D2xxManager getInstance mContext catch D2xxManager D2xxException ex LogInfo ex getMessage IntentFilter filter new IntentFilter filter addAction UsbManager ACTION USB DEVICE DETACHED public void LogInfo String val MainActivity mContext onMsgShow val n public boolean Gen38KHzIR byte nECIRAddress byte nECIRCommand int i int j int devCount ftD2xx createDeviceInfoList mContex
24. nt Reference No FT 000901 Clearance No FTDI 370 6 Example application reading To test the IR reader a sample waveform was generated from a PC application driving the IR output section 6 1 This is then used to drive the IR reader being run on the Android platform ASYNC BITBANG TRANSMITTER Figure 6 1 IR Reader Test Setup SYNC BITBANG RECEIVER 6 1 Sample application to drive the IR reader The following Visual C program is able to generate different Baud Rates MyAsyncBitBang cpp A Visual C application to test the carrier waveform MyAsyncBitBang cpp Defines the entry point for the console application H include stdafx h include windows h include FTD2XX h include stdl ib h include lt stdio h gt include lt conio h gt define REPEAT FT_STATUS ftS DWORD dwNumBy DWORD dwNumBy 18020 atus esToSend 0 Index of output buffer esSent 0 dwNumBytesRead 0 dwNumInputBuffer 0 BYTE ByteDataRead WORD i 0 int j BYTE DataOutBuffer REPEAT BYTE InputBuffer 1024 int BAUDRA BOOL Bitbang I ftSta ftSta ftSta ftSta if Cf TE 7102 int BAUDRATE 6793 nit us l FT Se us FT Se us FT Se us l FT Se 8 8 usec 9 2u usec ial FT HANDLE ftHandle Status FT OK LatencyTimer ftHandle 2 Set the latency timer BitMode ftHandle 0x0 0x00 Reset controller BitMode ftH
25. o illustrates using Sync bit bang mode to perform continuous reading 1 1 Overview This document is designed for engineers who want to design an IR module with simple SetBitMode Read and Write commands for an Android system 1 2 Scope NEC Philip RC 5 and Philip RC 6 IR waveforms are described in following sections 2 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited Ea Application Note d FTDI AN_260 IR Remote Control Implementation by Java D2XX Chi Version 1 0 AN I Document Reference No FT 000901 Clearance No FTDI 370 2 Infra Red IR Data Protocols Infra red data is typically serial data It is encoded to different protocols that different vendors support As an example such encoding is what allows a TV remote control to work with one TV but not another 2 1 NEC IR Protocol NEC IR features are listed below 8 bit address and 8 bit command Address and command are transmitted twice Pulse distance modulation Carrier frequency is 38KHz Bit time is 1 125 ms logical 0 or 2 25 ms logical 1 NEC IR protocol is listed as following mm ii in iti Figure 2 1 NEC IR Protocol NEC IR modulation 4 Logical 1 gt Logical 0 gt Nu mW 550us A 550us A 550us gt 2 25ms gt 1 12ms gt Figure 2 2 NEC IR Modula NEC IR carrier LL 1 tk 455 kHz 88us ner fr
26. t int AddOffset 0 int CmdOffset 0 if devCount 0 The offset of Address The offset of Command D2xxManager FtDeviceInfoListNode deviceList new D2xxManager FtDeviceInfoListNode devCount ftD2xx getDeviceInfolist devCount deviceList switch devicelist 0 type case D2xxManager FT DEVICE 232B LogInfo Device Name FT232B device break case D2xxManager FT DEVICE 8U232AM LogInfo Device Name FT8U232AM device break case D2xxManager FT DEVICE UNKNOMN Product Page Document Feedback LogInfo Device Name Unknown device break 9 Copyright 2014 Future Technology Devices International Limited FA FTDI Application Note AN_260 IR Remote Control Implementation by Java D2XX e Version 1 0 Sw Chip Document Reference No FT_000901 Clearance No FTDI 370 case D2xxManager FT DEVICE 2232 LogInfo Device Name FT2232 device break case D2xxManager FT DEVICE 232R LogInfo Device Name FT232R device break case D2xxManager FT DEVICE 2232H LogInfo Device Name FT2232H device break case D2xxManager FT DEVICE 4232H LogInfo Device Name FT4232H device break case D2xxManager FT DEVICE 232H LogInfo Device Name FT232H device break case D2xxManager FT DEVICE X SERIES LogInfo Device Name FTDI X SERIES break default LogInfo Device Name FT232B device break ftDevice ftD2xx openByIndex mContext 0 if null ftDevice LogInfo
27. ts cendi iet mdeseesic ear e ia geo teret er aeneo Uo dedssateceasersdaeyaseaiecagectede2ese 18 8 Contact Information ire ce tere heii pened eet ence robe cr aide eee 22 Appendix A References sscccccecsesssssecsececeesesssnnaesececessssesauseseceesessaesausececessessausausecececsesssasanseceeeess 23 8 1 Document References ceeccseseceessecesseeceeeceseseeeesaeeeeaaeceeaaessaeeeeaaeceeaceseeaaesaeeeeaaeceeaaeseeneeens 23 8 2 Acronyms and Abbreviations c ccccccssssssnsccecesssssassensececessessnaseesececeesenseasacseceseeseassaneeeas 23 Appendix B List of Tables amp Figures ccccccccccsssssssssecececessesenseeeeeescesseauseseseesseesesasaeceesesseesenaeaeeeeeess 24 8 3 LiSt Of FIBUEBS eite estu etes depo ou desse de ieu ea euxe denen diese ussa deseo utes deae 24 Appendix C Revision History cccscsssessececessessessecsececessesseasecsececeusenseassesecessassaseessecececsesscanansecteeess 25 1 Product Page Document Feedback Copyright 2014 Future Technology Devices International Limited y 7 d Application Note FTDI AN 260 IR Remote Control Implementation by Java D2XX Chip Version 1 0 Document Reference No FT_000901 Clearance No FTDI 370 s 1 Introduction This application note illustrates how NEC IR 38 KHz RC 5 and RC 6 waveforms are generated by an Android device using Java D2XX with an FT X chip working in Async bit bang mode with minimum hardware cost Als
28. uN FTDI Chip y Application Note AN 260 IR Remote Control Implementation by Java D2XX Version 1 0 Issue Date 2013 09 25 This application note illustrates how NEC IR 38 KHz RC 5 and RC 6 waveforms are generated by an Android device using Java D2XX with an FT X chip working in Async bit bang mode with minimum hardware cost Also illustrates using Sync bit bang mode to perform continuous reading Use of FTDI devices in life support and or safety applications is entirely at the user s risk and the user agrees to defend indemnify and hold FTDI harmless from any and all damages claims suits or expense resulting from such use Future Technology Devices International Limited FTDI Unit 1 2 Seaward Place Glasgow G41 1HH United Kingdom Tel 44 0 141 429 2777 Fax 44 0 141 429 2758 Web Site http ftdichip com Copyright 2014 Future Technology Devices International Limited 7 d Application Note f FTDI AN 260 IR Remote Control Implementation by Java D2XX e Version 1 0 WES Chip Document Reference No FT 000901 Clearance No FTDI 370 Table of Contents T ntrOQUCtiOn inet eene eek erai a terr tiat eot eed rou Cerca lace side had e pae s cer heats 2 1 1 em 2 1 2 SCO o Clee e a A A TE EE E E 2 2 Infra Red IR Data Protocoles a enirita T E ERR E et eR VE seus YE rh A a pun 3 2 1 NEC IR PEOtOCO L siete tete detegere tou ve EE E EEEE tour ke EE a dee E 3 2 2
29. ync another 256 bytes ftDevice read DataInBuffer 256 Sync read 256 bytes ftDevice close SyncBitBang java package com example syncbitbang4ir import com ftdi j2xx D2xxManager import com ftdi j2xx FT Device import android app Activity import android content IntentFilter import android hardware usb UsbManager public class SyncBitBang CompareThread compareThread private Activity mContext private D2xxManager ftD2xx null private FT Device ftDevice null public static final int TwoK 2 1024 private byte DataOutBuffer new byte TwoK private byte DataInBuffer new byte TwoK get data to this buffer public SyncBitBang Activity activity mContext activity try ftD2xx D2xxManager getInstance mContext catch D2xxManager D2xxException ex IntentFilter filter new IntentFilter filter addAction UsbManager ACTION USB DEVICE DETACHED LogInfo ex getMessage public void LogInfo String val MainActivity mContext onMsgShow val n public boolean Gen128KHzIR int devCount ftD2xx createDeviceInfoList mContext LogInfo Inside of Gen128KHzIR function if devCount gt 0 D2xxManager FtDeviceInfoListNode deviceList new D2xxManager FtDeviceInfoListNode devCount ftD2xx getDeviceInfolist devCount deviceList send data and loop back JI oeieeeeeeee Configure Baud rate Reference AN232BM 1 to set the baud rate
Download Pdf Manuals
Related Search
Related Contents
FLAUBERT – BIBLIO 18 MANUEL D`UTILISATION - Amazon Web Services Samsung Aspirateur traîneau Compact SC5400, 2100 W Manuel de l'utilisateur (Windows 7) 1524 PhotoDirector 3 Life Fitness MTSLC User's Manual Organic Laboratories 100052369 Instructions / Assembly Manual de usuario Angel4.pptx User Manual Les arts et la culture Copyright © All rights reserved.
Failed to retrieve file