i2C on raspberry pi target

1 view (last 30 days)
Guillermo
Guillermo on 23 Apr 2013
I've successfully set up the raspberry pi as a target hardware and have performed some of the examples. I've also made my first model that toggles a GPIO pin to turn on an LED similar to turning on the board's "green LED". Now I want to add an ADC, DAC and Accelerometer to the RPi. The ADC is an i2C board (ADS1115), the DAC is an SPI board (I'm leaving this one last as I haven't found drivers for the chip I'm using DAC8814) and the accelerometer that I have is ADXL345 which is i2C.
Has anyone made any simulink models for the RaspberryPi to connect/control/read to i2C components?

Answers (2)

Guillermo
Guillermo on 26 Apr 2013
Edited: Guillermo on 26 Apr 2013
I just figured out how to "burn" an image of a different distro using the matlab targetupdater.
The steps were somewhat involved but in short they are: (this assumes you've already installed the RaspberryPi as a target in Matlab as you'll need the 7-Zip utility)
  1. download the distro into a directory of your choice "YOUR/DIR" and expand if in a .zip
  2. re-compress using the 7-zip utility
  3. check the MD5 sum for both the .img (firmware) and the .img.7z (archive) and copy them to a temp file get tool from: http://www.winmd5.com/
  4. get the size (not the size on disk) of both the firmware and archive (in Win, right click, Properties) copy them to the temp file and remove any characters leaving only the numbers (remove the coma if in Win)
  5. run targetupdater (at the matlab command prompt)
  6. at the first option select RasPi, NEXT>
  7. Select Board Version, NEXT>
  8. when you get to the "Get Firmware" step select "From local folder"
  9. Browse to "YOUR/DIR" where the files are saved
  10. Hit "OPEN", this will result in an error but the updater will create the "raspberrypi_fwinfo.xml" file
  11. open this file (raspberrypi_fwinfo.xml) in the text editor of your choice
  12. Replace all the following fields:
  13. name= "your_firmware_name.img"
  14. archive="your_firmware_name.img.7z"
  15. archivesize="The archive size you saved in the temp file, step4)"
  16. archivemd5sum="The archive MD5 #s you saved in the temp file, step3)"
  17. firmwaresize="The firmsware size you saved in the temp file, step4)"
  18. firmwaremd5sum="The firmware MD5 #s you saved in the temp file, step3)"
  19. save the file
  20. "OK" the error you got in step 10
  21. Hit "OPEN" again
if all went well then it will advance to the next window and ask you to select the SD card and keep advancing until it starts to write the image to the SD
I Haven't tested the SD card but I'm hoping this will produce an RasPi OS that has all the goodies that Adafruit has packaged (sensor supports, etc) as well as the ones that Matlab updates the kernel with. I'll try to better document these steps with figures and possibly a video and some comments after I test it.
  2 Comments
Guillermo
Guillermo on 26 Apr 2013
Edited: Guillermo on 30 Apr 2013
UPDATE: OK so now I'm confused. I re-installed the default Matlab SD image (download from internet, etc.) and it still is reporting the same error.
I'm wondering if it is something else now, not on the RasPi but on the MatLab side...
This Sd image did have the /etc/modprobe.d/uvcvideo.conf file so I copied the entries to the adafruit Sd image
NOT SURE HOW BUT IT FINALLY WORKED. I WAS READING THE SUPPORT PDF: http://www.mathworks.com/support/solutions/en/data/1-LTA2JJ/
AND JUST DID THE !ping command and it worked.... YAY!!! Now to read the i2c devices from within simulink (I hope taht works)

Sign in to comment.


Walter Roberson
Walter Roberson on 23 Apr 2013

Categories

Find more on MATLAB Support Package for Raspberry Pi Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by