01/13/2012 03.37.15 IM http.//rea2eectronIcs.bogspot.com/2009/09/arduIno-and-rs485-engIsh-versIon.htm Arduino and RS485 ENGLISH VERSION) . NEWS = Are you Intereste In CAN 8us wIth AruIno: 7IsIt http://secuuIno.blogspot.com/ FS485 Is a stanar serIal protocol , wIth bus topology where you can connect several evIces In a very cheap way. Here wIll be explaIne how to create a mIcrocontrollers network just wIth 2 wIres. t Is base In a IfferentIal couple of wIres wIth whIch we can get a halfuplex comunIcatIon channel . The rIver has a confIgurable Input that provIes us the possIbIlIty to set our transceIver as sener or receIver. What o we nee apart of our AruIno: |AX485 SN75176 (cheaper) What wIll be It use for: t Is a voltage level converter In orer to use our UAFT as FS485 Interface. Dk, now we are reay to start. FS485 resIes In the physIcal layer base on the DS |oel, so It just tell us about voltages, physIc parameters,.... Fecommene lInks: http://www.ImIcro.com/pf/artIculos/rs485.pff http://www.maxImIc.com/appnotes.cfm:appnote_number=76JEC|P=WP1 http://www.neoteo.com/rs485omotIcaalalcanceetumano15810.neoalcanceetu mano15810.neo FS485 DscIlloscope Screenshots http://www.sbcsupport.ch/faq/fIles/fIles.get.php:ZSESSDN0=nJ8bphov4ls4csvtb8tl6jb4EfI_ Inex=100179 Then, we nee an structural way to sen our InformatIon. We wIll use as frames a confIguratIon alreay create by FujI In theIr InustrIal varIators. Look at: http://www.cautomatIon.com/ownloa/ENC_L_|_FUJ_FS485_CD||_for_FFENC |InI.P0FL_|_FUJ_FS485_CD||_for_FFENC|InI.P0F Let's take a look at the frame confIguratIon: MENU HDhE PACE LINKUIND: PapId PrototypIng +LNK0UND: LInksys + AruIno + TelnetExcel +LNK0UND:TwItter +LNK0UND:Embee Web Server +LNK0UND:Control LC0 ese Internet +LNK0UND:Software para TELE|ETFA +LNK0UND:00WFT + DPTWAFE + NEW-> AF0UND A0C: muestreo alta velocIa + NEW-> |aqueta e Control 0IctIca + NEW-> TImer2:ntrouccIon + NEW-> T7out=AruIno + T7 + NEW-> CAN 8US=AruIno + |CP2515 CAN 8US 0Isplay SensoraIser AruIno y FS485 (Espaol) AruIno an FS485 (EnglIsh) UnIeno Excel con AruIno AaIeno logger a tu AruIno Nunchuck + |atlab + AruIno Power Sleep |oe ShIft LIghts con AruIno (Tacometro) Clculo numero marcha meIante velocIa y rpm AruIno + Kst (grfIcas en real tIme) E-mail UNIQUE VISITORS Tinkering with Electronics... Physical Computing - Rapid prototyping hardware 2 TInkerIng wIth ectronIcs.... ArduIno and IS485 (GISI VISO) 01/13/2012 03.37.15 IM http.//rea2eectronIcs.bogspot.com/2009/09/arduIno-and-rs485-engIsh-versIon.htm 8yte 1: Start 8yte ( 0 hexaecImal ). 8yte 2J: ASC AruIno's aress. 8yte 4: 8yte ENQ, ACK or NAK (0x05h, 0x06h y 0x15h) . 8yte 5: ASC Fequeste comman. 8yte 6 y 7: ASC FunctIon number. 8yte 8: SIgn byte (PosItIve 0x20h y NegatIve 20) 8yte 912: ASC of ata bytes (0x00h0xFFFFh) 8yte 1J: 8yte EDT (En of Text) (0x0Jh) 8yte 1415: Checksum (aItIon from 2n byte to 1Jth byte) WIth thIs confIguratIon we have 1 8yte InIcatIng the FunctIon Number 2 8ytes InIcatIng the subfunctIon Number So ImagIne the possIbles combInatIons!!! For Instance: A01 Fequet of value on Analog Input 1 P01 Fequest ConfIguratIon of PW| 1 wIth setup ata In 0ATA bytes An so on!!!! s not wonerful: NotIce: Commans are ASC Coe Control bytes are not ASC Coe t Is a nIce feature ue to, In case we receIve a 0x00 (thInkIng It Is the start byte), the program wIll unerstan It Is the startIng frame Instea of as 0 value, because In thIs case, It shoul be sent as ASC (0xJ0). Please take a look at the ASC Table, even better prInt It! :P Probably most of us we have a copy paste In front of us all the tIme, wrong: http://www.cs.utk.eu/-pham/ascII_table.jpg 7Iew |y Stats LINKS Patterns for TImeTrIggere Embee Systems 8DDK:The Complete 8egInners CuIe to the AruIno 8uIl t. Share t. ProfIt. Can Dpen Source Harware Work: A7F LIbc Homepage A7F Freaks AF0UND FDFU| AF0UND HD|ESTE 8rIcogeek LIbelIum Sparkfun |ake: en Espaol Twitter Happy ChrIstmas!! http://t.co/s1Wp8wcF 2J ays ago AquIsIcIon e atos en tIempo real con #AruIno y #KST = http://t.co/NJjp1Px 1J0 ays ago El borraor el poyecto e la #7IrtualCamp en http://bIt.ly/pS1tlW 179 ays ago @KybalIon_Croup http://t.co/epsymp0 181 ays ago #hackathon #vIrtualcamp 0anole uro a la maqueta e control con AruIno!!! 181 ays ago Follow me on TwItter VISITOR LIve TraffIc Fee See your vIsItors In FealTIme ! Cet the Free LIve TraffIc Fee Cet FeejIt Now ! A vIsItor from 7Ila Nova 0e CaIa , Porto vIewe TInkerIng wIth ElectronIcs ... 7 mIns ago A vIsItor from Tuela , Navarra vIewe TInkerIng wIth ElectronIcs ...: |aqueta e control P0 con AruIno 11 mIns ago 3 TInkerIng wIth ectronIcs.... ArduIno and IS485 (GISI VISO) 01/13/2012 03.37.15 IM http.//rea2eectronIcs.bogspot.com/2009/09/arduIno-and-rs485-engIsh-versIon.htm Let's see an example: magIne we nee an aruIno(master) whIch wIll ecIe eIther swItch on or swItch off a remote lIghts. Then, It have to sen a comman on our FS485 network an then other aruIno (slave) wIll Interpretate the comman an excute It. Then, the master wIll follow the swItchces state, a an as neee, the master wIll sen the frame requestIng swItch on/off to the slave calle 01. The functIon wIll be calle 0 an number 0.(you can set It up as neee). So, |aster sens: Slave(01)Fequest executIon functIon(0)SubFunctIon(0) 0x00 0xJ0 0xJ1 0x05 0x44 0xJ0 0xJ0 0x20 0xJ0 0xJ0 0xJ0 0xJ1 0x0J 0x01 0xEE Slave answers: AKNDWLE0CE (ACK). 0x00 0xJ0 0xJ1 0x06 0x44 0xJ0 0xJ0 0x20 0xJ0 0xJ0 0xJ0 0xJ1 0x0J 0x01 0xEF The salve' s ACK frame has the followIng confIguratIon(take a look at 8yte 4 ue to here Is specIfIe ACK) Even better, watch the followIng vIeo: http://www.youtube.com/watch:v=A8cjU0Ua4 PlugIn content Urgh!!!!Sorry but the swItcher Is just a couple of wIres goIng from 7CC to CN0! ;) n orer to see the frames flowIng on the net, you nee just a US8 FS2J2 lIke FT02J2 or |AX2J2+|AX485,... f you have an AruIno PC8, notIce you can remove the uC from Its socket an you'll have an US8 Fs2J2 converter! LNK0UND : LInksys + AruIno + Excel Telnet vIa 2 .bp .blogspot .com 17 mIns ago A vIsItor from Salamanca , CastIlla y Leon vIewe TInkerIng wIth ElectronIcs ...: LNK0UND : SDFTWAFE PAFA TELE|ETFA 42 mIns ago A vIsItor from 8uapest vIewe TInkerIng wIth ElectronIcs ...: AruIno an FS 485 ( ENCLSH 7EFSDN ) 4J mIns ago A vIsItor from Tampere , Western FInlan vIewe TInkerIng wIth ElectronIcs ... 1 hour 2 mIns ago A vIsItor from Paraguay left TInkerIng wIth ElectronIcs ...: LNK0UND : LInksys + AruIno + Excel Telnet vIa cI 2 ee 689 fJ5J f1 5 bc .skyrIve .lIve .com 1 hour 11 mIns ago A vIsItor from Frek mistek , |oravskoslezsky kraj vIewe TInkerIng wIth ElectronIcs ...: AruIno an FS 485 ( ENCLSH 7EFSDN ) 1 hour 15 mIns ago A vIsItor from Eschborn , Hessen left TInkerIng wIth ElectronIcs ...: AruIno an FS 485 4 TInkerIng wIth ectronIcs.... ArduIno and IS485 (GISI VISO) 01/13/2012 03.37.15 IM http.//rea2eectronIcs.bogspot.com/2009/09/arduIno-and-rs485-engIsh-versIon.htm f you want to monItorIze what Is goIng on , you can use HypertermInal, or any one that Inclue some useful features as format output, savIng optIons,....for Instance we lIke: FealTerm FFEE SEFAL TEF|NAL |DNTDF Feally nIce If you want to snIff FS2J2 frames n thIs example we have J aruInos connecte. The master have 2 swItchers use to swItch on/off les connecte to each of the slaves. . A vIsItor from Eschborn , Hessen vIewe TInkerIng wIth ElectronIcs ...: AruIno an FS 485 ( ENCLSH 7EFSDN ) 1 hour 25 mIns ago Feal tIme vIew |enu Get visitors to your site6,000,000 ad views for 49 5 TInkerIng wIth ectronIcs.... ArduIno and IS485 (GISI VISO) 01/13/2012 03.37.15 IM http.//rea2eectronIcs.bogspot.com/2009/09/arduIno-and-rs485-engIsh-versIon.htm PlugIn content Let's see how It works: http://www.youtube.com/watch:v=S9FSQaTo7Z4 Now...THE CD0E! IhPDPTANT: Checksum cre done drectly n hex nstecd o] convert t to ASCll. Chcnye t could be necesscry , to dont hcve problems. Ths entry s c howto pcper to show you how RS485 works cnd explcn how to mplemnt c protocol, but s not 100 debbuyed. hASTEP: //---------------------------------- //RS 485 //By Tgo Rea //24-06-09 //---------------------------------- by1e da1a|12], uhs1ghed ohg pev1ous_11me, uhs1ghed ohg pev1ous_11me2, by1e 11mes_epea1=5, by1e 11mes_epea12=5, by1e s1a1e=0, by1e s1a1e2=0, #de11he p1hC0hTR0L 02 #de11he myaddess 01 SLAVES: (you have to change myaress to 01 or 02) 6 TInkerIng wIth ectronIcs.... ArduIno and IS485 (GISI VISO) 01/13/2012 03.37.15 IM http.//rea2eectronIcs.bogspot.com/2009/09/arduIno-and-rs485-engIsh-versIon.htm //---------------------------------- //RS 485 //By Tgo Rea //24-06-09 //---------------------------------- by1e da1a|12], by1e addess, by1e 1uhc11oh, by1e 1uhc11oh_code, uhs1ghed 1h1 da1a_ece1ved, by1e by1e_ece1ve, by1e s1a1e=0, by1e coh11=1, by1e 1ace_0K=0, uhs1ghed 1h1 checksum, uhs1ghed 1h1 checksum_1ace, Now, we wIll learn how to wIre a bus topology: .
. Each AruIno or gaget connete to the net, Is wIre wIth an Y wele whIch comes out 2 connectors from same famIly Ifferent kIn(|ale/female). The shorter the better. Each connector wIll have 7CC,SgInal A, SIngal 8 an CN0. ThIs way, If we want to connect another evIce onto the net, you nee just Insert each evIce or put It at the en. Now Is easy unerstan why we are puttIng a Y , It' s extremely easy connect an Isconnect a evIce from the bus, ue to each evIce has male an female. s worthy have always a couple of connectors wIth a enresIstor between SIngal A an SIgnal 8 FS485 pIns In orer to close the wIres' en. f we nee a another evIce Is as easy as Isconnet the connector wIth the enresIstor, Insert the new evIce an close agaIn wIth that connector. WIre 7CC an CN0 Is extremely easy, an In future, wIll make thIngs really easIer In possIble expansIons..... Take care, an twIst SIgnal A an SIgnal 8 wIres. Please take a loot at next lInk If neee : http:// www.rs485.com/ownloa/48520network20topology.pf . ThIs paper was base on spanIsh gor F's one. Thanks gor F!! Cheers!!! . . ArItz P. . . PublIcao por ArItz F EtIquetas: aruIno, atmega, atmega168, atmel, avr, bus, 0Y, electronIc, electronIca, manual, mIcrocontrolaor, mIcrocontroller, pcb, rs485, tutorIal, uno 11 comentarIos: AnnImo dIjo... ThIs Is just as a note for other people: t took me a whIle to realIze that you nee to connect the wrIte enable an rea enable lInes to the IgItal pIn 2 on the mIcrocontroller. 16 e enero e 2010 0J:28 7 TInkerIng wIth ectronIcs.... ArduIno and IS485 (GISI VISO) 01/13/2012 03.37.15 IM http.//rea2eectronIcs.bogspot.com/2009/09/arduIno-and-rs485-engIsh-versIon.htm Igor dIjo... HI, Please, fIn below the pIn out of the |AX485 (0P8) PNDUT |AX485 AruIno 1 FD (FeceIver Dutput) to pIn 0 (Fx) 2 FeceIve enable to a IgItal Input (ej: pIn2) J 0rIver enable to a IgItal (ej:pIn2) 4 0 (0rIver n) to pIn 1 (Tx) 5 CN0 to gn of the aruIno 6 SCNAL A (bus FS485) 7 SCNAL 8 (bus FS485) 8 7cc to 5 voltIos of the aruIno Fegars, gor 1J e mayo e 2010 14:11 AnnImo dIjo... ThIs Is great, 've been lookIng for thIs for a whIle! Coo etaIle explInatIon. Thanks from NL Fob 1 e septIembre e 2010 06:49 FIorIs dIjo... NIce tutorIal! questIon: Is It possIble to sent ata from the slave to the master In the ACK (In the byte 9 .. 12): FlorIs at eboktor ot nl 16 e septIembre e 2010 0J:57 Igor dIjo... HI FlorIs, Df course you can. ts the esIgner who ecIes how the protocol works. ts 100 open. The FS485 only efInes the phIsIcal layer. Cheers!! gor 16 e septIembre e 2010 07:28 8 TInkerIng wIth ectronIcs.... ArduIno and IS485 (GISI VISO) 01/13/2012 03.37.15 IM http.//rea2eectronIcs.bogspot.com/2009/09/arduIno-and-rs485-engIsh-versIon.htm CIangI dIjo... HI gor, Thanks for your work. semplIfIe your coe, It Is easIer to mantaIn It too: voI senACK_NAK(byte type,byte aress1,byte aress2,byte ata_type,byte coe1,byte coe2,byte SIgn,byte ata1,byte ata2,byte ataJ,byte ata4)[ unsIgne Int checksum_ACK; checksum_ACK=aress1+aress2+6+ata_type+coe1+coe2+SIgn +ata1+ata2+ataJ+ata4+J; UCSF0A=UCSF0A (1 TXC0); IgItalWrIte(pInCDNTFDL,HCH); elay(1); SerIal.prInt(0,8YTE); SerIal.prInt(aress1,8YTE); SerIal.prInt(aress2,8YTE); SerIal.prInt(type,8YTE); SerIal.prInt(ata_type,8YTE); SerIal.prInt(coe1,8YTE); SerIal.prInt(coe2,8YTE); SerIal.prInt(SIgn,8YTE); SerIal.prInt(ata1,8YTE); SerIal.prInt(ata2,8YTE); SerIal.prInt(ataJ,8YTE); SerIal.prInt(ata4,8YTE); SerIal.prInt(J,8YTE); SerIal.prInt(((checksum_ACK8)E255),8YTE); SerIal.prInt(((checksum_ACK)E255),8YTE); whIle (!(UCSF0A E (1 TXC0))); IgItalWrIte(pInCDNTFDL,LDW); ] voI senACK(byte aress1,byte aress2,byte ata_type,byte coe1,byte coe2,byte SIgn,byte ata1,byte ata2,byte ataJ,byte ata4)[ senACK_NAK(6, aress1, aress2, ata_type, coe1, coe2, SIgn, ata1, ata2, ataJ, ata4); ] voI senNAK(byte aress1,byte aress2,byte ata_type,byte coe1,byte coe2,byte SIgn,byte ata1,byte ata2,byte ataJ,byte ata4)[ senACK_NAK(15, aress1, aress2, ata_type, coe1, coe2, SIgn, ata1, ata2, ataJ, ata4); ] 19 e enero e 2011 0J:15 CIangI dIjo... An thIs one too: byte hex2num(byte x)[ byte result; If (x=48 EE x=57)[ //numbers 09 9 TInkerIng wIth ectronIcs.... ArduIno and IS485 (GISI VISO) 01/13/2012 03.37.15 IM http.//rea2eectronIcs.bogspot.com/2009/09/arduIno-and-rs485-engIsh-versIon.htm result=x48; ]else If (x=65 EE x=70)[ //AF result=x55; //A=10, 8=11, .,F=15 ] return result; ] 19 e enero e 2011 0J:15 CIangI dIjo... gor thInk there Is a bug In the orIgInal senNAK functIon. Shoul the row checksum_ACK=aress1+aress2+6+ata_type+coe1+coe2+SIgn +ata1+ata2+ataJ+ata4+J; be correcte In checksum_ACK=aress1+aress2+21+ata_type+coe1+coe2+SIgn +ata1+ata2+ataJ+ata4+J; : NotIce the 21 value (0x15h) Instea of 6 because you wrote ENQ, ACK or NAK (0x05h, 0x06h y 0x15h). n thIs case the coe Is much sImplIer because you can merge the sen|SC coe too: voI sen|SC(byte type, byte aress1,byte aress2,byte ata_type,byte coe1,byte coe2,byte SIgn,byte ata1,byte ata2,byte ataJ,byte ata4)[ unsIgne Int checksum_ACK; checksum_ACK=aress1+aress2+type+ata_type+coe1+coe2+SIgn +ata1+ata2+ataJ+ata4+J; UCSF0A=UCSF0A (1 TXC0); IgItalWrIte(pInCDNTFDL,HCH); elay(1); SerIal.prInt(0,8YTE); SerIal.prInt(aress1,8YTE); SerIal.prInt(aress2,8YTE); SerIal.prInt(type,8YTE); SerIal.prInt(ata_type,8YTE); SerIal.prInt(coe1,8YTE); SerIal.prInt(coe2,8YTE); SerIal.prInt(SIgn,8YTE); SerIal.prInt(ata1,8YTE); SerIal.prInt(ata2,8YTE); SerIal.prInt(ataJ,8YTE); SerIal.prInt(ata4,8YTE); SerIal.prInt(J,8YTE); SerIal.prInt(((checksum_ACK8)E255),8YTE); SerIal.prInt(((checksum_ACK)E255),8YTE); whIle (!(UCSF0A E (1 TXC0))); IgItalWrIte(pInCDNTFDL,LDW); ] voI senACK(byte aress1,byte aress2,byte ata_type,byte coe1,byte coe2,byte SIgn,byte ata1,byte ata2,byte ataJ,byte ata4)[ sen|SC(6, aress1, aress2, ata_type, coe1, coe2, SIgn, ata1, ata2, ataJ, ata4); ] 10 TInkerIng wIth ectronIcs.... ArduIno and IS485 (GISI VISO) 01/13/2012 03.37.15 IM http.//rea2eectronIcs.bogspot.com/2009/09/arduIno-and-rs485-engIsh-versIon.htm PubIIcar un comentarIo en Ia entrada voI senNAK(byte aress1,byte aress2,byte ata_type,byte coe1,byte coe2,byte SIgn,byte ata1,byte ata2,byte ataJ,byte ata4)[ sen|SC(15, aress1, aress2, ata_type, coe1, coe2, SIgn, ata1, ata2, ataJ, ata4); ] 19 e enero e 2011 07:46 Igor dIjo... Coo poInts CIangI!! Please feel free to sen me your Improvements an can publIsh them here. Thanks! ;) 20 e enero e 2011 14:19 AnnImo dIjo... HI, 'm wonerIng If there won' t be any problems wIth aresses If set master to 01 an slaves as u wrote 01 an 02. Shouln' t be for ex. master 01, slave_1 02, an slave_2 0J :: hope It Isn't a stupI questIon ' m just startIng wIth It cheers. 29 e abrIl e 2011 05:46 beerwInkeI77 dIjo... HI, can sen me a schematIc to buIl thIs: Where to put the resIstor an where the jumper: Thank You Anreas 9 e octubre e 2011 14:J6 11 TInkerIng wIth ectronIcs.... ArduIno and IS485 (GISI VISO) 01/13/2012 03.37.15 IM http.//rea2eectronIcs.bogspot.com/2009/09/arduIno-and-rs485-engIsh-versIon.htm Entraa ms recIente Entraa antIgua Th1oduce 1u comeh1a1o... Comentar como: Seecconar perf ... sta preva PgIna prIncIpal SuscrIbIrse a: EnvIar comentarIos (Atom)