Solutions Cubed Technical Support Forum: H bridge with Parallax Stamp - Solutions Cubed Technical Support Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

H bridge with Parallax Stamp

#1 User is offline   yabree 

  • Starting Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 03-April 07
  • Location:USA

Posted 03 April 2007 - 05:56 AM

Do anyone have any sample code for a Stamp 2 for controlling the H-bridge?

Thanks.
0

#2 User is offline   Lon 

  • Advanced Member
  • PipPipPipPipPipPip
  • View blog
  • Group: Root Admin
  • Posts: 640
  • Joined: 03-March 04

Posted 03 April 2007 - 09:53 AM

Here's some simple code that controls motor direction with 4 i/o lines. You could reduce it down to 2 i/o's if you need to. To control motor speed you need to PWM the low sides. The BASIC STAMP2 doesn't do this well, other stamps might (check with www.parallax.com). The datasheet for the Simple Bridge shows an application where a PIC controller is used to control a motor's speed and direction as well.

See the datasheet for external circuit components that can help reduce voltage spikes.

Lon

' {$STAMP BS2}
' CONTROLLING A DC MOTOR FORWARD, REVERSE, AND STOP USING
' A BASIC STAMP2 AND A SIMPLE BRIDGE
' L1 = P0
' L2 = P1
' H1 = P2
' H2 = P3

'
H2 CON 3 'DIRS 1 RESET 0
H1 CON 2 'DIRS 1 RESET 0
L2 CON 1 'DIRS 1 RESET 0
L1 CON 0 'DIRS 1 RESET 0
'

START:
OUTS = %0000000000000000
DIRS = %0000000000001111

STOP_MOTOR:
LOW L1
LOW L2
LOW H1
LOW H2
PAUSE 1000

FORWARD_MOTOR:
LOW L2
LOW H1
HIGH L1
HIGH H2
PAUSE 4000

REVERSE_MOTOR:
LOW L1
LOW H2
HIGH L2
HIGH H1
PAUSE 4000

GOTO STOP_MOTOR

END:
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users