Small little update

Its been over a week since I last posted but I haven’t been slacking off! Instead, I’ve been seriously thinking through and writing the code which will hopefully take LOCARB to Hawaii.

My code is pretty straight forward, with global variables holding the sensor data, and functions all written out for grabbing that data. The main loop is actually just function calls. One of the hurdles I had to overcome was writing the functions in a way which were non-blocking; code which would allow other operations to run while waiting for the previous function to finish. Arduinos aren’t multitasking so they just run through a loop from start to finish and any code which use delays or for/while loops will block the other code from running until it is finished. I got pretty familiar with millis() as it allows functions to run by checking the time instead of pausing the execution of code using delay().

The waiting game…

I was also able to decide on which rudder servo I would go with. I contacted KST servos through Alibaba and was able to purchase two servos which had both contact-less position sensors and brush-less motors. They are the KST models MS-815 and MS-825. Once I get them, ill be able to test power consumption and performance with the Pixhawk. If everything checks out with the power consumption, ill be happy to have a servo that has metal gears and components which should be able to withstand the number of mechanical actuations for a roundtrip from San Francisco to Hawaii.

I also received my Rockblock Naked MK2 modem from Sparkfun, but am waiting on the 5v – 3v logic shifter so I can connect it to my Arduino (Arduino uses 5v TTL, Sat modem 3v). While waiting for that to arrive, I worked on the function which will format the data to be sent by the Rockblock modem. At the moment I have an sprintf function which sends out a string text message around 80 bytes long. Since Rockseven charges 1 credit per 50 bytes of short burst data, it will probably cost ~.20c per message. Trying to keep running costs low, I added a way to change the messaging interval on LOCARB while its at sea. I figure ill want to track LOCARB with a little more frequency when its closer to a body of land than when it is in the middle of the ocean.

So at this time, i’m waiting on my KST servos and logic level shifters to come in the mail. After I receive them, ill be able to focus on the main send/receive functions using the Rockblock modem. I’m pretty excited about the progress I’ve made with the electronics portion of LOCARB, as satellite communications comprise around the last 20% of the job. Once that’s done, I can then move to building LOCARB’s hull and finalizing/building the power system with real power consumption figures from the sat comm modem and rudder servo.

A little about formatting a message…

In case you wanted to see how sprintf works on the Arduino, I’ve included a test sketch which shows how I formatted the message. One thing to note is that sprintf doesnt work well with float variables on the Arduino. However, there is a function which handles converting a float variable to a char array which allows you to easily incorporate floats into a string buffer.

The dtostrf() function easily takes a float variable and formats it into a char array for use with a string buffer. Its nice and easy!

Here is the console output of the above code. I know many of you are probably wondering why i’m formatting the GPS coordinates with a decimal now, rather than later…This is something I still haven’t decided yet, but I figure since i’m sending 80 bytes anyways, i might as well take up the limit of 100 bytes before the next credit is charged. This way I wont need to write additional code on the web server which will be receiving this data to properly format the GPS coordinates. I just realized I need to do the same thing with my battery voltage as well… This is something that I could very well handle on the server side, so its up for revision as I begin to work with the sat comm modem.

If you want to read some resources that helped me on this part of the process, check out these links: