tag:blogger.com,1999:blog-90209512940551960152024-02-20T10:28:08.670+00:00Experimenting with Arduinoidhttp://www.blogger.com/profile/11932466603117832284noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-9020951294055196015.post-42991556510418087542009-07-13T13:10:00.005+01:002009-07-13T13:31:53.774+01:00Using UDP with ArduinoUnfortunately, Arduino Ethernet library does not provide UDP support for sketches. This sad fact encouraged me to create an extended version quickly: it is a modified Client.c/.h files (named as ClientUDP.*), placed in the Ethernet library directory. <br /><br />It is nothing special with this code, because UDP supported by sockets library, used in Arduino, but not not available for sketches directly. <br /><br />You can download it here: <a href="http://arduino.idanilov.ru/files/b/udp/ClientUDP_1.1.zip">ClientUDP_1.1.zip</a> ( unpack to arduino-0016 \ hradware \ libraries ). <br /><br /><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/EZYaDEhVc_I&hl=ru&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999"><param name="allowFullScreen" value="true"><param name="allowscriptaccess" value="always"><embed src="http://www.youtube.com/v/EZYaDEhVc_I&hl=ru&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>idhttp://www.blogger.com/profile/11932466603117832284noreply@blogger.com4tag:blogger.com,1999:blog-9020951294055196015.post-29873164389513613062009-03-24T18:03:00.003+00:002009-07-12T18:41:10.189+01:00REPEATED START in ArduinoI2C support for Arduino based on <a href="http://arduino.cc/en/Reference/Wire">Wire</a> library.<br /><br />But, when I try to work with a <a href="http://molotok.ru/search.php?string=DS1307&us_id=12114900&country=168">DS1307</a> RTC chip, I found that repeated start mode not covered by original Wire library:<br /><br /><a href="http://picasaweb.google.com/lh/photo/qlxuFHSbl3Jm40j_SVtpcQ?feat=embedwebsite"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi58PLeWqidPHEB_hA0mKQxDs0NifocJ-yhlXKi892uOB0dQKEFsq0LGBKeCjQ0y5qZp11SZAKRvwJKzEjb8cqAWeyXVHgSrZSJG32aJ8WKYkxEOMraRBb03TZlKier2g1FCSpnMm56pbcv/s400/i2c-rs.png" /></a><br /><br />Wire library can't send second START condition without STOPping the I2C bus. Some chips, like DS1307, reset internal address register after that.<br /><br />So, what can we do?<br /><br />1. Forget about Wire library and use another - one for example, from <a href="http://jump.to/fleury">Peter Fleury</a>.<br /><br />2. Upgrade Wire library with new functionality (my way).<br /><br />OK, new Wire function prototype is:<br /><br /><span style="font-size:85%;">uint8_t TwoWire::transmitAndRequest(uint8_t quantity)<br /></span><br />And it <span style="font-style: italic;">must</span> be used <span style="font-style: italic; font-weight: bold;">instead of</span> <span style="font-family:courier new;">endTransmission()</span>:<br /><br /><span style="font-size:85%;"><span style="font-family:courier new;">Wire.beginTransmission(address)</span><br /><span style="font-family:courier new;">Wire.send(data);</span><br /><span style="font-family:courier new;">Wire.send(data);</span><br /><span style="font-family:courier new;">...</span><br /><span style="font-family:courier new;">Wire.transmitAndRequest(quantity);</span></span><br /><br />This code provides transmission buffer sending, than running receiving after REPEATED START. Function returns read bytes count. The highest bit (0x80) is a <span style="font-weight: bold;">error</span> flag, so if we got a value > 127, it is an error code, same as for endTransmission() (without this bit, of course).<br /><br />Download modified Wire library: <a href="http://mk90.idanilov.ru/files/arduino/Wire.zip">Wire.zip</a> (tested with Arduino IDE 0014).idhttp://www.blogger.com/profile/11932466603117832284noreply@blogger.com0