contorlling servo motor


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi,
    IIRC the resolution of the pulsout command is 10uS no matter what osciallator frequency you are using -as long as you let PBP know what frequency you are using.

    So if you tell PBP that you are using a 10Mhz clock but in reallity it's 20MHz you'll get 6.5ms instead of 13 with Pulsout 0,130. Just remeber that all timing sensetive commands, like Pause, Serin/out, Pulsin etc also is affacted the same way.

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Exclamation

    Hi, Henrik

    No,NO ...PULSOUT is one of the XTAL freq dependant commands ... There's NO DEFINE to get rid of that !!!

    @ 20Mhz, the result will simply be 20/4 times that @ 4Mhz ...

    Alain
    ************************************************** ***********************
    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
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Alain,
    Yep, you're right! I didn't remeber correctly..... :-(

    To quote the docs:
    If a 4MHz oscillator is used, the Period of the generated pulse will be in 10us increments. If a 20MHz oscillator is used, Period will have a 2us resolution. Defining an OSC value has no effect on PULSOUT. The resolution always changes with the actual oscillator speed.
    Sorry for the confusion!

    /Henrik.

  4. #4
    Join Date
    May 2008
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    so do u all mean this:

    When a 20MHz crystal is used, the time
    interval of PULSOUT is in units of 2us. For example, the following PicBasic statement generates a pulse with a width of 1.3 ms from bit 0 of PortB (1.3 ms = 1300us and 1300/2 = 650):
    PULSOUT 0, 650

    izzit like that?? can u all give sample codes, so i can see clearly..
    thanks

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi, Shirleyzzzzzzzz ...

    that's it !

    Find here an application ...

    Code:
    '****************************************************************
    '*  Name    : Glow Driver with Fail Safe - 1                    *
    '*  Author  : Ironsides                                         *
    '*  Notice  : Copyright (c) 2004 C                              *
    '*          : All Rights Reserved                               *
    '*  Date    : 24 Feb 2004                                       *
    '*  Version : 1.0                                               *
    '*  Notes   : Turns on glow driver to glow plug at low throttle *
    '*            If sigal is lost for 5 secs, engine is killed and *
    '*            glow power turned off                             *
    '*          ; An N Channel MOSFET is needed to carry the current*
    '*          ; See the circuit diagram for details               *
    '*  Caution : Should have a safety cut off switch in the pits   *
    '*          : For PIC 12F675                                    *
    '****************************************************************
    
    ;The 12F675 has both analog converters and analog comparators.  
    ;You must disable both to use the I/O pins for digital functions.  
    ;In addition, the register that controls the analog converters 
    ;has been named ANSEL, and it has a different format that the ADCON1 
    ;register found on most PICmicro MCUs
    PCON.3 = 1
    ANSEL = 0               ;needed as as above
    CMCON = 7
    ASM
          errorlevel  -302  ; Suppress message 302
          bcf   STATUS,RP0  ; Bank 0
          clrf  GPIO        ; Init GPIO
          movlw 07h         ; Set GP<2:0> to
          movwf CMCON       ;   digital IO
          bsf   STATUS,RP0  ; Bank 1
          clrf  ANSEL       ; Digital IO
          movlw 0Ch         ; Set GP<3:2> as inputs
          movwf TRISIO      ; and set up GP<5:4,1:0> as outputs
    endasm
    
    DEFINE OSC4             ;sets up 4 meg internal oscillator
    THROTTLE VAR GPIO.1     ;Outputs to throttle servo                    - Pin 6
    GLOW     VAR GPIO.2     ;Output to MOSFET driving glow driver         - Pin 5
    RADIO    VAR GPIO.3     ;Input from receiver                          - Pin 4
    
    TEST     VAR WORD       ; Used to test for loss of signal
    P        VAR WORD       ; This stores the PULSIN value    
    N        VAR WORD       ; Loop counter        
    ;*********************************************************************
    TEST = 0
    RX:                     ; This is where we wait for a signal from the Tx                         
    PULSIN RADIO,1,P        ; With 4 meg oscillator, PULSIN measures at 10 millisecs
    IF (P < 50) and (test = 0) then GOsub LOS ; Loss of signal 
    PULSIN RADIO,1,P        ; Check to see if signal re-established
    if (P < 50) and (test = 1) then goto kill_glow
                            ; There is loss of signal - kill the engine
    IF (P > 100)  and (P < 130) THEN GOSUB SW_ON       ; Turn on glow
    IF (P > 130)                THEN GOSUB SW_OFF      ; Turn off glow
    
    goto RX    
    ;********************************************************************
    
    SW_ON:
        HIGH GLOW                 ; This tunrs on the glow signal on Pin 5
        PULSOUT THROTTLE, p       ; send the normal signal to the throttle servo
        RETURN
    
    SW_OFF:
        LOW GLOW                  ; This turns off the glow signal on Pin 5
        PULSOUT THROTTLE, p       ; send the normal signal to the throttle servo
        RETURN
    
    LOS:    
         TEST = 1                 ; Set for loss of signal
         For N = 1 to 5
         Pause 1000               ; one second  - 5 secs total
         NEXT n
         return
    
    KILL_GLOW:
         low glow               ; Turn off the glow plug 
         
    KILL_ENGINE:
         PULSOUT throttle, 101  ; Kill engine  - adjust this value to get the 
                                ; carb closed to prevent dirt from entering
         pause 50               ; Needs a pause to stop servo hum
         goto KILL_ENGINE       ; Keep in loop to stop spurious signals
    
    ;********************************************************************
    
    END                         ;Terminate the program
    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  6. #6
    Join Date
    May 2008
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    so the code that i write, izzit correct....i mean pulseout code for 20MHz???

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Cool

    Hi, Shirleyzzzzzzzz ...

    that's it !

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

Similar Threads

  1. PMDC SERVO MOTOR WITH quadrature encoder DRIVE ?
    By phoenix_1 in forum Schematics
    Replies: 37
    Last Post: - 22nd November 2009, 19:45
  2. More Servo Woes
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 13th May 2009, 08:40
  3. how to change servo motor PWM
    By dboy in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 21st September 2008, 07:02
  4. Replies: 10
    Last Post: - 26th May 2008, 07:00
  5. information on how to make servo motor
    By rod27cn in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 17th December 2006, 11:59

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