[PD] modifying Reduzent's [Solenoiduino] to control 44 solenoids (electro-mechanical piano)
reduzent at gmail.com
Wed Sep 11 00:24:19 CEST 2013
On Tue, 2013-09-10 at 01:53 -0400, Epic Jefferson wrote:
> To control solenoids with dynamics, I adapted Reduzent's
> [Solenoiduino] abstraction and arduino sketch to include the TLC5940
> functions, which is what the Practical Maker PWM shield is based on.
> So far, I'm able to control 44 solenoids using custom drivers and 2
> stacked PWM shields. This is an excellent alternative if you want to
> build a relatively cheap electro-mechanical piano setup.
> The problems i've run into:
> 1. if 2 or more messages get sent simultaneously, one of them
> might get dropped (this happens a lot)
This shouldn't happen and actually never happened in my own experience.
A single 2-byte message sets and one pin to HIGH and sets a timer for
that pin. So, if you need two set two pins simultaneously, you need to
send two 2-byte messages. I don't see how the code could omit a message,
unless two subsequent messages set the same pin.
If you modified the code, you can send me a copy, so I'll look into it.
> 1. the handshake does not seem to work on Linux (Ubuntu 11)
It's pretty crude. Whenever you send it a '255' (0xff) byte, it responds
with the following ASCII sequence: 'SOL 0 1'. You can easily test that
with [comport] directly.
The ugly thing is that [solenoiduino] has to make sure not to send any
0xff bytes and thus some values for periods are not allowed / replaced,
e.g 127, 255, 383 etc.
> 1. the original code only supports 16 solenoids
> This last one is the one that goes over my head, since the code uses
> that bit twiddling stuff, I can't figure out how to send the
> appropriate messages to any solenoids past 15. So, I'm a little stuck
> here, any help?
The solenoiduino code uses two bytes per message, while the first bit of
each is used for defining the byte order. This leaves 14 bits for the
payload. The current implementation uses 4 bits for the pin address and
10 bits for the duty cycle. If you can live with a lower duty cycle
resolution, you can shift some bits around. For instance, you could
adapt the bitmask to use 6 bits for the address (allows to control 64
solenoids) and use only 8 bit for the velocity / duty cycle.
Alternatively, you could extend the protocol to use 3 bytes per message.
This would give you a payload of 21 bits to be distributed between
address and duty cycle. Of course, this reduces your maximum message
rate by 1.5.
More information about the Pd-list