1 University of Electronic Science Technology of China(UESTC) Model Vehicle Control system design Real-Time Systems Lab
1 Real-Time Systems Lab University of Electronic Science & Technology of China (UESTC) Model Vehicle Control system design
2 1 OUTLINE University of Electronic Science Technology of China(UESTC) There is a model vehicle >4 cartwheels; >2 motors:One is steering engine (130s Brushless motor) that is used to control the front two cartwheels;the other is speed motor (Brushless ESC (Electronic Speed Controller))that is used to drive the rear two cartwheels; >1LCD(LCD1602): >3 ultrasonic sensors (SRF05); >1 freescale 5213 card (MCF 5213); >1 batter. Real-Time Systems Lab
2 Real-Time Systems Lab University of Electronic Science & Technology of China (UESTC) 1 OUTLINE There is a model vehicle 4 cartwheels; 2 motors: One is steering engine (130s Brushless motor) that is used to control the front two cartwheels; the other is speed motor (Brushless ESC (Electronic Speed Controller)) that is used to drive the rear two cartwheels; 1 LCD (LCD 1602); 3 ultrasonic sensors (SRF05); 1 freescale 5213 card (MCF 5213) ; 1 batter
3 1 OUTLINE University of Electronic Science Technology of China(UESTC) Your mission >Drive the model vehicle to go ahead while keeps it at a given distance(50 cm)from a wall. Real-Time Systems Lab
3 Real-Time Systems Lab University of Electronic Science & Technology of China (UESTC) Your mission Drive the model vehicle to go ahead while keeps it at a given distance (50 cm) from a wall. 1 OUTLINE
4 1 OUTLINE University of Electronic Science Technology of China(UESTC) Requirements >Detect the current distance from the wall in real time by the ultrasonic sensors; >Display the detected distance by the LCD; >Your program runs on the top of uC/OS II >Codewarrior,C&Assemble language. How to design? Real-Time Systems Lab
4 Real-Time Systems Lab University of Electronic Science & Technology of China (UESTC) 1 OUTLINE Requirements Detect the current distance from the wall in real time by the ultrasonic sensors; Display the detected distance by the LCD; Your program runs on the top of uC/OS Ⅱ; Codewarrior, C & Assemble language. How to design?
5 2 Problem (P) University of Electronic Science Technology of China(UESTC) P:How to detect the distance in real-time? >Distance=(TimeDuration 340m/s)/2; >How to get the TimeDuration? Real-Time Systems Lab
5 Real-Time Systems Lab University of Electronic Science & Technology of China (UESTC) 2 Problem (P1 ) P1 : How to detect the distance in real-time? Distance=(TimeDuration * 340m/s)/2; How to get the TimeDuration?
6 3 Problem (P),(P3),(P4) University of Electronic Science Technology of China(UESTC) P2:How to organize and design the software architecture on the top of uc/OS II >DFD(Data Flow Diagram) >Task structure ☐P3:How to( drive t the steering e engine to turn Left/Right? Given a turning a angle,How to implement the "turning"command? P:How to determine the turning angle in each adjustment Real-Time Systems Lab
6 Real-Time Systems Lab University of Electronic Science & Technology of China (UESTC) 3 Problem (P2 ), (P3 ), (P4 ) P2 : How to organize and design the software architecture on the top of uc/OS II ? DFD (Data Flow Diagram) Task structure P3 : How to drive the steering engine to turn Left/Right? Given a turning angle, How to implement the “turning” command? P4 : How to determine the turning angle in each adjustment ?
4 Implement the above design on the top of uC/OSII University of Electronic Science Technology of China(UESTC) APIs provided by the uC/OS II? Task management:OSTaskCreate ( Mail Box: OSMBoxCreate OSMBoxPost OSMBoxPend ( >Synchronize:OSSemCreate() OSSemPost O OSSemPend ( Mutex:OSMutexCreate ( OSMutexPost ( OSMutexPend ( >Interrupt:OSVectSet ( a111 Real-Time Systems Lab
7 Real-Time Systems Lab University of Electronic Science & Technology of China (UESTC) 4 Implement the above design on the top of uC/OSⅡ Task management: OSTaskCreate () Mail Box: OSMBoxCreate () OSMBoxPost () OSMBoxPend () Synchronize: OSSemCreate () OSSemPost () OSSemPend () Mutex: OSMutexCreate () OSMutexPost () OSMutexPend () Interrupt: OSVectSet () ...... ...... APIs provided by the uC/OSⅡ?
8 4 Implement the above design on the top of uC/OS II University of Electronic Science Technology of China(UESTC) Interfaces for ultrasonic MCF_GPIO_PORTDD&=~Trig /produce a 20us pulse >TestTimeSum=Gettime[1]-Gettime[0]//Calculate the distance Interfaces for PWM OSSpeeddown O OSSpeedup ( OSTurnLeft ( OSTurnRight ( ■Interfaces for LCD LCDWcmd ( /Determine the position on the LCD LCDWdata ( /Display the given information LCDShowChar ()/Display the detected distance Real-Time Systems Lab
8 Real-Time Systems Lab University of Electronic Science & Technology of China (UESTC) 4 Implement the above design on the top of uC/OSⅡ MCF_GPIO_PORTDD&=~Trig // produce a 20us pulse TestTimeSum=Gettime[1]-Gettime[0] //Calculate the distance Interfaces for ultrasonic OSSpeeddown () OSSpeedup () OSTurnLeft () OSTurnRight () Interfaces for PWM LCDWcmd () // Determine the position on the LCD LCDWdata () // Display the given information LCDShowChar () // Display the detected distance Interfaces for LCD
9 5 How to design a more perfect control system? University of Electronic Science Technology of China(UESTC) More sensors(A group of photoelectric sensors) More tasks Perfect control algorithm Optimize your program Responsibility,Stability Other control applications ▣Q&A Real-Time Systems Lab
9 Real-Time Systems Lab University of Electronic Science & Technology of China (UESTC) 5 How to design a more perfect control system? More sensors (A group of photoelectric sensors) More tasks Perfect control algorithm Optimize your program Responsibility, Stability Other control applications …… Q & A
10 University of Electronic Science Technology of China(UESTC) 8 Square waves(40 HZ)(Ultrasonic) Utrasonic Sensor GND VCC Echo Trig (20 us pulse) GPIO Capture the Time Duration of high-level voltage GPT MCF 5213 Real-Time Systems Lab
10 Real-Time Systems Lab University of Electronic Science & Technology of China (UESTC) Utrasonic Sensor GND VCC Echo Trig (20 us pulse) GPIO GPT Capture the Time Duration of high-level voltage MCF 5213 8 Square waves (40 HZ) (Ultrasonic)