A screenshot of the Arduino IDE |
This post requires a bit of background before I jump in.
I'm in a club here at Penn State called the Student Space Program Laboratory (SSPL for short). It's pretty much what it sounds like: a space program for students at Penn State. It's most heavily targeted at aerospace engineering students, but students from other disciplines like mechanical or electrical engineering are more than welcome.
Now, I should make it clear that the club isn't launching Penn State students, or cars, or anything terribly exciting into space; it's mostly just small satellites. But, still, it's pretty darn cool to have anything in space.
But I digress. I'm not actually working on anything this semester that will be shot into space, or even attached to a rocket of an appreciable size. Instead, I'm doing the Student Training Program, or STP. New members of the club are split into groups, and each group designs a payload for a small model rocket. This payload has to measure, record, and transmit various types of data, from acceleration to UV radiation.
It's a pretty simple task, but the point of the STP is less to test ourselves and more to familiarize ourselves with the design process, workflow, and some of the hardware and software used in SSPL. This is also the stage where students determine what skills they can contribute most to SSPL with. The groups (which are usually around six people) split into three or four subgroups each, with each subgroup tackling one component of the problem: software, electronics, housing design, etc.
As it turns out, the skill of mine that is most useful to my group is my programming experience. This came as something of a surprise to me; I'm no CS major, and heck, the C++ class I'm taking this semester is the first formal programming course I've ever taken. But I used an Arduino for a high school engineering project, and that gave me more experience related to programming a flight computer than anybody else in the group.
So, that's what I did this past Sunday: program an Arduino (well, technically a SAMD 21). How was it?
Terrible.
The actual program part wasn't bad at all. All we needed to do was collect, store, and transmit the data at predetermined intervals, and that's almost trivially easy to do with the Arduino IDE. The hard part was the setup code.
See, for most of the dozen or so sensors we plan to use for our payload, some setup code is required: to turn the sensor on, to set the data collection settings, to calibrate the sensor, and so on. Usually, this is as simple as importing a library and copying and pasting some sample code. In this case, not so much.
The most frustrating problem I ran into was an issue between the SPI library (SPI is a communications interface) and the Adafruit Sensor library (Adafruit is an electronics supplier, and this library is a general-purpose library used by most of their sensors). Trying to compile the code gave an error stating that a certain function, SPI, was defined twice, once in each of these libraries.
This seemed like an easy fix: just delete the function from the Adafruit Sensor library, and the problem should be solved. But the function wasn't actually in that library, despite the compiler saying it was. It took me at least a solid half hour of frantic Googling before I realized my mistake: in another section of the code, I initialized a SERCOM (a general-purpose communications port) to use SPI communication, and I called that instance "SPI."
The day was full of little hiccups like this. And my eyes hurt aftwerwards. And, jeez, the coding was just downright boring most of the time. I definitely would not recommend doing this
Ha, I am not a big fan of messing around with code and programming anything either. I built a 3D printer this semester (like way back before Christmas break) and it just now starting printing anything useful. The code was all messed up and I ran into so many hiccups. However, I'm just grateful that it's working now. As a fellow engineering, I feel your pain. It's about time to pass this part of our projects onto our fellow Comp Sci peers.
ReplyDelete