caramoan tour package

caramoan tour package

Author Topic: Control servo using switch with PIC 16f877A- via assembly(Need help)  (Read 265 times)

Offline shuzero

  • LR44 Battery
  • *
  • Posts: 4
  • Pogi/Ganda Points: 0
Guys can anyone help to my problem? Meron akong biniling robotic arm s gizmo....kailangan ko syang controlin s pamamaggitan ng pic n meron switch...I have 2 sevo motoe...gusto ko sana pagclose ng switch maactivate yung servo motor...gagalaw muna yung una para ibaba niya at pagkatapos yung isa naman will function to hold the item...I hope you can help me....pwede rin po kba kyong magbigay ng circuit design para s servo kasama yung switch...hirap ksing paganahin.....ITO nga pla yung code ko di ako sure meron pangmali kindly help me with my problem



    __CONFIG 0x3D72 ; XT MODE,WDT OFF, BOREN _LVP_OFF & _XT_OSC & _WDT_OFF & _PWRTE_ON
   list p=16f877a,W=-302


   include "p16f877a.inc"
BANK_0  EQU  0x00
BANK_1  EQU  0x80
BANK_2  EQU  0x100
BANK_3  EQU  0x180
COUNT1  EQU  0x20
COUNT2  EQU  0x40
COUNT3  EQU  0x60                               
 
 org 0x000
           
   MOVLW B'11111110'
   BANKSEL BANK_1
   MOVWF TRISB
   BANKSEL COUNT_0
 
   goto start

start
   STATUS    equ 03h   ;STATUS=03h
   TRISA   equ 85h   ;TRISA=85h
   movlw   H'21' ;0010 0001
   bsf STATUS,RP0   ;go to bank 1
   movwf   TRISA    ;rb0 be output
   movlw   H'20'
   movwf   TRISB      ;
   bcf   STATUS,RP0   ;bank 0

none
   movlw   B'000000'   ;
   movwf   PORTB
   goto MAIN

light
   movlw   B'000101'
   movwf   PORTB
        goto Anti
   goto MAIN

Anti       MOVLW   B'11111111'         
            MOVWF   PORTB     
            CALL       Delay1
            CALL       Delay1                         
            CALL       Delay1
            CALL       Delay1
            MOVLW    B'00000000'                         
            MOVWF   PORTB 
            CALL       Delay1
            CALL       Delay1
            CALL       Delay1
            CALL       Delay1
            DECFSZ   COUNT1,F
            GOTO      Anti
            CALL       Delay2
            CALL       Delay3
 
                 
Pause    MOVLW    B'11111111'         
            MOVWF    PORTB     
            CALL       Delay1
            CALL       Delay1                         
            CALL       Delay1
            CALL       Delay1
            CALL       Delay1
            CALL       Delay1
            MOVLW   B'00000000'                         
            MOVWF   PORTB 
            CALL       Delay1
            CALL       Delay1
            CALL       Delay1
            CALL       Delay1
            CALL       Delay1
            CALL       Delay1
 
            DECFSZ   COUNT1,F
            GOTO      Pause
            CALL       Delay2
            CALL       Delay4
            GOTO      Start
 
Delay4           
   MOVLW 0x20
   MOVWF COUNT3

Loop4
   DECFSZ COUNT3,F
   GOTO Pause
   RETURN
 
Delay3           
   MOVLW 0x20
   MOVWF COUNT3

Loop3
   DECFSZ COUNT3,F
   GOTO Pause
   RETURN
 
Delay2           
   MOVLW 0xF9
   MOVWF COUNT2

Loop2
   DECFSZ COUNT2,F
   GOTO Loop2
   RETURN

Delay1             
   MOVLW 0xF9
   MOVWF COUNT1

Loop1
   DECFSZ COUNT1,F
   GOTO Loop1
   RETURN


MAIN
   btfss PORTB,0
   goto none

   goto light

   goto MAIN

   end


 
 Please help me with my problem here my program...

Philippine Electronics Forum


Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #1 on: June 11, 2012, 11:10:24 PM »
Wow assembly. ;D
Please post your schematics sir.
It would really help us help you.
So far ito opinion ko.

Code: [Select]
start
   movlw   H'21' ;0010 0001
   bsf STATUS,RP0   ;go to bank 1
   movwf   TRISA    ;rb0 be output
   movlw   H'20'
   movwf   TRISB      ;
   bcf   STATUS,RP0   ;bank 0

Nagkapalit yata ang TRISA at TRISB dito sir.
And the comment should be, rb0 be input.
Because I think yung switch mo ay nasa RB0 dahil sa Main label mo meron nito,
Code: [Select]
btfss PORTB,0Nanghuhula lang din ako kasi wala kang schematic dito sa circuit mo sir. ;D


Code: [Select]
none
   movlw   B'000000'   ;
   movwf   PORTB
   goto MAIN

light
   movlw   B'000101'
   movwf   PORTB
        goto Anti
   goto MAIN

At dito naman you are putting a value to RB0.
Am i missing something?
By the way matagal na ako hindi nakagamit ng assembly sir. ;D



The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Philippine Electronics Forum

Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #1 on: June 11, 2012, 11:10:24 PM »

Offline shuzero

  • LR44 Battery
  • *
  • Posts: 4
  • Pogi/Ganda Points: 0
Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #2 on: June 11, 2012, 11:40:09 PM »
thanks for the reply the input should be porta and output should be portb...i don't have schematic diagram...I just code it... can you help me....mali lng yung iba ksi yung una kong program portb input tapos output porta.... bka meron png mali yung s servo sir....yung gusto kong maayos....tama b yung code ko sir...

Philippine Electronics Forum

Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #2 on: June 11, 2012, 11:40:09 PM »

Offline glutnix_neo

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4161
  • Pogi/Ganda Points: 166
  • Gender: Female
  • A journey to a thousand lines begins w/ LED Blink
    • Underground Workbench
Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #3 on: June 12, 2012, 12:52:04 AM »
@TS why would you use assembly in the first place?
If we hear,we forget;if we see, we remember;if we do,we understand.
Let's support the use of free and open source softwares...
http://UndergroundWorkbench.wordpress.com

Philippine Electronics Forum

Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #3 on: June 12, 2012, 12:52:04 AM »

Offline e-tronix

  • Lead Acid Battery
  • *******
  • Posts: 981
  • Pogi/Ganda Points: 26
Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #4 on: June 12, 2012, 10:39:51 AM »
yun ang required yata ng prof eh

Philippine Electronics Forum

Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #4 on: June 12, 2012, 10:39:51 AM »

Offline shuzero

  • LR44 Battery
  • *
  • Posts: 4
  • Pogi/Ganda Points: 0
Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #5 on: June 12, 2012, 11:39:24 AM »
yan lng alam ko assembly language. Also I have only assembly compiler

Offline glutnix_neo

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4161
  • Pogi/Ganda Points: 166
  • Gender: Female
  • A journey to a thousand lines begins w/ LED Blink
    • Underground Workbench
Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #6 on: June 12, 2012, 11:47:31 AM »
free ang hitech C compiler, and better if you use C,
If we hear,we forget;if we see, we remember;if we do,we understand.
Let's support the use of free and open source softwares...
http://UndergroundWorkbench.wordpress.com

Offline e-tronix

  • Lead Acid Battery
  • *******
  • Posts: 981
  • Pogi/Ganda Points: 26
Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #7 on: June 12, 2012, 11:48:59 AM »
use MPLAB TS. my built-in assembly and C compiler na.

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #8 on: June 12, 2012, 10:32:41 PM »
TS sundin mo na ang mga advice sa masters.
Mas maganda sana gamitin ang assembly sa mga PIC10 at PIC12. ;D
At pwedi ka naman mag dagdag ng assembly codes sa mga C compilers na binanggit nila sa taas.
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Philippine Electronics Forum

Re: Control servo using switch with PIC 16f877A- via assembly(Need help)
« Reply #8 on: June 12, 2012, 10:32:41 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com