Continuous acquisition with FTDI module

조회 수: 8 (최근 30일)
Hugues DE CARVALHO
Hugues DE CARVALHO 2019년 4월 2일
댓글: Hugues DE CARVALHO 2021년 7월 26일
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)no processing--00000.png
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:
processing--00000.png
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
Tom K
Tom K 2021년 7월 26일
Where you able to fix it?
Hugues DE CARVALHO
Hugues DE CARVALHO 2021년 7월 26일
I ended up using a NI HSDIO module for continuous acquisitions.
https://forums.ni.com/t5/LabVIEW/Generating-signals-on-Trigger-interrupt-with-HSDIO-PXI-6451/m-p/3915326?profile.language=en
Hope that helps :)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by