August 25, 2009
During my microprocessor lab last spring I started programming a PIC 18F1220 for fun. I started with a bunch of small projects that I put together to make this autonomous robot. For this robot, I learned how use a digital ultrasonic range sensor and how to write my own software PWM (pulse width modulation). I decided not to use the hardware PWM because at my clock speed it would not output at the 50Hz necessary for servo motors. If I wanted to use the hardware PWM for servos, I’d have to sacrifice speed. The software PWM I created has 3 outputs, one for the servo that moves the sensor, and the other two for the drive motors. Currently the robot does not drive in a straight line. I’ve tried to fix this in software but the differences in the motors is not constant. I’m working on adding an encoder so the motors can be set the same.
Since the video below was shot, I’ve made some modifications to the code to improve it’s autonomous navigation.
May 2, 2009
My first pic microcontroller project was counting on a 7 segment display. Technically I started with a flashing led but what kind of project is that? This was my first project that actually did something. I used a pic 16F84A, a 7 segment driver chip and a 7 segment display. The program was fairly simple. it needed to count to 9 then I could either have it count down or reset to zero. I also had to create some delay so that the number would actually be seen on the 7 segment display.
This program logically was not difficult but inexperience made the process slow. First I didn’t think of ordering an oscillator when I ordered the sample pic. After some reading in the data sheet I figured out there was an RC mode where I could use a resistor and capacitor. This seemed simple enough until I realized that I didn’t have the capacitor that I needed. I read online how someone used just a resistor and the stray capacitance from the breadboard. I decided to give this a try. This is the most unstable method you could use. It worked alright but sometimes the pic would be slow and other times it would fly through the program.
This was the project that I learned all the general information about programming a microcontroller. I learned how to configure ports for input and output and how to move and manipulate data in the microcontroller. The most valuable thing I learned was how to look up information in the data sheet. At first It was difficult to follow and understand how things were organized in the data sheet. After a while I got good at searching for key words.
Link to code: 7-segment