​ ​ ​ ​ Problem with buzzing servo - Page 2
Page 2 of 2 FirstFirst 1 2
Results 11 to 17 of 17

Thread: Problem with buzzing servo

  1. #11
    Senior Member
    Join Date
    Jan 1970
    Location
    Perth, Western Australia
    Posts
    4,453

    Default

    Remember that you are now creating pulses by executing a series of commands in a loop. The pulse timing (mark and/or space) may not be ideal for what the servo is expecting. The overall cycle time (mark + space) for each pulse should be 20mS. The execution time (time taken for each command to be read/unpacked/executed) for each command will affect the length of the pulse. This is most noticeable when using the PauseuS command. It may be better to replace the High/PauseuS/Low sequence with a PulsOut command for a more accurate and linear output.
    Last edited by inglewoodpete; 07-06-2018 at 02:44.

  2. #12
    New Member
    Join Date
    Oct 2017
    Location
    United Kingdom
    Posts
    14

    Default

    Quote Originally Posted by inglewoodpete View Post
    Remember that you are now creating pulses by executing a series of commands in a loop. The pulse timing (mark and/or space) may not be ideal for what the servo is expecting. The overall cycle time (mark + space) for each pulse should be 20mS. The execution time (time taken for each command to be read/unpacked/executed) for each command will affect the length of the pulse. This is most noticeable when using the PauseuS command. It may be better to replace the High/PauseuS/Low sequence with a PulsOut command for a more accurate and linear output.
    Hi Inglewoodpete, thanks for the input. May be a stupid question but do I literally just replace the PauseuS commands with PulsOut commands and try the numbers again starting from 75 - 225?

    Any help greatly appreciated.

  3. #13
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    24,346

    Default

    Quote Originally Posted by Dr Jekyll View Post
    do I literally just replace the PauseuS commands with PulsOut commands and try the numbers again starting from 75 - 225?
    That's almost correct. This -

    Code:
    For z = 75 to 225
       high C.4
       pauseus z
       low C.4
       pause 20
    Next z
    becomes -

    Code:
    low C.4
    For z = 75 to 225
       pulsout C.4, z
       pause 20
    Next z

  4. #14
    Senior Member
    Join Date
    Feb 2012
    Location
    London
    Posts
    2,872

    Default

    Hi,

    The (interpreter) timing "overhead" between the High and Low edges and of a "PAUSEUS 0" (zero) is quite close to 1 ms in total (@ a 4MHz clock). So I would expect the "PAUSEUS Z" in the first format to be roughly equivalent to a "PULSOUT ... (Z + 100)" [pseudocode, not a legitimate PICaxe command] in the second. Which should also overcome the concern about the possible need for a "negative" delay.

    Cheers, Alan.

  5. #15
    New Member
    Join Date
    Oct 2017
    Location
    United Kingdom
    Posts
    14

    Default

    Quote Originally Posted by hippy View Post
    That's almost correct. This -

    Code:
    For z = 75 to 225
       high C.4
       pauseus z
       low C.4
       pause 20
    Next z
    becomes -

    Code:
    low C.4
    For z = 75 to 225
       pulsout C.4, z
       pause 20
    Next z
    Hi Hippy, just given that a try and I came close but no cigar. The servo moves to one end fast, then moves slowly back. The 5 second delay before it's supposed to move back automatically doesn't seem to work at all. Any hep greatly appreciated. Here's my current code:

    Code:
    Output C.4
    Input C.3
    Symbol z = W8
    
    init:
    high C.4 ; initialise servo
    pauseus 75
    low C.4
    pause 20
    
    Main:
    Pause 10
    If PinC.3 = 0 Then Goto Main
      
    '// Move Servo QUIETLY over a period of 2 seconds or so // 
    low C.4
    For z = 75 to 225
       pulsout C.4, z
       pause 20
    Next z
     
    '// Wait 5 seconds 
    Pause 500
    
    '// Move Servo the other way // 
    low C.4
    For z = 225 to 75
       pulsout C.4, z
       pause 20
    Next z
     
    '// Wait 5 seconds 
    Pause 500
    
    Goto Main

  6. #16
    Senior Member
    Join Date
    Feb 2012
    Location
    London
    Posts
    2,872

    Default

    Hi,

    Stepping from 75 to 225 with a 20 ms loop period should actually take just over 3 seconds. Note that STEP +1 is the assumed default.

    Then, the PAUSE 500 will delay for only 0.5 second. For 5 seconds use a PAUSE 5000 or a WAIT 5.

    However, the major omission is a STEP -1 in the second loop, otherwise the loop condition is immediately met and the loop terminates at a value of 226.

    Therefore, changing the second loop to FOR z = 225 TO 75 STEP -1 should fix the problem.

    Cheers, Alan.
    Last edited by AllyCat; 08-06-2018 at 16:33.

  7. #17
    New Member
    Join Date
    Oct 2017
    Location
    United Kingdom
    Posts
    14

    Default

    Quote Originally Posted by AllyCat View Post
    Hi,

    Stepping from 75 to 225 with a 20 ms loop period should actually take just over 3 seconds. Note that STEP +1 is the assumed default.

    Then, the PAUSE 500 will delay for only 0.5 second. For 5 seconds use a PAUSE 5000 or a WAIT 5.

    However, the major omission is a STEP -1 in the second loop, otherwise the loop condition is immediately met and the loop terminates at a value of 226.

    Therefore, changing the second loop to FOR z = 225 TO 75 STEP -1 should fix the problem.

    Cheers, Alan.
    Thanks Alan, appreciate your input. I'll give that a try now. I wasn't ignoring your earlier reply BTW - I just didn't understand it. I'm a total beginner with Picaxe.

    Cheers
    Nick

Bookmarks

Posting Permissions

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