Be the first to rate this file! 52 Downloads (last 30 days) File Size: 132 KB File ID: #41027
image thumbnail

ADLX345 i2c Driver for Arduino Mega

by

 

01 Apr 2013 (Updated )

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

| Watch this File

File Information
Description

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

Acknowledgements

Device Drivers inspired this file.

This file inspired Arduino S Function For Mpc4725 I2 C Dac.

MATLAB release MATLAB 8.1 (R2013a)
Other requirements Arduino Mega 2560 Sparkfun 9DOF sensor stick
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
29 Jan 2014 Eddy Trinklein

Addie,

Have you tried a different compiler?

Thanks,

Ed

25 Jan 2014 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

13 May 2013 efrianto tanto

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

22 Apr 2013 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

19 Apr 2013 phil

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
01 Apr 2013

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.

Contact us