Ir Rangefinder issues

I hooked up the second robot and programmed it with the same code as the other one but it kept crashing and resetting. After about and hour of debugging we narrowed it down to the Ir rangefinders. Unfortunately, it's not the sensor itself but something wrong with circuit.It only crashes when both of them are plugged in. I'm guessing there is a short from one of the grounds to a dataline on the opposite side. Either way, that means we're going to have to pull it all apart again to try and find the short. Not fun...

Rundown

A lot has been done since my last post, so this one will be in point form.

- Second robot finished.
- Created basic algorithms for wall following.
- Got usb to serial connection working on my linux laptop.
- Ir beacon identification code finished and working well.
- Figured out and fixed drive problem.
- Started central python program that will control the bots.
- Started the graphical display using game engine for bruteforce optimization.

One Down One To Go

One of the robots is finished and fully operational. Also, all of our low level code is finished. We're finally getting into the higher level programming! I got very basic obstacle avoidance with the sonar going in less than a few minutes. I'm actually shocked at the little amount of changes the code needed to work 100% on the new board. David is starting the other robot now and i'm going to try to get RF working between the pc and the robot tomorrow.

Soldering

David already made one of the beacons and put the pic, RF reciever/transmitter, leds, h-bridge and power connectors on tha main board. The RF is working great. The beacon code needs to be modified a bit because the timing is off. David soldered on the diodes backwards for the drive. It wasn't his fault though because it was labeled wrong on the schematic. Hopefully it will work once he flips them. We can start getting it driving around.

Boards are In!

The boards finally came in the mail! They actually have our names written on them XD. I cut them up and David is putting on the voltage regulator right now because he's much better at soldering. I'll do some of the easier stuff like beacons later on so that I don't mess up anything important.  

Schematic/Artwork Pictures


Artwork

Dave is back today. He's been sick the whole week. We started placing the components ont the artwork and deciding how we want to lay it all out. Hopefully in a couple days, we'll be ready to order the board.

Board Mechanical Artwork

I did the board layout today and got the screw hole locations measured and added them to the artwork. It's harder than you think....

Footprints anyone?

We haven't made a blog entry in a while already. However, there isn't really much to report. We've been working on the schematic mostly and it's proving to be a bigger pain than we anticipated. We have to find/make and add a footprint to every single component individually. It's very time consuming and the software we're using is pretty buggy so it can get a little frustrating at times. But we're almost done so it's all good.

Too Much Wasted Time

Today we tried to go from the number of bits to our actual binary message. To simplify things we coded in visual c++ rather than MP Labs. It took a while but we got the number of bits translated into binary by storing the binary message in another array. After we got that right we tried to do the same thing by bit shifting within one variable (to save memory) rather than using arrays. In the end we got that method mostly working but we decide to stick with the arrays because we didn't have any problems with it and we aren't worried about memory space. Tomorrow we will try and implement that into our code.

More IR Detector-Emitter

Ilia was away... agian. This left me with pretty much nothing to do because Ilia was doing most of the programming work before and didn't comment. I hate to admit it but I sort of need him for the programming. So... not much got done.

10101010101

We got the code working today!
It is able to successfully transmit/read bits.
It goes like this:

Read the current pulse time

The pulse duration is equal to the previous time, subtracted from the current time.

The number of bits in each wave is the pulse duration divided by 1300 (one bit).

This gives an output similar to this:

1 1 2 1 2 1 1 1 4 2

Each digit represents an edge of the wave and their values are how many bits are in each wave.

So in binary it would look like:

01001001 01000011

If you still don't get it, this should clear it up:

1 | 1 | 2   | 1 | 2   | 1 | 1 | 1 |4        | 2
0 | 1 | 00 | 1 | 00 | 1 | 0 | 1 |0000 | 11

Convert that to Ascii and you get: "I C" ( My Initials XD )

Ground

We spent half an hour today debugging the beacon circuit. It was working and then all of a sudden stopped. We hooked up the scope and found that the pulse was around 44khz and it was supposed to be at 36khz. We fixed the code but the receiver still wasn't picking it up. Then we found the problem, we accidentally reversed the  output and ground pins on the detector *facepalm* .  However, if this didn't happen we wouldn't have found the problem with the frequency. Anyway, after reprogramming the beacon, we slightly modified the input capture code that we used with the digital compass to work with the beacon detector. It doesn't really work yet though, so that's what we'll be working on tomorrow.

IR Beacon-Detector Cont.

We continued working on the IR beacon-detector. We moved our program for the beacon from our emulator on to our actual PIC so we can use the emulator to get the detector working. To do this we had to actually breadboard the beacon circuit and figure out how to use the programmer. We also had to change a lot of our code to go on the PIC we are using for the beacon because it's a different type of PIC than the one we are emulating.

Beacon Schematic

We did most of the beacon schematic today. We're going to have either 4 or 5 ir leds per beacon and I'm thinking of adding an extra regular red or green led so we can get some visual feedback from it too. There is going to be a 3 pin dip switch so we can choose preset output patterns by setting the corresponding pattern on the dip switch. This way, we won't have to reprogram the beacon's pic every time we want to change the message being pulsed out. I'm hoping to get the cirtuit breadboarded tomorow with the actual dsPic30f2012 that we will be using for the beacons.

Bitwise

We made A LOT of progress today. First we wrote a function that converts a character into it's binary value and stores it into an array. Once we got that working we had the ir beacon pulse out the binary values. Due to the way the detector works, we had to invert the signal to keep the output from cutting out. After doing this, the results were pretty consistent. We then moved on to getting it to pulse out whole strings which was surprisingly simple. The funny thing is that we only really need it to pulse out a 4 bit pattern. You could say we got a little carried away. Nevertheless, this has to be one of the coolest things we've done so far.

IR Beacon-Detector

Our IR beacon-detector parts came in today. XD. We started by writing the code for the emitter. Then we hooked up the oscilloscope to the output pin to calibrate the frequency (mostly trial and error). After we got the timing right we connected the emitter circuit to the pic and the detector to the oscilloscope on a different channel to see the relation between output and input IT WORKED FIRST TIME! We are both still in shock. Today was a good day.

Presentation Day

Other than my voice cracking every other word and me putting up a slide backwards, the presentation went pretty well. We made it simple enough (I hope) that everyone in the audience understood what we are trying to do but still technical enough to make us sound smart :p.

Presentation...

We spent the day putting finishing touches on our presentation...

Presentation Prep

We have a presentation in two days for all the other mentorship students and their parents. We decided to use a software called Inspirartion which will display our ideas in a manner that is very visual and easy to understand. We also talked about ways to present our ideas and project goals in a way that will be comprehensible to an audience without any technical background.

Almost Done...

Ilia didn`t show up today, again without telling me (btw I checked my email and Ilia didn`t email me the last time either). I don`t really blame him for not comming in; today was very boring (Ilia would have just slowed me down anyway :P). I finished drawing in the connection for all our components other than the IR detector because we haven`t bought one yet.

More Schematics

We worked on the schematic today, (btw I don`t know what Dave`s talking about becasue I`m better than him on OrCAD). Anyway, we got all the hard parts of the schematic done today. I drew up the H-Bridge circuit becasue Dave was away the day I did that. The rest will be relatively easy, just time consumming.

OrCAD

Now that the libraries are finished and we know how all the hardware will hook up to our PIC, we decided to start on the schematic. Mike helped teach me OrCAD (Ilia is useless at this stuff) to start drawing the schematic. I learned the basics by hooking the PIC up to power ground and connecting the programing and master clear lines. I think Ilia slept though most of the lesson, but now I know OrCAD well enough to work without Mike to produce the schematic.

Digital Compass Woes

The compass was still giving us trouble, so around 1:30 so we called in the experts. Another hour with an oscilloscope and we finaly figured out that we forgot to put the pull-up resistors in... agian. Nevertheless, we got it working. WOOOOOOOOOOOO!!!!!!!!

Libraries..continued

We finished organizing the code all except for the digital compass which for some reason just didn`t want to work. We`ll have to figure that out on Monday becasue we`re too tired and it`s a Friday night.

Libraries

Dave`s not here today so I thought it would be a good day to start organizing our code. Right now it`s a huge mess. It wasn`t even devided into functions and most of the variables and code was canibalized for other applications so half the original code didn`t even work. I spent the day putting everything into legible and usable functions with relivant variable names and then putting them into header files.

IR beacon (continue)

Before I begin this post, I feel that I must defend myself. First of all, I emailed dave telling him that I wans`t going to be there. The fact that he doesn`t check his emails isn`t my fault. Daves ``averaging function`` was basicaly just him rounding it from 3 to 1 decimal places. My method was WAY better. Also, the calibration functioned mentioned was 95% written by me and was my idea.

Ok, back on topic. We continued to work ok the IR emmitter-detector setup which we started the day before. No real progress was made today. It was mostly just testing out different configurations in the way the ir led and detector diode were positioned and shielded. The detector was picking up a lot of ambient Ir light and it had a very wide field of view so we used some black electrical tape to focus the detector on a specific spot. This method worked pretty well.

IR Detector-Emiter

We started experimenting with some IR leds and an IR detector diode we found in the shop. Unfortunately, the first IR detector diode got fried. My bad... We found a newer diode to use instead and got both it and the IR led working. We conected the diode through an analog pin on the PIC and had it displaying values in Hyperterminal. It worked well enough for testing but at a very limited range. We`ll need to find a higher powered IR emitter as well as a more sensitive detector for better range.

Accelerometer... Again

Ilia didn`t show up today (without telling me) so I decided to give the accecelerometer another try. I rewrote the averaging functions the way I wanted to do it. Last time Ilia forced me to do it his way which didn`t work as well. I got the accelerometer giving acurate readings to 1 decimal place with the calibration function holding it to 0.0 constantly. However, when we moved the accelerometer around to test it`s distance calculations the speed did not go back to 0 when we stopped. It`s definatly an improvement from what we had and maybe we can still incorporate it.

Digital Compass (I2C)

The I2C connection gave us a lot more trouble than we thought it would. We already had working example code to use but it took us half the day and three oscilloscopes to figure out that the compass does not have on board pull-up resistors. Once we added those, it worked. We compared the sets of readings in Hyperterminal and the I2C was much more consistent and had a higher resolution than the PWM.

Digital Compass (PWM)

The digital compass has two options for interfacing it (I2C, PWM). We tried PWM input capure becasue it seemed like the easier option. Becasue the clock restarts at 40 it took a bit to figure out how to get a reading in degrees from the pulse width capture reading. I got eventually... However, the readings were not really accurate and the values liked to spike sometime for no apperant reason. Since the I2C pins were not being used by anything else so we decided it would be the best option.

Even More Accelerometer

We finally figured out a working example of code that translates the acceleration to a semi accurate distance reading. The averaging still needs tweaking though. However I think we might not end up using the accelerometer at all because the readings are not as acurate as we had hoped for. There are just to many things that throw it off. I think we're just going to end up figuring out the distance travelled by calculating the average speed and including the slip when the robot starts and stop into the equasion.

More Accelerometer

The accelerometer reading were still not as acurate as we wanted them. Most of the day was spent coming up with better way of averaging and figure out how to single out random spikes so the can be exculded from the averaging. We got it working a bit better, but the only solution that really worked was to round the output value a decimal space. It's not the best way to do it, but we're out of ideas.  

Drive Control

Dave left me hanging today so I'm here by myself. I didn't really feel like using my brain today so I decided to figure out the motor control instead of the accelerometer. We were originally thinking of making our own H-Bridge, but we have time restraints and there's no point in reinventing the wheel so we just bought a simple module the will do the job. We bought the L293 QUADRUPLE HALF-H DRIVER NE ic. I got it working on a breadboard and I finished writing the basic functions in mplabs.  

Another Library Workshop...

Read the title, enough said...

Interfacing the IR, Sonar and Accelerometer

Today we got the sonar working. It didn't take a lot of time because the code was almost identical to the IR rangefinder. Also, the equation for converting the analog value to distance is linear so it's even easier. The accelerometer also uses analog to digital so we started on that too. We got a lot of problems with the values it was outputting because they were inconsistent and jumping all over the place. We solved this by adding a decoupling capacitor to the accelerometer's power supply and incorporating averaging into our code. I can tell already that the equation for getting speed from acceleration using this thing isn't going to be easy at all. 

Sensor Interfacing

Before starting a schematic we decided to individually test and debug each of our sensors/modules with the ICE emulator and prototype board. Ilia thought (and I agreed) that it would be a good learning experience for us to write ALL our own code rather than use third party libraries. Today we started with the IR rangefinder by modifying our previously written A to D conversion code. I figured out the equation to convert the A to D value to distance in centimeters

y = 32.14294004 x4 - 195.6090369 x3 + 437.1088864 x2 - 446.8068463 x+ 202.2574821


(No thanks to Ilia who was "sick". Whatever, he wouldn't have helped anyway).

Sensors

The order finally came in:

IR Range Finder














Sharp GP2D12 IR Range Sensor - 10cm to 80cm.

Accelerometer:













ADXL322 2g +/- Buffered Accelerometer.
This will be used for mapping to measure speed and distance traveled. 

Ultrasonic Range Finder















LV-MaxSonar -EZ3.
Will be used for mapping and navigation for object detection/avoidance. 

RF Transmitter/Receiver













On Shine 433MHz. For robot control and robot to robot communication.


Digital Compass
 


CMPS03 Module. For direction orientation during mapping.






A to D and Uart

Continued programming in MPLABS. We moved on to more complex programs (no more leds). We got serial communication going through the Uart port so that we could display debugging information in Hyperterminal. After this, getting analog to digital conversion working was much easier. By the end of the day we were successfully displaying analog readings from the potentiometers in Hyperterminal.

Library...

Library Worshop....  >_<

MPLABS

Started programming with MPLABS. Simple digital input/output (ie blinking leds and pushbuttons)

Block Diagram




After deciding all the sensors/components we wanted to use, the first real step we took in the design process was to make a very general block diagram to get a good idea of how everything was going to interface. All the modules were assigned to specific pins on the PIC microcontroller to ensure that there were enough space to incorporate everything we wanted to.

Wall Following


Wall following seemed like it would be very helpful for room exploration/mapping. We figured the easiest (and cheapest) way to do this was with those analog IR Rangefinders. When you're making two of something, the price likes to add up. $12.63 * 2 per robot * 2 robots  = $50.20....

Wireless


We decided to use RF for wireless communications instead of wifi because of budget restraints. I decided to get the On Shine 433MHz High RF transmitter/receiver pair from Robot Shop. It's cheap and looks like it will cover our needs.

Chassis

Due to time constraints, we decided to purchase a premade chassis opposed to desgning/constructing our own. We chose the Arduino Robot Rover platform from RobotShop. It comes with the drivetrain and it already has mounting spots for most of the sensors/hardware we plan on using so there will be hardly any modification needed. Win win!

Microcontroller


We are using the dsPic30F6014A microcontroller by microchip. We also get to use an MPLAB ICE 4000 emulator with a dsPICDEM 1.1 development board which is awsome for testing and debugging.

Day 1

This was our first day at Mentorship. I met Ilia my partner and Tom MacDonald our mentor. We spent most of the day brainstorming project ideas. After much debate we finally settled on making a robot (or pair of robots) that autonomously search a room for an IR (infrared) beacon.