Continuous acquisition with FTDI module

9 visualizaciones (últimos 30 días)
Hugues DE CARVALHO
Hugues DE CARVALHO el 2 de Abr. de 2019
Comentada: Hugues DE CARVALHO el 26 de Jul. de 2021
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 comentarios
Tom K
Tom K el 26 de Jul. de 2021
Where you able to fix it?
Hugues DE CARVALHO
Hugues DE CARVALHO el 26 de Jul. de 2021
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 :)

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by