Unformatted text preview: Lecture #15 - Blimp September 22, 2010 Outline
Lab 3, part 3 Control algorithms algorithms Lab 3, Part 3
Compass pairs – use the compass readings to control the servo.
Set a desired heading
TA may tell you to change this during check off, so either make it a #define or have the use pick a heading from a menu. The menu options s ou d include a e e user c ead o eu e e u op o s should c ude North, East, South and West. Remember that the compass returns results in 1/10 of degrees so East is 900 in these units, South is 1800, … Open loop vs. closed loop Proportional control (P) Comments on Quiz 4 – PCA (next week) Calculate a heading error – the difference between the desired heading and the actual. error = desired – actual; // This doesn’t always work. If the error is more than 180 degrees ( or 1800 in units of 1/10 of a degree), then your correction will be in the wrong direction. The same is true if your error is less than -180 degrees (-1800 depending on your units.) (Use the error to calculate new steering pulsewidth Use proportional Use the error to calculate a new steering pulsewidth. Use proportional control. There isn’t a good way to determine a good gain constant until control. Lab 4. So for this lab we just need to see the proper type of response with the expectation that you will change the gain constant later. You must check that your pulsewidth is within the allowable range before changing the capture/compare module compare number. Use the results of you Lab 3 part 1 code to determine the limits for your car.
Lecture #15 - Blimp 3 9/22/2010 Lecture #15 - Blimp 2 9/22/2010 The Steering Servo
Steering control can be simple. Proportional control works on the car. th The Steering Servo – this is closed loop control
Control of the steering servo motor can be based on the following block diagram.
Desired heading neutral offset error error = (desired heading) – (actual heading) PWM = centerpw + Kp* error + kp - pulsewidth generation Servo/car This is proportional control, the PWM is proportional to the error proportional to the error Warning: if error > 1800 or < -1800 then the equation above won’t work.
9/22/2010 Lecture #15 - Blimp 4 actual heading (feedback) Compass error = (desired heading – actual heading) (d If our proportional control is set correctly, our control loop will automatically try turn the car until it is traveling in the desired direction. But of course the car isn’t moving yet, (Lab 4.)
9/22/2010 Lecture #15 - Blimp 5 1 Lecture #15 - Blimp September 22, 2010 Lab 3, Part 3
Ranger pairs – use the ranger readings to control the speed controller. Speed control is open loop, for Lab 3 and Lab 4
There isn’t any sensing of the actual car speed
Output from ultrasound sensor range Set a neutral height.
If the first echo seen by the ranger comes from an object at the neutral height, the car is stopped. If the first echo comes from something closer to the car than the neutral height, the car goes forward. If it is further away, the car goes backwards. Control algorithm Calculate a speed pulsewidth based on the actual reading and the neutral height. Pick a constant so that the car will run full speed forward using the range of distances achievable in the room. You must check that your pulsewidth is within the allowable range before changing the capture/compare module compare number. You will need to take the car to the floor to do a valid test of the code.
Lecture #15 - Blimp 6 pulsewidth generation Speed controller and car Result is the actual speed of the car. Algorithm could be: PW = neutral + K*(neutral height – range) Be careful that PW is always within limits
9/22/2010 Lecture #15 - Blimp 7 9/22/2010 Suggestions for your code
Error must be a signed variable Crossbar Quiz 4 (next class) PCA and crossbar Given XBR0=0Xnn; answer which pin, if any, while have TX0 or SDA or CEX2 Determine the correct value for XBR0 if you need to use UART0 and SPI0 but not SMB0 or any PCA pins. Variations of this line How to: to:
Enable the PCA Enable the desired CCMs (Capture Compare Modules) Pick input signal Enable PCA overflow interrupts Clear the overflow flag in the interrupt service routine desired and actual will always be positive they typically are desired and actual will always be positive, they typically are unsigned unsigned error = desired – actual; /* error is often negative */ printf each take a significant amount of the available code space printf is required for labs 5 and 6 Use getchar() and pick from a menu of options getchar() Don’t put a printf into the I2C functions. Only use printf statements before the I2C start and after the I2C stop. Don’t put printf statements in Interrupt Service Routines
Lecture #15 - Blimp 8 PCA I/O Set the pulse width
Determine the pulse width value in counts for a desired pulse width in msec Determine and write the correct value into the correct CCM (Capture Compare Module.) Do the above with correctly using SYSCLK or SYSCLK/4 or SYSCLK/12 printf statements take time ti Set the period the period
Use the preset method to shorten the period Determine the correct preset value for a desired frequency (F) or desired period (T) F=1/T Given a preset value, determine the output frequency or period Given the above, what is the duty cycle of the output
duty duty cycle = (on time / period)*100% PCA_plotter isn’t allowed during the quiz
9/22/2010 Lecture #15 - Blimp 9 9/22/2010 2 Lecture #15 - Blimp September 22, 2010 Today and Next Class
Today If you haven’t had a check off for Lab 3, part 2, do so. Work on Lab 3, part 3 Quiz 4 Finish Lab 3, part 3 If you are behind, use open shop time to catch up. We start Lab 4 on November 1 and 2. Compass and ranger pairs team up. Everybody must have Everybody completed Lab 3, all parts, by November 1.
Lecture #15 - Blimp 10 Next class 9/22/2010 3 ...
View Full Document
- Spring '08
- Algorithms, blimp, Proportional control