[PD] how to pd2stepper motor?

Hans-Christoph Steiner hans at eds.org
Thu Nov 2 16:49:14 CET 2006


On Nov 2, 2006, at 9:53 AM, Martin Peach wrote:

> Hans-Christoph Steiner wrote:
>>
>> On Oct 6, 2006, at 9:53 AM, Martin Peach wrote:
>>
> ...
>>> In the Pd_firmware.pde code the pins are set on at a time even if  
>>> the data is sent as two bytes:
>>>
>>>      for(i=0; i<7; ++i) {
>>>        mask = 1 << i;
>>>        if( (digitalPinStatus & mask) && !(pwmStatus & mask) ) {
>>>          digitalWrite(i, inputData & mask);
>>>        }
>>>      }
>>
>> I am definitely open to suggestions as to how to make the code  
>> work better.  I've been focused on the protocol design, so little  
>> optimization has happened.  In this case, its not quite as simple  
>> as just getting the byte from the serial port and writing it to  
>> the ports.  If a PWM is running, then you don't want to write to  
>> that port, that's what pwmStatus is doing.
>>
>> From what I read about the functions that write a byte at a time  
>> to the digital pins, you have to have all of the pins set to  
>> OUTPUT in order to use them.  But I could be wrong.
>>
> In assembly you can definitely write bytes to the ports, the PWM  
> pins and any other special-purpose pins just ignore the values. In  
> the PIC version that's what I do, because the bit-write  
> instructions don't work properly unless all the pins are outputs. I  
> guess it's Wiring that needs looking at...


There is not a Wiring/Arduino function for writing bytes, but in that  
environment you can just use avr-libc and other libs as if you were  
writing straight C/C++:

#include <blah.h>

blah_bytewrite(writeThisByte);

The Wiring/Arduino environment basically just does some  
preprocessing, otherwise its straight C++ compiled by gcc.

.hc

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

                                               http://at.or.at/hans/






More information about the Pd-list mailing list