ME461_Lab9 - ME 461 Laboratory #9 Wall Following and RC...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ME 461 Laboratory #9 Wall Following and RC Driving Goals: 1. Sample and convert a sequence of ADC channels on the microcontroller and use the Data Transfer Controller (DTC) to load results directly into memory. 2. Implement an IR rangefinder‐based wall following algorithm. 3. Implement a radio‐controlled (RC) driving controller using a wireless key fob transceiver pair. Exercise 1: (50 points) Two Sharp IR distance sensors are mounted to the top of your robot. They output an analog voltage that is inversely related to the distance from the reflective surface. The operating range is approximately 10cm – 80cm. The relationship between voltage and distance is nonlinear, the details of which we are not concerned with. They are connected to channels A0 (2.0) and A2 (2.2). Configure your microcontroller to read the two analog channels connected to the IR rangefinders. You should use the Data Transfer Controller (DTC) to load conversion results directly into a global array in memory. Use the sequence of channels, single conversion mode so that an interrupt occurs after each conversion of all channels is complete. Configure the ADC to convert all channels in the sequence automatically once the conversion trigger is set. You should start with the configuration you already have from previous labs and add the code for sampling multiple channels. Don’t forget that you need to re‐initialize the ADC10SA register each time a sequence is complete. Refer to homework 9 for guidance. Use the serial I/O application to determine an appropriate right‐wall setpoint by placing the robot a fixed distance from a right wall and recording the ADC conversion result. Use this setpoint directly; do not attempt to convert to a distance. Now, implement a proportional control law to regulate the right‐ wall distance to the setpoint. The control effort produced by this law will be the “turn” setpoint of the PI controller you developed in lab 8. Hand‐tuning the proportional gain for this law will be sufficient. You may use any logic you like to generate the forward reference velocity, but a constant signal would definitely suffice. Introduce another proportional control law that is activated when the front‐wall distance is smaller than some threshold. The goal of this controller is to turn the robot left when a front wall is near so that right‐wall following may resume on the front wall. Use a front‐wall setpoint that is large so that the controller will turn the robot until the front wall is on its right. Keep in mind that some dead zone (hysteresis) is necessary to avoid rapid switching between the two modes. Once again, use your judgment and trial‐and‐error to generate the forward velocity reference signal. The wall‐following controller is summarized by the following pseudo‐code. Wall‐following Controller: if right wall follow then tref = Kp,right × (refright – distright) vref = vright if distfront < threshold 1 then right wall follow = FALSE end if else tref = Kp,front × (reffront – distfront) vref = vfront if distfront > threshold 2 then right wall follow = TRUE end if end if (right‐wall following controller) (front wall is near) (activate left turn) (left turn controller) (front wall is far away) (resume right‐wall following) The robot should be able to drive around inside the arena with the wall on its right. Keep in mind that when hand‐tuning controller gains, it behooves you to use as much common sense and intuition as possible. Gain signs may be positive or negative, so make sure you keep track of sign conventions. It sometimes helps to trace a given state (in this case, distance from a wall) to the control effort that is produced to ensure the controller is behaving properly. Demonstrate your wall‐following controller to the TA. Exercise 2: ( points) A rolling‐code UHF receiver is connected to the robot’s PCB. The wireless remote causes the receiver to send binary (on/off) signals to pins 3.0‐3.3 on your microcontroller. Each pin corresponds to a button on the wireless remote. Pressing a button on the remote will cause the corresponding pin to go high (V ≈ 3.3V) the entire time the button is pressed. If the LED near the receiver doesn’t light when a button is pressed, the “learn” procedure will need to be executed; see your TA for help. Configure pins 3.0‐3.3 as digital inputs with pull‐up/down resistors disabled. Use the serial I/O interface or UART_printf to determine which pin corresponds to each button. Note that the receiver can handle up to three simultaneous pressed buttons. Now, implement an algorithm that will allow you to drive the robot using the remote. Use whatever logic you like to generate the specific actions, but the general framework should allow for driving in forward and reverse and turning in both directions. For the sake of commonality (and the sanity of your TA), use the diagram below as a guide. Also include in your algorithm a key combination or sequence (simple is best) that causes the robot to switch between RC driving and wall following. FWD RIGHT LEFT REV Congratulations, you just programmed your own RC robot car! ENJOY! ...
View Full Document

Ask a homework question - tutors are online