Serout to serial servo


Closed Thread
Results 1 to 21 of 21
  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.

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


    Did you find this post helpful? Yes | No

    Default

    I just found out that I can't even make an Led to blink. Maybe there's a problem with the Pic itself. I will try to use another Pic this evening and try again with the code provide by arati.

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by azmax100 View Post
    I just found out that I can't even make an Led to blink. Maybe there's a problem with the Pic itself. I will try to use another Pic this evening and try again with the code provide by arati.
    Hi azmax100,
    Let's pretend we never used a BS2, and we are using just PICs, and lose Include BS2Defs . . . and all their hokey renaming of ports cause it really just confuses hell out of me anyway.
    Go back to the basics, check your config settings, did you set tris and port registers properly, disable all the analog . . . does your chip have ansel, adcon, adcon1, adcon0, cmcon, cmcon0, cmcon1, . . . . Did you DEFINE OSC ? Does it match the config ? Is mclr or mclre enabled? If so do you have a pullup resistor ? Make sure the LED is not reverse biased (this is an issue, I have LEDs where the Anode is the long lead and I have LEDs where the cathode is the long lead). Is the power supply voltage correct and of sufficient power output? Is it filtered properly? Make sure LVP is disabled, until all is working, enable PWRTE and WDT
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by azmax100 View Post
    I just found out that I can't even make an Led to blink. Maybe there's a problem with the Pic itself. I will try to use another Pic this evening and try again with the code provide by arati.
    I was afraid of that. So, like Joe said, lets start from scratch.

    First, these are a must read:
    http://www.picbasic.co.uk/forum/showthread.php?t=561
    http://www.picbasic.co.uk/forum/showthread.php?t=562
    http://www.picbasic.co.uk/forum/showthread.php?t=543

    Now for the configs. In the PBP directory you will see *.inc files as the thread above talks about. Comment out the correct lines. Make it look like this.
    Code:
        NOLIST
        ifdef PM_USED
            LIST
            include 'M16F87xA.INC'  ; PM header
         ;   device  pic16F877A, xt_osc, wdt_on, lvp_off, protect_off
            XALL
            NOLIST
        else
            LIST
            LIST p = 16F877A, r = dec, w = -302
            INCLUDE "P16F877A.INC"  ; MPASM  Header
       ;     __config _XT_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
            NOLIST
        endif
            LIST
    I will assume you are using Micro Code Studio. Make sure MPLAB is installed and have MCS set to use MPASM. This is not really needed for this PIC but in the future it will be so we will start off right. In MCS tool bar - View-Compiler and Program Options- then the Assembler tab. Check use MPASM.

    Now for some basic code to see if all is working.
    Code:
    '16F877A       HEART_BEAT
        DEFINE OSC 20
    '####################
        @ __config _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF &_BODEN_OFF
        ADCON1=7
        CMCON=7
        
    START:
        HIGH PORTD.2
        PAUSE 100
        LOW PORTD.2
        PAUSE 100
        GOTO START
    When the above is working we can do a simple serial output to a terminal. MCS has on built in.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    I am very sorry to trouble you people with my problem. I really appreciate your help.
    Now I can make the leg moving but after three or four move it will stall. It's seem like I have to off and on the signal voltage to make it move smoothly. I don't know what happen.
    This is my first time with serial servo and humanoid.

    here is my code:
    [/CODE]

    include "BS2DEFS.bas"

    @ DEVICE HS_OSC ' System Clock options
    @ DEVICE LVP_OFF ' Low-Voltage Programming

    DEFINE OSC 20
    ADCON1 = 7 ' all digitals
    CMCON = 7 ' all digitals

    TrisB = %00000000 'Setup port b as all outputs
    Trisd = %00000000
    PortB = %00000000
    PortD = %00000000

    Rleg var portb.2
    Lleg Var portd.1




    pause 1000



    PAUSE 1000
    GOSUB Stand
    GOSUB PostR
    gosub R1a
    pause 1000
    gosub R2a
    pause 1000
    gosub R3a
    pause 1000
    gosub R4a
    pause 1000
    gosub R5a
    pause 1000
    gosub R6a
    pause 1000
    end
    R1a:
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
    SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
    SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
    SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
    SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
    SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
    SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
    PAUSE 500
    return

    R2a:
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Lleg,396,20,[255,5,40,110,161,144,145,95]
    SEROUT2 Lleg,396,20,[255,5,40,110,161,144,145,95]
    SEROUT2 Lleg,396,20,[255,5,40,110,161,144,145,95]
    SEROUT2 Lleg,396,20,[255,5,40,110,161,144,145,95]
    SEROUT2 Lleg,396,20,[255,5,40,110,161,144,145,95]
    SEROUT2 Lleg,396,20,[255,5,40,110,161,144,145,95]
    PAUSE 500
    return

    R3a:
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,150,145,94,111,120,115]
    SEROUT2 Rleg,396,20,[255,5,150,145,94,111,120,115]
    SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
    SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
    SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
    SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
    SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
    SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
    SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
    PAUSE 500
    return

    R4a:
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
    SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
    SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
    SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
    SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
    SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
    SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
    PAUSE 500
    return
    R5a:
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    PAUSE 1000
    Return
    R6a:
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
    PAUSE 1000
    Return
    R7a:
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    PAUSE 1000
    Return
    R8a:
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
    PAUSE 1000
    return
    R9a:
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
    PAUSE 1000
    return
    R10a:
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
    SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
    SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
    SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
    SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
    SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
    SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
    PAUSE 1000
    return

    Stand:
    SEROUT2 Lleg,396,20,[255,5,125,110,161,144,120,155]
    SEROUT2 Lleg,396,20,[255,5,125,110,161,144,120,155]
    SEROUT2 Lleg,396,20,[255,5,125,110,161,144,120,155]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,135,110]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,135,110]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,135,110]
    PAUSE 1000
    RETURN

    PostR:
    SEROUT2 Lleg,396,20,[255,5,130,110,161,144,110,150]
    SEROUT2 Lleg,396,20,[255,5,130,110,161,144,110,150]
    SEROUT2 Lleg,396,20,[255,5,130,110,161,144,110,150]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
    PAUSE 1000
    RETURN



    [CODE]
    Last edited by azmax100; - 29th July 2009 at 16:43.

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


    Did you find this post helpful? Yes | No

    Default

    Joe and I must be good!!! You went from not being able to make an LED blink to having the leg move very quickly

    Take a look at the flow of your code.

    I see it GOSUBing right to END. I do not see any place that LOOPs.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    The code is for the left and right leg. I am using gosub to make the leg move in different angle.
    I am not sure either this is the correct way but I am just trying a lot of time to makes thing correct.

    The angle of the leg move up to gosub R2a then it stall. The servo is holding the position and not moving to other angle.

    Am I doing the right thing?

    One more thing. I got this when I compiled the code -

    Warn Isobot1.ASM 893 :[102] code cross bounadry @800h
    Warn Isobot1.ASM 1549 :[102] code cross bounadry @1000h


    What is that mean.
    Last edited by azmax100; - 30th July 2009 at 03:06.

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


    Did you find this post helpful? Yes | No

    Default

    One of your questions and maybe future questions is answered here.
    http://www.picbasic.co.uk/forum/showthread.php?t=11116

    your code.

    If that is just the leg routine and you have more then I do not see a problem there. And with it only getting part way through it....

    Kind of sounds like it good be a power supply problem causing a brown out. Can you monitor the voltage coming into the PIC? Maybe add if you do not have one a capacitor or two between VSS and VDD.

    At this point a schematic, configs and the whole code might help us figure it out. I am guessing you did rewrite this as Joe suggested and loose the BS2 stuff?
    Dave
    Always wear safety glasses while programming.

  14. #14
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by azmax100 View Post
    I am very sorry to trouble you people with my problem. I really appreciate your help.
    Wow, do not be sorry, it is a challenge, not a trouble, if we were not happy to help, we would not do it.
    You have the code tags reversed, that is why they did not work for you, the [/code] goes after the code
    Now I can make the leg moving but after three or four move it will stall. It's seem like I have to off and on the signal voltage to make it move smoothly. I don't know what happen.
    This is my first time with serial servo and humanoid.
    I agree with Dave, make sure to bypass the power supply line going to the servos, I would put a capacitor at each servo's connection.
    Quote Originally Posted by mackrackit
    I see it GOSUBing right to END. I do not see any place that LOOPs.
    Again I agree with Dave, your code executes to the end and has nowhere to go, put a label ( main: ) before your sub directories and a goto main after them or a goto somewhere else you want it to go, you need some kind of loop that checks for YOUR input, since this robot will likely be under Your control. I understand this is just 1 legs control software, but until it becomes just a part of a larger program, it should have some way back to you, yes the returns should do it everytime, but it only cost a word or 2 to have the insurance policy.
    Try your PIC on a separate power supply (batteries) from your servos, as Dave pointed out it may be browning out or just getting a bunch of hash from the servos into it's power input.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  15. #15
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I am guessing you did rewrite this as Joe suggested and loose the BS2 stuff?
    He didn't remove the include "BS2 stuff" and replace it with include "modedefs.bas" but he is using PBP nomenclature now. He is getting there.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    I glossed over the part about being a trouble. Everything Joe said and I will add...
    Pick a subject that you " think" you know. Then find someone that wants to learn it. Try teaching them or help them with a problem. You will quickly find out how much you really know. May not be as much as you thought.

    For me this forum is a learning tool. So keep trying new things and share your problems.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Sorry for late reply.

    I check the batteries in fact I fully charge it and try it again with additional
    main: in the code but the problem remain the same.

    Actually I am hacking an Isobot Robot.

    Here's the video:

    By the way thanks to all who answered to this forum.

  18. #18
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by azmax100 View Post
    Hi,


    Actually I am hacking an Isobot Robot.

    Here's the video:

    By the way thanks to all who answered to this forum.
    Hey isn't that Michael Jackson ? looks like it's ready to do some Kung Foo . . ., teach that thing to moonwalk . . . What was the problem again? Oh yeah, servo stalls. Maybe it is losing the data connection when it goes into those antics, bad wire, bad connection . . . Try enabling WDT in case micro is locking up. You have a lot of PAUSE 1000 in your code. I would change them to for next loops, or better yet make a subroutine for next with say 0 to 100 pause 10 and when you move on to using interrupts your code will respond much faster. In thinking about it, I would move those serial routines to use HSEROUT and hardware serial routines, instead of all those bit banging serout2 commands.
    Last edited by Archangel; - 7th August 2009 at 17:57.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    Joe S,

    What do you mean WDT.Can you please elaborate more.

    If i use the Hserout do I have to use Include BS2defs.bas.

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


    Did you find this post helpful? Yes | No

    Default

    WDT. Watch Dog Timer. This is one of the config settings. Look at the PICs data sheet.
    You do not need the BS2 stuff with SEROUT2 or HSEROUT. In fact, being you still have that in you code might be causing some of the trouble. Not sure though.
    Dave
    Always wear safety glasses while programming.

  21. #21
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by azmax100 View Post
    Joe S,

    What do you mean WDT.Can you please elaborate more.

    If i use the Hserout do I have to use Include BS2defs.bas.
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    I strongly suggest everyone new to PICs read through all the posts in the FAQ section, really a lot of good things in there. WDT is what it it's name implies, it , like a watch dog, keeps an eye on your pic, and if allowed to time out, it resets it. After your code is perfect, turn it off if you like.
    If i use the Hserout do I have to use Include BS2defs.bas.
    I wouldn't put it in. It basically just redefines a bunch of stuff so you can use basic stamp syntax, it also includes modedefs.bas automatically, which you do not need to use hardware serial port either. You do need it (modedefs.bas) if using serout or serout2 and want to use the aliased baud notations like N9600 . . . instead of mode 396 . . . As far as BS2defs goes, I am assuming a 2 to 7 dollar PIC beats spending what . . . ? . . . 25 for a stamp ? I think you will not go back, so it's better to put that chapter behind you, with fond memories (of the money you spent), and get up to speed with PIC syntax. IMHO
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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