Go to Post the FIRST season is never over . . it just pauses a while so you can get some sleep. - Stuart [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-04-2010, 16:58
matrix_manshy matrix_manshy is offline
Registered User
no team
 
Join Date: Apr 2010
Location: egypt
Posts: 6
matrix_manshy is an unknown quantity at this point
please help in adxl345

hi am a new user to adxl345 accelerometer and i use it in graduation project to give output displacement i am really cant know a lot of things about it
first i use spi interface so i use only 4 pins cs ,sdio,sdo,sclk,i think 4 wire

second i want to know if the registers in the accelerometer is defoult cofigured that i can use to connect it directly to pic as i use 18f448 and make operation in pic

third the operation in pic is to convert the digital bits to coresponding current and then double integeration
am i write ???? please help me if you have any codes can help me in either configuring the accelerometer or in other operations

finally i am very sorry to disturb you all but really i am new in using this and i am really in great problem due to time limited !!!!!plz help me
[/b][/b]
Reply With Quote
  #2   Spotlight this post!  
Unread 24-04-2010, 20:27
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: please help in adxl345

Quote:
Originally Posted by matrix_manshy View Post
hi am a new user to adxl345 accelerometer and i use it in graduation project to give output displacement i am really cant know a lot of things about it
first i use spi interface so i use only 4 pins cs ,sdio,sdo,sclk,i think 4 wire
Here are the datasheets for the PIC18F448 [link] and ADXL345 [link]

Quote:
Originally Posted by matrix_manshy View Post
second i want to know if the registers in the accelerometer is default configured that i can use to connect it directly to pic as i use 18f448 and make operation in pic
The register defaults are in the accelerometer datasheet, but by default they're set to for 4-wire SPI, so you would connect _CS to _SS, SDI to SDO, SDO to SDI, and SCL to SCK. Just make sure that when you're configuring the SPI on the PIC, you select a clock divider such that the SPI clock isn't faster than 5 MHz and that the clock polarity and phase are set properly.

Quote:
Originally Posted by matrix_manshy View Post
third the operation in pic is to convert the digital bits to corresponding current and then double integration
am i right?
You don't need to convert to current; in the datasheet, the scales are listed as mg/LSB (milli-standard gravities per LSB), so just multiply the reading from the accelerometer by that scale, then divide by 1000 to get the number of gs of acceleration the accelerometer is measuring. You are correct that to get displacement you would then doubly integrate the sensor reading. Maybe use one of the PICs timers to compute delta time. Of course, integrating over large ranges of time will lead to large errors as noise accumulates.

Quote:
Originally Posted by matrix_manshy View Post
please help me if you have any codes can help me in either configuring the accelerometer or in other operations

finally i am very sorry to disturb you all but really i am new in using this and i am really in great problem due to time limited !!!!!plz help me
I wasn't able to find any PIC code for the ADXL345, but there is a listing for the Arduino here that might at least provide an outline of the command/response. You might also try asking on the SparkFun forums, there appear to be a few people using the ADXL345, whereas this forum is pretty specialized toward the hardware that the FIRST Robotics Competition includes with their kits of parts, which so far have been almost exclusively interfaced through analog or parallel digital interfaces.

Good luck,
--Ryan
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #3   Spotlight this post!  
Unread 25-04-2010, 04:35
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 671
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: please help in adxl345

We have written code to double integrate the ADXL345.
You can find the code here for the cRIO (http://proj.titanrobotics.net/hg/Frc...inc/TrcAccel.h)
But as Ryan said, it will cumulate error when you integrate it over time. Therefore, you must use caution when doing it. We reset the accumulator right before we start the PID control (which is what we use the accelerometer for). This will clear the cumulated error and start fresh. It works reasonably well for us. We also implemented Zero-G calibration to eliminate DC offset of the outputs.
__________________
Reply With Quote
  #4   Spotlight this post!  
Unread 25-04-2010, 09:56
matrix_manshy matrix_manshy is offline
Registered User
no team
 
Join Date: Apr 2010
Location: egypt
Posts: 6
matrix_manshy is an unknown quantity at this point
Re: please help in adxl345

thankssssssssssssssssssssssssss a lot really you both helped me alot i was really in a trouble and i will work on this data and hoping to acheive the result soon and sorry if i make a disturbance again as i will of course face trouble but in adxl345 i found delay time between samples is 5us between two samples i think this is the time use in the integeration (base) to calculate area under the curve ... is this right or i use some of pic timer as rayan said to know exactly the time between samples ..
Reply With Quote
  #5   Spotlight this post!  
Unread 25-04-2010, 13:30
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: please help in adxl345

Quote:
Originally Posted by matrix_manshy View Post
in adxl345 i found delay time between samples is 5us between two samples i think this is the time use in the integeration (base) to calculate area under the curve ... is this right or i use some of pic timer as rayan said to know exactly the time between samples ..
The datasheet says the maximum output data rate is 3200 Hz, which would put the integration time base at about 312.5us, unless I'm misinterpreting something.

the challenge is synchronizing the PIC and the accelerometer. if you configure one of the interrupt out lines of the accelerometer to assert each time a new sample is ready, and run the SPI at a high enough data rate to be able to transfer each sample and then process it on the PIC in less time than it takes the accelerometer to read one sample, then you can use the accelerometer's timing. If you don't get the timing fast enough, you risk dropping samples, and then your integration will be off. It would be even better to make use of the ADXL345's FIFO buffer, but you still have to make sure you can process the samples fast enough otherwise the buffer will overflow.

My suggestion to use the PIC's timer was in response to your question about using the accelerometer with its registers in their default state, as neither the interrupts or FIFO are enabled by default. So I was assuming that you would just be reading from the accelerometer periodically, and as such you wouldn't have an accurate timing from the accelerometer, so you would have to use timing from the PIC.

--Ryan
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #6   Spotlight this post!  
Unread 26-04-2010, 04:50
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 671
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: please help in adxl345

The code I quoted was designed to be independent of sample loss. Since it is determining the time between samples and use it as the interval for each integration, if you lose a sample, it will integrate with double the interval the next time. So it won't throw you off. I wouldn't assume a fixed sampling rate. I would figure out if the system has a hardware timer that you can read that will give you an accurate timestamp.
__________________
Reply With Quote
  #7   Spotlight this post!  
Unread 26-04-2010, 12:11
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: please help in adxl345

Quote:
Originally Posted by mikets View Post
The code I quoted was designed to be independent of sample loss. Since it is determining the time between samples and use it as the interval for each integration, if you lose a sample, it will integrate with double the interval the next time. So it won't throw you off. I wouldn't assume a fixed sampling rate. I would figure out if the system has a hardware timer that you can read that will give you an accurate timestamp.
Good point. That's basically what I was suggesting with using the PIC's timer. AFAIK, there's nothing as convenient as the GetMsecTime() function on the PIC platform, so just reading and resetting one of the timers when each sample is received is as close as you can get. It's probably still beneficial to try to synchronize the PIC reading samples as they're received, because there can still be oversampling problems.

--Ryan
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #8   Spotlight this post!  
Unread 27-04-2010, 12:04
matrix_manshy matrix_manshy is offline
Registered User
no team
 
Join Date: Apr 2010
Location: egypt
Posts: 6
matrix_manshy is an unknown quantity at this point
Re: please help in adxl345

thanks for all your efforts to help me and i will put all your point infront of me and i will care about it of course that i think i couldnt have been able to start the project without your help ryan and mikets ... and i wish god help me in my first and important project
Reply With Quote
  #9   Spotlight this post!  
Unread 17-05-2010, 07:08
jcch1969 jcch1969 is offline
Registered User
no team
 
Join Date: May 2010
Location: Portugal
Posts: 1
jcch1969 is an unknown quantity at this point
Re: please help in adxl345

Hi,

I am developing a buoy to measure the ocean wave heights with the ADXL345 and a dsPIC. Until now i was not able to communicate with the adxl345 via the SPI interface. Can anyone tell the correct SPI configuration for the dsPICs or PICs?

Any help will be much appreciated.
Best regards.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ADXL345 Programming enrique C/C++ 2 18-02-2010 15:56
ADXL345 using I2C tdidi C/C++ 1 29-01-2010 21:02
hook up ADXL345 to cypress breadboard at driver station erichahn525 Programming 4 23-01-2010 12:22
pic: please help us please mortals CD47-Bot Robot Showcase 5 25-01-2004 11:03
please help us, pretty please :) archiver 2001 0 24-06-2002 03:13


All times are GMT -5. The time now is 03:23.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi