[PD] pduino digital outs

Hans-Christoph Steiner hans at eds.org
Fri Oct 13 01:15:02 CEST 2006


Nice!  I guess its time to rename the [arduino] object...  
[microcontroller]?

Oops, I forgot to update the help patch.  I recently changed the  
order, and I changed the arduino-test.pd patch to match.  I didn't  
write the arduino-help.pd so I guess I overlooked that change.

But yes, the firmware and the arduino-test.pd patch should be the  
proper order.  I changed the order because I wanted to have the bits  
in the same order as it would be represented when writing out a  
digital number: MSB leftmost and LSB rightmost.  Plus I think it made  
some implementations a bit easier.  Feel free to update the help  
patch, I don't think I'll get around to it for a few days.

Also, I think the basic protocol is stable now, and can remain  
backwards compatible even after adding new features.  But I would  
like to hear any ideas, comments, feedback on the protocol.  I want  
to get it ironed out so that we can then start implementing objects  
in many languages, like Processing, Max, Java, Ruby, Python, etc.  
without worrying about breaking all of them when adding to the firmware.

.hc

On Oct 12, 2006, at 2:33 PM, <martin.peach at sympatico.ca>  
<martin.peach at sympatico.ca> wrote:

> I'm trying to implement the pduino using a PIC16F767.
> So far I have the analog ins and digital ins working well.
> In testing I find that the arduino-help patch sends digital outs as  
> 229, low7, high7, that is, the digital out token followed by the  
> bit pattern for the low 7 bits and then the bit pattern for the  
> high 7 bits. On the other hand, the Pd_firmware.pde code expects  
> the high byte first:
>
>     if(firstInputByte) {
>       // output data for pins 7-13
>       for(i=7; i<TOTAL_DIGITAL_PINS; ++i) {
>         mask = 1 << i;
>         if( (digitalPinStatus & mask) && !(pwmStatus & mask) ) {
>           // inputData is a byte and mask is an int, so align the  
> high part of mask
>           digitalWrite(i, inputData & (mask >> 7));
>         }
>       }
>       firstInputByte = false;
>     }
>     else { //
>       for(i=0; i<7; ++i) {
>         mask = 1 << i;
>         if( (digitalPinStatus & mask) && !(pwmStatus & mask) ) {
>           digitalWrite(i, inputData & mask);
>         }
>       }
>     }
>
> ...so which is correct?
>
> Also the digitalWrite(i, inputData & mask) should probably be  
> digitalWrite(i, (inputData && mask)?HIGH:LOW).
>
> Martin
>
>
>
> _______________________________________________
> PD-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/ 
> listinfo/pd-list


------------------------------------------------------------------------

Looking at things from a more basic level, you can come up with a  
more direct solution... It may sound small in theory, but it in  
practice, it can change entire economies.     - Amy Smith






More information about the Pd-list mailing list