November 21, 2024, 04:25:47 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


H Bridge Motor Controller to Prop 1

Started by chsom, March 25, 2014, 11:29:00 AM

Previous topic - Next topic

chsom


I am working on a project and I would like to hook up two 24V DC motors (http://www.allelectronics.com/make-a-store/item/dcm-351/24-vdc-gear-motor-w/turntable/1.html) to an H Bridge Motor Controller (http://www.thanksbuyer.com/image/cache/data/sku-26585-3-600x600.jpg). Then I would like to controller the motor controller with a Prop1 and make the motors rotate clockwise and counterclockwise. I think I need to hook up the out1 (one Prop1) to in1 (on motor controller), out2/in2, out3/in3, and out4/in4. If that is correct then I am not sure about how the programming code would look to make the motors move clockwise and counterclockwise.

I would appreciate any tips or assistance.

Thanks,
Daniel

JonnyMac

March 25, 2014, 07:11:24 PM #1 Last Edit: March 25, 2014, 07:13:54 PM by JonnyMac
That photo is not very helpful. Do you have a link to documentation?

If you can find 12V motors we would recommend the Parallax HB-25. With just one wire you can control up to two, high-current DC motors -- full control over speed and direction. You can connect a raw h-bridge to the Prop-1, but you'll only get full-speed in the selected direction.
Jon McPhalen
EFX-TEK Hollywood Office

chsom


Here is a more detailed description, sorry about that controller.
http://www.thanksbuyer.com/dual-h-bridge-dc-stepper-motor-drive-controller-board-module-arduino-l298n-26585#tab-description

We would only need full speed in the two directions. Speed is not a requirement for the project just direction. There is a price limit on what my team can spend on the project so the parallax controller would put us over the budget.

The project would just require the two motors to move forward and then backwards to the original postion.

Thanks,
Daniel

JonnyMac

Here's a template program that provides stop, forward, and reverse routines for two motors. If you change the connections (please don't), then you have to change the subroutines (which are a tiny bit tricky).

Note that ground must be common between the Prop-1 and the H-Bridge.


' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  M2_F            = 3                     ' P3 --> IN4
SYMBOL  M2_R            = 2                     ' P2 --> IN3

SYMBOL  M1_F            = 1                     ' P1 --> IN2
SYMBOL  M1_R            = 0                     ' P0 --> IN1


' -----[ Constants ]-------------------------------------------------------

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  TrOn            = 1                     ' active-high trigger
SYMBOL  TrOff           = 0

SYMBOL  IsOn            = 1                     ' active-high I/O
SYMBOL  IsOff           = 0

SYMBOL  Baud            = OT2400


' -----[ Variables ]-------------------------------------------------------

SYMBOL  timer           = B2                    ' for debounce loop


' -----[ Initialization ]--------------------------------------------------

Power_Up:
  ' put code here that only happens at power-up/hard reset

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00111111                              ' P5..P0 are outputs


' -----[ Program Code ]----------------------------------------------------

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  PAUSE 5                                       ' scan delay
  IF Trigger = TrOff THEN Main                  ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 100 THEN Check_Trigger             ' check timer

  ' program code here

  GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------

M1_Stop:
  PINS = PINS &/ %00000011
  RETURN

M1_Forward:
  PINS = PINS &/ %00000011 | %00000010
  RETURN

M1_Reverse:
  PINS = PINS &/ %00000011 | %00000001
  RETURN

' -------------------------------------------------------------------------

M2_Stop:
  PINS = PINS &/ %00001100
  RETURN

M2_Forward:
  PINS = PINS &/ %00001100 | %00001000
  RETURN

M2_Reverse:
  PINS = PINS &/ %00001100 | %00000100
  RETURN


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office