According to StarFive, developers have successfully used fire alarm devices on VisionFive/VisionFive 2, and the specific instructions are as follows:
Development board: VisionFive/VisionFive 2 SBC
Line tracker: 1-way line tracker and 2-way line tracker each
Map: A4 paper with black stripes
DuPont Line: Many
The specific line tracker modules used in this demo are as follows:
On line tracker, there is a pair of infrared emission and reception probes in each circuit. Its working principle is to use the different reflectivity of infrared to colors to convert the strength of the reflected signal into a current signal. The line tracker is effective when detecting a black high level, and is effective when detecting a white low level, with a detection height of 0-3cm. Affected by the light and black line of the site environment, it is necessary to coordinate with the knob Potentiometer on the sensor to adjust the detection sensitivity before actual use.
On the 1-way line tracker, there is also an AO output, which you can use in conjunction with the previous method of using ADS1115 to read analog signals. In this demo, we use the DO output of the line patrol sensor, which means that the development board directly receives high and low levels.
At first, refer to the following figure and connect the line tracker to VisionFive:
The power supply voltage should be determined based on the actual sensor used. The line tracker module in this demo uses a 5V power supply voltage.
Then write the following program:
# file: ~/projects/tracking/tracking_one.py import VisionFive.gpio as GPIO import time TRACKING_PIN = 12 def setup(): GPIO.setmode(GPIO.BCM) #set pin numbering system #Configure the direction of buzz_pin as out. GPIO.setup(TRACKING_PIN, GPIO.IN) if __name__ == '__main__': setup() try: while True: status = GPIO.input(TRACKING_PIN) if status == 1: print("巡线正常 status=%d" % status) else: print("路线偏离 status=%d" % status) time.sleep(1) finally: pass
To run the above program, you also need to install the corresponding StarFive GPIO support library, as follows:
# Install extension library sudo pip show VisionFive.gpio
After writing, run tracking_one.py and then keep the 1-way line tracker horizontally at 2cm above the map line.
The line tracker is above the line
Line tracker deviates from the line
The following is the output result:
When using a 1-way line tracker, it can detect whether it is on the line or off the line.
When using a 2-way line tracker, it can further detect whether it is left or right deviation to obtain more specific results.
Refer to the previous wiring instructions and connect the 2-way line tracker to the VisionFive, mainly connecting L and R to the corresponding GPIO.
Then, write the following program:
if __name__ == '__main__': setup() try: while True: status1 = 0 #GPIO.input(TRACKING_PIN_L) status2 = 0 #GPIO.input(TRACKING_PIN_R) if status1 == 1 and status2 == 1: print("巡线正常，继续保持 status1=%d status2=%d" % (status1, status2)) elif status1 == 1 and status2 == 0: print("路线右偏，请向左转 status1=%d status2=%d" % (status1, status2)) elif status1 == 0 and status2 == 1: print("路线左偏，请向右转 status1=%d status2=%d" % (status1, status2)) elif status1 == 0 and status2 == 0: print("路线脱离，请检查 status1=%d status2=%d" % (status1, status2)) time.sleep(1) finally: pass
After writing, run tracking_ two. py , and then use 2-way line tracker to align with the map for testing.
Normal position of line tracker:
Left deviation of line tracker:
Right deviation of line tracker:
Line tracker detachment:
In this demo, we learned about the use of 1-way line tracker and 2-way line tracker.
Line tracker are generally used by line tracker cars or robots to control small boats or robots to move along black or white lines. In addition, specific black and white color blocks can also be used to detect the correct placement of specific items.