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.

PIC18F ADC, PWM and Interrupts

Status
Not open for further replies.

noelcharles

New Member
Hi,
I am using a PIC18F1330 as a DC servo controller, and writing the code in assembler. It requires 2 analog inputs and produce a single PWM output, and a direction output.

The AD module is functioning, although the results are erratic. With Vdd as Vref, the result won't read less than 0164h and only reads above this when the input is very close to Vdd.

The PWM output is also functioning, but I cannot change the frequency or duty cycle - it is fixed at 50%.

I can get interrupts to operate, but only at the rate dictated by the selected prescaler, not at a specific rate.

Any help with initialisation values or code snippets that work, would be greatly appreciated.

Thanks
 
Check your timing on the AD - after you select the pin, you have to give it settling time BEFORE you start the conversion. Otherwise you get bad reads that sound similar to what you're seeing.

Also the conversion itself can only go so quick. If in doubt, use that internal oscillator. It's slower, but works.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top