[PD] how to pd2stepper motor?
Martin Peach
martin.peach at sympatico.ca
Thu Nov 2 15:53:53 CET 2006
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...
Martin
More information about the Pd-list
mailing list