Dale's Posts (1)

Sort by

SPI between ArduPilot, ArduIMU, SCP1000

Finaallly tonight got this to work more completely. SCP baro sensor to IMU was not so hard. Getting IMU and Pilot to work was more trouble for me.The layout I chose is: ArduIMU is spi master, SCP1000 and ArduPilot are slaves.ArduIMU requests airspeed from the ArduPilot, it will be used in combination with the gps based speed in the IMU. It will send the resulting AHRS data to the ArduPilot, as a predefined message, with variables in a certain order. The IMU requests baro from the SCP1000, it will be used in the IMU for altitude, better than the gps altitude. The IMU has the gps connected to it, it will send the req'd lat/lon, etc to the Ardupilot also over spi.As a slave on spi bus, ArduPilot uses the SPI interrupt to trigger shifting each new byte of data in & out of the spi data register SPDR. like this: http://www.rocketnumbernine.com/2009/07/03/using-spi-on-an-avr-3/Even though it's a slave, The SCP1000 uses an extra input to the IMU to tell it when it is ready with a new pressure reading, then the IMU proceeds with asking for it over spi. It could be done other ways, but in higher resolution mode, the SCP only samples about every .5 second. So this way the data is collected precisely when it's available.Pins on ArduPilot:this won't really work with current boards so well, for normal planes. I require only one servo channel. The spi slave requires use of d10, as SS, normally used for servo 2 output. Soldered to a via to access it and get it to a header with the d11, d12, d13.Pins on ArduIMU v1:needed two additional pins, output SS to the Ardupilot, and an input for data ready from the SCP1000. soldered to d8 and d9 (pins 12,13) on the atmega, and brought to a female header. the normal spi pins are nicely available already.Level converter:The SCP1000 is a 3.3v device, don't fry it with 5v lines. made a level converter with a dozen or so discrete components. like this: http://delphys.net/d.holmes/hardware/levelshift.html I even tortured myself with tiny surface mount transistors, oh so fun!Code:If anyone desires a similar scheme maybe this is a starting point. And maybe people will have suggestions for me. I'm sure there are things to improve. With the 1280 based ArduPilot, pins should not be an issue, and this should be faster communication between the micros than UART. But the code may be more complicated, and harder for people to get into.What it does so far is get the airspeed data from ArduPilot back to IMU, in response to a particular message number. And read the pressure sensor. Next will add one larger message from the IMU, with all the data that Pilot would like to have. Should be not too hard, framework is there for messages, just define them appropriately on both ends. There are added .pde files, spi.pde and scp1000.pde that have the relevant code, and some variables and declarations on the main .pde file. should be able to just take the spi and scp1000 files to add in to other code.ardu_100104.tar.gzThis is based on not the latest IMU & AP code, I need to work with that next too. Oh, the IMU code also is modified for 406 gps.Hope this is helpful, please let me know if any questions / comments. Thanks!
Read more…