Sparkfun ADXL 345 evaluation board

Hi,

I recently bought one of [these Sparkfun ADXL 345 evaluation boards.

I’ve recompiled the program to change the default g scale, but am having problems getting the code onto the board.

I’ve not used AVR / Arduino before (some programming of PICs) and don’t have an AVR ISCP programmer. If I’m reading the development board user guide right, I should just be able to take advantage of the Adruino bootloader to upload my files via USB / Virtual Com port using avrdude.

I’ve got the latest VCOM drivers - and can use PUTTY to connect to the accelerometer to read / write the registers - so I can communicate via the USB / VCOM - so far so good.

If I try to upload the simple blink sketch (my idea is to use the avrdude format displayed in the debugging to then upload the real .hex file I want on there) from the Arduino IDE (with the board set to Lilypad/mega328 as per the user guide) I get the following:


Binary sketch size: 920 bytes (of a 30720 byte maximum)

C:\Documents and Settings\raistrim\Desktop\arduino-0018\hardware/tools/avr/bin/avrdude -CC:\Documents and Settings\raistrim\Desktop\arduino-0018\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\.\COM4 -b57600 -D -Uflash:w:C:\DOCUME~1\raistrim\LOCALS~1\Temp\build5205186713608508249.tmp\Blink.cpp.hex:i

avrdude: Version 5.4-arduino, compiled on Oct 11 2007 at 19:12:32

Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

System wide configuration file is “C:\Documents and Settings\raistrim\Desktop\arduino-0018\hardware/tools/avr/etc/avrdude.conf”

Using Port : \.\COM4

Using Programmer : stk500v1

Overriding Baud Rate : 57600

avrdude: ser_open(): setting dtr

avrdude: Send: 0 [30] [20]

avrdude: Send: 0 [30] [20]

avrdude: Send: 0 [30] [20]

avrdude: Recv:

avrdude: stk500_getsync(): not in sync: resp=0x00

avrdude: Send: Q [51] [20]

avrdude: Recv:

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x4e

avrdude done. Thank you


I’ve tried permuations with the board powered off / memory card out and the only difference it makes is to sometimes change the resp value.

All of this is done on XP - though I have also tried with Vista 32 bit and get the same results.

Anybody any clues? Is there something I’m doing that’s fundamentally stupid here?

Cheers

Mike](https://www.sparkfun.com/commerce/product_info.php?products_id=9364)

I too have been having this same problem. I have tried everything that I can find.

I have tried XP and Vista. It is very aggravating that a board of this price has so little support and poor documentation. The fact that the schematic doesn’t even show the right processor is a little unnerving.

I really need to solve this problem.

I fact that the baud rate of 57600 is so much higher than the supported max speed of the arduino software makes me think that the problem is in insurmountable without a firmware change, but I am a total newbie with arduino and am unsure of all the inner workings at boot.

Same here.

Tried all combinations of cables, ports, drivers, you name it.

I have put in a call to sparkfun tech support today. Hopefully I will get an answer soon and can post some help here.

I have another question, I have captured the output into a python script that I wrote. I converted the numbers to positive and negative but really don’t know that I am right. It hasn’t mattered much because my app is more about simple motion detection.

How would you do it?

I downloaded the zip sketch files and installed the Arduino 0018. :smiley: I go to the sketch button then add file and loaded the Makefile file. Press play and it asked for main.c file and tried to compile it. It said it needed one of the other files. :roll: After awhile I figured it out that I needed to load them all. :idea: Then when I press the play button it gives me am error in the for loop in the ADXL345.c file stating :?

"In function ‘adxl345_read’:

error: ‘for’ loop initial declaration used outside C99 mode In function ‘adxl345_write’:".

So I found help files saying that you can’t declare a variable inside a function. :shock: So I move the “int bit=7” on line 45 before the “for” and fix the adxl345_write function too. 8)

So now it compiles further and hangs up in “fat.c” with a :?:

In function ‘fat_append_clusters’:

error: ‘for’ loop initial declaration used outside C99 mode In function ‘fat_interpret_dir_entry’:

In function ‘fat_write_dir_entry’:

In function ‘fat_get_fs_free_16_callback’:

In function ‘fat_get_fs_free_32_callback’:

Now this for loop is much more complex and I’m starting to think I must have something set up wrong but cant find it. :frowning: I know the Eval board works. I just cant compile the code that was associated with it. :cry:

Will this code work with an older version? :x

Do i need to apply the files in a certain way or place? :oops:

Please help! I keep reading and reading to figure this out but I can’t. If I could just compile the files that came with it I would feel free to experiment but If I burn blink to this board and cant reload the accelerometer function I wont do it. :lol:

You probably need to use the WinAVR version of gcc.

Thank you. I knew it was my ignorance. Thanks. :smiley: :smiley: :smiley:

I got the answer back from tech support. Unfortunately the board is NOT loaded with the Arduino boot loader and therefore will not run sketches as was advertised. It can be put on with an AVR programmer - which I don’t have.

Freebird - thanks for taking the time to post that up.

Wish I could pass on the same thanks to the Sparkfun team - it would have been useful if they could have been bothered to answer the question themselves here when it was posted. I guess they were busy updating the product web page and user guide to take out the not-just-a-little-bit-misleading-but-a-complete-fabrication-of-the-truth bits. Wait. No. Both still say Arduino bootloader. Ah well.

To answer your other question about positive / negative values - here’s a perl script I wrote to analyse my output file I’ve never used Python but I guess it should be fairly easy to work out the conversion:

$scale = .0156; #g/LSB

$sample = 100;

open (IN, ‘ADXL345_000.csv’);

while ($linein = ) {

if ($linein =~ /(\w+),(\w+),(\w+)/) {

$x = $1;

$count++;

$secs = $count / $sample;

$x2 = twoscomp($x) * $scale;

print (“$secs, $x2\n”);

}

}

sub twoscomp {

#Take a 16 bit hex value as twos complement - return the decimal value

my ($input) = @_;

$inputdec = hex $input; #Decimal value of the input

$msb = $inputdec & 32768; #Check to see if the MSB of the 16 bit word is 1

if ($msb == 32768) {

$input2 = ‘ffff’ . $input; #The MSB is 1 so add more 1s to a 32 bit value

$inputdec = hex $input2;

$neginput = ~$inputdec; # Ones complement

$neginput++; #Twos complement

$return = $neginput * -1; #Turn to negative decimal

} else {

$return = $inputdec;

}

return $return;

}

So what Programmer would you guys suggest? :cry:

I bought the tinyusb programmer from adafruit:

http://www.ladyada.net/make/usbtinyisp/

It seems to act a little wierd in that when you have it connected to the board and the board is running, when you connect the programmer to your PC (or boot the PC), it doesn’t detect the programmer. You need to switch off the board, then plug the programmer into the PC (at which point it’s recognised) and then switch on the board (so you can program it). At least it’s working that way for me on XP with SP3.

hello every body

i have purchased adxl345 to use it in our graduation project

i have read the datasheet

but there are things i do not understand, here they are:

1)the unit of sensitivity (lsb/g) what does it mean,what lsb stand for

2)the scale factor ,how will i use it

3)what is the value of g

i hope anybody help me as fast as possible

LSB - least significant bit?

g is the acceleration due to gravity (about 9.81 m/s^2).

mohamed mis:
hello every body

i have purchased adxl345 to use it in our graduation project

i have read the datasheet

but there are things i do not understand, here they are:

1)the unit of sensitivity (lsb/g) what does it mean,what lsb stand for

Least Significant Bit - so this is the value read from the accelerometer for 1g at your chosen range (2g, 4g, 8g, 16g)

2)the scale factor ,how will i use it

Inverse of the sensitivity. So get the value from the accelerometer, muliply by the right scale factor and you have the number of g.

3)what is the value of g

Leon is right - 9.8m/s/s - in terms of the accelerometers measurements however this would be ‘1g’

i hope anybody help me as fast as possible

Nostraquedeo:
Thank you. I knew it was my ignorance. Thanks. :smiley: :smiley: :smiley:

What did you do with WinAVR to make it work?

I’m completely new to Arduino and AVR products, but have this eval board (before the bootloader was added by Sparkfun :evil: ) and would like to know how to make it read 16g as the default start up sensitivity. If I’m reading my output values correct (and looking at the registers with a terminal), I’m only getting the default 2g. I can change the registers to make it (temporarily) 16g, but it resets back to 2g every time it is turned off and on.

Like I said before, I’m new to Arduino and AVR. I do have a decent knowledge of C and have programmer PIC microcontrollers before with the MPLab IDE.

So if anyone could give me a moderately to very detailed explanation of what you use the Arduino IDE, WinAVR (and what parts of WinAVR), and anything else important to program this, it would be awesome. I do have access to an AVR programmer, so if I have to program the bootloader to the chip, how easy is that?

Thanks in advance. :smiley:

This was really a waste of money and time. I got the tinyusb programmer that was recommended by the sparkfun team.

Now, I think I have a brick. It never gave a proper response and nothing seemed to work right. And nothing works now.

The fact that the board is suddenly out of stock immediately after posting an updated version makes me think that an intrinsic flaw was found.

The comments on the store sight indicate that it was co developed with someone else. I hope they think twice about doing that again.

This has really been a pain in the butt.

With things like programmers and debuggers it’s best to buy the manufacturer’s units. They might cost more than cheap knockoffs, but you will have far fewer problems.

Hi all

Thanks to motosota for the perl codes above. I have edited it a little to work for me and thought I would post here in case it helps others.

The mods are:

Take input from STDIN

Output a header line

Output all 3 values

Changed Scale value.

The scale value was changed to make the resting value of the Z axis read a G of ‘1’, as I believe it should at rest. Interestingly this doesnt quite seem to work for Y & Z - which end up at about 1.2 at rest, something to investigate.

#!/usr/bin/perl

viewtopic.php?f=7&t=20737

#$scale = .0156; #g/LSB

$scale = .004525;

$sample = 100;

#open (IN,‘ADXL345_000still.csv’);

print (“Secs,Right Left,Front Back,Up Down\n”);

while ($linein = ) {

if ($linein =~ /(\w+),(\w+),(\w+)/) {

$x1 = $1;

$x2 = $2;

$x3 = $3;

$count++;

$secs = $count / $sample;

$y1 = twoscomp($x1) * $scale;

$y2 = twoscomp($x2) * $scale;

$y3 = twoscomp($x3) * $scale;

print (“$secs,$y1,$y2,$y3\n”);

}

}

sub twoscomp {

#Take a 16 bit hex value as twos complement - return the decimal value

my ($input) = @_;

$inputdec = hex $input; #Decimal value of the input

$msb = $inputdec & 32768; #Check to see if the MSB of the 16 bit word is 1

if ($msb == 32768) {

$input2 = ‘ffff’ . $input; #The MSB is 1 so add more 1s to a 32 bit value

$inputdec = hex $input2;

$neginput = ~$inputdec; # Ones complement

$neginput++; #Twos complement

$return = $neginput * -1; #Turn to negative decimal

} else {

$return = $inputdec;

}

return $return;

}