General Design        FREDDY has at its heart an 8051 microcontroller. This microcontroller performs a number of tasks, from downloading the program to running the AI, and is mounted on one of three breadboards that contain the electronics in the center of the robot. All of the other electronics on these breadboards are used to either support the hardware (the stepper motors and the sonar) or the 8051 itself.         FREDDY is programmed with a very simple programming language summarized in the table below. Each command is one byte long with the first three bits being reserved for the instruction id. The first two bits are used to tell FREDDY to pause, move forward, left or right. The third is used to tell FREDDY to ignore the sonar and thus turn off the collision avoidance system. The other 5 bits are used to convey the number of times that the instruction should be repeated. This allows us to get more mileage out of our code space. For example, if the user wanted the robot to move forward in a straight line for 5 forward commands, instead of giving the system five seperate commands the user can send it one command to be repeated five times. In the systems memory, the directive will now take up one byte rather than five, leaving more space for other instructions.
   FREDDY's basic instructions set |
User Program: | Before we could do any real testing, we needed an easy way to download programs to the machine. We accomplished this by writing a program in VB that gave us an easy to use UI for creating and downloading, byte by byte, our programs. |
Control Logic: | Within the 8051, the first task that starts is the control logic. This is the task that sets everything up and does the central processing. The control logic also decides when to fire the sonar and decomposes and runs each instruction. |
Serial Interface: | This task has two functions, it downloads the program from the serial link as it comes from the PC and it serves to the control logic the next command in the queue as the program executes. The Serial Interface is divided into an interrupt driven upper half, and a normally scheduled bottom half. The upper half handles the first task, while the bottom half handles the second. |
Motor Controller: | This task runs the motors. It creates the pulses used by the motor driver chips to actually drive the stepper motors. The direction of each of the motors is determined by output bits set in the control logic. |
Sonar Controller: | This task controls the sonar and records the value of the counter upon detecting an echo from the sonar. It is also responsible for resetting the sonar for the next time that it is read. |
AI: | This is the biggest and most involved of all the tasks. When FREDDY first encounters an obstacle, this task is called. It pulls the remainder of the program, byte by byte, from the memory and uses it to determine where its ultimate destination. It then records the location of the obstacle in a grid map stored in memory. Each square on the grid, has four bits used for path finding. The grid map is 101x101 squares and each square is the width of one forward movement. Although the algorithm is fully functional in the compiler, we were unable to get it to work on the machine itself. |
Number | Item Description | Comments |
- | Cardboard base | This provided the main structure to the machine | 3 | Small Breadboards | Mounted in the center, these provide us a place to put our electronics | 1 | 8051 Microprocessor | This is the real heart of the machine | 1 | 32K external memory | Due to the complexity of the AI, the 256 byte memory of the 8051 proved insufficient. Thus we installed a 32K RAM. This RAM does not appear to be as functional as we had hoped. |
1 | RS-232 Tranciever | Used for downloading instructions from the user program |
2 | Stepper Motors | Provide the basic motive force for our vehicles |
2 | Motor Drivers | Provide power to the motors |
1 | TTL eight bit latch (SN74LS373) | Used in interfacing the external RAM with the 8051 chip |
1 | Sonar Tranciever | Used to provide forward rangefinding |
1 | 32 MHZ clock | Used by the 8051 |
Assorted | Capacitors, Resistors and Diodes | Used for various purposes | Assorted | Legos | Used to build supporting structures and the castor wheel in the back |
Problems        FREDDY was an interesting project in that there appeared to be more problems at the end than at the beginning. When we first began working on the device, we divided the programming into three small pieces, one for each of us. These pieces included the serial port, control logic and motor controllers. Each of us wrote our parts and then integrated the whole in a Tuesday lab session. After some debugging in the compiler, we burned the chip. FREDDY worked the first time. Then the problems started. Sonar        Here we experienced a number of problems due to the electrical characteristics of the sonar and the ATMEL. The biggest problem was the failure of the ATMEL to recognize the ECHO line on one of its interrupts. At first we thought that this was due to the interrupt pin only recognizing a falling edge on the line, so we added an inverter. This did not solve the problem. Then we switched the internal code to a busy wait (it didn't hurt us in terms of cycles since the sonar code was the only thing running on the ATMEL) yet the problem persisted. So our third course of action was to look at the electrical signals themselves. The AI        Timmy (the name has been changed to protect me from retribution) was a man who had a dream, he felt he could build an AI that would amaze even the greatest researcher in the field. So he began work on this marvel after the initial bot was complete. He worked tirelessly for hours not only building incrementally upon the algorithm, but learning the intricacies of the compiler as he tested and debugged the code on the way to perfection. And then it happened, he exceeded the standard code limit. Luckily he found dongles that allowed him to compile and was able to continue his activities on the full version of Kiel, but not without many trials along the way and many hours spent cursing Ectingdule. So he continued, and finally installed his program into the beast to be tested. |
Conclusion        FREDDY was a bit ambitious for the time that we had, but we successfully accomplished most of our design goals. We were able to build on the things that we had learned in class and through labs to add functionality rather quickly to the device. As this is a prototype device, we decided to remove some of the constraints that would be challenging not in their academic application, but in regards to available materials and time. This included the idea to use a wireless kit and to have an onboard power supply. We also added some functionality that was helpful mainly in testing the device, including ambilical cords for sending instructions and providing power to the device. If we were to continue development, the cords at least would be replaced by their wireless equivalents and we would probably spend more time on the design of FREDDY's body. We would also try to repair the electronics so that the external memory was fully usable as had been the hope in the original design. Despite these changes and the problems encountered along the way, FREDDY was a successful project. The platform we developed could concievably be used as the basis of future projects where the developers may wish to concetrate on some feature of robotics beyond the basics. |