PC Controlled Servo Controller. I'm a robo newb, be gentle

The Atom and the Pro currently have two separate IDE’s. That’s soon to change, but I’m not supposed to talk about it. :frowning: The post you linked was a guy using the wrong serial command format for the IDE he was using. So no big deal really. Getting the status of an I/O pin (input) is done like this.

[code]left_input var bit
right_input var bit

main:
left_input = in12 'this is for pin 12
right_input = in13 'this is for pin 13

if left_input = 1 then turn_left_motion
if right_input = 1 then turn_right_motion
goto main

turn_left_motion:
serout 15,i38400,$80, 0, 5, 127] 'whatever needs to be in there :wink:
goto main

turn_right_motion
serout 15,i38400,$80, 0, 5, 127] ’ in there too.
goto main[/code]

button1 var bit
button2 var bit

SEROUT 15, I8N1_9600, $80, 2,2]            'sets controller in two motor mode dont know if this is in the right spot

P14 = 0
pause 120
P14 = 1
pause 120

main:
forward = in4
reverse = in5

if forward = 1 then goforward
if reverse = 1 then gobackwards
goto main



goforward 
SEROUT 15, i9600, $80, 0, 5, 127] 
SEROUT 15, i9600, $80, 0, 7, 127] 
goto main

gobackwards
SEROUT 15, i9600, $80, 0, 4, 127] 
SEROUT 15, i9600, $80, 0, 6, 127] 
goto main 

Like this?
Edit: do i have the reset set right for pin 14? it needs to be kept high from what i can tell.

Because you only need to set up the motor controller once, I moved it above the loop. I also added a command to stop it if no button is pressed. Ha! look at ya having fun with no robot at all. lol :smiley:

button1 var bit
button2 var bit

SEROUT 15, I8N1_9600, $80, 2,2]            'sets controller in two motor mode 

main:
forward = in4
reverse = in5

if forward = 1 then goforward
if reverse = 1 then gobackwards
if forward = 0 and reverse = 0 then stopit
goto main

LOW 14                                 'motor controller reset on pin 14 
PAUSE 100 
HIGH 14 
PAUSE 120                              'motor controller startup time 

goforward 
SEROUT 15, i9600, $80, 0, 5, 127] 
SEROUT 15, i9600, $80, 0, 7, 127] 
goto main

gobackwards
SEROUT 15, i9600, $80, 0, 4, 127] 
SEROUT 15, i9600, $80, 0, 6, 127] 
goto main 

stopit
SEROUT 15, i9600, $80, 0, ?, 127] 
SEROUT 15, i9600, $80, 0, ?, 127] 
goto main 

Oh so i do keep

LOW 14                                 'motor controller reset on pin 14 
PAUSE 100 
HIGH 14 
PAUSE 120                              'motor controller startup time

I was worried it would keep resetting, looping maybe.

I used to program stuff on garry’s mod, a sandbox mod for half life 2, the computer game.
In the garry’s mod, there was an addon called Wire-mod.
I’d spend hours thinking up creative ways to control new contraptions.
Half the time i wasn’t even in game, i’d just lay back and visualise it.

It’s very similar to basic. An example of the code is exactly.

@inputs W A S D
@outputs Leftmotor Rightmotor
@Persist Lm Rm
Leftmotor = Lm
Rightmotor = Rm
W == 1 -> Lm = 1, Rm = 1;
S == 1 -> Lm = -1, Rm = -1;
A == 1 -> Lm = -1, Rmr = 1;
D == 1 -> Lm = 1, Rm = -1;
W == 0 & S == 0 & A == 0 & D ==0 -> Lm = 0, Rm = 0;

it automatically ask if, when -> is included.
if W is equal to 1 then Lm =1 and Rm = 1 end
== means it’s asking if it’s equal to

As you can see the general idea is the same, it’s just writing it out that’s different.
That is actual code used to control a tracked bot.
Or 4wheel bots where it turns like a tracked bot.

Edit:
I need to find a way to make an interface, make it so, i can send a hex byte, or number ASCII value over the serial com port,
I’m sure the atom half would be easy to program

Bot var nib              'i dont know if you can send nibs over a com port

SEROUT 15, I8N1_9600, $80, 2,2]            'sets controller in two motor mode 
LOW 14                                 'motor controller reset on pin 14 
PAUSE 100 
HIGH 14 
PAUSE 120                              'motor controller startup time 

main: 
Bot = in3                 'rs-232 com port Rx though i dont know if this is it

if bot = 0 then dontmove
if bot = 1 then forwards
if bot = 2 then backwards
if bot = 3 then rotateleft
if bot = 4 then rotateright

dontmove                                       'motor direction doesnt matter only speed friction will slow it
SEROUT 15, i9600, $80, 0, 5, 0] 
SEROUT 15, i9600, $80, 0, 7, 0] 
goto main

firward
SEROUT 15, i9600, $80, 0, 5, 127] 
SEROUT 15, i9600, $80, 0, 7, 127] 
goto main 

backwards
SEROUT 15, i9600, $80, 0, 4, 127] 
SEROUT 15, i9600, $80, 0, 6, 127] 
goto main 

rotateleft 
SEROUT 15, i9600, $80, 0, 4, 127] 
SEROUT 15, i9600, $80, 0, 7, 127] 
goto main

rotateright
SEROUT 15, i9600, $80, 0, 5, 127] 
SEROUT 15, i9600, $80, 0, 6, 127] 
goto main

4 = left track reverse, 5 left track forward
6 = right track reverse, 7 is right track forward.
Exact numbers i’m not sure about, the serial motor controller is confusing.

oops, yeah you must move those above the main label as well. Don’t know nuthin bout games though. Played Super Mario Brothers once. And I mean once! Stupid game, start over from the beginning… Doh! :unamused:

Let’s put it this way, garry’s mod, is just a construction sandbox.

You can create cars, planes, boats, what ever, even robots.
Though robots are really hard because theres no real servo, and attempts to program a servo have been mediocre at best.

The 2 closest things are motors, and actuators.

You also may need to refresh the page, i rarely double post, but i’ll edit my post a dozen times.

Edit: any ideas what i could use to program a simple interface that’ll transmit a command byte over the serial port?
Something that i could use to bind keyboard keys to sending out a specfic signal over the com port.

as long as the atom can detect the byte(s) it should work.

I’m not going to be much help for programming bidirectional coms. No real experience with it. When you have your hardware there are folks who can help.

Ya i probably get some basic control relatively quicking using the buttons from 4 and 5 on the bot board.

Once i can get the thing moving, i can get more advance stuff going.
I’m sure i’ll figure it all out, On the bright side, i’ll definitely be going the botboard/atom route, so no gimpy 8 servo controller.
It wont be the easiest to use, but i’ll make it work.

Edit ok i think it would be if i were to transmit ASCII decimals over the com port from 1-5

Bot var nib              

ENABLEHSERVO
ENABLEHSERIAL

SETHSERIAL H38400, H8databits, Hnoparity, h1stopbits          'there are spaces between the comma and the Hs or am i wrong
hserin [dec bot]                 'im sure this is right


PAUSE 20

SEROUT 15, I8N1_9600, $80, 2,2]            'sets controller in two motor mode 
PAUSE 20
LOW 14                                 'motor controller reset on pin 14 
PAUSE 100 
HIGH 14 
PAUSE 120                              'motor controller startup time 

main: 

if bot = 1 then forwards 
if bot = 2 then backwards 
if bot = 3 then rotateleft 
if bot = 4 then rotateright 
if bot <> 1 or 2 or 3 or 4 then fullstop 


forward 
SEROUT 15, i9600, $80, 0, 5, 127] 
SEROUT 15, i9600, $80, 0, 7, 127] 
goto main 

backwards 
SEROUT 15, i9600, $80, 0, 4, 127] 
SEROUT 15, i9600, $80, 0, 6, 127] 
goto main 

rotateleft 
SEROUT 15, i9600, $80, 0, 4, 50] 
SEROUT 15, i9600, $80, 0, 7, 50] 
goto main 

rotateright 
SEROUT 15, i9600, $80, 0, 5, 50] 
SEROUT 15, i9600, $80, 0, 6, 50] 
goto main 

fullstop                                     'motor direction doesnt matter only speed friction will slow it 
SEROUT 15, i9600, $80, 0, 5, 0] 
SEROUT 15, i9600, $80, 0, 7, 0] 
goto main

Since i dont know how to connect 2 computers together and have one read what the other is writing, i wont know if this works until i get it. Until then i’ll have to wait.

It’s official my order has been placed, got my money early.
Current Budget $196.18 (See how tight my budget was.)
Spent $195.41

Future budget as of July 3rd will be $35, and and additional $40 on July 6th.
Parts ordered were:

Tank Kit
Bot Board v2

Basic Atom Pro 28-M
Pololu Micro Dual Serial Motor Controller

I went with the pololu motor controller because it was cheap, and supplies over 2x the stall power of my motors. So it supples twice as much as the max limit of my motors, the motors on average take 70-80mA.

I’ll buy a 1A 5v regulator from radioshack for a buck and a half. Pocket change.

My pc has a Dedicated hardware serial port, but i’ll be using a usb to serial port.
I’ll be getting an eithernet DB25 bridge, and a DB25 to DB9 adapter (both free) will experiment with those.

My remaining budget which i dont get till the 3rd at earliest will be $35. Enough for a wireless camera, a breadboard and some jumper wires. I can get by without those for now.

And on the 6th, a bluetooth serial adapter, cheapest one i can find. Please submit links if you know of some really cheap ones.

Edit:
YAY, while taking apart an old 4.1 PC speaker setup, which no’one had used in years, it was sitting in a box.
I found a-
MC7805CT 1A 5V voltage regulator.
AND!!!
a L7809CV 1.5A 9V Voltage Regulator. JACKPOT!

Though the 9V regulator seems a bit off, i put 18v into it, and got 11.5v out, exactly 11.5v, not sure whats up there.
But the 5v regulator put out 5.06v and i have a nice little heatsink for it.

Edit2:
Anyone know how to write batch files?
Or a dos exe, Might be able to create a simple user interface in dos that can send specific commands.
If someone can write one that sends the ASCII decimal “5” when W is pressed in the window over com1, i can adapt it to cover all of my commands.

Edit3:
Can someone post the lines or at very least the commands needed for incriment and decrimint hservo controls.?

Example, if hservo’s position is 0(neutral) then how do i make it increase or decrease to a min/max. The speed is in the command.

So how do i make it add or subtract the pos while a button is pressed.

Example: a servo on Pin 4, with the speed of 255.
HSERVO [P4, var1, 255]

I wan’t var1 to have the min limit of -5000 and the max limit of +5000.
I wan’t it to start at 0 on startup, and if input1 = 1, it’ll increase from 0 to 5000, But if i press input2 it’ll decrease from what ever it’s current position is, to a max-negative of -5000. And then reset to 0 if input 3 = 1.

I know how to make it reset
if input3 = 1 then var1 = 0

Edit: i want it to remain at the value until i change it with one of the 3 inputs.

I think it uses a step counter with start and end values.

This is what i got so far, very basic, confirm if correct.

var1 = Sword
input1 = bit
input2 = bit
input3 = bit

ENABLEHSERVO
pause 10                 'Because i want it to

main:

for var1 = -5000 to 5000
if input1 = 1 then var1 + 100         'I dont know if these work youll have to help me with this im confused
if input2 = 1 then var1 - 200
if input3 = 1 then var1 = 0

HSERVO [P4,var1,255]
gotomain

I’m still trying to figure it out. I’ll edit the post and remove all this if i figure it out.
I’m visualizing this all in my head at the moment. So bear with me. Though i think i’m doing pretty good for not even having a robot yet.
I need something to do while i wait for my bot to get here, and it would be nice to know what i’m doing before i get started. So i dont mess anything up.

Edit again:

When i leave notes in my program code, am i using ’ or ; because when reading the atom pro manual pdf, they always use ;
But here on the forums i keep seeing ’
though it could be a font thing.

please search 32 servo controller on ebay there is one gpx-32
is currently on auction
just plugin the cable , add upto 32 servos i think u need 2 for ur project, power supply and control the slider from ur computer, takes 12-15 days to reach ur desitnation u may be lucky to get for under $40 also
for servos rotational motion just modify them add a 2.2 k after removal of the trim and ur ready. there are servos also been sold.
if your lookign for a pan tilt mech , just buy 2 servos, if u need more than 180 deg then u modify it other wise no need,
connect the servos directly to the gpx-32 board run the program from the computer add the power supply and run the sequencer.

thanks drgipatel but i already got placed my order for a bot board and an atom pro 28

Right now my last post had my current problem.

Edit:
Done with this thread, all my new questions about programming no longer fit into this thread.

Please refer to the Fallentine Help thread.

Mr Dude, you can lock this one if you want i probably wont check it anymore.