BeagleBoard I/O Pins code generation
Mostra commenti meno recenti
Hi,
Is there any way, using BeageBoard as hardware Target, one can create a simulink model that uses I/O pins on the BeagleBoard? I know there is an Embedded Coder BeagleBoard example but it doe not use any I/O pins (Analog and Digital.)
Thanks,
Ahmad.
Risposta accettata
Più risposte (1)
Murat Belge
il 6 Giu 2012
1 voto
The MATLAB R2012a release has a downloadable support package for BeagleBoard (installed by executing "targetinstaller" on the MATLAB command line). There are Simulink blocks for Video Capture, Video Display, Audio Capture/Display and UDP Send/Receive. There are no GPIO blocks as of yet. It is possible to use GPIO pins for digital Input/Output using the Embedded MATLAB function block. Let me know what exactly you are trying to do.
5 Commenti
Ahmad
il 6 Giu 2012
Murat Belge
il 7 Giu 2012
The BeagleBoard has no analog input capability. You need to use a suitable expansion board to interface to analog sensors. It is possible to use the GPIO pins as digital input or output; hence you can operate relays for example. I'll send out an example for GPIO programming with Simulink.
NASREEN
il 3 Ott 2012
@Murat Belge,
Can you please send out an example for GPIO programming with simulink. I would really appreciate your help as I am analysing analog signals to simulink model
Murat Belge
il 4 Ott 2012
Below is the code that you can paste into an Embedded MATLAB Function block to use a GPIO pin as an output. Using a GPIO pin as an input is very similar.
function fcn(u)
%#codegen
% This MATLAB function shows how to setup and use a GPIO pin as output. The
% function basically issues a number of system calls to do the following:
% 1. Export GPIO pin for use
% 2. Setup GPIO direction as output
% 3. Write the value of input u to the GPIO pin
%
% Note that input should be a boolean scalar. If the value of u is zero the
% GPIO pin goes low. Else GPIO pin goes high.
persistent firstTime;
gpioPin = '139';
coder.extrinsic('disp');
if isempty(firstTime)
firstTime = 0;
if isequal(coder.target, 'rtw')
% Export GPIO pin
cmd = ['echo ', gpioPin, '> /sys/class/gpio/export'];
coder.ceval('system', c_string(cmd));
% Set GPIO pin direction to output
cmd = ['echo out> /sys/class/gpio/gpio', gpioPin, '/direction'];
coder.ceval('system', c_string(cmd));
else
disp('Initialize GPIO pin as output');
end
end
% Set GPIO pin logic level using a system call
if (u > 0)
cmd = ['echo 1 > /sys/class/gpio/gpio', gpioPin, '/value'];
else
cmd = ['echo 0 > /sys/class/gpio/gpio', gpioPin, '/value'];
end
if isequal(coder.target, 'rtw')
coder.ceval('system', c_string(cmd));
else
disp(cmd);
end
end
function str = c_string(str) % Convert MATLAB string to C-string by adding a string termination % character str = [str, 0]; end % code end
Franziska
il 3 Dic 2013
Hi, My name is Fatemeh, Thank you for your code.I wanted to ask a question, Do you know how to access to the c code of GPIO block of matlab? my emmail address: fateme_nejatbakhsh@yahoo.com
Categorie
Scopri di più su Code Generation and Deployment in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!