Tuesday, June 26, 2018

Battery is Back and AMOS Meets the Public

Good news: the lithium battery just needed a bit of a voltage boost from a plug in battery charger. The folks at Ukko Versatile Energy Solutions (https://www.ukko.io/) offered me some helpful advice: basically the battery management system (BMS) inside the lithium battery pack has a safety switch to cutoff output when the voltage falls below 10 volts. But because the solar charger on AMOS requires some battery voltage in order to turn on, it wouldn't even start to charge the battery, no matter how brightly the sun was shining.

So I bought a $20 wall charger from Amazon and used it for 3 hours to bring the battery back to about 13 volts. To help avoid this problem in the future, AMOS now has some improved software to avoid getting too close to the dangerous 10 volt cutoff. If the measured voltage drops below 12 volts, it only allows half-speed operation, and if it drops below 11 volts, it shuts down the thrusters altogether. Once the voltage gets back to 13 volts, everything goes back to normal. Now that I think about it, it should probably also send an alert email / text to notify the user about the low voltage condition. I should probably also do some tests to see exactly how long the battery can last if it is close to being depleted. It's a bit tricky to know exactly how depleted the battery is, since its voltage tends to shoot back up whenever the thrusters are turned off.

AMOS went through a couple more field trials this week: the first was in the usual spot, but because it was a Saturday, my daughters Kirsten and Bexie joined me and we brought our dog Checkers and the canoe. AMOS started out well for about a minute, but then appeared to stop in the middle of the cove and start moving in circles. We paddled back to shore with AMOS in tow and I set about clearing some lake grass from the propellers and checking over the source code while the girls and Checkers paddled around the cove. I made a few minor changes to the software, but nothing really seemed to work: the boat would always just move a little ways, and then start moving in a circle, not always in the same direction. There was a lot of grass getting stuck in the propellers, and it seemed that that was the likely culprit; a more complete check of the ship logs later that evening and a more thorough cleaning of the propellers confirmed it.

The second trial happened the next day, just a little further down the road at a small boat launch. This time I went by myself, but a family of 4 was pulling up in a motorboat just as I was getting AMOS into the water. A young boy, probably about 12 was curious:

"Is that a robot boat?"

"Well, yes it is actually!"

"Cool! I like anything to do with technology... does it use an Arduino or a Raspberry Pi?"

"It uses a Raspberry Pi, and some other electronics, The Raspberry Pi handles most of the navigation, motor control, and stuff."

"I was going to learn Python, but I figured it would probably take FOUR hours or something, so I haven't done it yet."

"I use C++ myself, although I think most people now prefer to use Python. You might find that it takes a little bit more than four hours to learn though..."

The boy would have liked to see AMOS in action, but I was afraid of it getting stuck in the grass again, so this time I towed it out through the shallows and started it on the other side of a bridge in much deeper water. The following is the (nice and straight) track that AMOS followed:

It stopped mysteriously before reaching its final destination though, and I wasn't sure at the time what had happened. A quick check over the Bluetooth link with my phone confirmed that the program was not running, so I assumed that it had crashed. Fearing that some water had gotten in again (despite adding some layers of duct tape around the problematic U-bolts) I turned off the thruster power switch, hitched AMOS to the kayak and started back. While in the process of doing this, a man and woman driving a large pontoon boat came over to inquire about what I was doing:

"Are you alright there?"

"Oh yes, I'm fine thanks!"

"Did you find that thing in the water?"

"Ummm, no it's mine actually, I'm just testing it."

"Do you need us to take it somewhere for you?"

"No, that's OK, I think it just crashed. It happens a lot actually."

They seemed a bit perplexed about this, but then motored off somewhere else, leaving me to tow it back to the boat launch. Inside the hull, there was no evidence of water, and none of the leak sensors had detected anything. Looking at the ship log on shore confirmed that AMOS had not in fact crashed, but its program had been stopped by a keyboard press, presumably sent somehow by accident over the phone's Bluetooth link. The phone had been stored in the kayak's dry storage container, so I'm not exactly sure how this might have happened. It was quite windy with some waves though, so perhaps some jostling in the container was enough to momentarily turn on or register "screen touches" that were sent to the boat. I'll have to remember to turn off the terminal program for the next test. In order to more quickly diagnose these sorts of stoppages, I wrote a small program yesterday that just prints out the last 10 lines of text from the most recent ship's log file. Something that I should be able to access and read quickly while sitting in a kayak in the middle of a river.

Today I replaced the lithium battery back in AMOS, and also added a water-proof temperature sensor, the DS18B20. The wiring changes weren't much, but took me almost 3 hours, as I'm terrible at soldering and need to check, double-check, and triple-check the schematics and board layout to make sure I'm not going to wreck anything. Luckily, nothing got wrecked, and the temperature sensor appears to be working. I plan to just tow it along behind AMOS, a few inches below the surface of the water.

Wednesday, June 20, 2018

Death in the Night

The propulsion and course correction software for AMOS went through several iterations this week, all in a grand effort to make the boat drive in a straight line. The first couple of iterations actually made things worse; I didn't even need to use my kayak for those as AMOS either veered off towards the bank to the west or traveled about 30 m and then spun crazily around in a circle. Last night, I brought the laptop with me, intent on coding and re-coding until things improved.

After a couple of tweaks, things did improve and AMOS drove through the cove in a mostly straight line. I think it covered this distance (~ 500 m) the fastest it had ever done. Once the boat left the cove though, the wind was much stronger from the west and the water became quite choppy. Although the boat was pitching and rolling quite a bit, it seemed to move with a sense of purpose through the water. Whenever it approached one of the GPS destinations though, it would often veer off, or double back. I'm guessing that perhaps it was moving too fast near the destination, but I'll need to have a look at the ship's logs later on to confirm this. At one point a freezie wrapper became lodged between the blades of the left propeller creating a loud noise and causing the boat to spin around in circles.
I removed the wrapper, but about 10 minutes later, AMOS mysteriously stopped meandering around and just stayed put. It was after 8:30 by this point, so I turned off its power switch, hitched on the tow rope, and pulled it back to shore. Looking inside the hatch I could see that the leak sensor LED was lit, so although no water was visible, some drops must have gotten in; not surprising I guess given the choppy conditions and the imperfect sealing that has been applied over various holes made to the top of the boat.The computer was still responsive and behaving normally though.

That night, I left the boat in the garage to dry out, but still plugged in to the battery since everything still seemed to be running normally, even though I guess a few drops of water had gotten in.

This morning I awoke to find the interior dead! Normally there are a host of red, green, and blue LEDs merrily blinking away inside the hull, but this morning all was dark. A quick test of the Lithium battery showed that its voltage was zero. Nada. Zip. Nothing. So now I have to figure out what to do. I'm not sure if the battery can be saved or not, or what might have happened to it. I'm wondering if perhaps last night's test might have pulled its charge down too much? And then maybe just operating the computer overnight was enough to fully deplete it? Or maybe the little bit of water that got in somehow caused problems? If it can be saved I'll need to find a wall charger I guess, since the solar charger that I use requires the battery to have enough charge to power the charger.

(UPDATE: AMOS is now back online thanks to a $70 sealed lead acid battery from Canadian Tire. It is significantly larger and heavier than the Lithium one though, so hopefully the manufacturer will respond to the email that I sent with some suggestions for how to bring it back. The ship's log and other operating system logs seem to indicate that a reboot occurred at the end of last night's test. I'm not sure exactly why the reboot occurred; possibly it was a result of the water intrusion. Just a few minutes ago I squeezed the little sponge on one of the leak sensors near a U-bolt that supports the left propeller, and a few drops of water came out. That's the only water I found inside though, and the only leak sensor that indicated a leak.)

Tuesday, June 12, 2018

Woolastook Navigation Challenge Parts II, III, and IV

One of the things I got around to adding this past week was a nice little on / off motorcycle switch with a blue "on" light for controlling power to the thrusters' (+12 V power supply):

I also added a check in the main software for AMOS to look for a high to low transition in this switched voltage and this tells the program to close and the Raspberry Pi to reboot itself. This makes it easier for me to re-establish a Bluetooth link to the boat later. The switch itself makes recovering from mishaps a lot better, as I no longer have to wrestle with the hatch or fumble with my phone while trying to avoid falling out of the kayak.

Three attempts were made this week to complete the Woolastook challenge (the same route from last week). The first test had some issues in and around the cove with following the wrong heading... basically if the heading was off by more than about 10 degrees it would crash into the shore. I did a sort of crude 8-point compass calibration after that, and then re-tested, with the following result:

This second test was pretty good on the trip out, but crashed into the shore a number of times on the way back. Some of the crashes actually looked pretty hard and bent one of the solar panel rails a bit, but AMOS kept functioning and was able to extract itself from the shore each time, until near the end when it got securely stuck in some overhanging branches near the shore. The blue path of the boat shows how it would sometimes set out at an invalid heading, and then gradually correct its heading as it got closer to the waypoint. This observation gave me the idea to try splitting up the course (in AMOS' navigation software) into 10 interpolated stages between the main waypoints. The result (the 4th and finally successful) Woolastook challenge is shown below:

There was still one close call on this last test where AMOS nearly crashed into the shore, and there were some obvious problems with consistently maintaining a desired direction, especially when going into or perpendicular to the wind, which was quite strong for this test. I made some improvements today to the software used for trimming the propeller speeds though, so I think that will help a lot to maintain a more straight course. It looked promising in the pool, and I will get back to the river in a couple of days probably to try it out.

Tuesday, June 5, 2018

Foiled by a fishing line?

A lot of progress was made this past week, some of it good, some not so good.

First the good: 
1. A new GPS board arrived from China in only 3 or 4 days, so I printed out a holder for it, and glued it to the Plexiglas board that is currently holding the Raspberry Pi circuit board, so it should be well out of the way now, and shouldn't short-circuit against any other stray components.

2. I added alarm software (email and texting) into the main AMOS program, and it seemed to work pretty well. Currently it is just being used for leak sensing, but it could also be used for voltage monitoring, navigation warnings, or even for just sending periodic data updates.

3. I Added the ADC converter chip to AMOS, and hooked up a resistor divider circuit to the battery voltage to enable simple battery voltage monitoring. I also added the necessary I2C code for reading in the ADC values and tested it out a couple of nights ago to see how much the battery voltage dropped overnight while running the main AMOS program:

The test started at 10 pm, and showed some semi-regular voltage fluctuations that I don't really have an explanation for... perhaps the Pi was pulling more load for certain tasks throughout the night, I'm not sure. At any rate, shortly after 6 am, even though the weather was cloudy and a bit rainy, the voltage from the solar panel kicked in, resulting in the sharp voltage increase.

Then the bad:
1. In an effort to improve the look and quality of the wiring inside AMOS, I thought it would be a good idea to use some strip lighting terminals to replace the soldered wire junctions that I had been using up until now. The terminals that I bought off Amazon just used little springs inside them, and didn't have any screws, so there wasn't really enough force to hold the wires in securely. I think I realized that they probably wouldn't work well, but I still persisted in undoing all of the soldering and re-wiring things to use the spring terminals.

2. After the re-wiring, a field test was attempted back at Woolastook. It was a cold, wet, rainy sort of day, but I was hopeful that AMOS would zip off to the GPS waypoints without any difficulty. Right off the bat though, it looked like something was wrong. AMOS seemed to be turning too much to the left. I had to run after it from the start and grab it before it smashed into the gravel bank in the corner of the cove. I righted it, and it seemed to progress mostly in the right direction, but would still sometimes pull a bit to the left. I paddled after it in the kayak, but after a few minutes it veered more sharply to the left and then crashed into the western shore. Here's a map of the failed route (shown in blue, waypoints are red):

It was a bit of a struggle to remove the hatch while the propellers were still going, and I noticed that one of the propellers wasn't really moving and was making an awful noise. A post-mortem back at the house revealed this rock to be the source of the bad noise:

It was lodged in there quite firmly, and had slightly damaged the propeller blades, but I was eventually able to pry it out. After that, I had to fiddle with the bad wiring inside AMOS to get reliable power to the propeller, but once I did, it turned quite well... except that I noticed some sort of stringy material was attached to the prop after it stopped turning. This material turned out to be a considerable length of fishing line... I think I was able to cut and pull it (and some other lake crud) all out:

So between the bad wiring, the fishing line, and the rock, I guess AMOS had some excuses as to why it kept veering to the left. I've partly finished re-doing my soldering, and have ordered some better screw terminals, and prototype boards for holding the ADC circuitry (right now it's just on a breadboard). Hopefully this weekend I'll get a chance to try the Woolastook navigation challenge again.