5.0

5.0 | 2 ratings Rate this file 14 Downloads (last 30 days) File Size: 23.7 KB File ID: #38508
image thumbnail

Access GPIO pins on BeagleBoard from Simulink

by

 

This example shows how to access GPIO pins on the BeagleBoard using Simulink.

| Watch this File

File Information
Description

This submission contains two Simulink models showing how to access GPIO pins on the BeagleBoard. I developed the models using R2012a BeagleBoard Support Package. I used MATLAB Function Block to implement GPIO Read and GPIO Write functionality. The MATLAB Function Blocks are basically used to make GPIO related Linux system calls.

One can do a great deal using the same paradigm to call into Linux shell. This example showcases "system" and "popen" calls.

While the examples were developed in R2012a, they should work in R2012b as well.

NOTE: GPIO pins on the BeagleBoard use 1.8 V logic levels. Do not connect devices using +5V or +3.3V logic levels to the GPIO pins or you risk frying your board.

Required Products Simulink
MATLAB
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
23 May 2014 Mirko

Hi, I am a new user of Matlab/Simulink, for the first time, I would like to make a connection between a raspberry pi I2C and an Arduino using simulink. Someone could explain how this code and where do I pick up the data read?

There is a place in simulink Sfunction that creates a connection with I2C read and write?

29 Apr 2013 Murat Belge

Use external mode to see the data on a Simulink scope. Open Tools > Run on Target Hardware > Options menu from your Simulink model and check "Enable External mode" box. Build and run your model. If you connect the output port of your MATLAB function block to a Simulink scope, you will see the data on your host computer when you run your model. I recommend reading the "Getting started" demo.

19 Apr 2013 utya

hello. So i use i2cset and i2cget functions to recieva data from IMU. I use this code

function y = fcn()
%#codegen
persistent pf;
pf = coder.opaque('FILE *');
y = coder.nullcopy(uint8(0));
res = coder.nullcopy(uint8(zeros(1, 10)));
readOnly = c_string('r');
readCmd = c_string(['i2cget -y 1 0x53 0x32']);
if isequal(coder.target, 'rtw')
pf = coder.ceval('popen', coder.rref(readCmd), coder.rref(readOnly));
coder.ceval('fgets', coder.wref(res), 10, pf);
coder.ceval('printf', c_string('%s'), c_string(res));
end
end
function str = c_string(str)
% Convert MATLAB string to C-string by adding a string termination
% character
str = [str, 0];
end
But i dont know how to send data to Scope. Please help me.

12 Feb 2013 Ufuk Irmak  
08 Oct 2012 Murat Belge  

Contact us