Home
FINAL REPORT - Machine Intelligence Lab
Contents
1. 2 r if RED gt 80 amp RED lt 175 amp GREEN gt 41 amp GREEN lt 98 amp BLUE gt 15 amp BLUE lt 70 stop lcd clear_screen lcd out_string Red is delicious grab Pick up object while PINDIR amp 0x08 forward 20 goto end else Look for blue to avoid it else if RED gt 80 amp RED lt 130 amp GREEN gt 70 amp GREEN lt 125 amp BLUE gt 87 amp BLUE lt 132 ms_sleep 8 CMU_GM RED CMUResponseBuffer 1 GREEN CMUResponseBuffer BLUE CMUResponseBuffer 3 r 2 7 if RED gt 80 amp RED lt 130 amp GREEN gt 70 amp GREEN lt 125 amp BLUE gt 87 amp BLUE lt 132 open lcd_clear_screen led_out_string Blue is gross Turn around and reacquire line reverse 33 ms sleep 1024 R_turn 51 reverse 33 ms_sleep 1024 goto line acquire else Nothing open led_clear_ screen led_out_string Where s food led_clear_ screen For testing Display RGB values led_out_string lcd_out_int binary2int RED Red mean led_out_string led_out_int binary2int GREEN Green mean led_out_string led_out_int binary2int BLUE Blue mean ms sleep 4096 reverse 33 ms sleep 1024 R_turn 51 reverse 33 ms_ sleep 1024 goto lin
2. I broke up my code into seperate while 1 loops to increase the chances that Ant will navigate through my course x My demonstration was what I coded for As a result my code takes on a role playing game RPG feel This RPG appearance was unintentional if j gt x x The values stated below were found in the Harris rotunda of NEB Do not use these values elsewhere Af int main void DDRB 0x01 Turn LED enable on Iinitializations timer init sei Enable interrupts Lod init ad_init srf init servo ini tO uart0 init cmu_init dir init r center Delay to center servos Take dummy reads CMU_TC 90 180 0 90 10 70 ms_sleep 50 CMU GM lcd clear screen led_out_int 5666 ms_ sleep 512 lcd_clear_screen led_out_string I m hungry Test gripper open grab ms_sleep 512 open uintl6 t IR ad_readn 2 4 Dummy read IR channel 0 PORTF bit 0 4 times and average forward 33 First of multiple infinite loops while 1 Check IR for obstacle or edge IR average K if Ant turns ey IF ad_readn 2 4 Read IR channel 2 4 times and Warning These IR functions will send Ant off the edge under seven inches away from the edge IR gt 108 amp amp IR lt 339 ms_sleep 512 IR ad read
3. Select channel ADMUX ADMUX amp Oxe0 channel amp 0x07 ad _readn A D Converter read multiple times and average K Read the specified A D channel n times and return the average of x the samples ae uintl6 t ad_readn uint8 t channel uint8 t n uintl6o t t uint8 t i ad_chsel channel t ad_read Dummy read Sample selected channel n times take the average t 0 for i 0O i lt n itt ms_ sleep 1 t ad_read Return the average of n samples return t n Sonar ranger functions void srf init void DDRSRF 0x92 PORTD bit 1 4 and 7 are triggers amp bit 0 3 and 6 are echos PORTSRF 0 uint8 t 1 sonar void uintl6 t counter 0 Count PORTSRF L_TRIGGER Trigger SRF us 48 sleep 1 Hold trigger high for 48 microseconds PORTSRF amp L_TRIGGER while PINSRF amp L_ ECHO Wait until echo line rises while PINSRF amp L_ ECHO countertt us 48 sleep 1 Count instances of 48 microseconds until echo line falls return counter 2 2 8 Distance in inches uint8 t r_ sonar void uint8 t counter 0 Count PORTSRF R TRIGGER Trigger SRF us 48 sleep 1 Hold trigger high for 48 microseconds PORTSRF amp R_ TRIGGER while PINSRF amp R_ECHO while PINSRF amp R_ECHO countertt us_ 48 sleep 1 return counter 2 2 8 Dista
4. while PINDIR amp 0x08 forward 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 0x04 0x04 0x04 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 R_turn 20 ms sleep 512 led_clear_ screen led_out_string Following trail goto line track ms_sleep 60 Delay between sonar pulses uint8 t r_ range r_sonar if l_range lt threshold amp amp r_ range lt threshold lcd_clear_screen led_out_string Missed an object rand _ turn 40 else if r_range lt threshold lcd clear_screen lcd out_string Missed an object L turn 40 Clear ahead forward 33 Line Acquiring 3 if PINDIR amp 0x06 0x02 keep_turning 7 while PINDIR amp 0x08 reverse 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 L_turn 33 if PINDIR amp 0x08 goto keep turning7 goto line track else if PINDIR amp 0x06 0x04 while PINDIR amp 0x08 forward 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 R_turn 20 lcd_clear_screen led_out_string Following trail goto line track else if PINDIR amp 0x06 I assumed Ant goes right more often than not while PINDI
5. UARTO RX while tempChar tempChar UARTO RX CMUResponseBuffer i 0O Convert raw CMUCam data into an integer int binary2int unsigned char binary num int result 0 if binary num amp 1 result 1 if binary num amp 2 result 2 if binary num amp 4 result if binary num amp result if binary num amp result if binary num amp result if binary num amp result if binary num amp 128 result 128 return result This function was not tested uint8 t Read Color void uinte t 27 int t value 0 for i 0 i lt 4 i ms sleep 125 CMU TOLLIS 150 15 150 I7 35 value value binary2int CMUResponseBuffer 8 value value 4 return value i Servo functions Declarations int L_new_speed 0 R new speed 0 L old speed 0 R old speed 0 int increment 1 Increment the wheel speed as slowly as possible to preserve the servo void wheels int L desired speed int R desired speed L desired speed 5 R desired speed 5 Calibration while L_new_speed L desired speed R_new_speed R_desired_ speed if L desired speed gt L old speed L_new_speed L_old_speed increment else if L desired speed lt L old speed L new speed L old speed increment if R_desired speed gt R _ old speed
6. PORTSRF 0 go_to line Disable trigger iL LCD Functions void latch void PORTLCD ENABLE PORTLCD amp ENABLE Latch data strobe void lcd command nibble uint8_t nibble PORTLCD nibble latch Send void lcd_command uint8 t byte uint8 t temp byte Save command temp amp OxF0O Peel off the four MSBs Also to make RS 0 PORTLCD temp latch ms_sleep 5 Wait for LCD data to go temp byte temp lt lt 4 Shift the four LSBs up to the MSBs Or sending position temp amp OxF0O PORTLCD temp Load LSBs latch us_ 48 sleep 1 void lcd_clear_screen void Clear screen cursor home ms sleep 1 lcd command 0x01 ms_sleep 2 void lcd_init void DDRLCD 0b11111100 PORTLCD 0 ms_ sleep 20 For more than 15000 us 15 ms Normal lcd initializations For 4 bit mode lcd command nibble 0x30 ms _ sleep 5 lcd command _ nibble 0x30 us_48_sleep 3 lcd command nibble 0x30 ms_sleep 5 lcd command nibble 0x20 us_ 48 sleep 1 Two lines lcd command 0x28 us_48_sleep 1 Display on cursor on blink on yord Ll pos2tL lcd command 0x0F us 48 sleep 1 Clear screen cursor home lcd_clear_screen cd_out_char uint8 t byte uint8 t temp byte Save command temp amp OxFO Peel off the four MSBs PORTLCD
7. R_new_speed R_old_speed increment else if R desired speed lt R_ old speed R new speed R _ old speed increment L_ WHEEL WHEEL MID L_new_speed L wheel adjustment R_ WHEEL WHEEL MID R_new_speed R wheel adjustment L old speed L new _ speed R old speed R_new_speed ms sleep 3 Wheels functions void stop void wheels 0 0 void forward int speed wheels speed 0 91 speed Servos have to correct drift Hence the 0 91 void R_turn int speed wheels speed speed void L_turn int speed wheels speed speed void reverse int speed wheels speed speed xx T use this function but I am not sure if it works T only saw right turns from this function so far my void rand_turn int speed if TCNTO amp 1 speed speed else wheels speed speed void dir init void DDRDIR 0 Read off the DIR port A delay to allow the servos to be centered If needed void center void int 17 for i 0 i lt 8 i PORTB 0x01 ms_sleep 512 I don t use this It turns off some sensors volatile int go_to_ line 0 void deinit IR_sonar void ADMUX amp _BV REFSO Deselect AVCC internal for AD voltage source Only 8 bit A to D accuracy and channel 0 PORTFO only ADCSRA 0 Turn off ADC DDRSRF 0
8. temp RS Signal a write to DDRAM for display latch ms_sleep 5 Wait for LCD data to go temp byte temp lt lt 4 Shift the four LSBs up to the MSBs Or sending on temp amp OxF0 PORTLCD temp RS Load LSBs latch us_ 48 sleep 1 This will not word wrap Put in if elses if you want word wrap ai void lcd_out_string char s while s lcd_out_char s ae Function writeIntegerToLCD led out int i Parameters integer the integer that will be written to the LCD ji Purpose Coverts a standard 16 bit int into the ASCII K representation of the number and writes that number a to the LCD wx Note The maximum value that can be written is EF 9999 This is because there is no EE ten thousands place Support w Returns lt none gt void lcd _out_int uint16_t integer Break down the original number into the thousands hundreds tens and ones places and then immediately write that value to the LCD ds uint8 t thousands integer 1000 led_out_char thousands 0x30 0x30 zero in hexidecimal format 0b00110000 in binary format uint8 t hundreds integer thousands 1000 100 lcd out_char hundreds 0x30 uint8 t tens integer thousands 1000 hundreds 100 10 lcd out_char tens 0x30 uint8_t ones integer thousands 1000 hundreds 100 tens 10 lcd out_char ones 0x30
9. BV CS32 _BV CS30 TCCR3B _BV CS31 TCNT3 0 TCCR3C _BV FOC3A _BV FOC3B _BV FOC3C ETIMSK _BV TOIE3 Configure OC1A for mode 0 normal top Oxffff prescale 8 f 30 k k WGM33 0 WGM23 0 WGM13 0 WGM03 0 CS32 0 CS31 1 CS30 0 DDRB _BV PORTB5 _BV PORTB6 _BV PORTB7 TCCRIA amp _BV WGM11 _BV WGM10 _BV COM1A1 _BV COM1B1 _BV COM1C1 TCCRIA _BV COM1A0 BV COM1BO BV COM1CO TCCRIB amp BV WGM13 BV WGM12 BV CS12 _BV CS10 TCCRIB _BV CS11 TCNT1 0 TCCRIC _BV FOCI1A _BV FOC1B _BV FOCI1C TIMSK _BV TOIE1 GRIPPER 3800 Open gripper L WHEEL WHEEL MID Neutralize wheels R WHEEL WHEEL MID Gripper functions void open void GRIPPER 3800 void close void GRIPPER 1700 void grab void GRIPPER 2550 A to D functions void ad_init void DDRAD 0 Set AD data direction register DDRF for input PORTAD 0 ADMUX _BV REFSO Select AVCC internal for AD voltage source Only 8 bit A to D accuracy and channel O PORTFO only ms_sleep 16 Wait for power up ADCSRA _BV ADIE Set AD Enable Start a dummy conversion Set AD to run freely No AD interrupt Clear Flag Divide clock by 128 16 MHz 128 125 kHz uintl6 t ad_read void return ADC void ad_chsel uint8 t channel
10. mounts for circuit boards I screwed wheels to the very back to reduce the chance of Ant falling off an edge and improve how Ant responds to line detection I mounted a gripper low and in front to grab an object successfully The line tracker module was shifted with varying length screws and standoffs until the proper distance from the ground was tested and verified The PCBs were stacked above the lower shelf to avoid debris that may roll underneath the lower shelf I chose the length and width of the PCB I designed to match the PCB I already purchased to use fewer screws and other mounting parts I added standoffs on top of the PCBs to allow me to move wires in between the PCBs and mobile platform shelves Actuation I implemented two hacked servos to rotate the wheels and an un hacked servo to operate the gripper My servos behaved as Paul Dutka Summer 05 stated Un hacked servos provide movement to a position between 0 to a little over 180 In hacking a servo you simply remove the tab that drives the pot and then adjust it so that it does not turn at the zero position 1 5 ms This allows the servo to rotate a full 360 and control speed instead of position The servo circuitry uses a PWM signal to control the servo motor The signal has a 20ms period with a pulse width from Ims to 2ms to control the servos position speed See Fig 2 Pulse Width Modulation A 20ms Fen red eed Alger eee Un hacked
11. the eight inch minimum distance from the IR detector I mounted the IR detector six inches high and at an angle An object was detected when the analog output from the IR detector increased An approaching edge was detected when the analog output from the IR detector decreased significantly The choice of which IR detector suits you is complex I recommend that you consult lt http www acroname com robotics info articles sharp sharp html gt 2 Photoreflector I chose the Hamamatsu P5587 Photoreflector This model of photoreflector or digital infrared DIR detector sets the output low when over a black line A circuit to drive this sensor was pictured at the supplier s website I used DIR detectors to differentiate between white poster board and black electrical tape I screwed the PCB with two DIR detectors about 0 25 inches from the table pointing straight down I used only two DIR detectors for line acquiring and line tracking on straight ways and around curves 3 Sonar Ranger I chose the Devantech SRFO5 sonar ranger The SRFO5 has an LED to indicate when it sends a pulse To operate my sonar ranger I sent a pulse to a trigger line for 48 microseconds Next I waited until the echo line went high After that I counted the number of 48 microseconds until the echo line went low Finally I added two to the total number of 48 microseconds counted and divided by 2 8 to get the approximate distance between the sonar ranger and the object in i
12. tutorial on the website to set the programmer manually Turn off verification to save yourself time In the programmer run the hw hex file This should be from flash When you turn the power off and back on the program will run from its beginning Resave hw c as main c Change the makefile Open the Makefile file in Programmer s Notepad Change all instances of hw to main Delete CPU at90can128 From now on open a new folder for a new program copy and paste a former main c file and Makefile file into that folder Redo Make All from the tools tab to produce the main hex file for that program Open this different main hex file in the programming software In this way you will always have the software you need to run your program However there will be no way to add libraries into your code Libraries are supplemental files with h and c extensions that can clean and organize your code better In general approach a new program with a minimalist approach Go online and look at robots what did what are trying to do and copy the code exactly After that learn what the code does and modify it to suit your needs 4 Help If you have any questions corrections or statements that hide a question feel free to contact me by email at lt amay ufl edu gt Feel free to visit lt plaza ufl edu amay gt for illustrations other documentation and weekly reports Software ee TELS Autonomous Machine Software Purpose
13. volatile unsigned char CMUResponseBuffer 15 Delay functions void us 48 sleep uintl6 t us_ 48 TCNTO 0 us_48 count 0 while us_48 count us_48 Each loop takes 48 us NOT 1 us based on the 128 divisor I set in prescalers in function declared tamer Init void ms_sleep uintl6 t ms TCNTO 0 ms count 0 while ms_count ms 21 Each while loop takes 48 us but total function takes 21 times that 21 48 ms SIGNAL SIG OUTPUT _COMPAREO us_48 count ms counttt void timer init void Initialize timer0 to generate an output compare interrupt and set the output compare register so that we get that interrupt every 48 microseconds Ri TIFR _BV OCIEO TCCRO BV WGMO1 BV CS02 BV CS00 CTC prescale 128 TCNTO 0 TIMSK _BV OCIEO Enable output compare interrupt OCRO 6 Match in 48 us SIG OVERFLOW1 the timer 1 output compare function automatically ends the pulse precisely as specified by the OCR1x register which represents the servo position ad SIGNAL SIG OVERFLOW1 TCNT1 0 Configure to set outputs on compare match so we can turn on the pulse in the next statement ty TCCRIA _BV COM1A1 _ BV COM1A0 _ BV COM1B1 BV COM1BO BV COM1C1 _BV COM1CO r force compare match to set outputs TCCRIC _BV FOC1A _BV FOC1B _BV FOCIC configure to cl
14. 0x02 amp amp PINDIR amp 0x08 R_turn 20 led_clear_ screen led_out_string Following trail goto line track else if PINDIR amp 0x06 I assumed Ant goes right more often than not while PINDIR amp 0x08 forward 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 0x04 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 range 0x04 0x04 R_turn 20 ms_sleep 512 goto line_track uint8 t threshold 7 Point to turn robot For sonar ms_sleep 54 Delay between sonar pulses Check left sonar for an object ahead uint8 t 1 range l _sonar if l_range lt threshold lcd_clear_screen lcd out_string Missed an object R_turn 40 Line Acquiring 2 if PINDIR amp 0x06 0x02 keep turning4 while PINDIR amp 0x08 reverse 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 L_turn 33 if PINDIR amp 0x08 goto keep turning4 goto line track else if PINDIR amp 0x06 0x04 while PINDIR amp 0x08 forward 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 R_turn 20 goto line track else if PINDIR amp 0x06 I assumed Ant goes right more often than not
15. Decide how a robot will react to its environment ee Author Andrew May Date of Creation 04 22 06 xx Date of Revision 04 25 06 Ef Standard C libraries include lt avr io h gt include lt avr interrupt h gt include lt avr signal h gt include lt stdlib h gt include lt stdio h gt include lt inttypes h gt include lt avr pgmspace h gt include lt ctype h gt include lt stdlib h gt include lt string h gt Constant definitions Servos define SERVO3 OCR3C define SERVO5 OCRI1B define SERVO6 OCRIC define GRIPPER SERVO3 define L WHEEL SERVO6 define R WHEEL SERVO5 define GRIPPER_MID 2850 define WHEEL MID 2850 ie A to D define DDRAD DDRF define PORTAD PORTF Sonar rangers define DDRSRF DDRD define PORTSRF PORTD define PINSRF PIND define L TRIGGER 0x02 define L ECHO 0x01 define R_TRIGGER 0x10 define R ECHO 0x08 define C TRIGGER 0x80 define C_ECHO 0x40 Photoreflectors define PINDIR PINA PORTA holds Digital IR define DDRDIR DDRA define PORTDIR PORTA LCD definitions PORTO BIT xx 7 6 5 4 3 2 alt 0 k DB7 DB6 DB5 DB4 E RS NC NC y define DDRLCD DDRC define PORTLCD PORTC define ENABLE 0x08 define RS 0x04 Global variables Timer volatile uintl6 t us 48 count volatile uintl6 t ms count CMUCam amp UART volatile int MAX MSG SIZE 30
16. Lett 90 Hacked Fig 2 This signal is used to provide the desired speed position The farther the position the faster the servo turns to achieve it I coded a minimal shift in speed algorithm to preserve the mechanics in these hacked servos resulting in smoother acceleration One problem with these servos is that one servo pulled when the batteries lost power To correct this pulling I wrote software to move one servo slower than the other The un hacked servo closed to a pre determined angle I experimented to determine the exact pulse length to close the gripper properly I used what many including Dr Schwartz call a divide and conquer approach I started with a value below and above the desired but unknown value If the desired behavior was closer to the lower value then I tested in the lower half of the previous range and vice versa I repeated this process until I narrowed the values down to a single one the desired value Sensors I chose sensors that interacted with Ant s environment enough to achieve Ant s mission 1 Infrared IR Detector I chose the Sharp DP2YOA02YK This model of IR detector begins reading at eight inches Instead of four inches in most other Sharp IR detectors but goes beyond the distance of a basic GP2D12 An analog signal comes from this IR detector that increases when distance decreases I used an IR detector to detect an approaching edge or obstacle in front of the robot To account for
17. R amp 0x08 forward 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 0x04 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 R_turn 20 ms sleep 512 led_clear_ screen led_out_string Following trail goto line track while 1 line acquire Line Acquiring only To eliminate the possibility of entering an undesired behavior forward 33 if PINDIR amp 0x06 0x02 keep _turningl0 while PINDIR amp 0x08 reverse 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 0x04 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 L turn 33 if PINDIR amp 0x08 goto keep turningl0 goto line track else if PINDIR amp 0x06 0x04 while PINDIR amp 0x08 forward 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 0x04 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 R_turn 20 led_clear_ screen led_out_string Following trail goto line track else if PINDIR amp 0x06 I assumed Ant goes right more often than not while PINDIR amp 0x08 forward 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 0x04 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 R_turn 20 ms_sleep 512 lcd clear_screen lcd out_string Following trail goto l
18. Student Andrew May Teacher s Assistants Adam Barnett and Sara Keen Teacher A A Arroyo Associate Teacher E M Schwartz ANT FINAL REPORT DATE April 25 2006 EEL5666 Intelligent Machine Design Lab Department of Electrical and Computer Engineering University of Florida Introduction What if you could not get at something For example your home was hit by a hurricane As a result all of your belongings are soaked You want to retrieve your valuables but you don t want mold spores in your lungs Now wouldn t it be great if you could tell an oversized ant to enter that hazardous area and retrieve those valuables for you Now you can with Ant your object retrieving robot Other potential situations you could rely on Ant for include passing through live weapon fire accessing buildings that have been biologically contaminated and reaching things at the other end of the table Although I see Ant going anywhere strictly speaking the goals of this project are contained in a lab environment In a lab the robot will pick up a pre determined object and drop it off at a desired point Issues include obstructions blocking the object and edges of the surface that Ant is on Ant is built around a microcontroller The microcontroller is sandwiched between layers of sensors and actuators On the lower layer servos move Ant Below the servos and at the top of the robot sensors tell Ant what happened in the environment
19. To transfer signals between Ant s electronics circuit boards were implemented As a result of this hardware software was written that created the behaviors of Ant See the appendix for instructions on getting started with programming and example software Illustrations are posted at lt plaza ufl edu amay gt Integrated System As shown in the following graphic Fig 1 a microcontroller drives Ant s four sensors LCD feedback and two actuators Servo and digital gripper Servos and wheel Photoreflectors Microcontroller pa Fig 1 Mobile Platform My entire mobile platform was made out of wood and printed circuit board PCB Wood was more adaptable than plastic or metal I added holes and cut into my mobile platform after the original design PCB increased reliability by excluding for example breadboards and wire wrap I separated my mobile platform into an upper and lower shelf with PCB sandwiched in between to minimize its size The upper shelf raised my camera and infrared detector up to a height that provided enough light to the camera and enough distance to the infrared detector On this same upper shelf I put an LCD to see what Ant thought To protect this level I mounted two sonar rangers angled out at fifteen degrees These sonar rangers allowed Ant to perform obstacle avoidance On the lower shelf I interfaced locomotion a gripper a line tracker module and
20. e acquire while 1 end Assuming that a red Nutri Grain bar was picked up Line acquire forward 20 if PINDIR amp 0x06 0x02 keep _turningl13 while PINDIR amp 0x08 reverse 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 0x04 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 L turn 33 if PINDIR amp 0x08 goto keep turning13 goto finale else if PINDIR amp 0x06 0x04 while PINDIR amp 0x08 0x04 while 1 forward 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 R_turn 20 else if PINDIR amp 0x06 0 goto finale else Somehow Ant got off its trail stop lcd out_string No trail finale Go around a curve to the right and drop off food if PINDIR amp 0x08 0x08 if PINDIR amp 0x06 0x06 reverse 15 Off line completely else if PINDIR amp 0x06 0x02 R_turn 20 Right side off line else if PINDIR amp 0x06 0x04 L_turn 13 Left side off line else if PINDIR amp 0x06 forward 28 On the line else if PINDIR amp 0x08 Ant arrived at drop off point stop open Release object reverse 35 ms sleep 4096 stop lcd_clear_screen led_out_string I m
21. ear outputs on compare match so that the output compare function ends the pulse TCCRIA amp _BV COM1A0 _BV COM1B0 BV COM1C0 For gripper SIG OVERFLOW3 this interrupt handler starts the pulse for servos 1 2 amp 3 the timer 3 output compare function automatically ends the pulse precisely as specified by the OCR3x register which represents the servo position urd SIGNAL SIG_OVERFLOW3 the TCNT3 0 Configure to set outputs on compare match so we can turn on pulse in the next statement E TCCR3A _BV COM3A1 _BV COM3A0 _BV COM3B1 _BV COM3B0 _BV COM3C1 _BV COM3C0 r Force compare match to set outputs TCCR3C _BV FOC3A _BV FOC3B _BV FOC3C Configure to clear outputs on compare match so that the output compare function ends the pulse gi TCCR3A amp _BV COM3A0 _BV COM3B0 BV COM3C0 void servo init void Use Timers 1 and 3 to generate the pulses for 6 R C servos each timer can do up to 3 servos 4i Pe Configure OC3A for mode 0 normal top O0Oxffff prescale 8 30 k k WGM33 0 WGM23 0 WGM13 0 WGM03 0 CS32 0 CS31 1 CS30 0 4 DDRE _BV PORTE3 _BV PORTE4 _BV PORTES TCCR3A amp _BV WGM31 _BV WGM30 _BV COM3A1 _BV COM3B1 _BV COM3C1 TCCR3A BV COM3A0 _BV COM3B0 _BV COM3CO TCCR3B amp _BV WGM33 _BV WGM32
22. g for a line sonar ranges are checked for a minimum distance When that minimum distance is breeched Ant goes away from that obstacle 4 Color detection Generated by the CMUCam I took mean red green and blue values From these color values Ant grabbed a red object avoided a blue object and wondered what happened if there was no object apparently Thinking about the color required a delay of a second because the camera showed false color values while in motion Variance in ambient light dictated a range of color values around 60 Unlike I specified in my special sensor report the track color TC function was neglected because I was using the confidence value only The TC function is better for following a color that is moving TC can move a robot to center on a color too but not as well I cut costs by using GM instead of TC because I didn t need white LEDs consequently Experimental Layout and Results 1 IR detector I hooked up an LCD to see what the analog value from the IR detector was I intended to record the values in the environment that the final user would be in Based on the LCD displays I wrote software to act on the analog values received During this research I repeated scans of the same place I saw variance in the data of 10 A large issue was that the IR detector thought an edge was ahead when there was a black line ahead actually I fixed this slowdown by recording values while looking perpendicular to in parallel
23. home ms_ sleep 2048 Stay still until picked up Then avoid obstacles and edges but ignore trails Supervise Ant now y while PINDIR f goto avoidance while 1 average range avoidance IR ad_readn 2 4 Read IR channel 2 4 times and if IR gt 108 amp amp IR lt 339 ms_sleep 512 IR ad readn 2 4 Ignore black tape if IR gt 108 amp amp IR lt 339 lcd_clear_screen led_out_string I saw a trail Avoid an edge in front of a chair or something else lcd_clear_screen led_out_string Aaaah reverse 33 L_turn 40 ms_ sleep 760 else if IR gt 400 ms sleep 512 IR ad_readn 2 4 Ignore a flash of light if IR gt 400 Avoid an obstacle else if IR gt 460 lcd_clear_screen lcd_out_string Missed an object rand turn 33 Avoid an edge else if IR lt 50 lcd clear_screen lcd out_string Aaaah reverse 33 L turn 40 ms_sleep 760 uint8 t threshold 7 Point to turn robot For sonar ms sleep 54 Delay between sonar pulses Check left sonar for an object ahead uint8 t 1 range l _sonar if l_range lt threshold lcd_clear_screen lcd out_string Missed an object R_ turn 33 ms_sleep 60 Delay between sonar pulses uint8 t r_range r _ sonar if l_range lt threshold am
24. ine track while 1 line track PINDIR of 8 is the abitrator for stopping on a line I added this mechanical stop because my CMUCam took a long time to look for colors x Not that I blame my CMUCam My robot did not continue line tracking Ey if PINDIR amp 0x08 0x08 if PINDIR amp 0x06 0x06 reverse 18 Off line completely else if PINDIR amp 0x06 0x02 R_turn 15 Right side off line else if PINDIR amp 0x06 0x04 L turn 15 Left side off line else if PINDIR amp 0x06 forward 25 On the line else if PINDIR amp 0x08 stop CMU_GM Dummy read ms sleep 1024 Wait for transients to die out Very important CMU_GM Get means 15 min 240 max int RED CMUResponseBuffer 1 Red mean int GREEN CMUResponseBuffer 2 Green mean int BLUE CMUResponseBuffer 3 Blue mean ja Look for Red candy bar xx These ranges were determined at 4 PM in the Harris rotunda of the New Engineering Building on 04 23 06 for a Nutri Grain bar experimentally Do NOT use these values in other environments because the values will change 7 if RED gt 80 amp RED lt 175 amp GREEN gt 41 amp GREEN lt 98 amp BLUE gt 15 amp BLUE lt 70 ms_ sleep 8 Double check CMU_GM RED CMUResponseBuffer 1 GREEN CMUResponseBuffer BLUE CMUResponseBuffer 3
25. ing automatically For this board I used traces of 20 mils to prevent the traces from breaking during soldering or heat during operation The screw holes were of 125 mils 2 Line tracker Custom was at the heart of this design I followed the sensor data sheet exactly I made footprints in Protel 99 An older version of Altium DXP I laid out the sensors 0 5 inches apart in the center and one inch between the inner and outer sensors to capture the electrical tape correctly Behaviors 1 Edge of the world detection By edge of the world I mean where the ground that Ant started on ended As I stated previously when the light hitting the IR detector decreased beyond an experimentally determined value then there was an edge approaching 2 Line tracking Ant line tracked similar to how ants follow pheromone trails Ant reached the object because of the line tracking behavior that I incorporated When my robot sensed the black line for the first time it turned until it acquired the line While on the line the robot turned to the right if the left sensor read the line and vice versa I added more speed when turning depending on which direction Ant went on a curve 3 Obstacle avoidance Detection of obstacles was from IR detection and sonar ranging Ant detects an increase in infrared double checks that increase and turns if an increase in infrared was sustained to eliminate turning from camera flashes for example Next interleaved with checkin
26. n 2 4 Ignore black tape if IR gt 108 amp amp IR lt 339 lcd_clear_screen led_out_string I saw a trail Avoid an edge in front of a chair or something else lcd clear_screen led_out_string Aaaah reverse 33 rand turn 44 ms_sleep 760 else if IR gt 400 ms_sleep 512 IR ad readn 2 4 Ignore a flash of light if IR gt 400 Avoid an obstacle else if IR gt 460 lcd_clear_screen lcd_out_string Missed an object rand _ turn 33 Avoid an edge else if IR lt 50 lcd_clear_screen led_out_string Aaaah reverse 33 rand turn 44 ms sleep 760 First of three To increase detection probability line detection methods in this while 1 loop I should use case switches instead of if elses for speed Left line acquisition does NOT work if PINDIR amp 0x06 0x02 Left line acquisition keep _turningl1 while PINDIR amp 0x08 reverse 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 0x04 PINDIR amp 0x06 0x02 amp amp PINDIR amp 0x08 L turn 33 if PINDIR amp 0x08 goto keep turning1l goto line track else if PINDIR amp 0x06 0x04 while PINDIR amp 0x08 forward 20 while PINDIR amp 0x06 0x06 PINDIR amp 0x06 0x04 PINDIR amp 0x06
27. nce in inches uint8 t c_sonar void uint8 t counter 0 Count PORTSRF C_ TRIGGER Trigger SRF us 48 sleep 1 Hold trigger high for 48 microseconds PORTSRF amp C TRIGGER while PINSRF amp C_ECHO while PINSRF amp C_ECHO countertt us_ 48 sleep 1 return countert 2 2 8 Distance in inches This function was not tested uint8 t avg c sonar void intl total counter 07 Ine ay for i 07 ISA itt ms sleep 50 uintl6 t counter 0 Count PORTSRF C TRIGGER Trigger SRF us 48 sleep 1 Hold trigger high for 48 microseconds PORTSRF amp C_TRIGGER while PINSRF amp C_ECHO ard while PINSRF amp C ECHO counter us 48 sleep 1 total counter counter total counter total counter 4 return total_countert 2 2 8 distance in inches UART functions For CMUCam Initialize UARTO to 115 2k baud void uartO init void baud UBRROH 0x00 UBRROL 16 16 is for 115 2k if U2X 1 0x33 51 for 38 4k UCSROA 0x02 UCSROB 0x18 Bit 4 is Rx enable Bit 3 is Tx enable UCSROC 0x06 Bit 6 Mode 0 Ascync 1 Sync Transmit a message over UARTO in the form of a character array void UARTO TX char message MAX MSG SIZE int t 0 while t lt MAX MSG SIZE 1 amp message t 0x00 Wait for an empty transmit buffer
28. nches I used two sonar rangers I pulsed one 65ms out of phase of the other to preserve the echo received I set the software to avoid distances less than one and a half body lengths One key advantage in sonar rangers over IR detectors is close range operation IR detectors can not continue reading under four or eight inches One sensor that I never tested was the one from Maxbotix If you can I would recommend experimenting with this sensor because to see if it gives analog values of the distance as its suppliers claim 4 Camera Special Sensor I chose the Carnegie Mellon University Camera One CMUCam1 or just CMUCam The CMUCam2 was too much for the function that I desired I instructed the camera to recognize the color of Nutri Grain bar Red or Not Red I placed the camera above the jaws so that it would be as close to the bar as possible This close proximity reduced the chance of reading colors that appeared to be the same as the object that Ant was seeking but were not The camera was mounted with screws that were on a couple right angle connectors The camera was pointed downward at about a 45 degree angle The software was written in large part because of Fernando Hernandez Summer 05 However I modified Mr Hernandez s code to exploit the Get Mean GM function instead of the Track Color TC function GM was more accurate than TC because I was stopping Ant at a definite point The lighting conditions greatly affected this sens
29. ocontroller that uses a USB to serial driven JTAG ICE II programmer 1 Hardware Choose programmer I used a USB to serial JTAG ICE programmer because it eases debugging however ISPs are available too Navigate the maze of download links to find the software drivers for the hardware that you choose 2 Downloads To write and compile C code download the latest version v0 6 1 of Programmer s Notepad from lt http www pnotepad org download gt To program the flash memory of the Atmegal28 microcontroller download the latest version 4 12 build 460 of AVR Studio by clicking on the tiny CD icon To do less adaptable but cheaper and more popular serial or parallel programming download the latest version of PonyProg2000 from the latest link v2 06f BETA at lt http www lancos com ppwin95 html gt instead of AVR Studio To have a makefile and starting examples of code In addition to the examples of former IMDLers download and unzip at least one sample hello world from lt http www bdmicro com code hw gt 3 Configuration In Programmer s Notepad open the hw c file From the Tools tab click Make All As a result you should see file called hw hex In this case the hex file was provided already This is the file that the programmer needs In AVR Studio of PonyProg open the hw hex file If you have AVR Studio your fuse bits and other settings are set automatically If you have PonyProg you must set refer to William Dubel s
30. or I tested my robot in the environment of demonstration and media days to prevent accidents This testing can be extrapolated to be called alpha and beta user testing one of the benefits of this class I turned the camera on when I was in position to see a color only Circuit Boards I made two circuit boards to drive Ant One circuit board supplies power the other board line tracks 1 Power portal I poured most of Ant s energy through a central PCB The power board has multiple ports to match the differing components that the power board runs One 5V regulator 7805 spins Ant s servos only Servos tend to jitter more than any other part and can put electronics running from the same supply into a brownout Another 7805 drives up to five IR detectors The third a 7805 as well joined a potentiometer to power and adjust the contrast on an LCD Uniquely a 6V regulator powers the CMUCam because the CMUCam has a regulator already In addition I included a terminal to connect the CMUCam to the UART from the microcontroller As a result I could replace the LCD on the robot for a laptop that generated more information from the CMUCam if I wanted to The microcontroller is powered off the battery because it also has its own regulator From the microcontroller the sonar rangers and DIR detectors are supplied 5V A power switch allowed the robot to turn off when I needed the robot to stop On power up the program in flash memory ran from the beginn
31. p amp r_range lt threshold lcd clear_screen lcd out_string Missed an object rand _ turn 33 else if r range lt threshold lcd clear_screen lcd out_string Missed an object L turn 33 Clear ahead forward 33 return 0
32. s shown at the moment the camera almost touched the object This certain moment is an artifice that is impossible in real life I reran sections of the final software to expand the range of color values that I based a red blue or no object on I checked the colors to see if ambient light looked the same as red or blue but it did not See my special sensor report for more details Conclusion Ant is not ready to go into destroyed buildings and retrieve whatever you tell it to yet However Ant has performed obstacle avoidance edge detection line following and color recognition I modified circuit boards and software to drive Ant too Ant is limited to flat surfaces seeing the desired object before retrieving it and avoiding obstacles that are taller than it My photoreflector and power boards kept running long after I expected them to The one technical caveat that I pass on is that sometimes a problem in your robot is not as bad as you think it is For example I spent hours running the robot to try to fix the servos but I did not realize my problem was that my batteries were low In the future if I started Ant over I would not short out LCDs buy as fast as I did or neglect the assistance of software To enhance Ant I would make the gripper omni directional use the track color function with white LEDs to find objects randomly replace servos with motors place sonar rangers close to the ground enclose the wires and battery pack wi
33. th mechanical fasteners and add a voice chip Perhaps you can use a voice chip as a special sensor I would also specify that Ant have four edge of the world IR detectors at the corners of the robot s mobile platform to allow Ant to get closer to the edges safely I considered Ant an investment In my opinion little time or money that I spent on this robot was wasted Documentation CMUCam User s Manual v2 00 Anthony Rowe and Carnegie Mellon University edited by Charles Rosenberg and Illah Nourbakhsh lt http www 2 cs cmu edu cmucam Downloads CMUcamManual pdf gt SRF04 Ultrasonic Ranger Technical Specification lt http info hobbyengineering com specs devantech srf04 tech pdf gt Hamamatsu Photoreflector Data sheet lt http www acroname com robotics parts R64 P5587 pdf gt MAVRIC IIB Manual lt http www bdmicro com images mavric iib pdf gt Atmegal28 Complete Datasheet lt http www atmel com dyn resources prod_documents doc2467 pdf gt Thanks to Fernando Hernandez Su of 05 for his CMUCam documentation Matthew Yoder Sp of 04 for his circuit board diagrams Matt Moore for his PCB milling Ken peer for his approach to SRF05 programming Foley peer for his logistical help Drew peer for his website assistance Appendix To remedy the lack of information on how to program a robot I will discuss where to download programming tools and methods to program a robot based on an Atmegal28 micr
34. while UCSROA amp _BV UDREO 0 UDRO message t ttt Receive a message unsigned char UARTO RX void while UCSROA amp 1 lt lt RXCO return UDRO CMUCam functions void cmu_init void Reset UARTO_ TX RS r ms_ sleep 20 Poll Mode UARTO TX PM 1 r _ sleep 20 Raw Output RTO TX RM INEN _sleep 20 Middle Mass On RTO TX MM 1 r sleep 20 ack with the full window RTO TX SW 1 1 80 143 r sleep 20 Gans ans ans 3 x Get the mean average values of red green and blue R G B x and store them in the global CMUResponseBuffer E void CMU GM void int i 0 char tempChar UARTO_TX GM r Read and discard the first 255 framing byte tempChar UARTO RX Read 7 byte long type S packet for i 0 1 lt 7 i CMUResponseBuffer i UARTO RX Trash the last 255 framing byte while tempChar tempChar UARTO RX CMUResponseBuffer i O Tracks a color void CMU_TC int Rmin int Rmax int Gmin int Gmax int Bmin int Bmax Gmax int i 0 char tempChar tempMessage 30 sprintf tempMessage TC i i Si Si Si Si r Rmin Rmax Gmin Bmin Bmax UARTO_ TX tempMessage tempChar UARTO RX Return a 9 byte long type M packet for i 0 i lt 9 i CMUResponseBuffer i
35. with and at a 45 degree angle to the black line numbering six Then I wrote an if statement to ignore all IR values around the range of these six but still see an edge 2 Sonar ranger With an LCD and a JTAG in circuit emulator ICE programmer I looked at the calculated distances Then I turned Ant to see how much distance Ant needed to clear an obstacle Last I chose a large enough distance and added avoidance into the software 3 DIR detector I checked if any of the four original ones worked The right most one didn t because I melted the copper off the board when I soldered it Consequently I based the line following behavior on the two center DIR detectors primarily I modified the software to wait in a while loop until the sensors showed the robot was centered on the line These experiments taught me that I should try to be as random as possible so that my robot can adjust to any scenario that it enters 4 CMUCam It was crucial that I conduct all experiments with this sensor in the environment of the final user because this color reader changes from ambient light drastically Another source of noise for this sensor was if the sensor was in motion I had 100 error in values that were displayed while and less than 50 ms after Ant was moving I read mean color values of ambient light to assure the color values of the objects desired differed I read color values arbitrarily but the only ones that mattered in my case were those color
Download Pdf Manuals
Related Search
Related Contents
the VS-640 Brochure BALMORAL OPERATING INSTRUCTIONS Connect™ User Manual Blue Step Platform Edge-Core ET4201-LX LIP-ME201 User Manual Copyright © All rights reserved.
Failed to retrieve file