Serout to serial servo


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    49

    Default Serout to serial servo

    Hi,

    I need to send serial protocol to serial servo. I have success with BS2 and want to transfer to PIC as it has more memory.
    But I cant make the servo moving using Picbasic Pro.

    I am doing this for a humanoid robot.

    I am using PIC 16F877A for testing.

    Please Help.

    Here I include my BS2 code and Picbasic code.

    BS2 code
    [QUOTE]
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}



    Lleg CON 8

    PAUSE 1000

    SEROUT Lleg,396,[255,5,0,101,181,154,00,186]
    SEROUT Lleg,396,[255,5,125,101,181,154,126,182]
    SEROUT Lleg,396,[255,5,124,101,181,154,125,180]
    SEROUT Lleg,396,[255,5,124,101,181,154,124,179]
    SEROUT Lleg,396,[255,5,123,101,181,154,124,178]'
    SEROUT Lleg,396,[255,5,123,101,181,154,123,177]
    SEROUT Lleg,396,[255,5,122,101,181,154,122,175]
    SEROUT Lleg,396,[255,5,121,101,181,154,122,174]
    SEROUT Lleg,396,[255,5,121,101,181,154,121,173]
    SEROUT Lleg,396,[255,5,120,101,181,154,120,171]
    SEROUT Lleg,396,[255,5,120,101,181,154,120,171]
    SEROUT Lleg,396,[255,5,119,101,181,154,119,169]
    SEROUT Lleg,396,[255,5,118,101,181,154,118,167]
    SEROUT Lleg,396,[255,5,116,102,182,154,118,167]
    SEROUT Lleg,396,[255,5,113,103,184,154,118,167]
    SEROUT Lleg,396,[255,5,111,103,184,154,118,165]
    SEROUT Lleg,396,[255,5,110,103,184,154,118,166]
    SEROUT Lleg,396,[255,5,109,103,184,154,118,165]
    SEROUT Lleg,396,[255,5,107,103,184,154,118,163]
    SEROUT Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT Lleg,396,[255,5,120,73,184,154,120,146]/QUOTE]



    Picbasic Pro Code:
    [QUOTE]
    include "BS2DEFS.bas"
    DEFINE OSC 20
    DEFINE SER2_BITS 8
    OPTION_REG.7 = 0
    Trisb = %00000000 'Setup port b as all outputs
    Lleg Var portb.0

    PAUSE 1000

    SEROUT2 Lleg,396,[255,5,125,101,181,154,126,182]' B6 'repeated 7X,
    SEROUT2 Lleg,396,[255,5,124,101,181,154,125,180]' B4 'raise leg at hip
    SEROUT2 Lleg,396,[255,5,124,101,181,154,124,179]' B3
    SEROUT2 Lleg,396,[255,5,123,101,181,154,124,178]' B2
    SEROUT2 Lleg,396,[255,5,123,101,181,154,123,177]' B1
    SEROUT2 Lleg,396,[255,5,122,101,181,154,122,175]' AF
    SEROUT2 Lleg,396,[255,5,121,101,181,154,122,174] ' AE
    SEROUT2 Lleg,396,[255,5,121,101,181,154,121,173]' AD
    SEROUT2 Lleg,396,[255,5,120,101,181,154,120,171]' AB
    SEROUT2 Lleg,396,[255,5,120,101,181,154,120,171]' AB
    SEROUT2 Lleg,396,[255,5,119,101,181,154,119,169]' A9
    SEROUT2 Lleg,396,[255,5,118,101,181,154,118,167]' A7 ' repeated 16X
    SEROUT2 Lleg,396,[255,5,116,102,182,154,118,167] 'other joints begin motion
    SEROUT2 Lleg,396,[255,5,113,103,184,154,118,167]' A7
    SEROUT2 Lleg,396,[255,5,111,103,184,154,118,165]
    SEROUT2 Lleg,396,[255,5,110,103,184,154,118,166]
    SEROUT2 Lleg,396,[255,5,109,103,184,154,118,165]
    SEROUT2 Lleg,396,[255,5,107,103,184,154,118,163]
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146] ' 73 second servo
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]/QUOTE]
    Last edited by azmax100; - 17th July 2009 at 14:25.

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    With OPTION_REG.7 = 0 you have enabled the Weak Pull-UP's and this could disturb the serial connection.

    Tray this code:

    Code:
    INCLUDE "BS2DEFS.bas"
    DEFINE OSC 20
    
    ADCON1 = 7           ' all digitals
    CMCON = 7            ' all digitals
    
    TrisB = %00000000 'Setup port b as all outputs
    Lleg Var portB.0
    
    PAUSE 1000
    
    SEROUT2 Lleg,396,[255,5,125,101,181,154,126,182]' B6 'repeated 7X,
    SEROUT2 Lleg,396,[255,5,124,101,181,154,125,180]' B4 'raise leg at hip
    SEROUT2 Lleg,396,[255,5,124,101,181,154,124,179]' B3
    SEROUT2 Lleg,396,[255,5,123,101,181,154,124,178]' B2
    SEROUT2 Lleg,396,[255,5,123,101,181,154,123,177]' B1
    SEROUT2 Lleg,396,[255,5,122,101,181,154,122,175]' AF
    SEROUT2 Lleg,396,[255,5,121,101,181,154,122,174] ' AE
    SEROUT2 Lleg,396,[255,5,121,101,181,154,121,173]' AD
    SEROUT2 Lleg,396,[255,5,120,101,181,154,120,171]' AB
    SEROUT2 Lleg,396,[255,5,120,101,181,154,120,171]' AB
    SEROUT2 Lleg,396,[255,5,119,101,181,154,119,169]' A9
    SEROUT2 Lleg,396,[255,5,118,101,181,154,118,167]' A7 ' repeated 16X
    SEROUT2 Lleg,396,[255,5,116,102,182,154,118,167] 'other joints begin motion
    SEROUT2 Lleg,396,[255,5,113,103,184,154,118,167]' A7
    SEROUT2 Lleg,396,[255,5,111,103,184,154,118,165]
    SEROUT2 Lleg,396,[255,5,110,103,184,154,118,166]
    SEROUT2 Lleg,396,[255,5,109,103,184,154,118,165]
    SEROUT2 Lleg,396,[255,5,107,103,184,154,118,163]
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146] ' 73 second servo
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
    SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]

    ......... and see if it works.

    Al.
    Last edited by aratti; - 17th July 2009 at 16:43.
    All progress began with an idea

  3. #3
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    49


    Did you find this post helpful? Yes | No

    Default

    Hi Mr aratti,

    I've tried the code but still didn't work.

    I can do it easily with BS2 but it seem difficult with Pic. It's almost the same between Pbasic(BS2) and Picbasic Pro(Pic) but yet its not working.

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Tray adding a pace delay (see pag 140 PBP manual) number represent milliseconds delay between characters.

    example:

    Code:
    SEROUT2 Lleg,396,1,[255,5,125,101,181,154,126,182]' B6 'repeated 7X,
    This will delay 1 millisecond, perhaps you will need it longer.

    Al.
    All progress began with an idea

  5. #5
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    49


    Did you find this post helpful? Yes | No

    Default

    Still can't get it to work.

    Any other suggestion?

    I really need help from forum members.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I have to ask. Can you make an LED blink with the correct timing?
    What do you get if you connect the PIC to a terminal? Is it sending anything?
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. serial ports, the servo control.
    By m.nobre in forum Serial
    Replies: 0
    Last Post: - 7th December 2009, 16:16
  3. More Servo Woes
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 13th May 2009, 08:40
  4. Serial Servo Spider
    By gandora in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st May 2007, 06:48
  5. Keypad unlock (as in garage door possibly)
    By Fred in forum Code Examples
    Replies: 5
    Last Post: - 2nd April 2006, 04:26

Members who have read this thread : 1

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