Ultrasonic obstacle avoidance car based on FPGA, using ego1 100 hz clock, we can define your own different duty ratio of PWM to control the motor speed and steering Angle, we can write their own timer for ultrasonic wave back and forth the time required to measure distance, according to the distance returned to control the motor speed and the rotary Angle of steering gear, We can also add the function of OpenMV recognizing color blocks to simulate the car recognizing traffic lights and controlling the start and stop of cars. Combined with the above description, we can realize a color control start and stop using ultrasonic ranging obstacle avoidance car through FPGA. The following figure
According to the project task requirements, we can roughly divide the target tasks into the following points:
1. Use counter to achieve different duty cycle PWM output.
2. By controlling the trigger signal TRIG (TTL of 10us), the internal loop sends out 8 40KHZ pulses, namely driving ultrasonic wave, receives echo signal, and obtains the distance through echo.
3. Display the ultrasonic value on the nixie tube.
3. Configure the openMV terminal to transmit the color block information through the high and low levels of the I/O port.
To achieve the goal, we set up six modules (Vivado) in FPGA as shown in the figure below.
Module 1: Counter
The frequency division module detects the distance every 0.5s to determine whether to turn.
Module 2: Ultrasonic module
Issue triG regularly, detect echo signal, count and convert to distance.
Module 3: conversion module
Conversion module will be binary distance into four binary, convenient subsequent nixie tube display.
Module 4: Nixie tube module
The converted four-digit binary distance is displayed on the nixie tube.
Module 5: PWM module (motor)
By setting specific duty cycle PWM wave to make the motor reach the corresponding speed, and at the same time receive openMV power-on and power-off command.
Module 6: PWM module (steering gear)
By setting a specific duty ratio of THE PWM wave to turn the steering gear to the corresponding Angle
Hardware platform:
Ego-one(FPGA main control) :
Motor (PWM control) :
Steering gear (PWM control) :
Battery (power supply) :
Pressure stabilizer plate (pressure stabilizer) :
Motor drive (converting analog signal to motor adaptive signal) :
Ultrasonic (for ranging) :
Openmv camera (identifies color blocks and uploads information to ego1) :
Accordingly, we can design the following scheme:
1. Open the switch SW1, identify the specific color block, and move the car forward (OpenMV + motor)
2. Digital tube display front ultrasonic ranging indicator (ultrasonic)
3. If the number of pre-ultrasonic ranging indicator is greater than 80cm, the direction remains unchanged
If the number is between 80cm and 40cm, turn the direction by a small Angle
If the number shown is less than 40cm, turn a large Angle in the direction (steering gear)
4. Rotation direction judgment: through the comparison of the two ultrasonic ranging, if the steering gear to rotate the Angle, to the direction of the ultrasonic ranging, to achieve obstacle avoidance function.
5. The distance of the front ultrasonic is positively correlated with the PWM duty ratio of the motor (ultrasonic + motor)
6. Identify specific color blocks, car stop (OpenMV)
Some I/O port Settings:
Io mouth | FPGA IO PIN | Corresponding program variable | role |
IO_L18N | G17 | Go1 | Motor analog signal |
IO_L18P | H17 | Go2 | Motor analog signal |
IO_L17N | J13 | Go3 | Motor analog signal |
IO_L17P | K13 | Go4 | Motor analog signal |
IO_L16N | D17 | ECHO | Ultrasonic return pulse |
IO_L16P | E17 | TRIG | Ultrasonic transmission pulse |
IO_L15N | G14 | PWM | Steering gear analog signal |
IO_L14N | F16 | ECHO1 | Ultrasonic return pulse |
IO_L14P | F15 | TRIG1 | Ultrasonic transmission pulse |
IO_L13N | G16 | ECHO2 | Ultrasonic return pulse |
IO_L13P | H16 | TRIG2 | Ultrasonic transmission pulse |
The project is as follows:
Project_chaoshengbo. SRCS contains.v files and constraint files
Double-click project_Chaoshengbo.xpr to open the project
Resources have been uploaded, links and other review will be put in the article.