Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: katherina on September 30, 2007, 11:22:57 PM

Title: PWM (PIC 16F 877A) for window climbing robot...???
Post by: katherina on September 30, 2007, 11:22:57 PM
hi, me n my partner is trying to develop a window climbing robot using the PIC 16F877A to control its operation.

Im wondering, since the PIC 16F877A has only 2 pwm, n i dun intend to control the speed of the robot which in dat case, pwm have to be used.  here, i only need to control the angle of rotation  for 3 motors.

we wanted to develop something almost similar to below for our final project (we use this as our reference, and this is where we got the idea from):

http://www.mech.utah.edu/~minor/publications/IROS00-climber.pdf


if we need to use the pwm, we need 3 pwm. however, in PIC 16F877A they only have 2 pwm... does dat mean that i have to use 2 Chips of PIC116F877A???

tq....
Title: Re: PWM (PIC 16F 877A) for window climbing robot...???
Post by: creedcradle on October 01, 2007, 02:13:33 AM



if we need to use the pwm, we need 3 pwm. however, in PIC 16F877A they only have 2 pwm... does dat mean that i have to use 2 Chips of PIC116F877A???

tq....

a big NO.

i want to show you here the trick how to create a PWM with the  use of the ordinary PINs of any PIC MCU

here it goes

preconditions;
crystal is at 4 MHZ  

 org 0x000 
 
INITPORT   
                   bsf     STATUS,RP0 
         movlw   00h       
         movwf   TRISB       
         bcf     STATUS,RP0   
         clrf    PORTB     
 
SIMULA     
             movlw   d'40'       
             movwf   kaliwa_cntr      
KALIWA
         bsf     PORTB, 0   
         movlw   d'1'         ;decimal value for 1ms (para sa 4MHz oscillator) 
             movwf   Delay_time   
         call    BAGAL       
 
         bcf     PORTB, 0     
             movlw   d'20'       
             movwf   Delay_time 
             call    BAGAL       
 
         decfsz  kaliwa_cntr 
             goto    KALIWA       
                                               
           
             movlw   d'40'       
             movwf   kanan_cntr   
KANAN     
         bsf     PORTB, 0     
         movlw   d'2'         
             movwf   Delay_time 
         call    BAGAL       
 
         bcf     PORTB, 0   
             movlw   d'20'       
             movwf   Delay_time   
             call    BAGAL         
 
         decfsz  kanan_cntr 
             goto    KANAN         
             call    SIMULA       
   
   
BAGAL         
        movlw d'248'   
           movwf Delay_Cntr   
delay1ms   
           nop                   
           decfsz Delay_Cntr   
           goto delay1ms   
           decfsz Delay_time   ; 1ms; 2m O 20 ms 
           goto BAGAL   
        return
             
            end     
------------------------------------------
A little math makes a PWM works
Title: Re: PWM (PIC 16F 877A) for window climbing robot...???
Post by: katherina on October 01, 2007, 05:54:04 AM
but, dats in 'assembly' language rite?
we have to do the program in c....
i dun have any idea ???
Title: Re: PWM (PIC 16F 877A) for window climbing robot...???
Post by: annoyin_kid on October 01, 2007, 12:36:04 PM
y not get 3 servos and mod them just change the duration of the pulse and you get different speeds? im pretty sure that you can use them on any output pin i know that you can with picaxe but im not 100% with PIC 16F877A. only problem is that you will lose a lot of speed but you'll get much more torque.

can i just ask wot the window climbing thing is for? u planning to break into a house or something?
Title: Re: PWM (PIC 16F 877A) for window climbing robot...???
Post by: creedcradle on October 01, 2007, 03:59:50 PM
if you do it in C it is much easier,

just remember any general I/O pin can be modulated with a simple use of a loop

say

while (1)
set an I/O pin to high
delay in microsec(1000)
set the I/O pin to low
delay in microsec (20000)

it makes the servo moves forward