Problem with the Generate signal pulses example in Matlab

Applications, development tools, FPGA, C, WEB
Post Reply
Dirkowitz
Posts: 2
Joined: Sun Jul 24, 2016 6:14 pm

Problem with the Generate signal pulses example in Matlab

Post by Dirkowitz » Fri Sep 02, 2016 11:02 am

Hi everybody,

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);

lucy
Posts: 1
Joined: Mon Sep 19, 2016 6:58 am

Re: Problem with the Generate signal pulses example in Matla

Post by lucy » Wed Sep 21, 2016 10:01 am

Dear Dirkowitz,
since the amplitude of the Signal is between 0-1 V ,the code below such as :
%x=sin(t)+1/3*sin(10*t); % No Outputsignal why?
%x=sin(t)+1/3*sin(3*t+pi/4); % No Outputsignal why?
those signal are out of range,may be you can try to fix the signal like this:x=0.8*(sin(t)+1/3*sin(10*t));

Hope these help!

Dirkowitz
Posts: 2
Joined: Sun Jul 24, 2016 6:14 pm

Re: Problem with the Generate signal pulses example in Matla

Post by Dirkowitz » Thu Sep 29, 2016 3:10 pm

Thank you, that was exactly my failure. Now everything I want to do with the Red Pitaya works. Thanks a lot for your help.

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 99 guests