FPGA Cyclone IV DueProLogic Controls Raspberry Pi Camera
by roy_wch in Circuits > Raspberry Pi
988 Views, 0 Favorites, 0 Comments
FPGA Cyclone IV DueProLogic Controls Raspberry Pi Camera
Despite the FPGA DueProLogic is officially designed for Arduino, we are going to make the FPGA and Raspberry Pi 4B communicable.
Three tasks are implemented in this tutorial:
(A) Simultaneously press the two push buttons on FPGA to flip the angle of RPi camera.
(B) Raspberry Pi 4B controls the external LED circuit of FPGA.
(C) Live stream the Raspberry Pi Camera on Browser via WiFi
Build Electronic Circuit
Edit Verilog Code
When you buy the FPGA DueProLogic, you should receive a DVD. After you open "Projects_HDL", you should see the original HDL code file. After you set up the pin planner, add the highlighted code as shown in section 2A, 2B, 2C and 2D.
2A: To activate push buttons, you have to use this code
//Push Button Switches
input wire UBA,
input wire UBB
To communicate with Raspberry Pi, you need to add these.
reg sel_send; //activate Raspberry pi
reg rece; //received from raspberry pi
2B: To assigns values to the ports, you should edit the code accordingly
assign XIO_1[3] = start_stop_cntrl;
assign XIO_2[2] = rece; //output HIGH or LOW in LED circuit
assign XIO_2[3] = ~UBA; //push button
assign XIO_2[4] = UBB; //push button
assign XIO_2[5] = sel_send; // FPGA sends signal to raspberry pi
assign sel_read= XIO_5[1]; //FPGA receives signal from raspberry pi
assign c_enable = XIO_5[2]; //XIO_5 -- UB57 -- D17
assign LEDExt = XIO_5[5];
2C: If two push buttons are pressed simultaneously, the FPGA sends HIGH output to Raspberry Pi.
always @(sel_send or UBB or UBA) //send to RPi
begin
if (UBB == 1'b0 && UBA == 1'b0)
sel_send = 1'b1;
else
sel_send = 1'b0;
end
2D: The FPGA reads signal from Raspberry Pi with the clock frequency of 66MHz. The port XIO_2[2] is linked to 'rece'.
always @(sel_read) //read pi
begin
if (sel_read == 1'b1)
rece = 1'b0;
else
rece = 1'b1;
end
Upload Verilog Code
Then upload the compiled pof file to the FPGA. If no hardware is detected automatically, click "Hardware Setup" to correct it manually
Upload Raspberry Pi Code.
The highlighted lines allows the FPGA communicating with Raspberry Pi.
The full Raspberry Pi code for this project, https://roywchpi.blogspot.com/2020/06/12-fpga-cycl...
A = GPIO.input(pin) #read FPGA
print(A);
if(A==1):
camera.rotation = 0
GPIO.output(18,GPIO.LOW) #send to FPGA
if(A==0):
camera.rotation = 180
GPIO.output(18,GPIO.HIGH) #send to FPGA
Let's Try It!
Open your browser and type your IP address e.g. 192.168.xx.xxx:8000.
After all, the system should work!