- Download the required software. I have found success with ICProg (http://www.ic-prog.com/), with MPLabs IDE and their C18 compiler (Lite/Student)
- Setup your project in MPLabs according to their tutorials/user manuals. Get all the include files necessary for the C compiler to compile and link, and build. This generates a hex file.
- Run ICProg. First time setup will require you to also download and run the XP/2000/NT driver (icprog.sys) if you are using one of these OS. Not sure if it works for Vista or 7, and no idea what a good Unix hex programmer is.
- Side note: ICProg also allows you to do hardware tests. This sets the serial pins hi or lo for you to test your programmer's response with a DMM.
- Select your PIC (or other MCU), programmer (mine is similar to a JDM) and use the Windows API setting. I have I/O delay of 4. Com 1 is the serial port on my comp. Usually 1 and/or 2 are serial ports. Hit the Program All button!
- This will take some time (maybe a minute) and will put your program onto the micro. Unfortunately with my circuit the data only goes one way so it can't verify. Hope to fix that with my last opto-coupler for the next iteration.
This is my tech blog, where I post projects and things I'm working on. Over time it will become a personal portfolio. For information on my masters project: a gecko-inspired climbing robot, see the ESA article and video here
Wednesday, May 26, 2010
PIC Programmers
Monday, May 17, 2010
Arduino Fun
- The robot rotates 360 degrees to scan the room where it starts. The area it can see (un-occluded) is shown in grey. It will see mostly walls (or beds or tables) and then a small gap which could be a doorway, space between desk and bed etc. This gap is represented by a dotted line.
- The robot positions itself near the gap and scans around 360 degrees. Either it will fill in the gap (maybe this was a small, open closet) or the gap will remain open (eg. doorway, large space). If the gap remains open, it is marked as a doorway, and the room inside the doorway is marked for cleaning. If it is closed, the new area enclosed is also marked for cleaning.
- The robot then cleans the "room" that it has identified.
- If there is one "doorway" (dotted line), the robot drives through and scans the new "room". If there are multiple, it notes the location of all of them, and then chooses the closest one in its bank of un-scanned doorways to drive through and scan.
- This process is repeated until batteries run out.
- Could be tricky if the room is very large or open. It may be possible for the robot to spend all its battery energy attempting to enclose an area for cleaning, without doing any of the actual cleaning.
- Doesn't take advantage of the fact that the room generally will look the same from week to week. There is very little storage and reuse of maps.
- Representing the room in the robot's memory will be tricky. Currently my plan is to overlay a grid on the room, and have the robot identify which squares are occupied by walls, tables, etc. and which need cleaning. Memory usage will be inversely proportional to the resolution required (which I think will be around 10-15cm square).
- Rooms are cleaned in segments. This way when the robot runs out of battery, at least contiguous sections of the house are all clean.
- Low processing requirements. The toughest computations will be: calculating the position of ultrasonic identified objects, determining if walls are connected or if there is a doorway, and choosing a path through the room to clean all open the floor space.
Sunday, May 16, 2010
Schematic V1.0
Hardware design is almost done! Here's a link to the first version of the board that will sit onboard the Roomba:
http://sites.google.com/site/zambots/project-files/MCU_boardandProgrammer.pdf?attredirects=0&d=1
And here's how it works:
- Code for controlling the Roomba and distance sensor is written in C on a computer. This is converted into hex and sent via serial to the programmer. For this step, a serial cable must be connected between the computer and circuit board.
- The programmer is a set of hardware the allows for programming of the Microcontroller (MCU). It must hold the high voltage (MCLR) pin to between 9 and 13.5V, and then apply a clock signal and a synchronized data stream to the PGC and PGD pins on the MCU. The data stream contains the code to be executed.
- Once programming is done, the serial cable can be disconnected. When the programming is finished, the MCLR pin is held at 5V using a diode, and now acts as a reset switch (if pulled down to ground).
- Power for the MCU and associated devices comes from the Roomba battery. This is an unregulated 15V, and 3 different voltages are needed on this board (3.3, 5, and 12). This is accomplished through the use of 3 voltage regulators.
- Note that during programming, there is another set of voltages on the board. This is because the serial voltages are somewhere around 7.5V, which could damage the MCU. This motivated the use of opto-couplers, so that the serial voltages and its ground (from the computer) is kept separate from the MCU voltages and their ground (from the Roomba).
- The MCU collects distance data from the ultrasonic sensor at scheduled intervals. To do so it sends out a short pulse, and then waits to receive a pulse corresponding to the distance to the nearest object in the direction pointed. Directions will be calculated from wheel encoders, already integrated into the Roomba platform.
- The MCU also communicates with the Roomba. This is done through the UART. First a device detect pulse series is sent. Then serial communications can be sent. Instructions tell the Roomba to use its motors, LEDs etc. or to return sensor data packages.
- The MCU also communicates with the Arduino through the XBee module. This is done through the UART also. However the XBee operates on 3.3V, while the MCU operates on 5V. The 2 NPN transistors between the XBee and MCU are for level shifting the transmission voltages to avoid problems.
- In order to allow both Arduino and Roomba to communicate with the MCU via a single UART, a MUX/DEMUX chip facilitates communications. 2 control lines from the MCU can select which communication channel is open for transmission or receiving.
Design is one thing, practicality is another. Hope to be testing this in the next couple weeks, and I'm sure at that point I'll make some modifications to the board. Once this is working, I plan to post my BOM too, with digikey part numbers for all the electronics and suggested retailers for the rest.
-Mike