Testing AXI_ADC

Just about everything about Red Pitaya
Post Reply
thomasliuchang
Posts: 31
Joined: Mon Apr 18, 2016 12:30 pm

Testing AXI_ADC

Post by thomasliuchang » Thu May 12, 2016 2:16 pm

Hello,

I want to continuously sample the data with a trigger. Therefore, I connected the RP input1 with sine signal(amplitude: 1V, frequency 20kHz), input2 with ramp signal(amplitude: 0.8V, frequency 50kHz). Then, I tried the axi_adc (Thanks to Nils) without any modification in the Redpitaya/Examples/C in the following way.

Code: Select all

redpitaya> cd RedPitaya/
redpitaya> make api
Makefile:134: warning: overriding recipe for target 'tmp'
Makefile:131: warning: ignoring old recipe for target 'tmp'
make -C api/rpbase
make[1]: Entering directory '/root/RedPitaya/api/rpbase'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/root/RedPitaya/api/rpbase'
make -C api/rpbase install INSTALL_DIR=/root/RedPitaya/build
make[1]: Entering directory '/root/RedPitaya/api/rpbase'
make -C src install INSTALL_DIR=/root/RedPitaya/build
make[2]: Entering directory '/root/RedPitaya/api/rpbase/src'
mkdir -p /root/RedPitaya/build/lib
mkdir -p /root/RedPitaya/build/include
cp  ../../lib/librp.so /root/RedPitaya/build/lib
cp -r ../../include/redpitaya /root/RedPitaya/build/include
make[2]: Leaving directory '/root/RedPitaya/api/rpbase/src'
make[1]: Leaving directory '/root/RedPitaya/api/rpbase'
redpitaya> cd Examples/C
redpitaya> make axi_adc
gcc -g -std=gnu99 -Wall -Werror -I../../api/include -L ../../api/lib -lm -lpthread -lrp    axi_adc.c   -o axi_adc
redpitaya> LD_LIBRARY_PATH=/opt/redpitaya/lib ./axi_adc
The configuration and interface of the system is shown in the picture. It should work well.
interface.png
Then I tried to use Matlab UDP receiver to receive the data. Here is the help of matlab http://cn.mathworks.com/help/instrument/udp.html

Code: Select all

clear all; clc;
u = udp('192.168.1.1',5001, 'LocalPort', 9000);
fopen(u)
A=fread(u, 10);
fclose(u)
However, there isn't any data transferred to the computer. Did anybody use Matlab UDP to transfer data from RP to computer?
Or, could you please give me some suggestions or references for data transfer from RP to computer using the UDP protocol? Thank you very much.

Kind regards,
Chang
You do not have the required permissions to view the files attached to this post.

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Testing AXI_ADC

Post by Nils Roos » Thu May 12, 2016 4:56 pm

From the description of the udp object it seems that this object can only be used to create outgoing connections. You need something that creates a listening socket and accepts incoming connections. (compare http://cn.mathworks.com/help/instrument ... ckets.html)

Maybe the udp object is still the right way, but you should use 5001 as the 'LocalPort'.

thomasliuchang
Posts: 31
Joined: Mon Apr 18, 2016 12:30 pm

Re: Testing AXI_ADC

Post by thomasliuchang » Fri May 13, 2016 9:15 am

Hello Nils,

Thanks for your reply. I tried to used the 5001 as the localport but it still didn't work.

I am not sure for the following points:

1.To create the UDP in matlab(http://ch.mathworks.com/help/instrument ... hlight=udp), we should define the Remote address, remote port and local port.
For the server defined in axi_adc.c, Is this (192.168.1.1) a remote address? What is the data type (uint8, uint16, uint32 or double) in the UDP?

Code: Select all

#define SERVER_IP_ADDR          "192.168.1.1"
#define SERVER_IP_PORT_A        5001
#define SERVER_IP_PORT_B        5002
2. My LAN IP is 152.88.82.76. Should I use this address in the connection?

3. I used the dsp.UDPReceiver to receive UDP packets from network(http://ch.mathworks.com/help/dsp/ref/ds ... class.html), which only need to defined the LocalIPPort (I defined it as 5001) and RemoteIPAddress (I defined it as 192.168.1.1), but it also doesn't work. The codes are as follows:

Code: Select all

clear all;clc
hudpr = dsp.UDPReceiver('LocalIPPort',5001,'RemoteIPAddress','152.88.82.76','ReceiveBufferSize',8192,'MaximumMessageLength',255,'MessageDataType','uint32');
bytesReceived = 0;
for k = 1:20
   dataReceived = step(hudpr);
   bytesReceived = bytesReceived + length(dataReceived);
end
release(hudpr);
fprintf('Bytes received: %d\n', bytesReceived);
May I ask you how did you test the UDP in axi_adc before? I will really appreciate if you could give me some references. Thank you very much!

Best regards,
Chang

thomasliuchang
Posts: 31
Joined: Mon Apr 18, 2016 12:30 pm

Re: Testing AXI_ADC

Post by thomasliuchang » Fri May 13, 2016 2:03 pm

Hi, Nils,

I have some new progress.

The RP is the remote server (with the LAN IP 152.88.82.76 for my computer). We should know the local IP Address (152.88.82.147). Then I revised the configuration of the axi_adc.c and make the file.

Code: Select all

/* configuration constants */
#define SERVER_IP_ADDR          "152.88.82.147"
#define SERVER_IP_PORT_A        12345
#define SERVER_IP_PORT_B        12346
By using an UDP test tool, I can see the data transfer from RP to my computer.
udptesttool.png
Also, I can use the Matlab to acquire the data.

Code: Select all

clear all;clc
hudpr = dsp.UDPReceiver('LocalIPPort',12345,'RemoteIPAddress','152.88.82.76','ReceiveBufferSize',8192,'MaximumMessageLength',255,'MessageDataType','uint8');
bytesReceived = 0;
dataReceived = step(hudpr);
bytesReceived = bytesReceived + length(dataReceived);
release(hudpr);
fprintf('Bytes received: %d\n', bytesReceived);
But the data I received does not make sense. This should be caused by the wrong data type. The Matlab UDP receiver supports the data types | double | single | int8 | uint8 | int16 | uint16 | int32 | uint32 | logical |.
What is the data type that the RP send by UDP?

Looking forward to hearing from you. Thank you very much!

Best regards,
Chang
You do not have the required permissions to view the files attached to this post.

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Testing AXI_ADC

Post by Nils Roos » Sat May 14, 2016 2:32 pm

Hi Chang,

the data type is int16.
Are you using the 0.95 image for these experiments ? It is possible that the data you receive is not correct, there was an error in the AXI logic and I don't know if the version 0.95 already has the corrections built in.
If your data seems wrong, try loading this bitstream (with "cat red_pitaya.bit >/dev/xdevcfg").

thomasliuchang
Posts: 31
Joined: Mon Apr 18, 2016 12:30 pm

Re: Testing AXI_ADC

Post by thomasliuchang » Mon May 16, 2016 11:06 am

Hi Nils,

Yes, I am using the 0.95 image in the experiment. According to your suggestion, I have loaded the bitstream. Then, I can obtain the correct data. Thank you very much!

I have one more question.
Using the following matlab code, I can obtain several packaged data with 16384 byte (sometimes it drops to less byte, I understand that from viewtopic.php?p=4895#p4895)

Code: Select all

clear all;clc
hudpr = dsp.UDPReceiver('LocalIPPort',12345,'RemoteIPAddress','152.88.82.76','ReceiveBufferSize',16384,'MaximumMessageLength',8192,'MessageDataType','int16');
i=1;
while (1)
       dataReceived= step(hudpr);
       real_data(:,i)=dataReceived;
       i=i+1;
end
release(hudpr);
In this way, I can obtain a matrix real_data with 8192 rows (8192 sampled points with int16 data type) and N columns. I have checked the sampled data in each column is continuous and with good quality. From the axi_adc.c, I know the ACQUISITION_LENGTH is 200000. In other words, I can obtain the continuously sampled 200000 points. To my opinion, the data in the N columns should be in a continuous way, but they are not. In addition, the number of points I acquired does not equal to 200000.

Code: Select all

/* configuration constants */
#define SERVER_IP_ADDR          "152.88.82.147"
#define SERVER_IP_PORT_A        12345
#define SERVER_IP_PORT_B        12346
#define ACQUISITION_LENGTH      200000          /* samples */
#define PRE_TRIGGER_LENGTH      40000           /* samples */
#define DECIMATION              DE_8            /* one of enum decimation */
#define TRIGGER_MODE            TR_CH_A_RISING  /* one of enum trigger */
#define TRIGGER_THRESHOLD       0500            /* ADC counts, 2048 ≃ +0.25V */

/* internal constants */
#define READ_BLOCK_SIZE         16384
#define SEND_BLOCK_SIZE         17752
#define RAM_A_ADDRESS           0x1e000000UL
#define RAM_A_SIZE              0x01000000UL
#define RAM_B_ADDRESS           0x1f000000UL
#define RAM_B_SIZE              0x01000000UL


Maybe I misunderstood some ideas in axi_adc.c. How can I obtain the 200000 continuously sampled data points?

Looking forward to hearing from you.
With my heartfelt thanks,
Chang

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: Google [Bot] and 98 guests