File Exchange

image thumbnail

ADLX345 i2c Driver for Arduino Mega

version 1.1 (132 KB) by

This is a driver for the analog devices ADLX345 triaxial acceleration and an Arduino mega.

28 Downloads

Updated

View License

This driver utilizes the Arduino i2c libraries from version 1.0 and driver architecture found from various sources on the web. It configures the sensor to +/- 4 G's at 100 Hz. The data sample rate is set to 0.05 second period via the S-Function builder update rate. Additional settings are described in the manual.

For additional information and tips please look at the excellent description by Giampiero Campa.

http://www.mathworks.com/matlabcentral/fileexchange/39354

Comments and Ratings (7)

Claudio

Hi Eddy,
I tried to use your example (that works perfectly :) ) like a template to compile a different code that uses some additional cpp library, but when I try to compile on ArduinoMega it returns an error. There is something else that I have to take in account in add to your "readme" file? Thank you in advance.

Below the error log:
The call to realtime_make_rtw_hook, during the after_make hook generated the following error:
The build failed with the following message: "E:/Programmi/MATLAB/SupportPackages/R2013b/arduino-1.0/hardware/tools/avr/bin/avr-gcc" -I"F:/doc meccanica/Arduino/Test_simulink_compiling/Arduino_ADLX345_driver_v1_rtt" -I"F:/doc [...]

Dylan

Dylan (view profile)

Eddy Trinklein

Addie,

Have you tried a different compiler?

Thanks,

Ed

addie irawan

Hi Eddy:

  I have this problem on downloading your model to my ArduinoMega:

The call to realtime_make_rtw_hook, during the after_make hook generated the following error:
The build failed with the following message: "C:/MATLAB/Targets/R2012a/arduino-1.0/hardware/tools/avr/bin/avr-gcc" -I"C:\Users\user\Downloads\ADXL345_driver_v1\Arduino_ADLX345_driver_v1_rtt" -I"C:\Users\user\Downloads\ADXL345_driver_v1" -I"C:\Program Files\MATLAB\R2012a\extern\include" -I"C:\Program Files\MATLAB\R2012a\simulink\include" -I"C:\Program Files\MATLAB\R2012a\rtw\c\src" -I"C:\Program Files\MATLAB\R2012a\rtw\c\src\ext_mode\common" -I"C:\Program Files\MATLAB\R2012a\rtw\c\ert" -I"C:\MATLAB\Targets\R2012a\arduino-1.0\hardware\arduino\cores\arduino" -I"C:\MATLAB\Targets\R2012a\arduino-1.0\hardware\arduino\variants\mega" -I"C:\MATLAB\Targets\R2012a\arduino\include" -I"C:\MATLAB\Targets\R2012a\arduino-1.0\libraries\Servo" -I"C:\Program Files\MATLAB\R2012a\rtw\c\src\ext_mode\serial" -mmcu=atmega2560 -std=gnu99 -Wall -Wstrict-prototypes -gstabs -Os -D"MODEL=Arduino_ADLX345_driver_v1" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -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"TID01EQ=0" -D"F_CPU=16000000" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"_ROTH_MEGA2560_=" -D"_RTT_NUMSERVOS_=0" -D"EXIT_FAILURE=1" -D"EXTMODE_DISABLEPRINTF=" -D"EXTMODE_DISABLETESTING=" -c -x none ./HardwareSerial.cpp ./Print.cpp ./WInterrupts.c ./WMath.cpp ./WString.cpp ./new.cpp ./wiring.c ./wiring_analog.c ./wiring_digital.c ./io_wrappers.cpp ./rtiostream_serial.cpp ./ext_svr.c ./ext_work.c ./updown.c ./ext_serial_pkt.c ./ext_svr_serial_transport.c ./rtiostream_serial_interface.c ./ADXL345_driver_v1_wrapper.cpp ./Arduino_ADLX345_driver_v1.c ./ert_main.c
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./io_wrappers.cpp: In function 'void Serial_read(int, int, uint8_t*, int*)':
./io_wrappers.cpp:40: warning: 'libFcnOutput' may be used uninitialized in this function
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./rtiostream_serial.cpp: In function 'int rtIOStreamOpen(int, void**)':
./rtiostream_serial.cpp:28: warning: unused variable 'init_complete'
./ext_svr_serial_transport.c: In function 'ExtProcessArgs':
./ext_svr_serial_transport.c:247: warning: format '

The build process will terminate as a result.

Please help me on this. I have followed your steps in 'readme' file. But this error occurred. Your model is useful for my project to connect other chips with my ArduinoMega

Hello, I tried to build the slx file in simulink but the error in s -function'Arduino_ADLX345_driver_v1/S-Function Builder1':S-function'ADLX345_driver_v1' does not exist.
Could you please help me? Thanks,

Efri

Eddy Trinklein

Phil,

If you could provide more info on where you run into problems I might be able to help you. It sounds like you've used this example to build a custom LCD driver? Awesome, I would love help.

Thanks,

Ed

phil

phil (view profile)

hey man great work. i am trying to follow your steps but i keep getting errors when trying to upload my driver (lcd driver)...it would be amazing if you could maybe do a screenrecord of the process and put it on youtube...i cant figure out what i am doing wrong...thanks!

Updates

1.1

Two code revisions in the model outputs section due to compile errors, caught before anyone downloaded this file. Revision level kept the same to match readme file.

MATLAB Release
MATLAB 8.1 (R2013a)

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

» Watch video