Interfacing adxl335 with PSoC(Urgent!)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 Hello guys, I am a newbie when it comes to PSoC. I want to interface an ADXL335 accelerometer with PSoC3(CY8CKIT-030). Can anyone suggest me how to do so?

0 Likes
33 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Since the ADXL335 has analog outputs for X, Y and Z you wikk need an analog multiplexor and an ADC to digitize the incoming signals. Have a look at the ADC-example project that is offered when you create a new project or select the example by right clicking on the ADC component.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Although obsolete this kit had a code base interfacing an accelerometer -

   

 

   

    

   

          

   

http://www.cypress.com/?rID=38235     CY8CKIT-003

   

 

   

 

   

Juts go to the page for docs and ISO disk download that includes the

   

code. Should be pretty easy to adapt.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Hey, I want to change the intensity of an  LED using PWM with the inputs obtained from the accelerometer.Could you please tell me what changes do i need to make?(It would be really helpful if you could share the code with me). 

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

If you want to use PWM to do this, just place PWM, a pin, and in

   

PWM datasheet are the APIs to change its period. You would start

   

the PWM, then use the controlling API's.

   

 

   

Regards, Dana.

   

 

   

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

In previous post reset pin should be tied to logic 0.

   

 

   

Another way is to use the PRiSM module, specifically for this purpose.

   

Start to module and use APIs in datasheet to control 0 - 100 %.

   

 

   

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Note you should tie PRiSM enable to high, kill to low. I forgot to

   

do this.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Hey, thanks for the help, the PWM part worked. Now working on the accelerometer part.

0 Likes
Anonymous
Not applicable

 Hey, I want to control the intensity of the LED using the accelerometer can you tell me how should i do it? (If I make a gesture along the x-axis then the intensity of the LED should increase each time I make a gesture.)

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

 In code basically you take your reading from accelerometer and convert it

   

to PWM compare value which sets its duty cycle.

   

 

   

So if PWM is 8 bits, you have to convert the accelerometer value to a range

   

of 0 to 255, and write that value to PWM compare value using API.

   

 

   

void PWM_WriteCompare1(uint8/16 compare)  ( for UDB based PWM)

   

 

   

So say you accelerometer is a 16 bot value, PWM is 8, then right shift the

   

accel value by 8 to extarct its 8 MSBs, and write that using API.

   

 

   

Note set period to something like 100 Hz or faster to avoid any blink effects.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Hey, you mean the output of ADC right?(since I am using ADXL335 which is an analog accelerometer)

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Yes, thats correct. You perform A/D conversion on each channel of accelerometer

   

and convert/range that to PWM range. Ideally A/D bit resolution would be >= PWM

   

resolution. The faster A/D is sampling, the faster acceleration event can be handled.

   

 

   

Tradeoffs.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Hey, Thank You very much, it worked. Now, I want to receive the analog signal of the accelerometer through Xbees. I have configured the Xbees in API mode. How should i proceed?

0 Likes
Anonymous
Not applicable

 Also, If I want to control three different LED for each axis, then how should i do it? 

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

How about just using three PWMs, one for each channel / LED?

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Regarding the XBee: how are they configured? What is listening on the other side of the XBee link? Did you read the XBee manual, and set it up correctly?

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Consider using 3PrISMs, they will use less HW resources.

   

 

   

Regards, Dana.

   

 

   

0 Likes
Anonymous
Not applicable

 Configuration of Xbee(Receiver):

   

Zigbee Coordinator API

   

Pan ID-100

   

Configuration of Xbee(Transmitter):

   

Zigbee Router AT

   

Pan ID-100

   

Channel verification-enabled

   

D0/D1/D2- ADC (2) 

   

Set the Sampling rate 

   

(USED XCTU software)

   

 

   

I want to receive the analog signals of the accelerometer via these Xbees?Now , How should I proceed? can anyone share an example program to which i can refer to?(atleast for wireless communication using xbees)

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Hello, can you guys tell me why am I getting the error shown on the image(Implicit declaration of XBEE_UART_GetChar())

   

eventhough I am using the appropriate API mentioned in the datasheet.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

That is not an error, it is a warning. There are some lines flagged without any rason especially in PSoC3 Keil but when you compile your project the warnings and errors shown are relevant.

   

Check the message and check if the called function really exists.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 oh thank you, I figured out the problem, can you help me with the xbee part? as in share an example project(API mode) for receiving analog signal.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Do you have an actual, PSoC-related question? I suppose you have already read the xbee documentation, and did come up with a plan how to use it.

   

Do you want to connect the accelerometer directly to the xbee, and then send the data via it? Or should the PSoC read the data and transmit it via the xbee? What is on the other end of the xbee link?

0 Likes
Anonymous
Not applicable

 I have connected the accelerometer to the Xbee and then transmit it  to psoc(via transmitter-receiver xbees).

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

I guess xbee-only related question are out of the scope of this forum. Here you can find PSoC experts, but most of them won't know about xbee at all. So maybe you should try to find a XBee forum, and ask there how to work with analog sensors.

0 Likes
Anonymous
Not applicable

This might help -

   

 

   

    

   

          http://www.cypress.com/?rID=52137

   

 

   

The link on this page to msu is no good, maybe go to msu website and do some

   

searching, maybe you can hook up with the student or a prof and get a code

   

base. Or contact Patrick Kane if still at Cypress to see if he can supply a contact.

   

 

   

A link to a PSOC 4 solution, maybe you could port it ?

   

 

   

    

   

          http://www.element14.com/community/docs/DOC-63692/l/project-26--xbee-api-rxtx-example-psoc-4-pioneer...

   

 

   

Another possibility -

   

 

   

    

   

          http://www.docstoc.com/docs/159136930/Final-Presentationpptx---Department-of-Electrical-Engineering-...

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Thank you guys for bearing me, you guys have been of great help. 

0 Likes
Anonymous
Not applicable

 Hello , How do I check whether an rx interrupt is generated while using UART block of PSoC3? 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I would say: Set a breakpoint within the interrupt handler to check for an interrupt.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Or set a pin inside ISR and set scope to trigger on pin.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Is it possible to give input to an ADC through software????If yes, then how should I do it?

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

If you mean you have several signals and you want SW to control which

   

signal the A/D looks at answer is yes, use an analog mux at the A/D input.

   

 

   

If you do this pay attention to notes on settling time when you switch from

   

one mux channel to another.

   

 

   

Regards, Dana.

   

 

   

0 Likes
Anonymous
Not applicable

 No, I need to convert the analog sample data obtained from xbee packet into digital(correct me if I am wrong). I wanted to know how should I do that?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I think it wouldn't be too bad when at this stage you start to open an example project for PSoC3 and ADC and study it together with the appropiate datasheets.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The Xbee module takes serial data in, modulates RF and transmits over a RF

   

link, and then demodulates back to digital to send over serial UART. You need on

   

transmission side to "frame/format" the data sent in order to decode the data stream

   

on the other side back into its "values" and associated source of measurement.

   

This is briefly discussed here.

   

 

   

    

   

          http://www.cooking-hacks.com/documentation/tutorials/arduino-xbee-shield

   

 

   

Regards, Dana.

0 Likes