Motor Controller - Need some Help
Dear friends:
I am on a nightmare controlling my motors. Afte a very bad experience with Pololu controllers, commented earlier on this forum, I have purchased two HB-25 for my two motors.
After the wiring setup using only one motor, I have working with the code example provided on HB-25 documentation:
(this is portion of the code)
PAUSE 20 ' Wait 20 mS Before Ramping
FOR index = 0 TO 250 ' Ramp Up To Full Speed
PULSOUT HB25, 750 + index ' Motor 1 Forward
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
Running the code I get some strange behavior, because the motor begins to run· only near to the end of the loop, when the index value is about to 230. The motor start running at full speed during short period and I can´t get the Rampu Up effect.
Any suggestion or comments will be very appreciated.
Thanks a lot
merlin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my Personal Home Page:
http://darnoff.vtrbandaancha.net/
I am on a nightmare controlling my motors. Afte a very bad experience with Pololu controllers, commented earlier on this forum, I have purchased two HB-25 for my two motors.
After the wiring setup using only one motor, I have working with the code example provided on HB-25 documentation:
(this is portion of the code)
PAUSE 20 ' Wait 20 mS Before Ramping
FOR index = 0 TO 250 ' Ramp Up To Full Speed
PULSOUT HB25, 750 + index ' Motor 1 Forward
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
Running the code I get some strange behavior, because the motor begins to run· only near to the end of the loop, when the index value is about to 230. The motor start running at full speed during short period and I can´t get the Rampu Up effect.
Any suggestion or comments will be very appreciated.
Thanks a lot
merlin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my Personal Home Page:
http://darnoff.vtrbandaancha.net/
Comments
·· Since the part you posted seems to be slightly modified from the original I would suggest attaching (not pasting) the exact piece of code you are running so I can run it on my end and see what might be happening.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
' {$STAMP BS2}
' {$PBASIC 2.5}
HB25 PIN 7
index VAR Word
DO:LOOP UNTIL HB25=1
LOW HB25
PAUSE 5
PULSOUT HB25, 750
Main:
PAUSE 20
FOR index=0 TO 250
PULSOUT HB25, 750+index
DEBUG 1, DEC index
PAUSE 20
NEXT
PAUSE 3000
FOR index=250 TO 0
PULSOUT HB25, 750+index
DEBUG 1, DEC index
PAUSE 20
NEXT
STOP
I run the code using two typical DC motors, from differents brands, previously tested.
With the first motor, as I mention above, the motor start running at full speed only when the index value is near to 240 in the first For-Next cycle. Second For-Next have no effect on the motor.
Trying the second motor, the effect is even more weird: when the index value goes to 240 in the first cycle, the Stamp program interrupts the execution and begin from the start of the For-Next loop, again and again.
Pls give me some advise, I am little lost here.
Thanks in advance
merlin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my Personal Home Page:
http://darnoff.vtrbandaancha.net/
·· You wouldn't happen to be using the same power supply for both the BASIC Stamp and the HB-25 would you?· Also, how are you powering both devices?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Chris Savage (Parallax)) : 6/16/2006 3:03:00 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
Do you suspect a power issue here?
And yes, the DO-LOOP form described above working fine if you are using PBasic 2.5
Thanks and best regards
merlin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my Personal Home Page:
http://darnoff.vtrbandaancha.net/
Tks
merlin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my Personal Home Page:
http://darnoff.vtrbandaancha.net/
·· What is most likely happening is that when the motor goes to engage it draws enough current to sag the power supply.· What this happens the BASIC Stamp is browning out, and resetting.· In most cases where you would use an HB-25 you would have a separate power supply for the HB-25 from the BASIC Stamp OR you have to have the source voltage high enough that it won't reset the BASIC Stamp during peak current consumption when the voltage sags.· For example, I am using a 12V system on a robot and powering everything from that supply.· But even at peak current draw my supply never sags down below 9 volts and it would need to hit 4.8 to affect the BASIC Stamp.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
·· That is a terse way of saying, "Loop until this condition is met", without doing anything inside the loop.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
And the advantage of doing that over IF ... THEN is what, since it obviously must take up more code space?
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
·· You are correct in a sense.· One context of the command does use more program space.· What I should have done was:
Which would be the equivalent of:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I am familiar with the DO:LOOP construct but I haven't used the HB-25 and wasn't aware that it apparently provided a "Ready" signal. It just seemed odd to be looking for something FROM the HB-25. I though perhaps he actually meant to be looking for a switch closure or something...
My bad...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
Despite the interesting conversation about programming, I wish to return to the main problem I have with my two HB25 units, that is, the motor begins to run at full speed only when the counter is about 240 and the motor stops when is reached the end of the first loop. The second loop has no effect on the motor.
I have follow the advices and I have separated the power sources, giving a common ground, I have used also a 9v battery to energize the motor, and the result is exactly the same.
This is the problem here and I really I will appreciatte any guidance, due my two units works on the same way.
Thanks in advance, best regards
merlin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my Personal Home Page:
http://darnoff.vtrbandaancha.net/
·· Above you stated you were using a 9V battery and· 7V battery.· If you're using a 9V transistor battery this will provide insufficient current to run the motors and the HB-25.· I don't know what your 7V motor is.· What is it's current capacity?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
·· It's not that we're getting a "ready" signal, per se.· The HB-25 signal line is pulled high.· We can use this to detect that it's powering-up/connected.· Just a little trick since often the motor control/power is turned on after the controller in many systems.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I am using the follow powering for the robot system:
For the logical voltage I am using a 9v battery regulated via an LM7805 in order to get the 5v requeried. This voltage is applied to the BS2p.
For power voltage of motor I am using a 7v dry battery with 1Amp H. The leads of this battery are connected to the HB25 Power input terminal. Both grounds of power supplies are connected, so the whole system has only one common ground.
The servo pulse input requiered by HB25 comes from one I/O line of the BS2p
Thanks in advance
merlin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my Personal Home Page:
http://darnoff.vtrbandaancha.net/
As I posted before, I have two motors in my tests, both toys motors but one smaller than the other. The small one begins to run when the loop counter reach the 240 value. The second motor does not respond at any moment.
Thanks in advance
merlin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my Personal Home Page:
http://darnoff.vtrbandaancha.net/
I am very happy to share with you I have found the real source of this problem: it doesn't the Powering, it doesn't the code...it was the Microprocessor!!
From the very beginning on this thread I have post that I am using a BS2, wich is a major error. The fact is that I am using for my robot the new BS2px Microcontroller, but I assumed the behavior of one BS2px should be identical to one BS2...the asumption was not correct, because I have changed the BS2px for a simple BS2 and all runs in perfectly way. I have two BS2px chips, and the two experiments the errors I have posted, so I assume the difference is related to the microsprocessor.
I have read carefully the specific documentation about the BS2px and the PULSOUT command is mentioned, but I can figure out what changes has to be made on the main code to get on work this new chips. All help about this issue will be very appreciatted and thanks for all your time spended on this case.
Best regards
merlin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my Personal Home Page:
http://darnoff.vtrbandaancha.net/
·· Looks like you beat me to what I was going to say.· Now that I know you're using a BS2px I can tell you that the code won't work as listed just because the PULSOUT values are different.· If you look in the Help File it will tell you the differences and you should be able to make the changes based on that information.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I have checked the most recent Help file and I didn't find anything specifically related to BS2px regarding the Pulsout, Pulsin, Serout and Serin commands. In fact, the example used in the Help file in Pulsout is a BS2 code example, wich should be aplicable to any BS2 member family Stamps without changes.
So I guess I need "a little help from my friends" to go further in order to migrate my code from BS2 to BSpx.
Pls give me some initial guidance and I will follow for my own, thanks again.
Best regards
merlin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my Personal Home Page:
http://darnoff.vtrbandaancha.net/
·· Please update your software...The help file included with all recent version contains the following table, which does contain the information I referred to.· As you can see, the PULSOUT on the BS2sx, BS2p and BS2px has different timing from the BS2, so in fact the example code will not work for you.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I spend almost all day seeking for aditional information about the issues you have noted.
In fact, on this forum are many many post around this issue and you, support guys, had given thousand of answers about.
So at the end of my seek I have tons of info and in the meantime I have corrected some portions of my code and voil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
' {$PBASIC 2.5}
HB25 PIN 0 ' I/O Pin For HB-25
index VAR Word ' Counter For Ramping
'
[noparse][[/noparse] 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
PAUSE 1 ' 1 mS Delay
PULSOUT HB25,·750 ' Stop Motor 2 (If Connected)
' The Above 2 Lines May Be Removed
' If You Are Using Single Mode
'
[noparse][[/noparse] Program Code ]
top:
Main:
PAUSE 20 ' Wait 20 mS Before Ramping
FOR index = 0 TO 250 ' Ramp Up To Full Speed
PULSOUT HB25,·750 + index ' Motor 1 Forward
PAUSE 1 ' 1 mS Delay For Motor 2 Pulse
PULSOUT HB25,·750 - index ' Motor 2 Reverse
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
PAUSE 3000 ' Wait 3 Seconds
FOR index = 250 TO 0 ' Ramp Back Down
PULSOUT HB25,·750 + index ' Motor 1 Forward Slowing
PAUSE 1 ' 1 mS Delay For Motor 2
PULSOUT HB25,·750 - index ' Motor 2 Reverse Slowing
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
'STOP ' Use STOP To Prevent State
GOTO top
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen