Hi, I keep getting #failed to generate all binary outputs message when using the S function block.

조회 수: 1 (최근 30일)
Hi. I am using an Arduino UNO with an adafruit 10 dof IMU. I am running an example sketch on using only the accelerometer,on Simulink using the S-function block. Every time I run it I keep getting this error message. I didnt post the whole code as it is very long, just the part showing the error.
I/Users/Hammodi/Documents/MATLAB/SupportPackages/R2015b/arduino-1.6.1/Arduino.app/Contents/Resources/Java/libraries/Servo/src -I/Users/Hammodi/Documents/MATLAB/SupportPackages/R2015b/arduino/toolbox/target/supportpackages/arduinotarget/registry/../include -I/Users/Hammodi/Documents/MATLAB/SupportPackages/R2015b/arduino/toolbox/target/supportpackages/arduinotarget/registry/../scheduler/include -I/Users/Hammodi/Documents/MATLAB/SupportPackages/R2015b/arduinobase/toolbox/target/supportpackages/arduinobase/include -o "Accelerometer_wrapper.o" "../Accelerometer_wrapper.cpp"
../Accelerometer_wrapper.cpp:19:18: fatal error: Wire: No such file or directory
#include <Wire>.h
^
compilation terminated.
gmake: *** [Accelerometer_wrapper.o] Error 1
### Build procedure for model: 'Aceleromoter_test' aborted due to an error.
Error(s) encountered while building "Aceleromoter_test":
### Failed to generate all binary outputs.
  댓글 수: 1
Ahmed Ben Amer
Ahmed Ben Amer 2016년 4월 13일
Hi Guys, i just found out that it is not able to find the libraries specified for some reason even though i add them to the current path in Matlab. I dont know why it would do such a thing, would anyone have any idea?

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 4월 13일
#include <Wire.h>
You had the .h in the wrong place
  댓글 수: 2
Ahmed Ben Amer
Ahmed Ben Amer 2016년 4월 13일
Thank you so much, I cant believe i missed that. I have fixed it but now I am getting the following error for some reason. Am I also supposed to declare the function that is used in the void loop and void setup?, because I would have thought it is declared within the library itself.
"../Accelerometer_wrapper.cpp"
../Accelerometer_wrapper.cpp: In function 'void Accelerometer_Outputs_wrapper(real_T*, const real_T*)':
../Accelerometer_wrapper.cpp:49:1: error: 'accel' was not declared in this scope
accel.begin();
^
../Accelerometer_wrapper.cpp: In function 'void Accelerometer_Update_wrapper(const real_T*, real_T*)':
../Accelerometer_wrapper.cpp:67:3: error: 'accel' was not declared in this scope
accel.getEvent(&event);
^
../Accelerometer_wrapper.cpp:71:9: error: assignment of read-only location '* y0'
y0[0] = event.acceleration.x;
^
../Accelerometer_wrapper.cpp:72:9: error: assignment of read-only location '*(y0 + 4u)'
y0[1] = event.acceleration.y;
^
../Accelerometer_wrapper.cpp:73:9: error: assignment of read-only location '*(y0 + 8u)'
y0[2] = event.acceleration.z;
^
gmake: *** [Accelerometer_wrapper.o] Error 1
The code I used in the S-function is the following, for the libraries:
#ifndef MATLAB_MEX_FILE
#include <Arduino.h>
#include <math.h>
#include <Wire.h>
#include <Wire.cpp>
#include <txi.h>
#include <txi.cpp>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303_U.h>
#include <Adafruit_LSM303_U.cpp>
#endif
For the output:
if (xD[0]==1) {
# ifndef MATLAB_MEX_FILE
accel.begin();
# endif
}
As for the Discrete Update:
if (xD[0]!=1) {
#ifndef MATLAB_MEX_FILE
/* Get a new sensor event */
sensors_event_t event;
accel.getEvent(&event);
/* Display the results (acceleration is measured in m/s^2) */
y0[0] = event.acceleration.x;
y0[1] = event.acceleration.y;
y0[2] = event.acceleration.z;
delay(500);
# endif
xD[0]=1;
}
I am using an accelerometer and this code is supposed to give me 3 values through the scope, x,y and z. Any help is appreciated, thanks.
Walter Roberson
Walter Roberson 2016년 4월 14일
Which .h is accel declared in?
You should not be #include'ing a .cpp in this situation.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by