File Exchange

image thumbnail

Raspberry Pi Driver Block SFunction

version 1.1 (17.8 KB) by

Simple Digital Out SFunction example block showing how to use the WiringPi library

49 Downloads

Updated

View License

An example SFunction block for Raspberry Pi showing basic usage of the WiringPi library
The latest version of this file and others can be found at our Raspberry Pi downloads page:

http://minseg.webs.com/downloads

A complete Arduino library and curriculum is available here:
http://minseg.com/pages/downloads

coming soon:
- PWM
- Quadrature Encoder
- MPU6050

and others!

Comments and Ratings (22)

Pllvcn

Pllvcn (view profile)

I need to develop a S-function (target Rasperry) that use c++ headers (.h and .cpp) but the building has some problems.

someone knows how can i resolve it?

The call to realtime_make_rtw_hook, during the after_make hook generated the following error:
    Error executing SSH command: make: Entering directory '/home/pi/raspberrypi_gettingstarted_rtt'
"gcc" -I"./" -O3 -D"MODEL=raspberrypi_gettingstarted" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ON_TARGET_WAIT_FOR_START=1" -D"ONESTEPFCN=0" -D"EXT_MODE=1" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"ALLOCATIONFCN=0" -D"TID01EQ=0" -D"_USE_TARGET_UDP_=" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"EXIT_FAILURE=1" -D"EXTMODE_DISABLETESTING=" -c ./linuxUDP.c ./ext_svr.c ./ext_work.c ./rtiostream_interface.c ./updown.c ./rtiostream_tcpip.c ./rtiostream_utils.c ./GY87_wrapper.c ./ert_main.c ./raspberrypi_gettingstarted.c ./raspberrypi_gettingstarted_data.c
In file included from /home/pi/MPU6050_CCODE/I2Cdev.cpp:55:0,
                 from ./GY87_wrapper.c:22:
/home/pi/MPU6050_CCODE/I2Cdev.h:52:1: error: unknown type name ÔÇÿclassÔÇÖ
/home/pi/MPU6050_CCODE/I2Cdev.h:52:14: error: expected ÔÇÿ=ÔÇÖ, ÔÇÿ,ÔÇÖ, ÔÇÿ;ÔÇÖ, ÔÇÿasmÔÇÖ or ÔÇÿ__attribute__ÔÇÖ before ÔÇÿ{ÔÇÖ token
In file included from ./GY87_wrapper.c:22:0:
/home/pi/MPU6050_CCODE/I2Cdev.cpp:59:7: error: expected ÔÇÿ=ÔÇÖ, ÔÇÿ,ÔÇÖ, ÔÇÿ;ÔÇÖ, ÔÇÿasmÔÇÖ or ÔÇÿ__attribute__ÔÇÖ before ÔÇÿ:ÔÇÖ token
In file included from ./GY87_wrapper.c:22:0:

Raymond Chiu

2015a=>wiringpi (serial port) work. 2015b failed. Recommend using 2015a until issue 01934398 is resolved.

Esther

Esther (view profile)

Using R2015b -

Connecting an LED to the Toggle Digital Output Pin SFunction block, did anyone get the LED to change state (on/off) while running in External Mode? When I ran in External Mode and toggled the switch, the LED would not light up/turn off.

But the GPIO Write block worked fine - I could change the value in the constant block and see the LED respond.

Esther

Esther (view profile)

I have the same problem as stated by VCOpll before. The solution with "xmakefilesetup" does not work for me because the feature is not longer available in R2015.

Thanks for the comment Arnaud, glad it helped you. I've uploaded my version of the driver blocks with better documentation here: http://uk.mathworks.com/matlabcentral/fileexchange/51232-raspberry-pi-simulink-driver-blocks-adc-dac-pwm

I could not find the solution by myself but someone did using xmakefilesetup :

http://engineer.john-whittington.co.uk/2015/06/simulink-raspberry-pi-driver-blocks/

I could also build an s-function using BCM2835 lib and another to communicate with Phidgets sensors (bridges) on Rpi.

Many thanks to John !

VCOpll

VCOpll (view profile)

Has anyone figured this out?

I am getting the same error.

The call to realtime_make_rtw_hook, during the after_make hook generated the following error:
    Error executing SSH command: make: Entering directory '/home/pi/projects/scratch_220515_rtt'
"gcc" -I"./" -O3 -D"MODEL=scratch_220515" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ON_TARGET_WAIT_FOR_START=1" -D"ONESTEPFCN=0" -D"EXT_MODE=1" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"ALLOCATIONFCN=0" -D"TID01EQ=0" -D"_USE_TARGET_UDP_=" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"EXIT_FAILURE=1" -D"EXTMODE_DISABLETESTING=" -c ./MW_gpio.c ./MW_pinmux.c ./linuxUDP.c ./ext_svr.c ./ext_work.c ./rtiostream_interface.c ./updown.c ./rtiostream_tcpip.c ./rtiostream_utils.c ./SPI_scratch_wrapper.c ./ert_main.c ./scratch_220515.c
"gcc" ./MW_gpio.o ./MW_pinmux.o ./linuxUDP.o ./ext_svr.o ./ext_work.o ./rtiostream_interface.o ./updown.o ./rtiostream_tcpip.o ./rtiostream_utils.o ./SPI_scratch_wrapper.o ./ert_main.o ./scratch_220515.o -lm -ldl -lpthread -lrt -o ./MW/scratch_220515
./SPI_scratch_wrapper.o: In function `pinMode.constprop.13':
SPI_scratch_wrapper.c:(.text+0xeac): undefined reference to `softPwmStop'
SPI_scratch_wrapper.c:(.text+0xeb4): undefined reference to `softToneStop'
./SPI_scratch_wrapper.o: In function `pinMode':
SPI_scratch_wrapper.c:(.text+0x14ac): undefined reference to `softPwmStop'
SPI_scratch_wrapper.c:(.text+0x14b4): undefined reference to `softToneStop'
SPI_scratch_wrapper.c:(.text+0x1680): undefined reference to `softPwmCreate'
SPI_scratch_wrapper.c:(.text+0x168c): undefined reference to `softToneCreate'
./SPI_scratch_wrapper.o: In function `SPI_scratch_Update_wrapper':
SPI_scratch_wrapper.c:(.text+0x3184): undefined reference to `mcp3008Setup'
collect2: ld returned 1 exit status
_scratch_220515.mk:122: recipe for target 'MW/scratch_220515' failed
make: *** [MW/scratch_220515] Error 1
make: Leaving directory '/home/pi/projects/scratch_220515_rtt'

The build process will terminate as a result.

Error executing SSH command: make: Entering directory '/home/pi/projects/scratch_220515_rtt'
"gcc" -I"./" -O3 -D"MODEL=scratch_220515" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ON_TARGET_WAIT_FOR_START=1" -D"ONESTEPFCN=0" -D"EXT_MODE=1" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"ALLOCATIONFCN=0" -D"TID01EQ=0" -D"_USE_TARGET_UDP_=" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"EXIT_FAILURE=1" -D"EXTMODE_DISABLETESTING=" -c ./MW_gpio.c ./MW_pinmux.c ./linuxUDP.c ./ext_svr.c ./ext_work.c ./rtiostream_interface.c ./updown.c ./rtiostream_tcpip.c ./rtiostream_utils.c ./SPI_scratch_wrapper.c ./ert_main.c ./scratch_220515.c
"gcc" ./MW_gpio.o ./MW_pinmux.o ./linuxUDP.o ./ext_svr.o ./ext_work.o ./rtiostream_interface.o ./updown.o ./rtiostream_tcpip.o ./rtiostream_utils.o ./SPI_scratch_wrapper.o ./ert_main.o ./scratch_220515.o -lm -ldl -lpthread -lrt -o ./MW/scratch_220515
./SPI_scratch_wrapper.o: In function `pinMode.constprop.13':
SPI_scratch_wrapper.c:(.text+0xeac): undefined reference to `softPwmStop'
SPI_scratch_wrapper.c:(.text+0xeb4): undefined reference to `softToneStop'
./SPI_scratch_wrapper.o: In function `pinMode':
SPI_scratch_wrapper.c:(.text+0x14ac): undefined reference to `softPwmStop'
SPI_scratch_wrapper.c:(.text+0x14b4): undefined reference to `softToneStop'
SPI_scratch_wrapper.c:(.text+0x1680): undefined reference to `softPwmCreate'
SPI_scratch_wrapper.c:(.text+0x168c): undefined reference to `softToneCreate'
./SPI_scratch_wrapper.o: In function `SPI_scratch_Update_wrapper':
SPI_scratch_wrapper.c:(.text+0x3184): undefined reference to `mcp3008Setup'
collect2: ld returned 1 exit status
_scratch_220515.mk:122: recipe for target 'MW/scratch_220515' failed
make: *** [MW/scratch_220515] Error 1
make: Leaving directory '/home/pi/projects/scratch_220515_rtt'

Hi, exactly the same message as Walter and Chfakht chfakht :
The call to realtime_make_rtw_hook, during the after_make hook generated the following error:
Error executing SSH command: make: Entering directory '/home/pi/Essai_SPI_rtt'
"gcc" -I"./" -O3 -D"MODEL=Essai_SPI" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ON_TARGET_WAIT_FOR_START=1" -D"ONESTEPFCN=0" -D"EXT_MODE=1" -D"TERMFCN=1" - etc...

Please could someone help us ?
I could see that there are many files downloaded into the RPI but nothing on the /MW directory where the executable should be.

By the way I'm using R2013a and a RPI B+

Thanks in advance

Walter Veiga

Hi, I'm getting the same error as chfakht chfakht and Daryl. Did anyone manage to fix this ?

Tanks.

Hello ,
i have this error when trying to upload an example to the raspberry pi model b+

The call to realtime_make_rtw_hook, during the after_make hook generated the following error:
Error executing SSH command: make: Entering directory '/home/pi/MinSegMega_Demo_V2_rtt'
"gcc" -I"./" -O3 -D"MODEL=MinSegMega_Demo_V2" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ON_TARGET_WAIT_FOR_START=1" -D"ONESTEPFCN=0" -D"EXT_MODE=1" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"TID01EQ=0" -D"_USE_TARGET_UDP_=" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"EXIT_FAILURE=1" -D"EXTMODE_DISABLETESTING=" -c ./linuxUDP.c ./MinSegMega_Demo_V2.c ./ert_main.c ./ext_svr.c ./ext_work.c ./rtiostream_interface.c ./updown.c ./rtiostream_tcpip.c ./rtiostream_utils.c
"gcc" ./linuxUDP.o ./MinSegMega_Demo_V2.o ./ert_main.o ./ext_svr.o ./ext_work.o ./rtiostream_interface.o ./updown.o ./rtiostream_tcpip.o ./rtiostream_utils.o -lm -ldl -lpthread -lrt -o ./MW/MinSegMega_Demo_V2
./MinSegMega_Demo_V2.o: In function `MinSegMega_Demo_V2_output':
MinSegMega_Demo_V2.c:(.text+0x4c): undefined reference to `sf_HMC5883L_MPU6050_Outputs_wrapper'
./MinSegMega_Demo_V2.o: In function `MinSegMega_Demo_V2_update':
MinSegMega_Demo_V2.c:(.text+0xa8): undefined reference to `sf_HMC5883L_MPU6050_Update_wrapper'
collect2: ld returned 1 exit status
_MinSegMega_Demo_V2.mk:161: recipe for target 'MW/MinSegMega_Demo_V2' failed
make: *** [MW/MinSegMega_Demo_V2] Error 1
make: Leaving directory '/home/pi/MinSegMega_Demo_V2_rtt'

The build process will terminate as a result.

Caused by:
Error executing SSH command: make: Entering directory '/home/pi/MinSegMega_Demo_V2_rtt'
"gcc" -I"./" -O3 -D"MODEL=MinSegMega_Demo_V2" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ON_TARGET_WAIT_FOR_START=1" -D"ONESTEPFCN=0" -D"EXT_MODE=1" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"TID01EQ=0" -D"_USE_TARGET_UDP_=" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"EXIT_FAILURE=1" -D"EXTMODE_DISABLETESTING=" -c ./linuxUDP.c ./MinSegMega_Demo_V2.c ./ert_main.c ./ext_svr.c ./ext_work.c ./rtiostream_interface.c ./updown.c ./rtiostream_tcpip.c ./rtiostream_utils.c
"gcc" ./linuxUDP.o ./MinSegMega_Demo_V2.o ./ert_main.o ./ext_svr.o ./ext_work.o ./rtiostream_interface.o ./updown.o ./rtiostream_tcpip.o ./rtiostream_utils.o -lm -ldl -lpthread -lrt -o ./MW/MinSegMega_Demo_V2
./MinSegMega_Demo_V2.o: In function `MinSegMega_Demo_V2_output':
MinSegMega_Demo_V2.c:(.text+0x4c): undefined reference to `sf_HMC5883L_MPU6050_Outputs_wrapper'
./MinSegMega_Demo_V2.o: In function `MinSegMega_Demo_V2_update':
MinSegMega_Demo_V2.c:(.text+0xa8): undefined reference to `sf_HMC5883L_MPU6050_Update_wrapper'
collect2: ld returned 1 exit status
_MinSegMega_Demo_V2.mk:161: recipe for target 'MW/MinSegMega_Demo_V2' failed
make: *** [MW/MinSegMega_Demo_V2] Error 1
make: Leaving directory '/home/pi/MinSegMega_Demo_V2_rtt'

thanks

Daryl

Daryl (view profile)

Hi!

I have a problem when trying to run a sfunction which uses the wiringPi examples.

I can build the sfunction. After building i try to run the simulation on the external target. I then get a message with undefined references.

I noticed that the message also states:

"gcc" -I"./" -I"C:/Users/Daryl/SkyDrive/School/00_Matlab/Diy/raspberry_pi/home/pi/wiringPi/wiringPi"

Should this not be a direcory on the raspberry pi instead of a folfer on my windows computer?

Thanks in advance if one of you can help me!!

The complete error message is as follows:

The build process will terminate as a result.

Error executing SSH command: make: Entering directory '/home/pi/Digital_Out_SFunction_Example_rtt'
"gcc" -I"./" -I"C:/Users/Daryl/SkyDrive/School/00_Matlab/Diy/raspberry_pi/home/pi/wiringPi/wiringPi" -O3 -D"MODEL=Digital_Out_SFunction_Example" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ON_TARGET_WAIT_FOR_START=1" -D"ONESTEPFCN=0" -D"EXT_MODE=1" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"ALLOCATIONFCN=0" -D"TID01EQ=0" -D"_USE_TARGET_UDP_=" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"EXIT_FAILURE=1" -D"EXTMODE_DISABLETESTING=" -c ./MW_gpio.c ./MW_pinMux.c ./linuxUDP.c ./ext_svr.c ./ext_work.c ./rtiostream_interface.c ./updown.c ./rtiostream_tcpip.c ./rtiostream_utils.c ./Digital_Out_SFunction_Example.c ./Digital_Out_SFunction_Example_data.c ./ert_main.c ./sfcn_Digital_Out_wrapper.c
"gcc" ./MW_gpio.o ./MW_pinMux.o ./linuxUDP.o ./ext_svr.o ./ext_work.o ./rtiostream_interface.o ./updown.o ./rtiostream_tcpip.o ./rtiostream_utils.o ./Digital_Out_SFunction_Example.o ./Digital_Out_SFunction_Example_data.o ./ert_main.o ./sfcn_Digital_Out_wrapper.o -lm -ldl -lpthread -lrt -o ./MW/Digital_Out_SFunction_Example
./sfcn_Digital_Out_wrapper.o: In function `pinMode':
sfcn_Digital_Out_wrapper.c:(.text+0xfd0): undefined reference to `softPwmStop'
sfcn_Digital_Out_wrapper.c:(.text+0xfd8): undefined reference to `softToneStop'
sfcn_Digital_Out_wrapper.c:(.text+0x12c0): undefined reference to `softPwmCreate'
sfcn_Digital_Out_wrapper.c:(.text+0x12cc): undefined reference to `softToneCreate'
collect2: ld returned 1 exit status
_Digital_Out_SFunction_Example.mk:122: recipe for target 'MW/Digital_Out_SFunction_Example' failed
make: *** [MW/Digital_Out_SFunction_Example] Error 1
make: Leaving directory '/home/pi/Digital_Out_SFunction_Example_rtt'

long Nguyen

This link may be helpful.

https://groups.google.com/forum/#!msg/beagleboard/fC-Bg_-Ia34/cvTeQvJ2MAwJ

Maybe problem because the compiler not link to matlab

Biao

Biao (view profile)

Hi, I have similar errors with Alexander. I have already installed latest wiringPi lib. So how do you deploy it and make it running well at raspberry pi?

Miguel

Miguel (view profile)

Hi I have the following problem.
All to Tools -> Run on Target Hardware -> RUN
I get:
Error in S-function 'Digital_Out_SFunction_Example / Toggle Pin Digital Output With SFunction': S-Function 'sfcn_Digital_Out' does not exist

They know how to fix it, possess the xls file and I can not install it on my Raspberry Pi. Thank you.

Liang Xuan

Hi Daniel, the problem solved when you replace the original wiringPi library in the raspberry with the latest version.

Liang Xuan

Daniel

Daniel (view profile)

Alexander, I keep getting a similar error. What did you do to get yours working?

Thank you,
Daniel

Alexander

Ive got it, ty.

Alexander

hey, ive took this one by one and:

The call to realtime_make_rtw_hook, during the after_make hook generated the following error:
Error executing SSH command: make: Entering directory `/home/pi/Digital_Out_SFunction_Example_rtt'
"gcc" -I"./" -O3 -D"MODEL=Digital_Out_SFunction_Example" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ONESTEPFCN=0" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"TID01EQ=0" -D"_USE_TARGET_UDP_=" -D"_RUNONTARGETHARDWARE_BUILD_=" -c ./MW_gpio.c ./MW_pinMux.c ./linuxUDP.c ./Digital_Out_SFunction_Example.c ./Digital_Out_SFunction_Example_data.c ./ert_main.c ./sfcn_Digital_Out_wrapper.c
./sfcn_Digital_Out_wrapper.c:38:50: fatal error: /home/pi/wiringPi/wiringPi/gertboard.h: No such file or directory
compilation terminated.
make: *** [MW_gpio.o] Error 1
make: Leaving directory `/home/pi/Digital_Out_SFunction_Example_rtt'

The build process will terminate as a result.

Caused by:
Error executing SSH command: make: Entering directory `/home/pi/Digital_Out_SFunction_Example_rtt'
"gcc" -I"./" -O3 -D"MODEL=Digital_Out_SFunction_Example" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ONESTEPFCN=0" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"TID01EQ=0" -D"_USE_TARGET_UDP_=" -D"_RUNONTARGETHARDWARE_BUILD_=" -c ./MW_gpio.c ./MW_pinMux.c ./linuxUDP.c ./Digital_Out_SFunction_Example.c ./Digital_Out_SFunction_Example_data.c ./ert_main.c ./sfcn_Digital_Out_wrapper.c
./sfcn_Digital_Out_wrapper.c:38:50: fatal error: /home/pi/wiringPi/wiringPi/gertboard.h: No such file or directory
compilation terminated.
make: *** [MW_gpio.o] Error 1
make: Leaving directory `/home/pi/Digital_Out_SFunction_Example_rtt'

Some hints?

Regards,
Alex

Murat Belge

Updates

1.1

updated links

MATLAB Release
MATLAB 8.1 (R2013a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video