I have a problem with the example code Generate signal pulses, because I want to send different pulses as the example pulses, but I don't get a signal on my out. I don't understand why, because I just change the waveform of the pulses. The pulse has the same length as the example pulse. Maybe somebody can help me.
Here is my Matlab code.
Code: Select all
close all
clear all
clc
f=10000; % Frequency of one signal period
amp=1; % Amplitude of the Signal can choose between 0-1 V
fs=200*f;
%% Configuration for the Red-Pitaya connection
%% Configuration for the Red-Pitaya connection
IP= '192.168.111.27'; % Input IP of your Red Pitaya...
port = 5000; % If you are using WiFi then IP is:
tcpipObj=tcpip(IP, port); % 192.168.128.1
tcpipObj.InputBufferSize = 16384*64;
tcpipObj.OutputBufferSize = 16384*64;
flushinput(tcpipObj)
flushoutput(tcpipObj)
%% Open connection with your Red Pitaya and close previous
x=instrfind;
fclose(x);
fopen(tcpipObj);
tcpipObj.Terminator = 'CR/LF';
%% Calcualte arbitrary waveform with 16384 samples
% Values of arbitrary waveform must be in range from -1 to 1.
N=16383;
t=0:(2*pi)/N:2*pi;
%x=0.5*sin(t)+0.1;
x=sin(t)+1/3*sin(3*t);
%x=sin(t)+1/3*sin(10*t); % No Outputsignal why?
%x=sin(t)+1/3*sin(3*t+pi/4); % No Outputsignal why?
%Chirpsignal Test
%t = 0:0.001:2;
%x = chirp(t,0,10,20); % No Outputsignal why?
x=resample(x,N,length(real(x)));
plot(x)
grid on
%% Convert waveforms to string with 5 decimal places accuracy
waveform_ch_1_0 =num2str(x,'%1.5f,');
% latest are empty spaces “,”.
waveform_ch_1 =waveform_ch_1_0(1,1:length(waveform_ch_1_0)-3);
%%
fprintf(tcpipObj,'GEN:RST') % Reset to default settings
fprintf(tcpipObj,'SOUR1:FUNC ARBITRARY'); % Set function of output signal
fprintf(tcpipObj,['SOUR1:TRAC:DATA:DATA ' waveform_ch_1]) % Send waveforms to Red Pitya
fprintf(tcpipObj,['SOUR1:VOLT ',num2str(amp)]); % Set ampliude of output signal
fprintf(tcpipObj,['SOUR1:FREQ:FIX ',num2str(f)]); % Set frequency of output signal
fprintf(tcpipObj,'OUTPUT1:STATE ON');
fclose(tcpipObj);