motor step


Closed Thread
Results 1 to 3 of 3

Thread: motor step

  1. #1
    fox_53's Avatar
    fox_53 Guest

    Default motor step

    Unless all

    specify that are a beginner to the first arms with picbasic pro

    I intezione an engine to move step by step with classical schedina STEP and DIR
    and there are successful but when you want to see a given (acceleration) on LCD
    the frequency of work decreases paurosamente
    Almost as I understood the pic can not 'make girasre the engine and at the same time see a given
    and so?
    there is' a way around the obstacle?
    I thank you for helping me understand you can afford

    this and 'what I could do with a 16F877


    Code:

    Code:
    DEFINE OSC 20
    DEFINE  LCD_DREG        PORTD   ' Define LCD connections
    DEFINE  LCD_DBIT        4
    DEFINE  LCD_RSREG       PORTD
    DEFINE  LCD_RSBIT       2
    DEFINE  LCD_EREG        PORTD
    DEFINE  LCD_EBIT        3
    DEFINE LCD_LINES 4
    DEFINE LCD_DATAUS 50
    VEL  VAR  WORD    ' Velocita''
    VELOCITA VAR WORD       
    ACC VAR WORD            ' Accellerazio/decellerazione
    ACCELL VAR WORD
    servo1  VAR  PORTC.1 ' Uscita step motore 1     
    
             TRISA = 255     ' Enable first button row
             PORTA = %11111111  
            ADCON1 = 7      ' PORTA and PORTE to digital
            Low servo1      ' Servo output low
    Main:
        
     READ 0 ,VEL
     'read 1, VELOCITA
      READ 2, ACC
         READ 3, ACCELL
          LCDOut $fe, $80, "VEL =  ", #VEL 
          'LCDOut $fe, $c0, "VELOCITA =  ", #VELOCITA 
          LCDOut $fe, $94, "ACC =  ", #ACC 
          LCDOut $fe, $D4, "ACCELL =  ", #ACCELL 
         GOTO MAINLOOP
         
     
    UNO:
     IF PORTA.0 = 1 THEN
     ACC= ACC+1
     PAUSE 10
     ENDIF
     IF PORTA.1 = 1 THEN
     ACC = ACC-1
     PAUSE 10
            ENDIF
        Lcdout $fe, 1   ' Clear screen
            LCDOut $fe, $94, "ACC =  ", #ACC  
     WRITE 2, ACC
       IF PORTA.2 = 1 THEN GOTO DUE
     GOTO UNO
     
     DUE:
       IF PORTA.0 = 1 THEN
     VEL= VEL+1
     PAUSE 10
     ENDIF
     IF PORTA.1 = 1 THEN
     VEL = VEL-1
     PAUSE 10
     ENDIF
     Lcdout $fe, 1   ' Clear screen
            LCDOut $fe, $80, "VEL =  ", #VEL 
     WRITE 0 , VEL
      
       IF PORTA.3 = 1 THEN 
        GOTO MAINLOOP 
       ENDIF  
       GOTO DUE
        
    Mainloop:
          
           TRISB = $fe    
             PORTB = 1       
             
           IF PORTB.1 = 1 Then
           GoSUB MOTOR
         ELSE
         GOSUB MOTOR2
              ENDIF
         
                   
           IF PORTA.2 = 1 THEN
        Lcdout $fe, 1   ' Clear screen
            LCDOut $fe, $c0, "ENTRATA SETUP "
            PAUSE 1000
                                  
            GOTO UNO
            ELSE 
            GOTO MAINLOOP
            ENDIF
                                                        
        MOTOR:
        IF VELOCITA < VEL THEN
             VELOCITA = VEL
               ENDIF 
               
         servo1 = 1      ' Start servo pulse
            PauseUs VELocita
            servo1 = 0      ' End servo pulse
            PauseUs VELOCITA 
                 
              velocita = velocita - 1 
                   Lcdout $fe, 1   ' Clear screen
           LCDOut $fe, $c0, "VEL ",#VELOCITA  
               
               RETURN
         GOTO MAINLOOP 
         
      MOTOR2:
      
      
         IF VELOCITA < (VEL*3)  THEN         
         servo1 = 1      ' Start servo pulse
            PauseUs VELocita
            servo1 = 0      ' End servo pulse
            PauseUs VELOCITA 
             ELSE      
             VELOCITA = (VEL * 3)
              LOW SERVO1
               ENDIF 
          velocita = velocita + 1 
                 RETURN
         GOTO MAINLOOP 
       
      END

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Unhappy

    Hi,

    It's quite simple: your LCD needs some time to work ...

    and you can't go against that need of time ...

    GLCD tinkerers just begin to understand that ...


    the "simple" solution : one pic reads and writes WHILE another drives ...
    one "other" solution : use multiplexed 7 segments LEDS ... ( a 4x 16, 20, or 40 display might be funny ... I admit ! )

    Alain
    Last edited by Acetronics2; - 12th May 2008 at 13:06.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Alain-

    I am intrigued by the concept of having a dedicated LCD controller PIC. Then, one would send characters serially from the master PIC to the controller PIC? How much time does it take to send a string of characters, relative to the time waiting on the LCD? Is there a way to measure with a scope to determine when the LCD is done?

    I guess I'm trying to determine the "trade-offs" here.

    Dave

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts