Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC with Accelerometer and RC Servo

Status
Not open for further replies.

Fendy.K

New Member
Hi all, my name is Fendy, currently I'm trying to make a crane system with accelerometer for my project. My Accelerometer is ADXL330 (analog) and RC Servo (digital), but I haven't decided what PIC series to use yet. So these are my questions

1. PIC --> what PIC should I use in this case? Total of the pins that will be using in this project is 9 - 10 pins, so I need 18 pin micro controller. I've looked around my area and found PIC16F628 which have 4 ADC pins while others PIC16F-84A, 639, 54) don't have.
a. Is this PIC suitable for this project ?
b. Do I need to consider for the Crystal Oscillator ? The max is 200KHz, will it affect the performance or something ? (I don't really know what it does actually, it's just my other classmates are using minimum 1MHz, so I started to doubt it).

2. ADXL330 (3 - axis), is it necessary to connect ST (Self - test) Pin to PIC ? Can I leave it NC ? If it is necessary, which pin should I connect to ?

3. RC Servo --> what pin should I connect to PIC ? Since RC servo is controlled with PWM, does that mean the connection has to be in PWM pin and not others ?

Any suggestions or idea would be appreciated. Thanks.

This is my first project and my final year project. And hope you all don't mind with my broken English.
 
PIC16F628 should be fine, as is any PIC with A/D built-in and enough pins.

The PIC has more than one oscillator. One is the main clock, which for most PIC16 series can be up to 20 MHz with a crystal, or you can use the chip's built-in RC oscillator up to 8 MHz (won't be as accurate as a crystal). The crystal you're thinking of (the max 200 Khz one) is for running Timer1, which you could use if you need a more accurate timing reference in your project.

According to the ADXL330 datasheet, you don't need to connect the ST pin to the PIC.

For PWM for your servo, you have 2 options. One is to use the built-in CCP module, which can output PWM on the CCP1 pin. The other is to do PWM in software, which can be done on any output pin. You'll want to use a driver transistor to provide enough current to your servo.
 
Last edited:
Thanks kpatz, your explanations helped me a lots, the doubts that I had in my mind has almost all cleared and I could continue to do my project. Thanks.

PIC -- Clear :D

ADXL330 -- Clear:D

RC Servo -- Clear :D

Crystal Oscillator -- Thanks for the explanation, but I still have a little bit question for this.

Yeah, you right about the running timer, I read it from datasheet. So may you tell me what I should do ? I have one crystal oscillator (10MHz) in my tool box, so can I use that crystal and connect it to pin 16 (OSC1) and pin 15 (OSC2) with 33pF (parallel) ? or follow the running timer from datasheet ? I just can choose either one of them, right ?

Sorry for asking this kind of questions, I just can't understand what datasheet is telling. So your help is much more appreciated. :)
 
Darn, I thought it did.... my quick glance at the datasheet showed it being well featured, I didn't look specifically for the A/D.

PIC16F818 is a good choice too.

Does your application need any sort of accurate timing, or a clock speed over 8 MHz? If it does, use the crystal. If not, you can omit it and use the PIC's internal oscillator. The timers can run from the MCU clock or they can be triggered from an external source or (for timer1) a crystal.
 
They output is frequency for that sensor, so an A/D will not be needed :) You will need to use a CCP module perhaps to capture the frequency outputted by the sensor for each axis. I have never done this before so I will shut my mouth now :)
 
Thanks for the suggestion guys. :)

They output is frequency for that sensor, so an A/D will not be needed :)

The output of the ADXL330 is in analog, so A/D pin should be needed, no ? :confused: Because I've checked on some other post, they used accelerometer (different series) but most of their output are analog (you may choose to used digital).

About the crystal, I can't use that PIC16F628 anymore since there is not any A/D pin, unless what birdman0_o said is correct, I'll still used that PIC and external crystal. But I will go through the PIC series that you guys said, so I can know more about PIC. :D

Thanks again. :)
 
Yes, I did. But I may missed something. That is the reason that I'm posting a question here, as I mentioned in previous post, I just can't understand all what datasheet is telling. May you highlight me if there is anything wrong with my understanding ?

Thanks in advanced.
 
Thanks for the reply rajbex. :)

The only 18 pins PIC Microcontroller that's available in my area are 16f84, 16f628 and 16c57. None of them I could use after I looked at datasheet. So here I'm planning to use PIC16F876A (28 pins), (I'd tell to my supervisor that other PICs like 16F690 and so on aren't available, so that I go with 28 pins).

Currently I'm learning how to program this PIC by using C programming.

Any suggestion and advices would be appropriated. Thanks.

P.S Please feel free to correct me if I did wrong in any way and sorry for my broken English.
 
Currently I'm learning how to program this PIC by using C programming.

Ok, I'm back. and there is a little change on my programming, instead of doing it in C, I'll be doing it in asm.

This is what I'm trying to do.

1. RA0 - RA2 are analog input (I saw in some of the link saying that RA3 is needed to set as input by giving power supply 3.3V (for my accelerometer) because of VREF+). Is it correct ? Or I can let it NC ?

2. RB0 is input (to interrupt), since there is a push button to control one of the RC Motor (grabber). When I pressed the button, it'd grab and it'd release when I released the button.

3. RC0 - RC3 are output (for all of the 4 RC Motors). Since there are only 2 CCP pins, so rest of the pins would be done manually. I've no idea about this part, anyone has seen or done this ? Please give me the link or example on how to do it.

And this is my starting point
Code:
list p=16f876a

; *** Setup Constant value ***
status	equ		0x03
trisa		equ		0x05
porta		equ		0x05
trisb		equ		0x06
portb		equ		0x06
portc		equ		0x07
trisc		equ		0x07
rp0		equ		5

start		bsf		status, 5	;select bank 1
		movlw	0x05
		movwf	ADCON1	;set all input A as analog ????
		movlw	0x0F
		movwf	trisa		;set RA<3:0> as analog input while    others output ?

		movlw	0x06
		movwf	INTE		;set port B as interrupt ???
		movlw	0x01
		movwf	trisb		;set RB0 as interrupt pin ???
		bcf		status, 5	;select bank 0

Please correct it if there is a mistake, if not, I'd go to the next step. By doing so, I will able to understand on each of the command. Thanks in advanced.
 
Hi guys, it's been awhile. Now I just leave a little part more to finish my whole things. But currently I'm facing some connection problems, so that I'm here and hoping that you guys to help me.

I connect RC Servo to the output of LM7805 (5V) with one push button so that it's allowing the 5V voltage to pass through. But whenever I press the button, it short circuited. May any one tell me why ? The output is giving 5.0+V.

I've checked on all the connections, and all others are working nicely.

Thanks in advanced.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top