Noob question on program for servos

Hello, I have just purchased the Bot Board and BASIC 28 pin chip.
What i’m trying to program is a simple robot that has 6 servos and i what to test it out by just making it pick up an object. Nothing fancy, just trying to get the basics down. Could someone post some simple code for this (just servo one to 90 degrees and back to center or something)

Thanks

Bane

Hello Bane, try this code:

;===============================================
; Servo test code. Be carful not to instruct your servo to move beyond its
; mechanical limits. It's best to start at the middle (1500) and work left or
; right by adding to the value or subtacting from the value.
; Stay within 750 and 2400 for starters. 
;===============================================

;-------------------( Define Variable )-------------------------------------------

counter var word

;-----------------------------------------------------------------------------------

FOR counter = 1 TO 150 
    PULSOUT p0, 1500 ;<---- try values of 750 & 2400 but be careful not to go to far.  
    PAUSE 20 
  NEXT 
END

Let me know if there are any problems. I did not try to compile this code since I do not have a Basic Atom.

hello sn96, i tried the code (no errors) but no sign of servo motion.
Im using the BASIC Atom 28 pin and still new to its wareabouts.
I changed the pin to 5 on the program, is that how you change it properly?

here is some other posts :laughing:

societyofrobots.com/robotfor … pic=3153.0

thanks

bane

Sorry bane. I know you wanted a simple quick answer and people have been sending you all over the map. Programming is not one of my strengths, so I hooked up a servo to my bot board and started playing around.

Fist thing you need to check right off the bat is: Do you have the VS jumper set on the bot board? Each servo bank has a 3 pin header labeled “VS 5V” there needs to be a shunt (small plastic jumper) connecting the VS pins. Look in manual page #2 under “Enable Servo Connection”. This jumper allows power to the servo. Without it, the servo will just sit there.

After you have that done, make sure your battery is nice and fresh. Next try the code below. I have tested it out on my end and it works fine. If I were you, I would mark the servo horn to help you see where it’s pointing.

;=============================================== 
; Servo test code. Be carful not to instruct your servo to move beyond its 
; mechanical limits. It's best to start at the middle (1500) and work left or 
; right by adding to the value or subtacting from the value. 
; Stay within 750 and 2400 for starters. Make sure the jumper is set to "VS" 
; for the servo bank you want to use.
;=============================================== 

Main: 

low p11 ;<------------Set to pin you want to use
start:
   pulsout p11,1500 ; <----Make sure the pin here is the same. Change any number: from 750 - 2400
   pause 20
goto start

Let me know how that works for you.

Yes it worked! However, i still don’t understand why the other ways were not working. Do it have anything to do with what pin the servo is pluged into? I was using pin 4 before.
Thanks!
:smiley:
Bane

There are probably several others who can better answer this than I can.

First the change the SN96 made was to set the initial state of the pin to low. This is needed to tell the pulseout which way to do the pulses. That is assume H is the high state and L is the low state and your pulse width is represented by three text units. So if the initial state is low, you would have the output on the pin look something like:

LLLLLLLLLLLLHHHLLLLLLLL 

Note, I did not count the number of Ls that would be needed to get to the next pulse start. However if the pin was high to begin with you would end up with the output Looking exactly the inverse ie:

HHHHHHHHLLLHHHHHH

Which you could probably imagine the servo would treat very differently.

I think SN96 answered most of the other things to check for. But again make sure the IO pins you are plugging the servos into have the power pin jumpers set to VS not +5V

Also make sure you have a power supply/battery that is sufficient to power your servos (with the right voltage).

Good Luck.

im not sure what you mean by high and low, could you post some example code. as far as my servo power, i’m using 3 AA standard batteries, enough power? They do seem a bit weak then they move, i have 2 4.5 v 300mAh that i could hook up in series, would that work?

bane

300mA is not enough current. You need 1 to 2 amps with 6V to reliably run servos. As for the other examples I provided, they were not correct, my apologies. I have been spoiled using the SSC-32 to run all my servos and it has been a long long time since I tried moving a servo the conventional way. :laughing:

The terms “HIGH” and “LOW” refer to a pins state (meaning ON or OFF).
Think of a light switch; “HIGH” means you turned on the light, and “LOW” means you turned off the light. A microcontroller can do this several hundred times a second and we call this a digital signal. How long a pin remains “ON” or “OFF” is the duration.

hi bane

your battery setup is too small…you need 6 volts and 1 or 2 amps…

if you run more servos you need more amps…

If you dont have a big enough battery you can use 4 AA in a holder…it wont run a lot of servos maybe just one at a time but at least you can ck stuff that way…use the setup with the 9V battery and take off the VL-VS jumper as below…

to get them to run all you have to do is downlode lynxterm and run it…

it will allow you to “test” and set of pins ( as in set 1 - 5)

you need to set the proper baud rate too …115200 for PC…

read the lynxterm instructions its very simple…

any more help just ck back in…everybody thats here tries to help…

dont run more that 6 volts on the VS side or you can smoke the servo…

ck the VS and VL pins…its best to run the VL with a 9 volt battery and run a 6 volt on the VS side …
:exclamation: !! make sure you disconnect the VS-VL jumper…!! :exclamation:

that will allow the two sources of power to be separated

read the booklet it shows the pin settings…

hope that helps :smiley:

hey sheldon, i’ve got a question on the lynxterm… I don’t have a sequencer which appears to be the main advantage of the software. Is it still better than BASIC MICRON software?

(sequencer… need to get one of those badboys!) LOL

bane

I have programed the stamp and the atom but have tried the BASIC MICRON software …

sorry :frowning:

If you have programmed a Basic Atom or Atom PRO, then you have used Basic Micro’s software. The Atoms are made by Basic Micro. :slight_smile:

8-Dale

ohh I thought he was talking about "other software " companies stuff…
not lynx stuff…

im bad… :blush: