C-52EVBRobot Controller Wichit Sirichote, firstname.lastname@example.org
Usea C-52 EVB for simple robot experiments. Build a simple two wheels robotwith L293D H-Bridge driver and IR sensors. Write a C program controls robottracked with black tape. Fun with Ving-Peaw Competition 2543, course layout,day-by-day changed rule and scoring also included!
One of my student has made a disgracefulrobot that used two stepper motors and with a simple IR sensor. Yes, abovepicture is what I'm talking. Without battery carrying, a little bit torqueof the stepper and misalignment of driving shaft, makes it crawling notwalking, but first demo, showed quite impressive to me. He said he wrotea couple of program lines using C, his robot can track the black tape.I feel delighted his intention and endeavor. I thought, " he borrowed meDS5000, expensive one, a soft uController with internal bootloader, whyshouldn't try with our learning board C-52 Evaluation Board instead". Anotherone, told me the same day "I found the L293 Push/Pull Four Channel Driverat Ban-Moah, it costs 1.5 US$ ". I've been searching this chip for a year.The MiniBoard,a Motorola 68HC11 Robot Controller board designed by FredG. Martin, also uses this driver. The day after, I then decidedto prepare the page describing how to use C-52 EVB as a robot controllerboard. I asked my student for competition, build yourselves robot thatcan track the black tape. Prize for the winner is 100 US$, with a bit conditionthat the winner must pay for a big party at Soi Jinda's Somtum (PapayaSalad) shop. And one of the competitor is me. I thought the rule shouldbe conceived roughly by students and technically by me. The picture onthat day will put here soon.
C-52 EVB resources
Beforehand, let look at availableresources of C-52 EVB for robot experiments.
Basic circuit of using L293 formsan H-Bridge Driver is shown in Figure 1. As shown for such inductive loadas DC motor, external diodes for suppressing back EMF must be connected.The MiniBoard uses L293D instead, the L293D has internal diodes, howeverproviding a bit less driving capacity, i.e., 600mA @4.5V-36V. From thetruth table, we see that direction of the motor can control by pin C andD. VINH enable/disable power to the motor, thus for speed regulation, wethen use this pin for PWM signaling. See details, L293.pdfdata sheet.
A circuit connecting C-52 P1 to L293 driver chip is shown in Figure2. As shown Enable pin 1 connected to P1.0 is for PWM signaling. We useadditional inverter at pin7 and pin 15 to provide proper logic for easydirectional control. Please note that pin 4,5,12,13 are tied to groundand if heat sinking needed, one method is to make a large area of PCB orsoldering it with a metal sheet, say.
Line Tracking Sensor (I have to KUK)
Since there's no ADC for 89C52 chip, each competitor may build theirown Line Tracking Sensor, some may use LM339 QUAD comparator with IR transmitterand receiver, some may use LDR as described in LineFollower Robot . With an external comparator, it may not necessaryto have ADC, but with LDR, we need external ADC. " Having additional ADCfor 89C52 would be better", I thought. How can we provide ADC for 89C52with a cheap method? I chose PIC16C711 with 4-channel ADC, and 7-pin inputport. Interfacing to 89C52 is done with simple PISO protocol by using RB0for SCLK and RA4 for SDA. The code for such purpose was written in C, hereis the source file, C52ADC.C and the HEXcode, C52ADC.HEX. After some initialization,the 711 chip wait for trigger read signal at pin RB0, i.e., high-to-lowtransition, then it responses by sending 40-bit through RA4(SDA) with low-to-hightransition. 40-bit data stream begins with LSB of ADC0 to MSB of PORT B.Example of program fro testing ADC is ADC.Cand the hex file is ADC.HEX.
Simple Power Supply and Charger Circuits
Figure 4 shows a simple power supply circuit. I have tested with KABO,it works fine. For those who have a big capacity rechargeable battery,the resistance value of R can be selected for approx. 10% output chargingcurrent. DC in can be higher if your battery voltage higher than 8.4V,say. To ensure the output current is within the value calculated by R,measure DC current before. The maximum supply for LM317 is ~35V.
Using PAUL's Startup Header file with Micro-C
Before writing PWM generation for testing above circuit, let study howto use Paul's header. With a PAUL's startup header at the beginning ofthe application C program, after successfully downloading the hex code,just press RESET, the 89C52 then will run the application instead of PAULMON2monitor program. As long as the program remain in SRAM, running the programcan only be done with pressing RESET. To return to PAULMON2 prompt, turnthe board power off for a while, then back the power on again. This conceptof startup header allows us to use C-52 EVB as a dedicated controller besideas a learning board. Originally Paul has made with entirely in Assemblycode. However, I have adapted for Micro-C Compiler. I have put the headerfor startup code in the startup and runtime library for small memorymodel. The file C52ROBOT.ASM, will compileand link to the main( ) function with S=c52robot.asm when invoking commandcoordinator. Example of command line is;
c:\mc\cc51%1 -ilp h=c:\mc m=s s=c52robot.asm
%1is hello(.c), say
Manual Control Program demonstrates PWM generationwith KABO
One method ofdelivering DC power to motors is to use PWM. The PWM method supplys DCpulse with fixed frequency but with adjustable duty cycle. I used TIMER2in AUTO reload producing 1000Hz PWM frequency. Each time executing hasentering into service routine, a 16-bit PWM1 was shifted out to P1.7 andPWM2 to P1.6. Main program has a task that set the power for motor1 andmotor2 by writing 16-bit PWM pattern into PWM1 and PWM2 for motor1 andmortor2 respectively. The service routine for timer2 is put in startupcode. See example program, KABO1.C and C52ROBOT.ASM,for PWM demonstration with manual control. I have designed and built myown robot for the competition also. It names KABO having differential drivemethod. As shown in right-hand side, is the rare part powered by C52-EVB.The motor driver chip L293D and a 74LS04 are put at the soldering pad.
I suppose there should have ten robots to be competed. Details Ruleand Scoring will be launched soon, day by day changed. But first of all,competitors must know how difficult of the circuit and programming are.Hear is the actual course layout.
The original idea of what kind of the competition would be, came fromZongwit. Each round has two robots. Each robot must run along black tapeand try to touch the the other's target. Who touch first will be the winner.The slower is allowed to detect the faster, shifted out of the line for20 seconds, then back again. No limit for the robot size and uControllers,you may use ranging from a PIC16F84, 16F873/877, 89C2051/4051, 89C51/52/55,or 68HC11, say.
C-52 EVB Robot Controller Links