Serout to serial servo


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    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.

  2. #2
    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.

  3. #3
    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.

  4. #4
    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.

  5. #5
    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.

  6. #6
    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.

  7. #7
    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.

  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 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.

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