Developer

ArduPilot Mega sensor shield testing report II


Hi all,
This is the weekly report of ardupilot mega development :-)
We have developed the library for the DataFlash log memory. This function is really interesting, because we
would record the flights without the need to carry the laptop and telemetry all times... For example, for
testing the code I simply connected an small battery to the ArduPilot Mega, go outside to make the tests
without need of laptop, cables,... and then I download the results on laptop to analyze it. I´d like it.

Finally we use the standard SPI for the DataFlash chip and we change the AP_ADC library to use the serial port 2 in SPI mode. This way we sepparate the ADC (that is running inside an interrupt) from the standard SPI, and users can use also the SPI for other external devices. Also the ADC code can run a bit more efficient (now all ADC stuff at 400Hz use 3.7% CPU).
The DataFlash library isolate the user of the complexities of the internal registers, double buffer and page
distribution of the AT45DB161D flash memory. The library provides the functions to make sequential write and
read sessions and it´s written to be very efficient in the write sessions (it takes about 28us to write a byte,
this is near ten times better than a stardard serial port at 38400).

We have also converted the GPS code (Ublox) to a standard library. We will implement in the future libraries for other GPS (NMEA, EM406, ...). If all the libraries share the same interface, to change the GPS you only need to include your GPS library. Also this libraries are usefull for other DIY projects and Arduino users... (We made the library compatible with Atmega1280 (on serial port1) and also Atmega168/328). I could work on the library for NMEA GPS´s (I already have an Locosys) but I don´t have EM406, so somebody could work on this...

Now we have all the core parts of the future Ardupilot Mega running succesfully.
I´d really like the aspect of the code with the new libraries... It seems more easy, and an easy code is easy to maintain and modify by users...
The test code uses this:
- APM_RC : library to read the radio and output to servos
- APM_ADC : library to read data from the analog sensors (accels, gyros, ...)
- DataFlash : library to write/read to the flash memory to record flight parameters (log)
- GPS_UBLOX : library to access to the Ublox GPS
- IMU DCM code

Here are the codes:
Main test code: APM_Core_Test2.zip

Note that this codes are betas and will change when Jordi release the final version of the sensor shield because there will be different pin assignments.

One more thing I´d like to comment is that the new Ardupilot Mega main boards comes with a 16Mhz crystal for
the PPM encoder and works very great!! Now, the noise on the radio input is below 1us, this is nearly perfect Jordi...

Jose.
E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • well i believe there will be some spare serial ports you can add a sd card there
  • What about adding sdcard? Small heaps of atorage space and can easily be used to store differnet setup, log files etc..
  • Developer
    Again, nice and crisp code. Well commented. Good work!
    You mentioned the UBLOX library is hard coded to serial/serial1. What if you did something like,

    #if defined(__AVR_ATmega1280__)
    #define GPS_Serial Serial1
    #else
    #define GPS_Serial Serial
    #endif

    ...
    GPS_Serial.Begin(38400);


    This way you only need to use GPS_Serial for the rest of the code without all the #ifdefs. Also makes it easier for someone to use a different serial port.
  • Jose , good work, finally the mega picture is getting complete for those who want to imagine the complete setup. thanks for the picture.
  • Developer
    Doug, the Atmega1280 handle this function, the DataFlash is connected only to Atmega1280 via the SPI port...
    This code is on the setup() function. If we start the Ardupilot and the switch is on download position, the code starts to read the DataFlash memory and send the info via standard serial port...
    But this is only a test code, the final solution could be different...
  • Developer
    Hi Jose,

    Can you clarify on downloading info from the DataFlash. Does the PC via USB have direct access through hardware to the DataFlash?? Or do we have some portion of the firmware on the 1280 handle this function?
  • Nice work Jose !
  • Developer
    Thanks,
    This is how I implemented this on this test code. We have a switch on the board, one position is record mode, so all the information from IMU and GPS is recorded on the DataFlash memory. The other position of the switch is for download the information. We need to connect the board to the PC (via USB), open a serial terminal, and all the information is downloaded (you can save to a file to analize...).
    The second option (mount the flash memory like a drive) is not posible because we are using an FTDI chip that is a serial to USB converter, so the PC detect it as a COM port.

    Pedro, the size of the flash memory is 16Mbits, that is, 2Mbytes. This is more than enough to save a lot of info of the autopilot...
  • what is the size of the flash?
  • 3D Robotics
    Nice work, Jose! How exactly do you retrieve the data? Do you need a desktop app to get it via serial, or can you mount the flash memory via USB like a drive in Windows?
This reply was deleted.