Continuous acquisition with FTDI module
조회 수: 8 (최근 30일)
이전 댓글 표시
Good afternoon,
I am trying to settup a continuous acquisition through a FTDI Module FT232 and am having trouble with "real time" data processing and display.
I am using a .dll file provided by FTDI and this is how I can write/read data:
%declaration of buffers and other things
for k = 1:length(OutputBuffer_uint8_cell)
ftStatus = calllib(ftd2xx,'FT_Write',pChannelHandle,OutputBuffer_uint8_cell{k},length(OutputBuffer_uint8_cell{k}), dwNumBytesSent); %Writes OutputBuffer_uint8_cell{k}
ftStatus = calllib(ftd2xx, 'FT_Read',pChannelHandle, InputBuffer_cell{k}, length(InputBuffer_cell{k}.Value), dwNumBytesRead); %Reads data from FTDI buffer and puts it in InputBuffer_cell{k}
end
This is working well, here is an oscillogram of the SPI signals: (the first gap is due to the FTDI module)

Now if I add some processing on my output buffer :
%declaration of buffers and other things
for k = 1:length(OutputBuffer_uint8_cell)
ftStatus = calllib(ftd2xx,'FT_Write',pChannelHandle,OutputBuffer_uint8_cell{k},length(OutputBuffer_uint8_cell{k}), dwNumBytesSent); %Writes OutputBuffer_uint8_cell{k}
ftStatus = calllib(ftd2xx, 'FT_Read',pChannelHandle, InputBuffer_cell{k}, length(InputBuffer_cell{k}.Value), dwNumBytesRead); %Reads data from FTDI buffer and puts it in InputBuffer_cell{k}
InputBuffer_dec_array = 2^40*double(InputBuffer_cell{k}.Value(1:6:end))+2^32*double(InputBuffer_cell{k}.Value(2:6:end))+2^24*double(InputBuffer_cell{k}.Value(3:6:end))+2^16*double(InputBuffer_cell{k}.Value(4:6:end))+2^8*double(InputBuffer_cell{k}.Value(5:6:end))+double(InputBuffer_cell{k}.Value(6:6:end)); %decode
InputBuffer_hex_cell = arrayfun(@(x) dec2hex(x,12), InputBuffer_dec_array, 'UniformOutput', false); %dec -> hex
end
There are now gaps between each SPI Write instruction:

The size of those gaps is linear to the number of SPI samples read. Those gaps mean that I'm missing samples on my slave device and that isn't satisfactory for my application.
In oder to remove those gaps I think I would need to:
- speed up the processing so that its duration is lower than the acquisition
- multithread the acquisition and processing
Unfortunately, I don't know how I could do that and couldn't find anything online. Would anyone have any hint?
Thanks in advance!
댓글 수: 2
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!