You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
581 B
24 lines
581 B
% this is an example of sampling the ADC from Matlab and then plotting a
|
|
% FFT graph. The ADC unit called 'adc' is configured to use PA1 as Ch. 0
|
|
|
|
%transport = py.gex.TrxSerialThread(pyargs('port', '/dev/ttyUSB1', 'baud', 57600));
|
|
transport = py.gex.TrxRawUSB();
|
|
client = py.gex.Client(transport);
|
|
adc = py.gex.ADC(client, 'adc');
|
|
|
|
L=1000;
|
|
Fs=1000;
|
|
|
|
adc.set_sample_rate(uint32(Fs));
|
|
data = adc.capture(uint32(L));
|
|
data = double(py.array.array('f',data));
|
|
|
|
Y = fft(data);
|
|
P2 = abs(Y/L);
|
|
P1 = P2(1:L/2+1);
|
|
P1(2:end-1) = 2*P1(2:end-1);
|
|
|
|
f = Fs*(0:(L/2))/L;
|
|
plot(f,P1)
|
|
|
|
client.close()
|
|
|