Wednesday, March 14, 2012

Flight Computer and Sensor Integration


Flight Computer and Sensor Integration Addendum
Brett Russell

Flight Computer Initiation

                  The data logger needs to complete an initiation sequence before it will write to the USB drive, essentially syncing the chip with the Arduino.  This process can be completed by bridging the RTS/CTS pins, which I have found to require hard coded delays to ensure smooth transfers, or by running a digital output from the Arduino and setting it LOW during this initiation sequence. 
                  Once initialized the data logger needs to be sent two commands , FFC 0 and IPA, to indicate the communication handshake standard and set input commands to ASCII format respectively.

Now the data logger is ready to open, close, read and write to files assuming the proper wiring.

Data Writing Sequence

                  Recording data fast for extended periods of time requires the Arduino to know when the data logger needs a second to catch up and when the data logger has encountered a buffer overflow.  The latter situation completely stops the writing of data, explained in my previous entry, but I have implemented a sequence to prevent loosing the data as follows.
1.     Initiate the write sequence by sending the open write command to the data logger.
2.     Turn a digital pin wired to the RTS pin of the data logger high.
3.     Write the data using the write file command and ASCII character array.
4.     Drop the signal to RTS to low.
5.     Close the file.

                  Steps two and four are synchronizing the Arduino's transmissions to the data loggers internal clock.  Essentially, the Arduino "requests to send data" by setting the pin high, transmits in step 3, and signals the data logger that the transmission is over.  Opening and closing the file each write protects against data corruption from the file not being closed.  Worst case scenario, the data will still be recoverable.
                  A write delay() function, as seen in my last post, is still implemented to allow the data logger time to catch up if it signals for it.  Reading the RTS pin is as follows:

State
Analog Read
Voltage
Ready
0
0
Buffer nearing capacity
400 - 450
~2.1 V
Buffer overflow
700-750
~3.5 V

                  Initiate the delay() function if the analog read is greater than zero, but also call the reset() function inside of the delay() function.  If this is not done an infinite loop will be performed if the data logger has a buffer flow situation instead of executing the reset.  This function is simply protection to ensure that even if the data logger locks up from a bad transmission, data logging will restart itself.  The function itself is straight forwards; however, the location must be proper to avoid an infinite loop:  

1.     Determine if buffer overflow has occurred in the delay() loop.
2.     Have the data logger powered by a digital output on the Arduino, if 1 is true set to LOW.
3.     Wait 1 second.
4.     Turn the digital output to the data loggers power back on.
5.     Wait 2-3 seconds for the data logger to recognize the communication channel and USB drive.
6.     Perform the two initiation commands listed at the beginning of this post.
7.     Continue on with the loop.


No comments:

Post a Comment