libftdi Archives

Subject: Re: Bitbang speed/latency

From: "Peter Smith" <pete@xxxxxxxxxxxxxx>
To: "Jim Paris" <jim@xxxxxxxx>
Cc: "Peter Smith" <pete@xxxxxxxxxxxxxx>, libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Sun, 8 Mar 2015 01:21:44 -0000
> Peter Smith wrote:
>> Hi,
>>
>> I'm using the Device::FTDI Perl wrapper for libftdi to communicate
>> with an FT230X, which in turn is driving 16 cascaded shift
>> registers.
>> The communication speed is decent, but I'm hoping for more if
>> possible.
>>
>> Here's my code:
>>
>> use Device::FTDI;
>>
>> ##  0x08 CTS - LATCH
>> ##  0x01 TX - DATA
>> ##  0x02 RX - CLOCK
>>
>> $dev = Device::FTDI->new('vendor' => 0x0403, 'product' => 0x6015) ||
>> print $!;
>> $dev->set_bitmode(0xff, 0x01);
>>
>>    for (1...128) {
>>         $dev->write_data(0x01);
>>         $dev->write_data(0x03);
>>    }
>>
>>    $dev->write_data(0x08);
>>    $dev->write_data(0x00);
>
> Try something like this (untested):
>
> $data = '';
> for (1...128) {
>     $data .= chr(0x01);
>     $data .= chr(0x03);
> }
> $data .= chr(0x08);
> $data .= chr(0x00);
> $dev->write_data($data);
>
> Jim
>

Hi Jim,

It's actually one of your MicroFTX breakout boards that I'm using
(cheers - they arrived yesterday).

I've tried your code, but no joy - I suspect because it's now going
too fast. Because the FTX is talking to shift registers I need to set
my data pin high/low, then pulse the clock, then set the data pin,
then pulse the clock etc etc. Previously I had some usleep statements
in my code to sleep for a few ms between writes, but because of the
latency they're not needed. The clock pulses need to be a minimum of
40ns.

Thanks,
Pete




--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread