Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PWM and Servo, how important is the interval between pulses?

Status
Not open for further replies.
Hi,

Have not actually run your code, but couple of things -

You have Configed it for the internal osc but ideally also use the OSCCON register to set the frequency - ok it defaults to 4 meg but it adds clarity for the delays.

For some reason you setup ANSEL with IORWF ?? then start the ADC with ADCON0, followed a couple of intructions later by Clearing ANSEL ..? - not sure why.

If your servo is going mad at that voltage then its an ideal time to use debugger to see whats happening - but don't think it available on that chip.

You could run Sim, but instead of the ADC just input the binary value for 0.95v and see what happens when thats passed to your delay values.
 

Hi,
Have not actually run your code, but couple of things -
You have Configed it for the internal osc but ideally also use the OSCCON register to set the frequency - ok it defaults to 4 meg but it adds clarity for the delays.

Ok, I'll add that to my code.

For some reason you setup ANSEL with IORWF ?? then start the ADC with ADCON0, followed a couple of intructions later by Clearing ANSEL ..? - not sure why.

Ah, I've missed to change it back after my wild laboration.

If your servo is going mad at that voltage then its an ideal time to use debugger to see whats happening - but don't think it available on that chip. You could run Sim, but instead of the ADC just input the binary value for 0.95v and see what happens when thats passed to your delay values.

Hmm. I've tried to do that in Proteus, but there everything works all the way just fine. I'll try to do the same thing in MPLAB now, will see if I find anything there.

Thanks

/ Morgan

---------- Post added at 23:32 ---------- Previous post was at 23:23 ----------

It's working in MPLAB sim too :( But what is the binary for 0.95V?? Proteus was giving me the number 0xC3 is this right?? That is the value I've been testing, and it's working in both MPLAB and Proteus SIM.

Regards

/ Morgan

And one more thing.. 0.95V is working on the real thing without the Servo, when I'm checking the pulse with PICKit2 logic tool
:/

Here's video of the problem so you can see what I see..[video=facebook;1489378686837]http://www.facebook.com/video/video.php?v=1489378686837[/video]
 
Last edited:

Well I've found the problem, if pwm1 variable was zero from the conversion.. the DelayPWM delay counted pwm1 pass zero and suddenly it was FF and not 0. Had to keep it away from ever getting past zero! Now everything is working :)

Regards

/ Morgan
 

Hi,

Thats good news, alway a great feeling when you solve a problem like that !
 

Hi,

Thats good news, alway a great feeling when you solve a problem like that !

Hello
Yes, you're absolutely right about that.. feels great, I thought I was doomed there for a while.
And thanks too you for pointing out where to clean my code up.

/ Morgan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top