<div dir="ltr">The modified version of the arduino sketch is included in the .zip in my first email if you want to have a go at it. i haven&#39;t changed anything on the pd side. I would rather sacrifice duty cycle resolution and be able to control 64 solenoids, than making the entire message longer and slowing down the entire system. <div>
<br></div><div>As far as the dropped messages go, I&#39;m sending separate messages by packing the data and sending it to a single [trigger $1 $2{ message box. I&#39;ll try sending separate messages to see if that helps.<div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Sep 10, 2013 at 6:24 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 01:53 -0400, Epic Jefferson wrote:<br>
&gt; To control solenoids with dynamics, I adapted Reduzent&#39;s<br>
&gt; [Solenoiduino] abstraction and arduino sketch to include the TLC5940<br>
&gt; functions, which is what the Practical Maker PWM shield is based on.<br>
&gt; So far, I&#39;m able to control 44 solenoids using custom drivers and 2<br>
&gt; stacked PWM shields. This is an excellent alternative if you want to<br>
&gt; build a relatively cheap electro-mechanical piano setup.<br>
&gt;<br>
&gt;<br>
&gt; The problems i&#39;ve run into:<br>
</div>&gt;      1. if 2 or more messages get sent simultaneously, one of them<br>
<div class="im">&gt;         might get dropped (this happens a lot)<br>
<br>
</div>This shouldn&#39;t happen and actually never happened in my own experience.<br>
A single 2-byte message sets and one pin to HIGH and sets a timer for </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
that pin. So, if you need two set two pins simultaneously, you need to<br>
send two 2-byte messages. I don&#39;t see how the code could omit a message,<br>
unless two subsequent messages set the same pin.<br>
<br>
If you modified the code, you can send me a copy, so I&#39;ll look into it.<br>
<br>
&gt;      1. the handshake does not seem to work on Linux (Ubuntu 11)<br>
<br>
It&#39;s pretty crude. Whenever you send it a &#39;255&#39; (0xff) byte, it responds<br>
with the following ASCII sequence: &#39;SOL 0 1&#39;. You can easily test that<br>
with [comport] directly.<br>
<br>
The ugly thing is that [solenoiduino] has to make sure not to send any<br>
0xff bytes and thus some values for periods are not allowed / replaced,<br>
e.g 127, 255, 383 etc.<br>
<br>
&gt;      1. the original code only supports 16 solenoids<br>
<div class="im">&gt; This last one is the one that goes over my head, since the code uses<br>
&gt; that bit twiddling stuff, I can&#39;t figure out how to send the<br>
&gt; appropriate messages to any solenoids past 15. So, I&#39;m a little stuck<br>
&gt; here, any help?<br>
<br>
</div>The solenoiduino code uses two bytes per message, while the first bit of<br>
each is used for defining the byte order. This leaves 14 bits for the<br>
payload. The current implementation uses 4 bits for the pin address and<br>
10 bits for the duty cycle. If you can live with a lower duty cycle<br>
resolution, you can shift some bits around. For instance, you could<br>
adapt the bitmask to use 6 bits for the address (allows to control 64<br>
solenoids) and use only 8 bit for the velocity / duty cycle.<br>
<br>
Alternatively, you could extend the protocol to use 3 bytes per message.<br>
This would give you a payload of 21 bits to be distributed between<br>
address and duty cycle. Of course, this reduces your maximum message<br>
rate by 1.5.<br>
<br>
Roman<br>
<br>
<br>
<br>
<br>
<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>
</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></div>