Author Topic: help with my algorithm  (Read 966 times)

0 Members and 1 Guest are viewing this topic.

Offline minmxTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
help with my algorithm
« on: May 03, 2010, 10:55:00 AM »
hi, i need a lot of help, I'm trying to set this on a PIC16f84a, and send a PWM signal but someone say me that on this PIC there's no special pin for PWM signal, so he told me that i need to use a PWM software signal or something like that. So I'm in serious problems because i don't know what it is. if you can help me how to put the software signal in this PIC using a C or BASIC language please help me.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: help with my algorithm
« Reply #1 on: May 03, 2010, 01:42:28 PM »
If this is for a DC motor speed control I'd forget about using C or Basic in an 16F84. I have done a dual H-bridge PWM controller with an 16F84 on my first robot. You really need to do it in assembler and a Timer ISR.

Set up Timer0 to interrupt at 1/64 of the PWM period. This allows for 64 duty cycles which is enough for simple robots.
Set a register for the number of 1/64s of a PWM period you want for the duty cycle (31 = 50% duty).
Increment a counter (register) to count each time the timer0 ISR is entered.
    When the counter reaches 64 reset it to zero and set the PWM output pin ON.
    When the counter reaches the value in the duty cyle register set the PWM output pin OFF.

This will fully run on the Timer0 interrupt so the Main code loop can look at sensors, start/stop the motors and adjust the duty cycle as needed.

 


Get Your Ad Here

data_list