I took the boat for a test run and discovered some stuff about the new code. It's quite reliable (as long as the XBees are within range of each other), and the lag problem has been fixed. However, there's some weird bugs, but what can you expect?
First and foremost, when attempting to run the boat at full throttle, for no apparent reason, the boat will only move at a slow speed. If you move the joystick to just the right place, though, it will run much faster. I'm not sure if this is being exhibited by the ESC or not. It could be normal behavior, but this is unlikely-the ESC was intended for airplanes, and behavior like that could cause the plane to crash. I might be trying to output servo values that the ESC is misinterpreting. I'll have to poke around with the code and see what happens. I'm not sure if the problem's in the old code-I'll have to test that.
The other bug is also quite weird: once lit, the debug LED will never turn off on the controller. I have no idea why this is happening, so I can't give any commentary here.
There are some choices I regret making in this project-and some things that happened that were just plain funny.
- At first, I ordered two breadboard-style PCBs: one for the boat, and one for the controller. I was terrible at soldering back then, and I ruined many of the traces on the board. Oops. Oh well-the ruined board was too big for the controller, anyway. The one in the boat wasn't so bad, and it's still sitting in there.
- Originally, when I soldered up the transmitter PCB, I had added a 7805 for power regulation. Initial testing proved it to be okay, but I realized later that the 7805 had begun smoking, and the power LED was lighting even with the switch off. To top it all off, I made the fatal mistake of touching the 7805 to see just how hot it was. Not a good idea. I was a newcomer to electronics then, so that spooked me a bit, so I didn't work on the boat for a while after that. I'm still not sure why that 7805 was smoking.
- I eventually desoldered everything from the bad board except a pullup resistor, a reset switch, and the 28-pin ATMega socket. The board didn't look so good after all the rework. Sorry about the image quality-I didn't feel like getting out my regular camera, so I cheated and used a webcam.
- Also, the iron I started with wasn't that powerful and came with lead-free solder without flux...ugh. Sure, it's RoHS compliant, but it can be a pain to work with when your iron isn't powerful enough and you're just starting out.
- I never bothered adding an external programming header to the transmitter-I could just open it up, disconnect the radio and the other headers, and program it, right? Not a good idea-it turns out, I often end up having to disconnect everything, then reconnect it all again, disconnect, reconnect, just for one iteration of code. Annoying.
- I didn't plan out the wiring that well in the transmitter-there are three cables running between the halves (and one of them is just a single wire for the debug LED-ground runs through another cable), and there are a couple more just for the back half. Also, the power cable running to the switch and back is too short and tends to unplug itself when you lay it open to work on the inside. I would have just used one ribbon cable in hindsight, but oh well. Also, I'd probably have to use a separate pair of 22 gauge wires for power (due to the way the Arduino Pro Mini regulates power, the switch has to be connected to the 9v line in from the battery pack).
- The Air Hogs controller is a bit cramped and hard to work with, but it's got a nice huge 9 volt battery holder in there. Nope, not a 9v battery, but 6 AAs! Heavy, but they'll last forever. Also, I got free shoulder buttons!
- Someone I was working with on this project put some Mod Podge to try and waterproof the paint on the side of the boat (we weren't sure if it was water-soluble or not). It turns out, Mod Podge is sticky when cured, and some got on the bottom of the boat. We're careful to store it propped up now so it doesn't stick to whatever it's sitting on, but it's annoying. Oh well.
- The Parallax breakout for the analog stick has been hacked with thin wire so many times-I almost wonder why it's even still in there. Sure, it has nice mounting holes, but that's what hot glue and perfboard is for.
- Originally, I put a nonstandard ISP connector without +5v and GND on it on the boat receiver board (I still didn't have an FTDI breakout then). I ended up desoldering that and putting an FTDI header in the same place. On top of that, all the rework stressed out the board, so some of the traces have lifted. At least it's still holding out.
Does anybody have any ideas why my code is behaving strangely? Also, swapping the XBee out for the programmer is quite annoying on the boat end-I also have to disconnect the ESC, which normally provides power to the boat to protect the battery and regulator. Does anyone know of a better way?