Page 1 of 1

Matlab Slow Analog IO code issue

Posted: Tue Jun 05, 2018 7:07 pm
by davilloo
Hi !

For my project I'm going to use slow analog IO. For testing, I'm connecting the AO# to the AI# to measure the voltages. But when I use a variable to set the output voltage, it gives to the output the last value given before using the variable to set the value. Here is the code:

%% Define Red Pitaya as TCP/IP object

IP= ''; % Input IP of your Red Pitaya...
port = 5000;
tcpipObj=tcpip(IP, port);

%% Open connection with your Red Pitaya

tcpipObj.Terminator = 'CR/LF';


fprintf(tcpipObj,'ANALOG:PIN AOUT0,G'); % 0.3 Volts is set on output 0
fprintf(tcpipObj,'ANALOG:PIN AOUT1,R');
fprintf(tcpipObj,'ANALOG:PIN AOUT2,C');
fprintf(tcpipObj,'ANALOG:PIN AOUT3,P');

volts0=str2num(query(tcpipObj,'ANALOG:PIN? AIN0'))
volts1=str2num(query(tcpipObj,'ANALOG:PIN? AIN1'))
volts2=str2num(query(tcpipObj,'ANALOG:PIN? AIN2'))
volts3=str2num(query(tcpipObj,'ANALOG:PIN? AIN3'))

%% Close connection with Red Pitaya


Should I use a loop to refresh?