PDA

View Full Version : HB-25 Motor Controller help.



Andrew Parsons
10-22-2009, 04:50 AM
Hello all,
·
I would like to first say I am new to basic stamp, but I already love working with it. I just finished what’s a micro controller with relatively good success. Anyways before I go on to my questions please bear with me as I attempt to catch you up on my hobby of building ROVs for the last 5 years. My ROV have come along way with from my first ROV (t1a) which was a small water tight box that held servos and a drive shafts to rip around the tub and lakes. Although the t1a was fun I had to set it to neutral buoyancy. ROV t2a was quite a different looking machine using all PVC piping. T2a had external PVC battery tubes and internal bladder bags for buoyancy. T2a still used servos to control valves, motors, rudders and ECT. I created a few more ROV with little overall changes almost not enough to merit a type change. My last working ROV (t5b) made 25 meters before implosion along with most of the components. Since then I have been studying and leaning new control methods and housings. For ROV t6a I will do away with servos (manual switching) and move to basic stamps micro controllers. This move will open up a whole bunch of new options, i.e. temperature, pressure, humidity, pulsout motor commands to HB-25, surface video and serial rs-485 communication to the surface stamp. T6a will also not have a rudder but rather 4 top thrusters for buoyancy and 2 rear thrusters for thrust and turning. I am beginning to ramble a bit so I will cut myself short and move to the ·question.
·
I plan to use 6 HB-25 motor contollers. The 6 thrusters are made from gutted 12 volt drills with gearing left alone in order to achive slow torqe spin of the large blades. I have bought one HB-25 and gutted one of the drills but am running into problems with speeds. I know the HB-25 works one pulse out and will continue to work until a new pulse out is received. Top speed is not a problem
·
FOR index = 0 TO 250 ' Ramp Up To Full Speed
PULSOUT HB25, 750 + index ' Motor 1 Forward
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
·
Above runs the drill at top speed but if I want to run the drill at half speed
·
FOR index = 0 TO 125 ' Ramp Up To Full Speed
PULSOUT HB25, 750 + index ' Motor 1 Forward
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
·
The drill does not spin no motor noises at all, next I tried
·
FOR index = 0 TO 230 ' Ramp Up To Full Speed
PULSOUT HB25, 750 + index ' Motor 1 Forward
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
·
And still nothing.
·
Tried
FOR index = 0 TO 250 ' Ramp Up To Full Speed
PULSOUT HB25, 750 + index ' Motor 1 Forward
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
Again it works.
·
I also don’t think the engine is not ramping up as the demo code attempts.
·
Could someone please lend me a hand.
·
Sorry for the long long question.

Mike Green
10-22-2009, 05:03 AM
What you're describing and the code fragments you've posted should all work. There must be something else that's wrong. How do you have things connected and how are you powering it all?

Andrew Parsons
10-22-2009, 05:16 AM
Thank you for your quick reply.

I am using the battery from the dismatled drill which is connected to Vin and GND on the HB-25. The motor Pos term is connected to M1 and the Neg term to M2 on the HB-25. I have the J jumper on as i am only using the one HB-25 for now.

B is connected to ground and W is conneted HBpin.

Thanks for your help thus far




Post Edited (Andrew Parsons) : 10/21/2009 10:21:29 PM GMT

Mike Green
10-22-2009, 05:29 AM
That sounds correct.

I don't know why you're having problems. If it was me, I'd be checking the connections making sure they were what I thought they were and that they were secure and snug. I'd check the battery to make sure it was properly charged.

What you posted are small program fragments. Perhaps the problem is somewhere else in the program. Like I said, what you've posted seems correct ... yet it doesn't work ...

Geekgirl
10-22-2009, 06:32 AM
Which basic stamp are you using?

If it's a faster one, the PULSOUT command times differently.

To rule out motor issues,· Put some wires on a light bulb that draws some current, like an 1157 turn signal bulb and test for ramp up/down.

If that works OK, then check for isolation diodes in the motor wiring.

I did a project a while back where I used a pair of HB25s, and wanted to isolate them so that when the system was in manual/setup mode where high side drivers ran the motors directly, it wouldn't backfeed the HB25's outputs. I had blocking diodes on M1 and M2, and got the same results you are now, even though the diode polarity was correct.

I took the diodes off the negative side and bingo, it all worked properly.





Darlene

Chris Savage
10-22-2009, 08:13 AM
Also, if those code fragments are what you're using without the initialization section, that could cause problems as well.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage

Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65 (http://www.savagecircuits.com)
·

Beau Schwabe (Parallax)
10-22-2009, 02:17 PM
Andrew Parsons,

For the 'initialization section' (http://www.parallax.com/Portals/0/Downloads/docs/prod/motors/HB-25MotorController-V1.2.pdf) your program should look at the signal pin going to the HB-25 as an INPUT. When it detects a HIGH, this indicates that the HB-25 has powered up. Once this happens make the signal pin an OUTPUT and LOW followed by a 5ms pause. This will make sure that the HB-25 has initialized.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

Andrew Parsons
10-22-2009, 09:00 PM
Thank you for all your suggestions. I am·using the·BASIC stamp 2sx.·I will take a closer look at the motor and will try the same setup with a signal light when i get home.

I do have a·initialization statement which was pulled right from the sample code and is below:

' -----[ I/O Definitions ]-------------------------------------------------
HB25 PIN 15 ' I/O Pin For HB-25
' -----[ Variables ]-------------------------------------------------------
index VAR Word ' Counter For Ramping
' -----[ Initialization ]--------------------------------------------------
DO : LOOP UNTIL HB25 = 1 ' Wait For HB-25 Power Up
LOW HB25 ' Make I/O Pin Output/Low
PAUSE 5 ' Wait For HB-25 To Initialize
PULSOUT HB25, 750 ' Stop Motor 1

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

Any onther suggestions?

Post Edited (Andrew Parsons) : 10/22/2009 2:05:31 PM GMT

Andrew Parsons
10-23-2009, 05:51 AM
Okay so I got home and tested the setup using a turn signal light and ran into the same problem as i did with the motor where it only works at full.

Not even the ramp up is working. Full code below.


'·· {$STAMP BS2sx}
'·· {$PBASIC 2.5}


HB25··········· PIN···· 15············· ' I/O Pin For HB-25


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

index·········· VAR···· Word··········· ' Counter For Ramping


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

DO : LOOP UNTIL HB25 = 1··············· ' Wait For HB-25 Power Up
LOW HB25······························· ' Make I/O Pin Output/Low
PAUSE 5································ ' Wait For HB-25 To Initialize
PULSOUT HB25, 750······················ ' Stop Motor 1

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

Main:
· PAUSE 20····························· ' Wait 20 mS Before Ramping
· FOR index = 0 TO 50················ ' turn bulb on but low
··· PULSOUT HB25, 750 + index·········· ' Motor 1 Forward
··· PAUSE 20··························· ' 20 mS Smoothing Delay
· NEXT
· PAUSE 3000··························· ' Wait 3 Seconds
· FOR index = 50 TO 100················ ' turn bulb up
··· PULSOUT HB25, 750 + index·········· ' Motor 1 Forward Slowing
··· PAUSE 20··························· ' 20 mS Smoothing Delay
· NEXT
··· PAUSE 3000··························· ' Wait 3 Seconds
· FOR index = 100 TO 250·············· ' turn bulb up
··· PULSOUT HB25, 750 + index·········· ' Motor 1 Forward Slowing (this is the only one that works)
··· PAUSE 20··························· ' 20 mS Smoothing Delay
· NEXT
··· PAUSE 3000··························· ' Wait 3 Seconds
· FOR index = 250 TO 0················ ' turn off bulb
··· PULSOUT HB25, 750 + index·········· ' Motor 1 Forward Slowing
··· PAUSE 20··························· ' 20 mS Smoothing Delay
· NEXT
· STOP

Any suggestions? pelase and thanks

Beau Schwabe (Parallax)
10-23-2009, 06:09 AM
Andrew Parsons,

Your using an BS2SX ... the timing resolution of PULSOUT is 0.8us and not 2us

You need to increase all of your timing references by a factor of 2.5 i.e. 750 becomes 1875


1.0ms = 1250
1.5ms = 1875
2.0ms = 2500


Note:

The use and value of PAUSE stays the same

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

Post Edited (Beau Schwabe (Parallax)) : 10/22/2009 11:14:23 PM GMT

Andrew Parsons
10-23-2009, 06:15 AM
Worked like a charm! thank you so much!

Beau Schwabe (Parallax)
10-23-2009, 12:28 PM
Andrew Parsons,

Credit goes to Geekgirl when she first asked "Which basic stamp are you using?" - That clued me in and was the first thing I saw when you posted your code. I somehow missed your post when you said "I am using the BASIC stamp 2sx", but none the less, I'm glad you got it working.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

Steve DC
10-26-2009, 09:39 PM
I've spent 2 weeks trying to figure out why I couldn't get my HB-25 to work with my BS-2SX, is there anyway they can add a foot note or additional sample code to the documentation. While I understand the basics, electronics is my weak spot and I can only imagine how long I would of had to dig around to find the difference in clocking between an SX chip and the standard BS2..

Good thing is, I've decided to join the forums so I might not waste as much time thinking I have a wiring problem next time.

stamptrol
10-26-2009, 09:54 PM
You could also use one of the Parallax code sample templates which have the Conditional Compiling set up.

Eliminates having to remember to change the timing units.

Cheers

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk

http://www.siskconsult.com
·

Beau Schwabe (Parallax)
10-26-2009, 10:58 PM
Steve DC,

Typically example code is only written for the BS1, and BS2 as is the case for the HB-25 on page 8 of the datasheet.... www.parallax.com/Portals/0/Downloads/docs/prod/motors/HB-25MotorController-V1.2.pdf (http://www.parallax.com/Portals/0/Downloads/docs/prod/motors/HB-25MotorController-V1.2.pdf)

The time differences for critical timing commands such as PULSOUT between different BS2 flavors, in this case the BS2sx, can be found within the Basic Stamp Editor / Development System.




' {$STAMP BS2sx}
' {$PBASIC 2.5}

PULSOUT




...By highlighting the word PULSOUT and pressing F1, you can pull up information about the PULSOUT command including timing differences between the different variety of Stamps.

In this case the program was written to send a "center" servo position of 1500us which since the resolution of the BS2 is 2us this translates into a value of 750 for the BS2 ... 1500us / 2us = 750. Since the BS2sx has a resolution of 0.8us a value of 1875 needed to be used to obtain the same pulse width ... 1500us / 0.8us = 1875.
To scale the numbers in the program, all BS2 PULSOUT references needed to be multiplied by a factor of 2.5 ... 2us / 0.8us = 2.5

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

Andrew Parsons
10-26-2009, 11:11 PM
This is the most helpful forum I have ever been apart of.
Andrew

Thanks everyone

Steve DC
10-27-2009, 07:58 AM
We'll ive updated the code, but still doesn't seem to be working, does this code look correct?

I've left out portions not relavant, like variable declarations and the loop at the end that slows and stops the motor since it would be redundant.

this sees the HB25, starts the loop but motor doesn't do anything.


' -----[ I/O Definitions ]-------------------------------------------------
HB25··········· PIN···· 10············· ' I/O Pin For HB-25
LCD············ PIN···· 1
' -----[ Variables ]-------------------------------------------------------
index·········· VAR···· Word··········· ' Counter For Ramping
n9600 CON $40f0 ' Baudmode: 9600 baud
CLR CON 1
Line2 CON 192
I CON 254
' -----[ Initialization ]--------------------------------------------------
SEROUT LCD,n9600,[I,CLR]
SEROUT LCD,n9600,[" Hello World"]
PAUSE 3000
SEROUT LCD,n9600,[I,CLR]
SEROUT LCD,n9600,[" Waiting for HB25 to start!"]
DO : LOOP UNTIL HB25 = 1··············· ' Wait For HB-25 Power Up
SEROUT LCD,n9600,[I,CLR]
SEROUT LCD,n9600,[" Found HB25!"]
LOW HB25······························· ' Make I/O Pin Output/Low
PAUSE 50································ ' Wait For HB-25 To Initialize
PULSOUT HB25, 1875······················ ' Stop Motor 1
SEROUT LCD,n9600,[I,CLR]
SEROUT LCD,n9600,[" 1875"]
' -----[ Program Code ]----------------------------------------------------
Main:
· PAUSE 2000····························· ' Wait 2 seconds
· FOR index = 0 TO 600················· ' Ramp Up To Full Speed
··· PULSOUT HB25, 1875 + index
··· SEROUT LCD,n9600,[I,CLR]
··· SEROUT LCD,n9600,[DEC(index) + " " ]·········· ' Motor 1 Forward
··· 'PULSOUT HB25, 800
·· PAUSE 50
· '
· NEXT

NWUpgrades
11-04-2009, 10:51 AM
Baud rate is also different for the BS2sx. I found that out the hard way:

{$STAMP BS2}
' {$PBASIC 2.5}

SI············· PIN···· 0·············· ' serial input
FC············· PIN···· 1·············· ' flow control pin

#SELECT $STAMP
· #CASE BS2, BS2E, BS2PE
··· T1200······ CON···· 813
··· T2400······ CON···· 396
··· T9600······ CON···· 84
··· T19K2······ CON···· 32
··· T38K4······ CON···· 6
· #CASE BS2SX, BS2P
··· T1200······ CON···· 2063
··· T2400······ CON···· 1021
··· T9600······ CON···· 240
··· T19K2······ CON···· 110
··· T38K4······ CON···· 45
· #CASE BS2PX
··· T1200······ CON···· 3313
··· T2400······ CON···· 1646
··· T9600······ CON···· 396
··· T19K2······ CON···· 188
··· T38K4······ CON···· 84
#ENDSELECT

Steve DC
11-05-2009, 09:18 PM
Well after beating up the code and super duper simplifying I decided to go back and take it all apart and rewire checking everything.
It appears I had a couple issues. the biggest being that the 7.2V battery while not dead was low enough that by the time it got by the HB25 it was not enough to move the motors and relatively heavy wheels.
It occurred to me that the RC car I dismantled to build this originally ran on a 9.6V battery. I've corrected the issue by adding a second battery in parallel.
The other issues was the + and - on the HB 25 were touching the fuse post due to the larger than normal terminal connectors I used.
A pair of tin snips and that is now remedied. I'll probably create some kind of mount that allows me to connect the wires remotely from the HB25 so I don't run into that issue again. Maybe just add set of standoffs to it would be the quickest solution.

But everything works with the HB25 .... now have to add sensors and the camera

It would be nice to have the electronics and hardware done before the holidays so I can spend a little time programming it.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you need a machine and don't buy it, then you will ultimately find that you have paid for it, but don't have it" - Henry Ford