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