<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On Jun 22, 2006, at 8:34 AM, Alexandre Quessy wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite">Hi Hans and the PD list, <BR><BR>We are trying to use the PD Arduino firmware + PD patch that Hans has released. See <A href="http://at.or.at/hans/pd/objects.html">http://at.or.at/hans/pd/objects.html</A> and <A href="http://arduino.cc/"> http://arduino.cc/</A> for more info. Our goal is to use it a inputs only. (for now) <BR><BR>We realized that some analog inputs values were way too high. It worked, then it broked for some unknown reason. (apparently none) Then it worked again and broke again. So, we can say it is still unstable. <BR><BR>We think that it mighth be because of some equations in the Pduino Arduino code. We changed line 119 from : <BR>transmitByte = transmitByte + (2^(i+1-startPin)*digitalData);<BR>to : <BR>transmitByte = transmitByte + (2^(i+1+startPin)*digitalData); <BR><BR>Then, the analog-in stopped giving strangely high data. We found it strange the use of negative exponents (when startPin is 7). Was that a luck or what ? We had lot of fun debugging that. ;-D<BR></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Yes, that would be a bug, thanks for finding it.  I guess I never tested the higher digital inputs...  feel free to commit it directly.    I only tested analog 0-3 with sensors, but I never saw values higher than 1023.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR><BLOCKQUOTE type="cite">--- <BR>Regarding the digital inputs. In both cases, they were behaving strangely. Their state are constantly changing. Some work, but some not. Maybe it is just electric noise : should we ground everyother pin ? Probably. <BR></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Yeah, the code needs to be debugged, but yes, all of the inputs, digital and analog, will have floating voltages on them unless you tie them to ground or +5V.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BLOCKQUOTE type="cite">In the PDuino PD patch, are the serial streams always parsed as being the same length ? It is supposed to be so, but might not in every case. Maybe it would be better to use the [match] object. (because the selector, meaning that it it the beginning of the list, is 255) Maybe sometimes, because of calculation error (?), the number 255 is sent again. <BR clear="all"></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV></DIV><DIV><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px">The streams can vary in length, but there are some aspects that are fixed.  The 255 byte is always the cycle marker, marking the beginning of a cycle.  Then the next two bytes will always be the digital inputs, even if they are not being read, in which case those two bytes would be 0 and 0.  Then after those 3 bytes, you can have 0-6 pairs of bytes representing the analogIns.  So if you want to reduce the latency as much as possible, then you can have it only send the data for the number of analogIns that you are using.  This I have tested quite a bit and haven't seen any problems with it. <BR></P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><BR class="khtml-block-placeholder"></P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px">As for [match], I think that's a bad solution since it adds a lot of latency.  [match] would output until the whole sequence is matched.  For the full sequence, that will add about 8 times the latency. If there is a calculation error that is causing a random 255 byte, that should be fixed instead of making a [match] workaround.  I haven't seen random 255 bytes at all though, have you?</P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><BR class="khtml-block-placeholder"></P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px">FYI: I wrote up some documentation about the Pduino protocol:</P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><BR class="khtml-block-placeholder"></P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><A href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1148554125/1">http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1148554125/1</A></P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><BR class="khtml-block-placeholder"></P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><BR class="khtml-block-placeholder"></P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px">.hc</P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><BR class="khtml-block-placeholder"></P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><BR class="khtml-block-placeholder"></P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><BR class="khtml-block-placeholder"></P><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><BR class="khtml-block-placeholder"></P><DIV>------------------------------------------------------------------------</DIV><P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><BR></P><P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">Terrorism is not an enemy.<SPAN class="Apple-converted-space"> <SPAN class="Apple-converted-space"> </SPAN></SPAN>It cannot be defeated.<SPAN class="Apple-converted-space"> <SPAN class="Apple-converted-space"> </SPAN></SPAN>It's a tactic.<SPAN class="Apple-converted-space"> <SPAN class="Apple-converted-space"> </SPAN></SPAN>It's about as sensible to say we declare war on night attacks and expect we're going to win that war.<SPAN class="Apple-converted-space"> <SPAN class="Apple-converted-space"> </SPAN></SPAN>We're not going to win the war on terrorism.       </FONT><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica"><SPAN class="Apple-converted-space"><SPAN class="Apple-converted-space"> </SPAN></SPAN>- retired U.S. Army general, William Odom</FONT></P><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></BODY></HTML>