i2C on raspberry pi target

6 vues (au cours des 30 derniers jours)
Guillermo
Guillermo le 23 Avr 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?

Réponses (2)

Guillermo
Guillermo le 26 Avr 2013
Modifié(e) : Guillermo le 26 Avr 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 commentaires
Guillermo
Guillermo le 26 Avr 2013
UPDATE:
The SD image works However, when i try to "run" on target from simulink things fail.
The error message details are:
The call to realtime_make_rtw_hook, during the entry hook generated the following error: Could not connect to the board at 192.27.106.38. Please check: 1: IP address, User name and Password are valid. 2: The board is powered up and connected to the network
Details: SSH connection to host 192.27.106.38 failed: FATAL ERROR: Network error: Software caused connection abort
The build process will terminate as a result.
Caused by: Could not connect to the board at 192.27.106.38. Please check: 1: IP address, User name and Password are valid. 2: The board is powered up and connected to the network
Details: SSH connection to host 192.27.106.38 failed: FATAL ERROR: Network error: Software caused connection abort
So I figured that the packages that are supposed to be installed are not in the Adafruit distro. Installing the listed packages and following the directions found here: http://www.mathworks.com/matlabcentral/fileexchange/40313-simulink-support-package-for-raspberry-pi-hardware I thought should do the trick but it did not. I get the same error. One thing to note is the installing the "wiringPi" did not install with sudo apt-get install wiringPi so I had to follow the instructions found here: https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/ and it wasn't clear how to do the step:
  • Create /etc/modprobe.d/uvcvideo.conf and enable UVCVIDEO quirks
I checked on an SD that was created from the online choice in "Get Firmware" (see previous post) and it is not found there either and from some searches I found this is to enable web cams. In any case the fiel can be created by sodu nano /etc/modprobe.d/uvcvideo.config and adding the line options uvcvideo nodrop=1 to it.
After all this and after trying to manually start SSH on the Pi I still get the error. I'll have to put this away for some time and come back to it. If anyone has a way to get this going please post.
Guillermo
Guillermo le 26 Avr 2013
Modifié(e) : Guillermo le 30 Avr 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)

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 23 Avr 2013

Catégories

En savoir plus sur MATLAB Support Package for Raspberry Pi Hardware dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by