SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on the software and hardware for Atmel's STK standard.
By motosota

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,

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?


By freebird310
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.
By freebird310
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?
By Nostraquedeo
I downloaded the zip sketch files and installed the Arduino 0018. :D 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. :( 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:
By freebird310
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.
By motosota
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 = <IN>) {
if ($linein =~ /(\w+),(\w+),(\w+)/) {
$x = $1;
$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;
By motosota
I bought the tinyusb programmer from adafruit:

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.
By 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
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
By motosota
mohamed mis wrote: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
By latlax42
Nostraquedeo wrote:Thank you. I knew it was my ignorance. Thanks. :D :D :D
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. :D
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]