Experiment 4.B Position Control Electronics Design Laboratory 1
Procedures 4.B.1 4.B.2 4.B.3 4.B.4 Read Encoder with Arduino Position Control by Counting Encoder Pulses Demo Setup Extra Credit Electronics Design Laboratory 2
Experiment 4 B.1 Read Encoder with Arduino Connect the encoder output from both of your motors to the Arduino. A recommended wiring diagram is seen below. Place a 1kΩ resistor in series between the encoder and the Arduino Write a program that will count encoder pulses. You may reuse some of code from the examples posted online. Have both the left and the right wheel encoder counts printed out to the serial console using the following format for the left count, right count, and the count difference: >LEFT: #### RIGHT:#### DIFF ### Have Arduino reset the encoder counts, and then run both wheels at half speed for 1s. In your report, comment on why the left and right encoder counts are not the same. Note: the robot wheel radius is r = 6.5 cm Recommended Pin Connections Electronics Design Laboratory 3
Experiment 4 B.2 Position Control by Counting Encoder Pulses Using the example code on the course website, implement position control for your robot. When completed, you should be able to precisely control the distance your robot travels. It is recommended that you split this program into multiple functions. These functions may include int forward( char distance, char speed); int reverse( char distance, char speed); int turn_left( char degrees, char speed); int turn_right( char degrees, char speed); Modify your main loop function to have the robot preform the following tasks Stop, wait for the switch to be in the ON position Wait 1 second 180 o clockwise rotation of the robot 180 o counter clockwise rotation of the robot In the report: Include a copy of your code Comment on the position accuracy achieved, and how fast your robot could accomplish the positioning task Electronics Design Laboratory 4
Experiment 4 B.3 Demo Setup Show how the robot powered from 2 battery packs in series (approximately 10 V) can accomplish the specified Part B.2 positioning task: Stop, wait for the switch to be in the ON position Wait 1 second 180 o clockwise rotation of the robot 180 o counter clockwise rotation of the robot Accuracy: the robot should come back to the starting position Show your position control program Show complete speed control circuit, and complete LTspice diagram of your speed control circuit Answer questions related to your position control code and speed control circuit This Lab includes an extra credit opportunity: see next page Note: the robot wheel radius is r = 6.5 cm, each encoder pulse corresponds to approximately 0.53 mm distance traveled Electronics Design Laboratory 5
Experiment 4, B.4 Extra Credit The groups whose robot accurately completes the following tasks will be eligible for extra credit Robots will start centered on a floor intersection facing north From the starting position, robot must perform the following moves, as shown on the diagram: Move forward one square north Turn 90 o CC Move forward two squares west Turn 90 o CW Move forward one square north Turn 90 o CW Move forward one square east Turn 90 o CW Move forward two squares south Turn 90 o CC Move forward one square east Turn 90 o CC and stop At the end, the robot should ideally be in the starting position. Accuracy requirements: Robot platform must always cover a portion of the floor line along the route shown in the diagram In the end position, both wheel axis tips must be within +/ 5cm (+/ 2 ) of the southern horizontal floor line, and the caster wheel must be within +/ 5cm (+/ 2 ) of the eastern vertical floor line W N S E The robot wheel radius is r = 6.5 cm START and END Caster wheel 39.5 = 100 cm Electronics Design Laboratory 6