Enter Your Project for a chance to win a Nano Grand Prize bundle for the most innovative use of Arduino plus a $400 shopping cart! Back to homepage | Project14 Home | |
Monthly Themes | ||
Monthly Theme Poll |
The original plan for my Nanorama project with the Nano 33 BLE Sense generously donated by Element14 was to fix the Nano Sense to the tip of a water powered rocket, fire it off into 'space' and capture all the data when the rocket returned to earth. Regretfully, due to the current circumstances I am not able to fire a water powered rocket as I am restricted to my bacl grarden and it might not come back to me. So, instead, I have modified the design to make it a hand powered rocket, which I will thrown in my back garden. In a previous Blog I outlined the process of using TinkerCAD to design and 3D print the case (Using TinkerCAD to Make a Case for a NanoRama Project ). I did have a problem with the CR2032 battery holder with the wires being inconveniently placed and I thought I would have to sand off some of the lid, but on a closer inspection I realised that I could drill a hole into the battery holder and re-position the wires more suitably - so that is what I did, which can be seen in the video below. Now I do not have to make any adjustments to the lid of the case.
The circuit for the Nano Rocket is simplicity itself, due to the accelerometer sensor being already integrated into the Nano 33 BLE Sense PCB, consisting of just the battery, the Nano sense and the connections to the TTL to USB serial convertor, see circuit diagram below:
I soldered the battery holder directly to the Nano Sense rather than using any form of connectors; first to avoid any intermittent power connections when the rocket was launched or landed and secondly, to minimise the issue of storing wires inside the case. There is an ON/OFF switch on the battery holder (which I have accidentally omitted from the circuit diagram) The connections to the FTDI USB to TTL convertor PCB are made using Dupont plugs with only short wires, again to minimise wire storage inside the case. I have now realised that I should have used Dupont sockets rather than plugs as the pins are free to move about inside the case and could easily cause temporary electrical connections to other parts of the PCB during flight. Hopefully, this will not be a problem.
For the software I adapted the example programme provided for the Nano 33 BLE Sense for accessing the accelerometer data. The programme has a simple user interface. The onboard LED is flashed for one second once the accelerometer is setup and ready to go. There is then a 10 second delay for the user to get ready to throw and then a further flash on the LED of one second on is provided. At this point the data is read from the accelerometer as fast as possible and saved into a global array, after which the on board LED is flashed for 0.5 seconds on to signify the end of data sampling. The example programme states that a sampling frequency of 119 Hertz is achieved so I saved 1200 data values in a 1200 x 3 floating point array. This should result in a 10 second period of data sampling but the reality is an approximately 13 second data sampling period so it is likely that my programme has reduced the sampling frequency to something nearer to 100 Hz.
void loop()
{
float x, y, z;
int datacount;
dataxyz[0][0] = 0.0;
delay(1000);
digitalWrite(ledPin, HIGH); // will turn the LED on
delay(1000);
digitalWrite(ledPin, LOW); // will turn the LED on
delay(10000); // 10 second delay at the beginning to get ready
digitalWrite(ledPin, HIGH); // will turn the LED on
delay(1000);
digitalWrite(ledPin, LOW);
datacount = 0;
Serial.println("Transferring to Serial1 ");
while (datacount < 1200)
{
if (IMU.accelerationAvailable())
{
IMU.readAcceleration(x, y, z);
dataxyz[datacount][0] = x;
dataxyz[datacount][1] = y;
dataxyz[datacount][2] = z;
datacount++;
} /* if */
} /* while */
digitalWrite(ledPin, HIGH); // Indicate data collected
delay(500);
digitalWrite(ledPin, LOW);
After the data has been sampled and stored in the global data array the programme enters a while loop waiting for a command to be received on the serial communication link provided on the Nano Sense. Fortunately the Nano 33 BLE Sense has two hardwired serial communication links, one for the USB communications and one which is also brought out to pins TXI and RXO on the Nanno Sense. This loop is able to handle any corrupted serial input data caused by making the physical connections between the Nano Sense and the USB to TTL convertor as this has to be performed with power still connected to the Nano Sense, otherwise the captured data would be lost. I have put in two menu selections although only one is actually implemented. This is just to create the outline if any further option selections are wanted. The first option is implemented as a function called listdataxyz()on the menu which lists the collected data out to the second serial port (Serial1) at 9600 Baud.
while (1)
{
Serial1.println("Nano Rocket " );
Serial1.println("Dubbie Dubbie : Just for Fun " );
Serial1.println(" 8th Apr'20 ");
Serial1.println();
delay(500);
Serial1.println("Select Operation ");
Serial1.println("Show Dataxyz : 1 ");
Serial1.println("Not Imp Yet : 2 ");
Serial1.println();
int value = ' ';
while (Serial1.available() < 1)
{
delay(10);
} /* while */
value = Serial1.read();
switch (value)
{
case '1' : listdataxyz();
break;
case '2' : Serial1.println("Not Yet Implemented ");
break;
default : Serial1.println("Unknown Command ");
} /* switch */
delay(1000);
} /* while */
} /* loop */
void listdataxyz(void)
{
int dataindex;
dataindex = 1;
for (dataindex = 0; dataindex < 1200; dataindex++)
{
Serial1.print(dataindex); // index value
Serial1.print('\t');
Serial1.print(dataxyz[dataindex][0]); // x
Serial1.print('\t');
Serial1.print(dataxyz[dataindex][1]); // y
Serial1.print('\t');
Serial1.println(dataxyz[dataindex][2]); // z
} /* for */
} /* listdataxyz */
Once the USB to TTL serial convertor has been re-connected to the Nano Sense and the download data option selected PuTTY was used to display the data. This data can then be cut-and-pasted into a spreadsheet. I used Google Sheet online which enables the four columns of numeric values to be listed into four separate columns, a good feature. At this point the system can be tested, as illustrated in the video below:
Then the USB to TTL convertor is physically connected again and the data can be displayed on PuTTY.
Below is the data captured from my first throw. I'm not entirely sure what it shows so I will have to spend some time thinking about the data and repeating and refining the experimental process. However, my initial thoughts are that the first section where the data is fairly constant is when the rocket was flat on the step as I was getting it started. The next 'jumble' (that's a technical term) is when I was putting the lid on the case and then the lull and 'hump' (more technical terms) are when I drew back my arm and launched the rocket into space. After the hump should be when the rocket hit the ground but the de-acceleration spikes do not seem large enough, plus, ,I'm not sure what the pulsing in the bottom red trace is caused by. The data is for a period of about 13 seconds.
I will have to think about how to process and display the data from the accelerometer (x,y,z) to try and come up with a single measure of acceleration as the rocket is launched, flying and hitting the ground. Anybody any ideas?
I am pleased with the progress so far, apart from not being able to understand the data. I will now work on two improvements; first to try and understand the data and second to try and implement a BLE wireless communication link to avoid all the messing about with the TTL communication link.
Dubbie
Top Comments