i2C on raspberry pi target

2 次查看(过去 30 天)
Guillermo
Guillermo 2013-4-23
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?

回答(2 个)

Guillermo
Guillermo 2013-4-26
编辑:Guillermo 2013-4-26
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 个评论
Guillermo
Guillermo 2013-4-26
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 2013-4-26
编辑:Guillermo 2013-4-30
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)

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2013-4-23

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Raspberry Pi Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by