Page 1 of 1

Increase Sample Rate with MatLab (MexFile?)

Posted: Thu Oct 17, 2019 12:20 pm
by timosmd
Hello all,

for a project I need to acquire measurement data from a current (Hall-)sensor via MatLab.

To achieve this target I chose a Stemlab 125-14 as the datasheet for the slow analog input pins states that there is the possibility for 100kS/s.

Yesterday I set up my redpitaya and tried to gather the input voltage with MatLab, altered by a Potentiometer from 0-3.3V.

The problem I encountered is that I was able to achieve a maximum of 20(!) samples per second (with the most minimalistic matlab code possible), which is far away from the sample rate I need to achieve for the project (I would need at least a few thousand kS/s).

My guess is that the query function (volts1 = str2num(query(tcpipObj,'ANALOG:PIN? AIN1'))) in the MatLab code takes too long to read enough samples during a certain time period.

I thought a solution would be to start acquisition which writes the values to a buffer (which can then be read) by using SCPI commands - but RedPitayas technical support said it's not possible with the slow analog inputs (only fast ones).

So I had the idea to read the analog value in MatLab by calling a C-Function which uses API- instead of SCPI commands and should therefore be much faster.

But I have problems creating a MEX-File in MatLab to call the necessary C-Function. Did anyone maybe already do it like this or could help me out with this?


Sorry for these questions but I already googled/researched a lot and can't find any helpful information regarding this problem.

Hope you can help me with this.

Thanks!
TS