Basic STAMP running an H-Bridge

58 views
Skip to first unread message

jgeidl

unread,
Nov 4, 2009, 5:43:41 PM11/4/09
to HomeBrew Robotics Club
Maybe my ignorance has gotten me in another corner. I am hearing that
I won't be very successful trying to run an H-Bridge with two motors
with a Basis STAMP. Does anyone have any experience with this?

Here is the statement snippet with which I am experimenting and it
seems to work but I am not testing very scientifically:

PULSOUT 1, <some value>
PULSOUT 2, <some value>

I can understand where there might be a minute difference because the
statements follow one another but I am having a tough time
understanding how that amount of time is going to create a big
problem...once again, ignorance abounds here.

I fully realize that there are much better chips out there but I am
familiar enough with this one to be simi-successful when I try
things. At some point I will move up in processors but I would like
that to be later rather than sooner.

Jim, K6JMG

don clay

unread,
Nov 4, 2009, 5:59:38 PM11/4/09
to hbrob...@googlegroups.com
The Basic Stamp is limited in code space, resources, & speed. So while you can do
a lot with it, you can't do a lot at the same time.

Dave Hylands

unread,
Nov 4, 2009, 6:05:47 PM11/4/09
to hbrob...@googlegroups.com
Hi Jim,

On Wed, Nov 4, 2009 at 2:43 PM, jgeidl <but...@gmail.com> wrote:
>
> Maybe my ignorance has gotten me in another corner.  I am hearing that
> I won't be very successful trying to run an H-Bridge with two motors
> with a Basis STAMP.  Does anyone have any experience with this?
>
> Here is the statement snippet with which I am experimenting and it
> seems to work but I am not testing very scientifically:
>
> PULSOUT 1, <some value>
> PULSOUT 2, <some value>

This is fine for servos.

But you really need 2 PWM streams going at the same time.

So you can get something like a PWM co-processor:
<http://www.awce.com/pak5.htm>

or you can find an R/C Pulse to PWM converter,

or you can use an Intelligent H-Bridge which uses a serial interface,
or allows an R/C servo style interface.
<http://dimensionengineering.com/Sabertooth2X5.htm>

--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/

Randy M. Dumse

unread,
Nov 4, 2009, 6:11:11 PM11/4/09
to hbrob...@googlegroups.com
Jgeidl said: Wednesday, November 04, 2009 4:44 PM

> Maybe my ignorance has gotten me in another corner. I am
> hearing that I won't be very successful trying to run an
> H-Bridge with two motors with a Basis STAMP.
> ...
> PULSOUT 1, <some value>
> PULSOUT 2, <some value>

What you're missing here Jim, is the other half of the pulse,
when the output is low, that also counts as part of the PWM.

Let's say you do a 4mS pulse on one motor and an 8mS pulse on
the other. How long does it take you to get around the loop?
Basic Stamps get things done around 100 times a second, so you
don't come back (just guessing here) to the two pulse statements
for another, say 10mS. Okay, so your loop time might be 4+8+10
mS. Or 22mS. Wow. Not much pulse width there. You can only run
your motors about a quarter power with that scheme. So now you
want both motors to run the same speed. So you go 8+8+10, total
time goes to 26mS. So you now spend less time with the power on
to the faster motor, 8 out of 26 where before it was 8 out of
22. So speeding up the slow motor slows down the fast motor. Not
very satisfactory, is it?

Plus many motors are better pulsed 20,000 times a second (so you
don't hear a screaming audio from the motors being pulsed). You
can't even begin to get those speeds from a Basic Stamp.

The problem with PWM is you have to control both the PULSOUT
time, but also the PULSOUT-NOT-ON time. With the BS you can't
control two outputs simultaneously. You can't run your PULSOUTs
concurrently. (There are some sloppy tricks, but the time
resolution is...poor.) Generally, people use another micro to
generate PWM for the Stamp, so the Stamp just tells them
serially, "run the motor this fast" and lets something else do
the heavy real-time lifting.

Now what you can do with a Stamp, is turn a motor full on for a
while, and full off for a while, but PWM on two motors at a
time, without an aux processor of some kind, or an RC circuit
(which like a processor turns a short pulse into well applied
PWM) is very limited.

Now forgive me for mentioning my products, but just for
comparison, Our 'Pod's line of controllers were made for motor
control. They have hardware generated PWM output, so you can
just set the PWM ratio you want, and forget it. Up to the
Megaherts range. Plus it has quadrature encoder inputs, so when
ever you want to know where the motor has turned to, again
hardware has done the work for you, and you just read the
position from a register. The difference between a Stamp
designed a number of years into the last millenium and one
designed in this one, are pretty remarkable. (But then I
admitted my bias.)

Randy


James M.(Jim) Geidl

unread,
Nov 4, 2009, 6:57:33 PM11/4/09
to hbrob...@googlegroups.com
Randy,

I don't' mind your product plug at all, that's the only way I learn about
new things. My budget won't stand your stuff right now but maybe latter.

Jim, K6JMG
www.spinochio.com

No trees were harmed in the sending of this message; however, a large number
of electrons were terribly inconvenienced.


//


> [mailto:hbrob...@googlegroups.com] On Behalf Of Randy M. Dumse
> Sent: Wednesday, November 04, 2009 3:11 PM
> To: hbrob...@googlegroups.com
> Subject: [HBRobotics] Re: Basic STAMP running an H-Bridge

Nathaniel Lewis

unread,
Nov 4, 2009, 8:28:20 PM11/4/09
to hbrob...@googlegroups.com
The best way to do it would be to use the Basic Stamp PWM command, but the
basic stamp has no dedicated PWM lines you would have to issue the command
very frequently. The easiest thing to do would be to get a small 8 pin
microcontroller with PWM ability and have it listen for commands over a
serial line or other interface. Parallax sells a PWM board that the basic
stamp sits in then plugs into the stamp socket
(http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/pwm/List/0/S
ortField/4/ProductID/67/Default.aspx) but it is 30$. The first thing I
mentioned would cost no more than a few dollars.
Nathaniel

J O H N

unread,
Nov 5, 2009, 1:32:26 AM11/5/09
to hbrob...@googlegroups.com
The basic stamp only lets you do one thing at a time, so you'll never get
each motor running at the same time using separate io pins. The trick here
is to add some simple external logic so one basic stamp pin maps two
channels on the hbridge at the same time. You can use the 74LS32 (four 2
input or-gates on one chip, ~35 cents each) to do exactly that. I used it
with a two channel hbridge to control two motors (starboard and port), one
or-gate for each of the hbridge control inputs. Also, you'll want to use
the pwm command instead of the pulseout command for motor control.


Here's some parts of my controller code:

varous pins hooked up to the 74LS32 that pipe through to the h-bridge:

cPortRevStbdFwd PIN 1 : OUTPUT cPortRevStbdFwd : cPortRevStbdFwd = 0
cPortRev PIN 2 : OUTPUT cPortRev : cPortRev = 0
cPortFwdStbdRev PIN 3 : OUTPUT cPortFwdStbdRev : cPortFwdStbdRev = 0
cStbdRev PIN 4 : OUTPUT cStbdRev : cStbdRev = 0
cBothForward PIN 11 : OUTPUT cBothForward : cBothForward = 0

cRotatePort CON cPortRevStbdFwd
cRotateStbd CON cPortFwdStbdRev

some of the dispatching logic:

IF forward = 1 THEN
PWM cBothForward, hAPower, hDuration : OUTPUT cBothForward :
cBothForward = 0
ENDIF

IF port = 1 THEN
PWM cPortRevStbdFwd, hAPower, hDuration : OUTPUT cPortRevStbdFwd :
cPortRevStbdFwd = 0
ENDIF

IF starboard = 1 THEN
PWM cPortFwdStbdRev, hAPower, hDuration : OUTPUT cPortFwdStbdRev :
cPortFwdStbdRev = 0
ENDIF

IF aft = 1 THEN
PWM cPortRev, hAPower, hDuration : OUTPUT cPortRev : cPortRev = 0
PWM cStbdRev, hAPower, hDuration : OUTPUT cStbdRev : cStbdRev = 0
ENDIF

IF aftstarboard = 1 THEN
FOR counter = 1 TO 4
PWM cBothForward, hMaxPower, hMaxDuration : OUTPUT cBothForward :
cBothForward = 0
NEXT
ENDIF

Also, the pwmpal is a nice basic stamp addition. It adds background pwm
control and some counters - useful for simple navigation.

John

Alan Marconett

unread,
Nov 5, 2009, 12:50:37 PM11/5/09
to hbrob...@googlegroups.com
John, Jim,

Is this assuming the same speed for both motors (single PWM)?

If the stamp is 28 pins, then Basic Micro has an AtomBasicPro chip that can
drop in. They have some 24 pin modules as well. I'm told the 'Pros handle
multiple R/C (PWM) quite nicely.

Alan KM6VV

> -----Original Message-----
> On Behalf Of J O H N


>
> The basic stamp only lets you do one thing at a time, so you'll never get
> each motor running at the same time using separate io pins. The trick
> here
> is to add some simple external logic so one basic stamp pin maps two
> channels on the hbridge at the same time. You can use the 74LS32 (four 2
> input or-gates on one chip, ~35 cents each) to do exactly that. I used it
> with a two channel hbridge to control two motors (starboard and port), one
> or-gate for each of the hbridge control inputs. Also, you'll want to use
> the pwm command instead of the pulseout command for motor control.

> <snip>

> John
>


James M.(Jim) Geidl

unread,
Nov 5, 2009, 1:29:04 PM11/5/09
to hbrob...@googlegroups.com
Alan,

Sorry to be so dense but I don't understand what you are saying.

Jim, K6JMG
www.spinochio.com

No trees were harmed in the sending of this message; however, a large number
of electrons were terribly inconvenienced.


//


> [mailto:hbrob...@googlegroups.com] On Behalf Of Alan Marconett
> Sent: Thursday, November 05, 2009 9:51 AM
> To: hbrob...@googlegroups.com
> Subject: [HBRobotics] Re: Basic STAMP running an H-Bridge

Alan Marconett

unread,
Nov 5, 2009, 2:30:07 PM11/5/09
to hbrob...@googlegroups.com
Jim,

Then I didn't explain it well enough!

I'm saying that there are "bigger and better" modules that are
pin-compatible with the Stamp. And the new modules are faster, and handle
multiple R/C servos (drive signal for some servo modules) or PWM's better.

Check out Basic Micro at:

http://basicmicro.com/Category.aspx?CategoryID=43

> -----Original Message-----
> On Behalf Of James M.(Jim) Geidl

James M.(Jim) Geidl

unread,
Nov 5, 2009, 2:59:05 PM11/5/09
to hbrob...@googlegroups.com
Alan,

Sure you did I am just using my dumb-thinker to read it! It's the
pin-compatible that threw me. If I get this, I ~could~ drop this chip into
a Board of Education board from Parallax and treat it as if it were a STAMP.
Obviously, I would have to use the programmer from the Atom people. Am I on
the right track?

Jim, K6JMG
www.spinochio.com

No trees were harmed in the sending of this message; however, a large number
of electrons were terribly inconvenienced.


//




> -----Original Message-----
> From: hbrob...@googlegroups.com
> [mailto:hbrob...@googlegroups.com] On Behalf Of Alan Marconett
> Sent: Thursday, November 05, 2009 11:30 AM
> To: hbrob...@googlegroups.com
> Subject: [HBRobotics] Re: Basic STAMP running an H-Bridge
>
>

Alan Marconett

unread,
Nov 5, 2009, 3:14:08 PM11/5/09
to hbrob...@googlegroups.com
Hi Jim,

That's the idea! The Parallax, while a fine starting place, is quite slow
(and limited) in today's round of parts.

How many pins on your Basic Stamp? 24? 28??

28 would be better, it opens up more doors. The 'Pro part is the way I'd
go, if your BOE 'bot can accept it.

BA offers free downloads of the IDE's. Studio IDE is just out.

There are other concerns, such as the programming cable (simple 9-pin RS-232
cable for BA), and which pins your Parallax uses for it's programming.

Dig me up a URL for the BOE manual (I might already have it) and we'll check
out what you have. Others on this list have been commenting on these
"chips", and might already have the conversion figured out!

Alan KM6VV

> -----Original Message-----
> On Behalf Of James M.(Jim) Geidl
>
> Alan,
>

James M.(Jim) Geidl

unread,
Nov 5, 2009, 3:32:38 PM11/5/09
to hbrob...@googlegroups.com
Alan,

Here is a link to a most of the Parallax manuals.
http://www.parallax.com/tabid/440/Default.aspx

It seems to me that "pin-compatible" should mean the programming, serial-in
and serial-out, must be on the same pins on both the STAMP and the ATOM.

I have a couple 24pin BOE boards so am going to try the 24-M ATOM.

Jim, K6JMG
www.spinochio.com

No trees were harmed in the sending of this message; however, a large number
of electrons were terribly inconvenienced.


//


> [mailto:hbrob...@googlegroups.com] On Behalf Of Alan Marconett

> Sent: Thursday, November 05, 2009 12:14 PM


> To: hbrob...@googlegroups.com
> Subject: [HBRobotics] Re: Basic STAMP running an H-Bridge
>
>

Alan Marconett

unread,
Nov 5, 2009, 3:49:28 PM11/5/09
to hbrob...@googlegroups.com
Hi Jim,

Yeah, looks like it'll drop in!

Alan KM6VV

> -----Original Message-----
> On Behalf Of James M.(Jim) Geidl

> Sent: Thursday, November 05, 2009 12:33 PM


> To: hbrob...@googlegroups.com
> Subject: [HBRobotics] Re: Basic STAMP running an H-Bridge
>
>

Nathaniel Lewis

unread,
Nov 5, 2009, 4:40:18 PM11/5/09
to hbrob...@googlegroups.com
I came across thing a while ago, it is called the basicX. It is based
around a ATmega32 AVR and has multiprocessing and hardware pwm, a2d, i2c,
serial, etc. It uses a BASIC style language and it should fit into the
stamp socket. www.basicx.com
Nathaniel

-----Original Message-----
From: hbrob...@googlegroups.com [mailto:hbrob...@googlegroups.com] On
Behalf Of Alan Marconett

Rupert Hart

unread,
Nov 5, 2009, 5:06:32 PM11/5/09
to hbrob...@googlegroups.com
I use the Basic Micro Atom all the time for several years. It doesn't have
the partition issue of the stamp, has two hardware PWM pins, and is pin for
pin compatible with the stamp. www.basicmicro.com.

You can also buy a very handy prototyping system called the Ultimate OEM
module using the BasicMicro Atom chip (no relation to Intel's tom chip!) at
www.beginnerelectronics.com

The BasicX, if I remember correctly, uses more of a visual basic, which is
not so compatible with your existing stamp software.

Anybody who needs more detailed advice, you're welcome to email me directly
on rup...@ruperthart.com.


Regards
Rupert

James M.(Jim) Geidl

unread,
Nov 5, 2009, 6:50:28 PM11/5/09
to hbrob...@googlegroups.com
Thanks, Nathaniel, I'll take a look at it too.

Jim, K6JMG
www.spinochio.com

No trees were harmed in the sending of this message; however, a large number
of electrons were terribly inconvenienced.


//


> [mailto:hbrob...@googlegroups.com] On Behalf Of Nathaniel Lewis
> Sent: Thursday, November 05, 2009 1:40 PM

James M.(Jim) Geidl

unread,
Nov 5, 2009, 7:04:02 PM11/5/09
to hbrob...@googlegroups.com
Rupert,

This looks interesting too.

BTW, I've noticed that there is no price fixing on this stuff. :-) Funny
how every one of the 24p systems are $49.

I don't have any code to worry about porting so a change in language is too
big a deal as long as it is in the same general form, i.e. Basic. Visual
Basic would actually be a real slick improvement as I like the object
oriented stuff.

Jim, K6JMG
www.spinochio.com

No trees were harmed in the sending of this message; however, a large number
of electrons were terribly inconvenienced.


//

Nathaniel Lewis

unread,
Nov 5, 2009, 7:43:20 PM11/5/09
to hbrob...@googlegroups.com
My original thought however, would be the cheapest. If you got a small 8
pin AVR to serve as a pwm co-processor, you would not have to go buy another
$50-$60 part. The ATTiny45 is an 8 pin avr, it can even fit in the Board of
Education breadboard. You could connect a serial line to it and communicate
with it through the stamp's serout command. I could piece together some
code to control an AVR in this configuration if you would like.

James M.(Jim) Geidl

unread,
Nov 5, 2009, 8:10:09 PM11/5/09
to hbrob...@googlegroups.com
Nathaniel,

Yes, you are correct, it would be cheaper but more moving parts, so to
speak. I could use a Picaxe, with which I am slightly familiar, as well.

Jim, K6JMG
www.spinochio.com

No trees were harmed in the sending of this message; however, a large number
of electrons were terribly inconvenienced.


//


> [mailto:hbrob...@googlegroups.com] On Behalf Of Nathaniel Lewis

> Sent: Thursday, November 05, 2009 4:43 PM


> To: hbrob...@googlegroups.com
> Subject: [HBRobotics] Re: Basic STAMP running an H-Bridge
>
>
> My original thought however, would be the cheapest. If you
> got a small 8 pin AVR to serve as a pwm co-processor, you
> would not have to go buy another $50-$60 part. The ATTiny45
> is an 8 pin avr, it can even fit in the Board of Education
> breadboard. You could connect a serial line to it and
> communicate with it through the stamp's serout command. I
> could piece together some code to control an AVR in this
> configuration if you would like.
>
> Nathaniel
>
> -----Original Message-----
> From: hbrob...@googlegroups.com
> [mailto:hbrob...@googlegroups.com] On Behalf Of James M.(Jim) Geidl
> Sent: Thursday, November 05, 2009 3:50 PM
> To: hbrob...@googlegroups.com
> Subject: [HBRobotics] Re: Basic STAMP running an H-Bridge
>
>
> Thanks, Nathaniel, I'll take a look at it too.
>
> Jim, K6JMG
> www.spinochio.com
>
> No trees were harmed in the sending of this message; however,
> a large number of electrons were terribly inconvenienced.
>
>
> //
>

<snip

Nathaniel Lewis

unread,
Nov 5, 2009, 8:30:55 PM11/5/09
to hbrob...@googlegroups.com
I have never used them but that would work as well. My thought was to drop
the chip into the BOE's breadboard, wire up 5v, ground, and a serial line to
one of the basic stamp's I/O pins. You would then connect two wires from
the chip to your pwm inputs on your motor drivers. It would be best to keep
to 8 pins as to not need so much space.

James M.(Jim) Geidl

unread,
Nov 5, 2009, 8:35:56 PM11/5/09
to hbrob...@googlegroups.com
Nathaniel,

This does sound like a simple solution but I will still have to program the
ATTiny45 and don't know how nor do I have the programmer or a programming
interface...or do they accept serial input for programming?

Jim, K6JMG
www.spinochio.com

No trees were harmed in the sending of this message; however, a large number
of electrons were terribly inconvenienced.


//


> [mailto:hbrob...@googlegroups.com] On Behalf Of Nathaniel Lewis
> Sent: Thursday, November 05, 2009 5:31 PM

Nathaniel Lewis

unread,
Nov 5, 2009, 9:12:33 PM11/5/09
to hbrob...@googlegroups.com
They do not, but programming is not a complicated. It requires you to get a
programmer such as this: http://www.pololu.com/catalog/product/1300 . It is
$20 but it has a USB connection allowing it to interface to modern
computers. There are other cheaper ones and do-it-yourself ones but they
use serial ports or parallel ports to communicate. I use the Pololu one and
it can program all of the ATTiny series and ATMega series and others. The
programming environment is C/C++.

J O H N

unread,
Nov 7, 2009, 3:30:36 AM11/7/09
to hbrob...@googlegroups.com
eh?

----- Original Message -----
From: "Alan Marconett" <KM...@SBCGLOBAL.NET>
To: <hbrob...@googlegroups.com>
Sent: Thursday, November 05, 2009 9:50 AM
Subject: [HBRobotics] Re: Basic STAMP running an H-Bridge


>

slamer

unread,
Nov 22, 2009, 4:15:15 PM11/22/09
to HomeBrew Robotics Club
Probably needs to add a servo control board to save processor time.
It's a Simple solution that works really well.
> >> John- Hide quoted text -
>
> - Show quoted text -

James M.(Jim) Geidl

unread,
Nov 22, 2009, 8:26:58 PM11/22/09
to hbrob...@googlegroups.com
What is a servo control board?

Jim, K6JMG
www.spinochio.com

No trees were harmed in the sending of this message; however, a large number
of electrons were terribly inconvenienced.


//


KM6VV

unread,
Nov 22, 2009, 8:36:01 PM11/22/09
to hbrob...@googlegroups.com

James M.(Jim) Geidl

unread,
Nov 22, 2009, 9:30:54 PM11/22/09
to hbrob...@googlegroups.com
There is just way too much cool stuff to play with: I'm never going to get
around to all of it.

Jim, K6JMG
www.spinochio.com

No trees were harmed in the sending of this message; however, a large number
of electrons were terribly inconvenienced.


//


> From: KM6VV [mailto:KM...@sbcglobal.net]
> Sent: Sunday, November 22, 2009 5:36 PM
> To: hbrob...@googlegroups.com

don clay

unread,
Nov 22, 2009, 9:51:59 PM11/22/09
to hbrob...@googlegroups.com
Play harder.

slamer

unread,
Nov 20, 2009, 3:21:36 AM11/20/09
to HomeBrew Robotics Club
Yes I have used the pulsout command with the BASIC stamp2 to talk to
servos, it works. The problem you run into with the stamp or other
controllers is you have to update the pulseout or PWM command very
frequently and the Stamps ends up using up most of its processing time
doing this. Trying to run other tasks makes your motors run with a
jerky motion.
The best thing I found to do is add a (Parallax PSC Servo control
board). Adding a Servo control board takes over the task of generating
PWM signals and all it needs is an occasional serial data update from
the Stamp. Now the Stamp is free and happy to do useful things like
read sensors or radio signal or whatever. This is how I built my
robots and is has been working well with both a Stamp based robot
(EVA) and a 300 lb PC based robot (ETHEL) using a (Lynxmotion SSC-32
Servo control board). Both of these robots have articles written about
them in ROBOT Magazine Nov-Dec 2009 and Jan-Feb 2009. Once you get
your controller or PC speaking Standard (hobby servo control)1.0-2.0
ms PWM signals there are a ton of speed controllers and electronic
switches to use for controlling anything and it's all off the shelf.

http://www.parallax.com/tabid/160/List/0/CategoryID/35/Level/a/Default.aspx?SortField=ProductName,ProductName

http://www.lynxmotion.com/Category.aspx?CategoryID=52

James M.(Jim) Geidl

unread,
Nov 23, 2009, 2:11:25 PM11/23/09
to hbrob...@googlegroups.com
Thanks, I will explore this more as it does look like a potential solution
if I choose to stay with the Stamp.

Jim, K6JMG
www.spinochio.com

No trees were harmed in the sending of this message; however, a large number
of electrons were terribly inconvenienced.


//




> -----Original Message-----
> From: slamer [mailto:teamki...@gmail.com]
> Sent: Friday, November 20, 2009 12:22 AM
> To: HomeBrew Robotics Club
Reply all
Reply to author
Forward
0 new messages