Tag: PyGame

Data Visualiser

Data Visualiser

Along side the main project software, we developed a visualizer that would allow us to view the numerical data in a visual sense.

Simulator

Simulator

Testing some prototypes can be expensive, so we decided to simulate what the hardware and software would go through to see the effects and find bugs (unexpected features) in the software.

Setting Up the Code

Setting Up the Code

We’ve started working on the data logging side of the software, and a working prototype will be complete – of both software and hardware – in time for our YICTE competition entry.

We have decided on using C++ and Arduino as the programming languages for the software. This is because both Madeleine and I are familiar with Arduino and C++ and we know we can run this software type on our micro-controller – the Intel® Edison.

The first section of the code we have started to build is the “Setup” loop, as based off our state machine. This will contain all of the pre-flight checks and warn us if anything is disconnected or not working. Detecting these problems before the launch is vital and will allow us to know whether any hardware needs fixing right before the launch.

Within the loop, it initialises the serial ports and baud rate, creates the SD card data file and runs a sensor check. Below is a code snippet of what the setup loop will look like.

[code id=”code_id” language=”cpp”]
void setup() {

Serial.begin(9600);

while (!SD.begin(4)) { // check to see whether the SD card can be accessed
Serial.println("SD card inaccessable.");
delay(1000); //wait one second before trying again
}

for (int i =0; i++) {
//("gasp%d.csv", i)
if (!SD.exists(file)) { //check whether the new file already exists
break;
}
else {
Serial.print(file);
Serial.println(" already exists. Attempting File \"gasp%d.csv\". ", i+1);
}}

Serial.print("Creating ");
Serial.println(file);

// file = filename, f = actual file
File f = SD.open(file, FILE_WRITE);

if (f == NULL) {
Serial.println("File could not be accessed.");
while (true) {
delay(1000);
}
}
// load sensors
Serial.println("Loading Sensors…");

for (int i = 0; i < NUM_SENS; i++) {
Serial.print("Loading ");
Serial.print(i);
Serial.println("…");
Sensor* sensor = sensor[i]
}
}
[/code]

Once the setup loop is complete it will be time to work on the body of the data logging software – the part that actually logs the data. This code will be contained inside the main loop or “loop()” as Arduino defines it as.

After all of the main logging software has been completed we will undergo thorough testing to ensure that the addresses and connections of the hardware match the addresses used inside the software. Hopefully, this will prevent the software from failing unless under extreme external circumstances – like if the power is off (or someone’s bad soldering).