Moving Average on Red Pitaya example
-
- Posts: 32
- Joined: Wed Sep 13, 2023 12:46 pm
Moving Average on Red Pitaya example
Good morning,
I am working on the Red Pitaya FPGA Moving Average example (from: [https://redpitaya-knowledge-base.readth ... arage.html#][/url]). I have followed all the tutorial and when I read monitor 0x40600050 I get FEEDBACC.
Just when I open the oscilloscope from the web browser I get 0x00000000 from this command. After doing the monitor 0x40600008 3 I read 0s from the 0x40600008 as well. So, I am not being able to make the example work by connecting OUT1 to IN2. What do you think is going on? How can I fix it?
I would appreciate it if someone could help me with this. Thank you all in advance!
I am working on the Red Pitaya FPGA Moving Average example (from: [https://redpitaya-knowledge-base.readth ... arage.html#][/url]). I have followed all the tutorial and when I read monitor 0x40600050 I get FEEDBACC.
Just when I open the oscilloscope from the web browser I get 0x00000000 from this command. After doing the monitor 0x40600008 3 I read 0s from the 0x40600008 as well. So, I am not being able to make the example work by connecting OUT1 to IN2. What do you think is going on? How can I fix it?
I would appreciate it if someone could help me with this. Thank you all in advance!
-
- Posts: 32
- Joined: Wed Sep 13, 2023 12:46 pm
Re: Moving Average on Red Pitaya example
I tried this example using OS version 2.00 and 1.04 and neither version worked (I also tried to change the path of the fpga.conf (ScopeGenPro) in case this was related...) The example provided here [url][/https://lniv.fe.uni-lj.si/redpitaya/redpitaya-proc.htm] did work but only when using version 1.04.
- redpitaya
- Site Admin
- Posts: 967
- Joined: Wed Mar 26, 2014 7:04 pm
Re: Moving Average on Red Pitaya example
Hello TheGeri,
Thank you for reporting this and sorry for the late reply.
I will test it out on the 2.00 OS and make sure to update the tutorial. I'll let you know when it is fixed.
Modifying the fpga.conf only works on 1.04 OS or older, the same goes for the example at https://lniv.fe.uni-lj.si/redpitaya/redpitaya-proc.htm. As the way the FPGA is loaded has changed in 2.00, where you have to replace the existing fpga.bit.bin file with your own FPGA version (and make a back-up of the original).
Since the programmed FPGA register is working fine (you get the FEEDBACK), then it is most likely a mistake in the FPGA logic controlling the fast analog inputs/outputs.
Thank you for reporting this and sorry for the late reply.
I will test it out on the 2.00 OS and make sure to update the tutorial. I'll let you know when it is fixed.
Modifying the fpga.conf only works on 1.04 OS or older, the same goes for the example at https://lniv.fe.uni-lj.si/redpitaya/redpitaya-proc.htm. As the way the FPGA is loaded has changed in 2.00, where you have to replace the existing fpga.bit.bin file with your own FPGA version (and make a back-up of the original).
Since the programmed FPGA register is working fine (you get the FEEDBACK), then it is most likely a mistake in the FPGA logic controlling the fast analog inputs/outputs.
-
- Posts: 32
- Joined: Wed Sep 13, 2023 12:46 pm
Re: Moving Average on Red Pitaya example
Good morning,
Don't worry and thank you very much, I will be very grateful if you can let me know when the example is updated.
On the other hand, I would like to use the oscilloscope's web browser adding my own functionalities. For example, clicking a button (that is now implemented) and calling my own functionality (instead of the one designed, for example). Or adding another button on the screen itself... Do you have a tutorial or could you give me clues or advice on how to continue with this path?
Thank you in advance,
Kind regards
Don't worry and thank you very much, I will be very grateful if you can let me know when the example is updated.
On the other hand, I would like to use the oscilloscope's web browser adding my own functionalities. For example, clicking a button (that is now implemented) and calling my own functionality (instead of the one designed, for example). Or adding another button on the screen itself... Do you have a tutorial or could you give me clues or advice on how to continue with this path?
Thank you in advance,
Kind regards
- redpitaya
- Site Admin
- Posts: 967
- Joined: Wed Mar 26, 2014 7:04 pm
Re: Moving Average on Red Pitaya example
Good day to you too,
We have a short tutorial on web applications here:
https://redpitaya.readthedocs.io/en/lat ... plications
You can then use the examples to get you started and then modify the existing oscilloscope application code that is available here:
https://github.com/RedPitaya/RedPitaya/ ... copegenpro
Sincerly
We have a short tutorial on web applications here:
https://redpitaya.readthedocs.io/en/lat ... plications
You can then use the examples to get you started and then modify the existing oscilloscope application code that is available here:
https://github.com/RedPitaya/RedPitaya/ ... copegenpro
Sincerly
-
- Posts: 32
- Joined: Wed Sep 13, 2023 12:46 pm
Re: Moving Average on Red Pitaya example
Good afternoon,
Perfect, I'll look at it. Thank you very much!
Kind regards,
Perfect, I'll look at it. Thank you very much!
Kind regards,
-
- Posts: 32
- Joined: Wed Sep 13, 2023 12:46 pm
Re: Moving Average on Red Pitaya example
Good afternoon,
I followed the first example: https://redpitaya.readthedocs.io/en/lat ... eparations using Latest Stable version (2.04-35). When compiling I get the following:
But I don't see the application in the web browser. Do you know what could be the reason?
Thanks in advance again,
Kind regards,
I followed the first example: https://redpitaya.readthedocs.io/en/lat ... eparations using Latest Stable version (2.04-35). When compiling I get the following:
Code: Select all
root@rp-f06276:/opt/redpitaya/www/apps/myFirstApp# make INSTALL_DIR=/opt/redpitaya
make -C src
make[1]: Entering directory '/opt/redpitaya/www/apps/myFirstApp/src'.
g++ -c -Wall -fPIC -Os -s -std=c++11 -I/opt/redpitaya/include -I/opt/redpitaya/include/api2 -I/opt/redpitaya/include/apiApp -I/opt/redpitaya/rp_sdk -I/opt/redpitaya/rp_sdk/libjson main.cpp -o main.o
g++ main.o -o ../controllerhf.so -shared -Wall -fPIC -Os -s -L/opt/redpitaya/lib -L/opt/redpitaya/rp_sdk -Wl,--whole-archive,--no-as-needed -lcryptopp -lrpapp -lrp -lrp_sdk -Wl,--no-whole-archive
make[1]: Abandoning directory '/opt/redpitaya/www/apps/myFirstApp/src'.
Thanks in advance again,
Kind regards,
-
- Posts: 32
- Joined: Wed Sep 13, 2023 12:46 pm
Re: Moving Average on Red Pitaya example
Update: If instead of using the template file I used the one of the following examples, it worked correctly!
- redpitaya
- Site Admin
- Posts: 967
- Joined: Wed Mar 26, 2014 7:04 pm
Re: Moving Average on Red Pitaya example
Hello The Geri,
Sorry for the late reply. I found the mistake after a lot of checking.
The moving average.vhd in the current form causes and overflow in the "sum" variable.
Since the sum has 14 bits and each of the registers also has 14 bits this results in an overflow, which causes the error. I have no idea why this works on 1.04 OS - it should not.
The solution is to resize the sum to 16 bits (sum of three binary numbers of 14 bits can have a maximum of 16 bits).
Here is the new code:
Sorry for the late reply. I found the mistake after a lot of checking.
The moving average.vhd in the current form causes and overflow in the "sum" variable.
Since the sum has 14 bits and each of the registers also has 14 bits this results in an overflow, which causes the error. I have no idea why this works on 1.04 OS - it should not.
The solution is to resize the sum to 16 bits (sum of three binary numbers of 14 bits can have a maximum of 16 bits).
Here is the new code:
Code: Select all
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.all;
entity moving_average is
Port ( data_i : in std_logic_vector (13 downto 0); -- unfiltered adc data in
clk_i : in std_logic; -- bus clock
rstn_i : in std_logic; -- bus reset - active low
tag_i : in unsigned (1 downto 0); -- filter value
data_o : out std_logic_vector (13 downto 0)); -- filtered adc data out
end moving_average;
architecture Behavioral of moving_average is
type mem_t is array (0 to 2) of signed (13 downto 0);
signal regs: mem_t := (others =>(others => '0')); -- buffer for moving average algorithm
signal sum: signed(15 downto 0);
begin
regs(0) <= signed(data_i);
process (clk_i)
begin
if(rising_edge(clk_i)) then
if (rstn_i = '0') then
sum <= (others => '0');
else
case tag_i is
-- regs
when "01" => data_o <= std_logic_vector(resize(sum, 14)); -- leave the same
-- regs / 2
when "10" => data_o <= std_logic_vector(resize(shift_right(sum, 1), 14)); -- divide by 2
-- (regs * 85) / 256
when "11" => data_o <= std_logic_vector(resize(shift_right(sum * 85, 8), 14)); -- mulitply by 0.33203
-- (regs * 85) / 256
when others => data_o <= std_logic_vector(resize(shift_right(sum * 85, 8), 14)); -- mulitply by 0.33203
end case;
if (tag_i(1) = '1') then
regs(1) <= regs(0);
else
regs(1) <= (others => '0');
end if;
if (tag_i(0) = '1') then
regs(2) <= regs(1);
else
regs(2) <= (others => '0');
end if;
sum <= resize(regs(0), 16) + resize(regs(1), 16) + resize(regs(2), 16);
end if;
end if;
end process;
end Behavioral;
- redpitaya
- Site Admin
- Posts: 967
- Joined: Wed Mar 26, 2014 7:04 pm
Re: Moving Average on Red Pitaya example
I will update the tutorial on the web with the new version. Thank you for pointing this out.
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 1 guest