<div dir="ltr">Awesome, thanks! <div><br></div><div>i tested it quickly and i can now address all of the solenoids from within pd. </div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 11, 2013 at 6:26 PM, Roman Haefeli <span dir="ltr">&lt;<a href="mailto:reduzent@gmail.com" target="_blank">reduzent@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, 2013-09-10 at 21:34 -0400, Epic Jefferson wrote:<br>
&gt; The modified version of the arduino sketch is included in the .zip in<br>
&gt; my first email if you want to have a go at it. i haven&#39;t changed<br>
&gt; anything on the pd side. I would rather sacrifice duty cycle<br>
&gt; resolution and be able to control 64 solenoids, than making the entire<br>
&gt; message longer and slowing down the entire system.<br>
<br>
</div>I adapted the bitmask stuff in the the Pd patch and the Arduino sketch<br>
so that 6 bits are used for the pin address. This means, the velocity<br>
has now only 256 steps. Check the attachments.<br>
<br>
Beware, I wasn&#39;t able to actually test the modifications as I currently<br>
don&#39;t have an arduino at hand.<br>
<div class="im"><br>
&gt; As far as the dropped messages go, I&#39;m sending separate messages by<br>
&gt; packing the data and sending it to a single [trigger $1 $2{ message<br>
&gt; box. I&#39;ll try sending separate messages to see if that helps.<br>
<br>
</div>I&#39;m not totally sure if I understand you correctly, but this should be<br>
fine, as long as [solenoiduino] receives &#39;trigger X Y&#39; messages.<br>
<br>
The main difference between your version and mine is that yours uses the<br>
Tlc stuff. I don&#39;t know how this part behaves if you set and update<br>
twice in a row very quickly. May be this is the culprit? Just a guess, I<br>
can&#39;t test here and I don&#39;t have a clue what this code does or if it<br>
does something time critical at all. A cheap work-around might be to<br>
rate-limit the messages on the Pd side.<br></blockquote><div>   </div><div>I think it might be correct to assume that the dropped messages could be on the Tlc side of things, </div><div>i have a feeling that while it&#39;s setting and updating, any incoming message could be lost.</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Regarding the handshake: You may skip that all-together if it doesn&#39;t<br>
work for you, as it isn&#39;t really necessary. I thought it might be a<br>
convenient way check to make sure the hardware has the correct firmware<br>
loaded. To quickly test send 255 to [comport] and see if you get<br>
something back. If so, the problem might be in the [solenoiduino]<br>
abstraction.<br></blockquote><div><br></div><div>this is a small problem, for some reason sending an &#39;open X&#39; type message to solenoiduino doesn&#39;t bang the &#39;255&#39; message box. i have to click on it myself for it to work, wierd. Now that i think of it, the new max velocity is 255, is it possible the arduino could interpret this as trying to establish a connection again and not as the &#39;velocity&#39; byte? I haven&#39;t noticed a problem but i haven&#39;t tested it properly yet. I might opt for removing the handshake entirely</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Roman<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
&gt; On Tue, Sep 10, 2013 at 6:24 PM, Roman Haefeli &lt;<a href="mailto:reduzent@gmail.com">reduzent@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;         On Tue, 2013-09-10 at 01:53 -0400, Epic Jefferson wrote:<br>
&gt;         &gt; To control solenoids with dynamics, I adapted Reduzent&#39;s<br>
&gt;         &gt; [Solenoiduino] abstraction and arduino sketch to include the<br>
&gt;         TLC5940<br>
&gt;         &gt; functions, which is what the Practical Maker PWM shield is<br>
&gt;         based on.<br>
&gt;         &gt; So far, I&#39;m able to control 44 solenoids using custom<br>
&gt;         drivers and 2<br>
&gt;         &gt; stacked PWM shields. This is an excellent alternative if you<br>
&gt;         want to<br>
&gt;         &gt; build a relatively cheap electro-mechanical piano setup.<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; The problems i&#39;ve run into:<br>
&gt;<br>
&gt;         &gt;      1. if 2 or more messages get sent simultaneously, one<br>
&gt;         of them<br>
&gt;         &gt;         might get dropped (this happens a lot)<br>
&gt;<br>
&gt;<br>
&gt;         This shouldn&#39;t happen and actually never happened in my own<br>
&gt;         experience.<br>
&gt;         A single 2-byte message sets and one pin to HIGH and sets a<br>
&gt;         timer for<br>
&gt;         that pin. So, if you need two set two pins simultaneously, you<br>
&gt;         need to<br>
&gt;         send two 2-byte messages. I don&#39;t see how the code could omit<br>
&gt;         a message,<br>
&gt;         unless two subsequent messages set the same pin.<br>
&gt;<br>
&gt;         If you modified the code, you can send me a copy, so I&#39;ll look<br>
&gt;         into it.<br>
&gt;<br>
&gt;         &gt;      1. the handshake does not seem to work on Linux (Ubuntu<br>
&gt;         11)<br>
&gt;<br>
&gt;         It&#39;s pretty crude. Whenever you send it a &#39;255&#39; (0xff) byte,<br>
&gt;         it responds<br>
&gt;         with the following ASCII sequence: &#39;SOL 0 1&#39;. You can easily<br>
&gt;         test that<br>
&gt;         with [comport] directly.<br>
&gt;<br>
&gt;         The ugly thing is that [solenoiduino] has to make sure not to<br>
&gt;         send any<br>
&gt;         0xff bytes and thus some values for periods are not allowed /<br>
&gt;         replaced,<br>
&gt;         e.g 127, 255, 383 etc.<br>
&gt;<br>
&gt;         &gt;      1. the original code only supports 16 solenoids<br>
&gt;         &gt; This last one is the one that goes over my head, since the<br>
&gt;         code uses<br>
&gt;         &gt; that bit twiddling stuff, I can&#39;t figure out how to send the<br>
&gt;         &gt; appropriate messages to any solenoids past 15. So, I&#39;m a<br>
&gt;         little stuck<br>
&gt;         &gt; here, any help?<br>
&gt;<br>
&gt;<br>
&gt;         The solenoiduino code uses two bytes per message, while the<br>
&gt;         first bit of<br>
&gt;         each is used for defining the byte order. This leaves 14 bits<br>
&gt;         for the<br>
&gt;         payload. The current implementation uses 4 bits for the pin<br>
&gt;         address and<br>
&gt;         10 bits for the duty cycle. If you can live with a lower duty<br>
&gt;         cycle<br>
&gt;         resolution, you can shift some bits around. For instance, you<br>
&gt;         could<br>
&gt;         adapt the bitmask to use 6 bits for the address (allows to<br>
&gt;         control 64<br>
&gt;         solenoids) and use only 8 bit for the velocity / duty cycle.<br>
&gt;<br>
&gt;         Alternatively, you could extend the protocol to use 3 bytes<br>
&gt;         per message.<br>
&gt;         This would give you a payload of 21 bits to be distributed<br>
&gt;         between<br>
&gt;         address and duty cycle. Of course, this reduces your maximum<br>
&gt;         message<br>
&gt;         rate by 1.5.<br>
&gt;<br>
&gt;         Roman<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;         _______________________________________________<br>
&gt;         <a href="mailto:Pd-list@iem.at">Pd-list@iem.at</a> mailing list<br>
&gt;         UNSUBSCRIBE and account-management -&gt;<br>
&gt;         <a href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; <a href="http://www.epicjefferson.com" target="_blank">www.epicjefferson.com</a><br>
&gt; <a href="http://www.avmachinists.org" target="_blank">www.avmachinists.org</a> Puerto Rico based Art Collective/ Non-Profit Org<br>
<br>
</div></div><br>_______________________________________________<br>
<a href="mailto:Pd-list@iem.at">Pd-list@iem.at</a> mailing list<br>
UNSUBSCRIBE and account-management -&gt; <a href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><a href="http://www.epicjefferson.com" target="_blank">www.epicjefferson.com</a><br><a href="http://www.avmachinists.org" target="_blank">www.avmachinists.org</a> Puerto Rico based Art Collective/ Non-Profit Org
</div></div>