Monday, April 25, 2011
Attachment of Showcase Handout
Monday, April 18, 2011
Completed!
Friday, April 15, 2011
New drive values - implemented!
In my video, I start out pushing the stick to the right, then slowly circle counterclockwise slowly about 1.25 times around. If you follow my rotated unit circle from my previous post (and you have a good idea of the decimal values of fractions shown) you can see that this will work just fine.
(Currently my video is not uploading right... I'll take a look tonight and fix it then.)
UPDATE: So the Jing video I recorded is a .swf file, and for some reason it isn't letting me upload it. Suffice to say, I won't be worrying about the video... but believe me, it was good. :-) No it wasn't, it was a bunch of numbers flying up a screen. I'm really tired... only thing left to do is paint him and he's done done.
Thursday, April 14, 2011
Drive values solved... hooray trigonometry!
Today I was brainstorming and thought "maybe cyclical trig functions would help out", so I looked up the unit circle:
I got this picture from: http://www.mathpeer.com/images/trig/unit_circle.gif |
Well, this isn't exactly helpful... I mean, full Y and no X should be both wheels forward... here, it would be full right, no left. Then I put my head on my chin and thought some more... and while my head was tilted on its side, I finally got it... what if:
... I turned the unit circle a little bit (about 45 degrees). Now, full Y and no X would give me the same value for both wheels (with sine and cosine). What about my other conditions? Well, full left X and no Y will give two values of equal magnitude, but opposite direction... and full right X and no Y gives the opposite effect... AND full backward Y and no X gives the same values, but both negative. EUREKA!
So, my new process will be:
1) Input X and Y axis values from the controller (from 0 to 255)
2) Map these values so there are negative and positive values (ie: -200 to 200)
(this will allow me to determine which quadrant of my new unit circle the stick is in)
3) Determine the angle from one of the axes using the X-Y values and arctangent (arctan(X/Y) = angle)
4) Assign cosine of this angle to one wheel, and sine of this angle to the other
(these sine/cosine values will now act as percentages of SPEED, determined by how far from center the stick is [calculating the length of the hypotenuse, since X and Y act as the other two sides])
5) Multiply these assigned percentages to the speed and set the results to the wheels
Voila! No if-else trees, just short pre-process calculations then set values and go.
In theory... I've only come up with these just now during my Thursday classes. I'll test these ideas tomorrow and hopefully, that will be the end of the drive tweaking (and indeed, the end of the software development entirely).
Wednesday, April 13, 2011
Construction 99% Completed - Phase IV
Tuesday, April 12, 2011
Magic legs - Phase III
R2D2's got magic legs! I finally decided on how to attach the legs to the main body... with removable pins through a support beam. I've also decided at this stage that (unless there are any complaints from Professor McDaniel) this will be the last picture I post until the big reveal at the expo. I'll still post updates, but I'm really proud of my droid and I want his final appearance to be a surprise. See you guys on the 21st!
Sunday, April 10, 2011
Late night body building - Phase II
Droid all in pieces (except the lowest level because I had all the wires run through it) |
Speaker placed |
Arch with the XBee unit placed |
Third level with the dome motor placed |
Dome placed |
New front caster with shell (no wheel binding this time!) |
Side view of the new hotness... I mean caster. :) |
Saturday, April 9, 2011
Front wheel woes
So after mounting the front caster last night, I thought that it might be a little too far out front, but I decided to go with it. I spent a couple hours putting the shell around the caster and framing it up, but now it REALLY looks too far out... so I might be dismantling that soon. I'll wait until after I build him up more before deciding...
Body construction - Phase I
I have begun construction on the body. I'm taking a triple decked approach, each level will be removable so that I can get to any of the parts. So far, I have built the lowest level with the chassis and battery packs, mounted the front caster, and started the second level (which is where the arduino, shields, and hopefully the speaker will be held). The third level will have the dome motor mounted to it. I'll post more as I build it.
Friday, April 8, 2011
Dome construction
Wednesday, April 6, 2011
Sound work continued - Motor shield integration
Today was scary. Really scary. Really REALLY scary. So scary, that had I screwed something up while doing what I was doing today... I would have had no droid for my final project. But as Seth Rogan said in the movie Paul, "Sometimes you just gotta roll the dice." So I rolled. And after a couple of hours, I breathed a sigh of relief. My motor shield still works. My wave shield works. And most importantly, they work TOGETHER. Let me share with you what I did today.
First, it had been a while since I loaded up the wave shield, so I brought that out and put the new R2D2 files on it. Works like a charm. Next, I needed to be able to access each file directly instead of consecutively, so I grabbed some of the sample code from the library and there it was. Piece of cake. Then, I said to myself, "Self... let's stack these things." So I did. I stacked the wave shield on top of my motor shield (which is on top of my arduino), and I copied in just the part of the setup code that would read the available files on the SD card (for now).
As expected (because I've been lucky with a bunch of things on the project so far, so I figured that I would run out about now) the files could not be read. I was prepared for this, thanks to Mike's truth table he sent earlier this semester. So I went to work un-soldering 4 of the 5 jumpers from pins 2-5. While I was at it, I decided to add some headers so I could test back and forth until I got the right combination right. The prototyping jumpers are a little less permanent, but that will be ok for the final project. After I put the headers in, I put the jumpers in the way they were first to test out the shield (by itself again). Success. Now came the first hard part... figuring out how to modify which pins the wave shield is looking to use for the DAC control.
Luckily, there wasn't much code in the WaveHC library to go through, so in the WavePinDefs.h file, I found four sets of declarations like this (this is what my code looks like now, I put the original lines in comments at the end):
// use arduino pins 2, 3, 4, 5 for DAC
// pin 2 is DAC chip select
/** Data direction register for DAC chip select. */
#define MCP_DAC_CS_DDR PIN19_DDRREG // originally PIN2_DDRREG
/** Port register for DAC chip select. */
#define MCP_DAC_CS_PORT PIN19_PORTREG // originally PIN2_PORTREG
/** Port bit number for DAC chip select. */
#define MCP_DAC_CS_BIT PIN19_BITNUM // originally PIN2_BITNUM
So I followed the definitions of PINx_DDRREG back to ArduinoPins.h, and saw a bunch more definitions, I believe the were some 70 pin definitions for each grouping (probably for Mega support). So I said "let's give it a whirl and reset these definitions to the analog pins (referenced as digital pins 14-19)." So I did that and put the jumper wires in the proper places. Success, my wave shield was now running off the digital pins 16-19, leaving pins 2-5 available for the motor shield. So I tried the two shields together again. Fail. What NOW?
I went back to the truth table (thanks again Mike!) and there were still some pin interactions that I needed to resolve. But now I had no idea how, because the motor shield PCB is made in this way... I didn't add jumper wires like the wave shield. So I did a search for wave and motor shield and came across this forum thread (http://www.adafruit.com/forums/viewtopic.php?f=31&t=8066#p63795). I took a double take. Cut the what? Traces? Never done that before... let's google it! (http://www.diystompboxes.com/smfforum/index.php?topic=81879.0;prev_next=next) So at this juncture, I was floored. Take my perfectly fine working on its own motor shield, solder some new wires and TAKE AN X-ACTO KNIFE TO THE BOARD?? ARE YOU NUTS?? I looked again, and there really was no other way around it... the SD card needs pins 11, 12, and 13 (from its documentation), so if I want these two to work together, gonna have to get in there. This is where the dice rolling came in. Soldering mistakes I can fix, but scraping out the traces is kinda permanent. I highly doubted that I could've ordered a new motor shield in time, but I pretty much had no other option. I followed the instructions by poster 'jonharrell' and soldered in new wires and scraped out the traces for the other two pins. His pictures were life-saving with this. I am (hopefully only) sacrificing servo capabilities to have 4 DC motors and wave shield functionality.
Well, lady luck was once again with me after all and I succeeded. Now I have control of at least the two drive motors (haven't rigged up the third yet to test) and I can trigger a sound to be played with any of the controller buttons. ::phew:: Now the only concern I have is whether the sounds will still be audible from inside the droid's body as well as heard over the motors (even on the other side of the shield where I could specify a higher frequency, the motors were still loud), but that's completely out of my hands unless I find a much louder speaker...
But that'll have to wait until everything else is finished if I have some time left.
Tuesday, April 5, 2011
Starting sound work
So I thought I'd take a short break from working the motor part of my project and do a little bit with the sound. I got 161 R2D2 sound bytes from my older brother today, so I wanted to make sure that the speaker I had would work. I cut the plug off an old pair of headphones and soldered some wires to it.
Fortunately, the wiki page description of which parts were which was accurate and now the speaker works with my wave shield. I've selected 16 sound bytes for the SD card (because I'm going to use combinations of the 4 top buttons to index these).
Next step is to make sure the wave shield works on top of the motor shield...
Wirelessly remote controlled Droid demo
How I'm juggling my sketch uploads
The other part I have to contend with is to upload sketches to the Fio, one of the manual pages somewhere said to not have the XBee attached when uploading sketches... so everytime I go to upload, I have to remove the XBee (don't want to fry it so close to deadline). So I have my controller setup on the right side of my laptop and the arduino/motor setup on the left side... and each respective sketch is on the matching side of my laptop screen. Phew... get all that? Good.
Wireless communication - Part Deux
I finally stumbled upon a post about other people using the NewSoftSerial library for Arduino (http://arduiniana.org/libraries/NewSoftSerial/), and what I found was that the 57600 baud rate that some of the XBee tutorials told me to use is on the absolute edge of capability of this NewSoftSerial library. So I used X-CTU to reconfigure the XBees to communicate at 19200, and changed all serial calls in my sketches to use 19200, and...
VOILA!!!
Appropriate value passing is now occuring. Likely, if I really wanted to, I could probably upload sketches wirelessly now... but I'm fine with my current way... I've gotten used to it.
What is that? I didn't describe to you my current way of uploading sketches? Ok, since you asked so nicely... I'll tell you in my next post. Just need to snap some photos. ;-)
Monday, April 4, 2011
Wireless communication - Part I
The one page that best sums up the necessary steps is this page from AdaFruit (the most important part is getting the X-CTU software to allow you to modify the settings on the radio(s)):
http://www.ladyada.net/make/xbee/point2point.html
Except that since I have an Arduino Fio, I did not need to rig a connection to the board... that's already been done for me. I was also having some issues with the sketch sample at the bottom of the page (sometimes when I tried to transmit more than one character at a time it would garble them i.e. if I sent "1", I got back "1", but if I sent "123", I got back "12c"). So I went for broke and just re-uploaded my PS2 controller sketch, mounted the transmitting XBee to the Fio, connected up the serial port on my laptop via FTDI cable, and hit reset on the Fio. BINGO! Serial communication achieved. Next up, modifying my motor demo sketch to look for serial input and hope my luck can continue...
Droid Mark II body sketch
My proof of concept droid crashed during the demo last week and the supports holding the battery pack in place fell off. I was sad for a moment (nobody wants to see their creations crash and burn like that), but I knew in advance that I would need to be rebuilding the body anyway, so I was good.
From that failed demo, I learned some very important things: 1) put the heavy battery pack near the bottom and as far forward as possible, 2) get a lower profile caster for the front wheel to reduce the amount of backwards tilt, and 3) never underestimate the power of coincidence.
Funnily enough, the power of coincidence ran high this week when I learned that my father, whilst trudging around at MegaCon, had purchased an old land line phone... in the shape of R2D2. As I was looking at it, I quickly realized that it was almost exactly the size that I had envisioned for my droid. So I quickly took up a ruler and pencil to measure all the vital tidbits of info that I could... and I also sketched out some specific layout... because pictures are 2D, it's possible I could have gotten my proportions all wrong going off the high res images from the interwebs. Now, I'm 99% confident about my information!
Rest in pieces, Mark I droid... your sacrifice will not be in vain,
Mark I droid
March 26th, 2011 - March 28th, 2011
(Click on the picture above to get the full size image if you wish to read my chicken scratches)