CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Accelerometer adxl335

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

Accelerometer adxl335
PostPosted: Mon Mar 01, 2010 3:35 pm     Reply with quote

Hi

I try use this sensor, but it don't work Crying or Very sad

This is my sensor: http://www.sparkfun.com/datasheets/Components/SMD/adxl335.pdf

I connect this sensor direct on ADC ports with 100nf to GND, but on terminal when I run my breadboard I don't have variations on Z and Y only X move little...
Code:

#include <18F252.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP,BROWNOUT,STVREN
#use delay(clock=20000000)
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

void main ()
{
 long adc1, adc2, adc3;
 
   setup_adc_ports(AN0_AN1_AN3);
   setup_adc(ADC_CLOCK_INTERNAL);
 
 while (1)
 {
 
 set_adc_channel(0);
 delay_us(10);
 adc1 = read_adc();
 set_adc_channel(1);
 delay_us(10);
 adc2 = read_adc();
 set_adc_channel(2);
 delay_us(10);
 adc3 = read_adc();
 
 printf("Z: %4lu Y: %4lu X: %4lu\r\n",adc1,adc2,adc3);
 delay_ms(100);
 
 }

}


the result:


If I the strange value is on PIN_A2 "X:" but if I change with other values continue wrong on PIN_A2...

Someone can help to find my error?

Best regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 01, 2010 3:51 pm     Reply with quote

Quote:

setup_adc_ports(AN0_AN1_AN3);

set_adc_channel(2);

What's wrong in your set_adc_channel() setting ? Can you see it ?
Also, since you're using channels AN0, AN1, and AN3, do you have
the ADXL335 connected to those channels on the PIC ?

Quote:

#include <18F252.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP,BROWNOUT,STVREN
#use delay(clock=20000000)

setup_adc(ADC_CLOCK_INTERNAL);

Internal RC clock is not recommended for use with the 20 MHz oscillator.
This is the recommended divisor to use: ADC_CLOCK_DIV_32

Also, since this is a Sparkfun product, you should search their forum
for posts on the ADXL335. Like this one about using OpAmp buffers:
http://forum.sparkfun.com/viewtopic.php?p=88789
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Mon Mar 01, 2010 4:39 pm     Reply with quote

Hi

thanks, PCM programmer, I change my conections .. it stay wrong and with your link I solve other problem, I need buffer for this work..

thanks Laughing
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Wed Mar 03, 2010 6:18 am     Reply with quote

Hi

now I have buffers in my ADC ports, but I continue without have correct values, but I start this witch problem stay on my ADC configure...

on datasheet stay write witch this sensor produce 300mV/g, so is my scale goto 0V-5V, I don't have resolution to my sensor correct?

on datasheet tell witch output start on Vcc, how I can start my pwm scale on this value? don't is possible I compare values? how I can use comparate of 18f252?

how I can solve this? I can read ADC direct correct?

best regards
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group