Serout to serial servo


Closed Thread
Results 1 to 21 of 21

Hybrid View

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

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

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

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

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

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

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

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

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