Serial Servo Spider


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    May 2007
    Posts
    26

    Talking Serial Servo Spider

    Parts:
    A bunch of servos, some computer shell pieces, a cutting board, some sheats of plastic, and a bunch of wires and screws.

    PIC:16F88

    Well, I have finnaly come to the point where I have enough knowledge to create the basics of a robotic spider.

    I now have a body and one leg of my planned 4 to 8 legs. I will share pictures when I get a chance to take some. But I wanted to share the code and since it is my first multiservo driver I wanted to see if anyone had any suggestions.

    Notably I will need to control at least 9 servos per pic, and I don't think this particular routine will work as well with more servos than the current 3. Feel free to make code suggestions, or ask any questions.

    I thought it would be neat to work on my first real robot with public input. Feel free to use the code, just let me know if you make anything cool using any of my code (and I'll feel special ^^). Now if you have read this far, heres the code ^^

    Code:
    '****************************************************************
    '*  Name    : mserv.BAS                                         *
    '*  Author  : Joseph Dattilo                                    *
    '*  Notice  : Copyright (c) 2007 Joseph Dattilo                 *
    '*          : All Rights Reserved                               *
    '*  Date    : 5/10/2007                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
            define OSC 8
            OSCCON = %1111110 ' sets internal osc to run at 8MHZ
    
    '----------turn analog on porta off, and use as digital input/output
    '----------this is used to allow serial input on the A bus.
            CMCON = 7 'Comparators OFF
            ANSEL = 0 'A/D OFF -- Port pins all digital
    '----------
    
    '---**Pins
    
    basepin var portb.4
    thighpin var portb.5
    kneepin var portb.6
    
    '---**Variables
    counter var word
    
    '--pulses
    basepulse var word
    thighpulse var word
    kneepulse var word
    
    '---**Initial Positions (for when powered on, without immediate directives)
    basepulse=240     'initial position   :base
    thighpulse=320     'initial position  :thigh
    kneepulse=120     'initial position   :knee
    
    '------**main program
    
    
    
    main:  
    
    
    '----send serial request, and get user input for motor drive       
            serout2 porta.0, 16468, ["ready set go!"] 'call for data           
            '--- use lag time between pc recieve and transmit to keep motors pulsing
             'pulse one more time to keep from dropping load and for pc lag
                    pulsout basepin, basepulse     'drive motor to keep smooth
                    pulsout thighpin, thighpulse   'drive motor to keep smooth
                    pulsout kneepin, kneepulse     'drive motor to keep smooth
            '----        
            
            serin2 porta.1, 16468,70,drivemotor, [dec3 basepulse,wait("|"),_
            dec3 thighpulse,wait("|"),dec3 kneepulse]    'recieve data
    
    '-----end serial request
    
    goto drivemotor
           
    goto main   'loop forever
    
    
    
    
    drivemotor:
    '----drive motor   
                for counter = 1 to 13
    
                    pulsout basepin, basepulse
                    pulsout thighpin, thighpulse
                    pulsout kneepin, kneepulse
                    pause 30
    
                next   
                
    '----end motor drive  
    goto main
    
    end

    I am sure some of you are thinking... okay so how on earth does he hit send within a couple microseconds? If you were, I have designed some simple C# software that takes the call word that it is sent, and instantly sends qued messages through the serial port.

    Actually not so instantly it is probably the biggest problem with the controller, it has to wait at least 60 or so microseconds to recieve the message which means a short time where a load drops slightly (which gives the impression of a heart beat actually ^^).

    I haven't finished the program to a point where its ready to include, however for now lets just assume that works (cuz it does). I will however include it and its source at a later time. I figure it could save someone alot of headaches ^^. (I know it would have for me) If anyone wants me to put it up soon so they can play with it, let me know and I'll probably get around to it faster (especially if I forgot)

    Well Sorry if I rambled a bit, hope you enjoy the code.

  2. #2
    Join Date
    May 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Post A few things to know

    I thought I should probably provide a few problems that I have already identified.

    First: obviously if I could decrease the time where the motors are not driven.

    Second: motion can be rather choppy as there is no provision for controlling the time it takes to get from A to B, which means the servos will attempt to go from 80 to 480 in the same time that they would go from 450 to 480. which makes for alot more comand driven motion thats still too choppy.

    Third: If there was a way to decrease the amount of time where a command cannot be sent without effecting smoothness of motion (drammatically), it would improve the ability to make more complicated, and rapid movement sequences. (always good)

    Fourth: Introducing more motors with the current algorithm could spell disaster. The time between pulses needs to be regulated.

    Fifth: A problem that will soon be solved, and you can't really help me with is the fact that my robot only has one leg at this time. Which makes it look really funny when it try's to walk ^^.

  3. #3
    Join Date
    May 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Smile Pictures

    Here it is just lying around. The led stays lit when the power is plugged in but the Controller is off. When you turn it on the light turns off.



    He may only have one leg but hes not letting that get in his way!


Similar Threads

  1. serial ports, the servo control.
    By m.nobre in forum Serial
    Replies: 0
    Last Post: - 7th December 2009, 16:16
  2. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 16:46
  3. More Servo Woes
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 13th May 2009, 08:40
  4. Help with Servo Control Please!
    By wireman22 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th June 2007, 18:15
  5. Multiple Servo Control --Serial
    By gbm_designs in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th December 2004, 01:28

Members who have read this thread : 0

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