HB-25 w/ Propeller Issues [Revised name]
John Board
Posts: 371
Hi.. I'm back - with my new HB-25's and my robot... and my dreaded motors....
Yeap, even with the fancy-pants HB's I'm still having trouble, I believe it is to do with the code
Some pics are attached anyway.
So, I'm using the demo board which is connected to mains power. I've got the motor driver connected to my battery (7.4v, 3.6AH) and I have connected the grounds. I am using a multimeter to check the voltage, I have no motor connected to the driver. I am aiming to get my code to get the output voltage around the 1.5v - 3.3v.
1. How can I achieve this
2. What have I done wrong in my code/wiring
3. Help!
Thanks for helping my constant stream of questions,
John
[Edit] This is some new code I've tried, it looks promising, but it always goes from 0v to 8v, I need it to go from 0v to 3v (or less)
Driver:
Demo:
EDIT 2:
G'day,
I would just like to note that I believe I copied some of this code from another person's source which may have been covered by the MIT license, and since I removed the MIt license before, I wish to edit the post to have it in now.
Yeap, even with the fancy-pants HB's I'm still having trouble, I believe it is to do with the code
Some pics are attached anyway.
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 UpperLimit = 2100 'Set Maximum allowed pulse width LowerLimit = 900 'Set Minimum allowed pulse width '910 is full bore one way '2090 is full bore the other way '1600 is stop pub start repeat pulsout (0,2100) 'pin & speed,direction 900-2100 PRI PULSOUT(Pin,Duration) | ClkCycles Duration := LowerLimit #> ||Duration <# UpperLimit ClkCycles := Duration * (clkfreq / 1_000_000) - 1050 dira[pin]~~ waitcnt(ClkCycles + cnt) outa[pin]~~ waitcnt(ClkCycles + cnt) outa[pin]~ { [COLOR=#000000][FONT=sans-serif]MIT LICENSE[/FONT][/COLOR] [COLOR=#000000][FONT=sans-serif]Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:[/FONT][/COLOR] [COLOR=#000000][FONT=sans-serif]The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.[/FONT][/COLOR] [COLOR=#000000][FONT=sans-serif]THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.[/FONT][/COLOR] [COLOR=#000000][FONT=sans-serif]}[/FONT][/COLOR]
So, I'm using the demo board which is connected to mains power. I've got the motor driver connected to my battery (7.4v, 3.6AH) and I have connected the grounds. I am using a multimeter to check the voltage, I have no motor connected to the driver. I am aiming to get my code to get the output voltage around the 1.5v - 3.3v.
1. How can I achieve this
2. What have I done wrong in my code/wiring
3. Help!
Thanks for helping my constant stream of questions,
John
[Edit] This is some new code I've tried, it looks promising, but it always goes from 0v to 8v, I need it to go from 0v to 3v (or less)
Driver:
{ } CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 UpperLimit = 2100 'Set Maximum allowed pulse width LowerLimit = 900 'Set Minimum allowed pulse width HoldTimeM1M2 = 1500 'Minimum Hold time from Motor1 to Motor2 HoldTimeM2M1 = 5500 'Minimum Hold time from Motor2 to Motor1 VAR long cog,HB25_Stack[20] long Motor1WidthNew,Motor1WidthOld,Motor1WidthTemp long Motor2WidthNew,Motor2WidthOld,Motor2WidthTemp long Motor1Rate, Motor1RateTemp long Motor2Rate, Motor2RateTemp PUB stop 'Stop HB25 motor controller if started if cog cogstop(cog) PUB start(Pin) 'Start HB25 motor controller cog := cognew(HB25(Pin),@HB25_Stack) PUB SetMotor1(Motor1WidthNew_) 'Note: A negative Width value indicates Ramp mode Motor1WidthNew := Motor1WidthNew_ ' A positive Width value indicates Immediate mode PUB SetMotor2(Motor2WidthNew_) 'Note: A negative Width value indicates Ramp mode Motor2WidthNew := Motor2WidthNew_ ' A positive Width value indicates Immediate mode ' A "Zero" Width value deselects Motor2 PUB SetMotorS(Motor1WidthNew_,Motor2WidthNew_) SetMotor1(Motor1WidthNew_) SetMotor2(Motor2WidthNew_) PUB SetRamp(Motor1Rate_,Motor2Rate_) 'Note: A negative Rate value will cause the motor to Motor1Rate := Motor1Rate_ ' exponentially ramp. A positive Rate value will Motor2Rate := Motor2Rate_ ' cause the motor to linearly ramp. PUB Pulse(Pin,Motor1Width_,Motor2Width_) PULSOUT(Pin,Motor1Width_) 'Send first Pulse (Motor 1) If Motor2WidthTemp <> 0 Pause(HoldTimeM1M2) 'If Motor 2 selected wait minimum hold time between motor 1&2 PULSOUT(Pin,Motor2Width_) 'If Motor 2 selected send second Pulse (Motor 2) Pause(HoldTimeM2M1) 'wait minimum hold time between motor 2&1 PRI HB25(Pin) repeat '---------------------------------------------Motor 1 Ramp logic-------------------------------------------- If Motor1WidthNew < 0 if ||Motor1WidthNew <> Motor1WidthOld if Motor1Rate < 0 'Detect Proportional Rate mode... Motor1RateTemp := (||(||Motor1WidthNew - ||Motor1WidthOld))* ||Motor1Rate Motor1RateTemp /= ((UpperLimit - LowerLimit)/2) else '...or Linear Rate mode Motor1RateTemp := Motor1Rate Motor1RateTemp := 1 #> Motor1RateTemp if ||Motor1WidthNew > ||Motor1WidthOld 'Detect Width increase... Motor1WidthOld += Motor1RateTemp else '...or Width decrease Motor1WidthOld -= Motor1RateTemp Motor1WidthTemp := Motor1WidthOld else Motor1WidthTemp := Motor1WidthOld := Motor1WidthNew '---------------------------------------------Motor 2 Ramp logic-------------------------------------------- If Motor2WidthNew < 0 if ||Motor2WidthNew <> Motor2WidthOld if Motor2Rate < 0 'Detect Proportional Rate mode... Motor2RateTemp := (||(||Motor2WidthNew - ||Motor2WidthOld))* ||Motor2Rate Motor2RateTemp /= ((UpperLimit - LowerLimit)/2) else '...or Linear Rate mode Motor2RateTemp := Motor2Rate Motor2RateTemp := 1 #> Motor2RateTemp if ||Motor2WidthNew > ||Motor2WidthOld 'Detect Width increase... Motor2WidthOld += Motor2RateTemp else '...or Width decrease Motor2WidthOld -= Motor2RateTemp Motor2WidthTemp := Motor2WidthOld else Motor2WidthTemp := Motor2WidthOld := Motor1WidthNew Pulse(Pin,Motor1WidthTemp,Motor2WidthTemp) PRI PULSOUT(Pin,Duration) | ClkCycles Duration := LowerLimit #> ||Duration <# UpperLimit ClkCycles := Duration * (clkfreq / 1_000_000) - 1050 dira[pin]~~ outa[pin]~~ waitcnt(ClkCycles + cnt) outa[pin]~ PUB Pause(Duration) | ClkCycles ClkCycles := ||Duration * (clkfreq / 1_000_000) - 1050 waitcnt(ClkCycles + cnt) { [COLOR=#000000][FONT=sans-serif]MIT LICENSE[/FONT][/COLOR] [COLOR=#000000][FONT=sans-serif]Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:[/FONT][/COLOR] [COLOR=#000000][FONT=sans-serif]The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.[/FONT][/COLOR] [COLOR=#000000][FONT=sans-serif]THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.[/FONT][/COLOR] [COLOR=#000000][FONT=sans-serif]}[/FONT][/COLOR]
Demo:
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ HB25 : "HB-25" PUB Demo HB25.SetMotorS(1500,1500) HB25.SetRamp(-20,20) HB25.start(0) HB25.Pause(4000000) repeat HB25.SetMotorS(-2000,-2000) HB25.Pause(4000000) HB25.SetMotorS(-1500,-1500) HB25.Pause(4000000) { [COLOR=#000000][FONT=sans-serif]MIT LICENSE[/FONT][/COLOR] [COLOR=#000000][FONT=sans-serif]Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:[/FONT][/COLOR] [COLOR=#000000][FONT=sans-serif]The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.[/FONT][/COLOR] [COLOR=#000000][FONT=sans-serif]THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.[/FONT][/COLOR] [COLOR=#000000][FONT=sans-serif]}[/FONT][/COLOR]
EDIT 2:
G'day,
I would just like to note that I believe I copied some of this code from another person's source which may have been covered by the MIT license, and since I removed the MIt license before, I wish to edit the post to have it in now.
Comments
0.0
*2 seconds later*
8.0
-Looping-
In my mind it should go something like this:
0.0
0.1
Because the pulse width is going from 1500 (Halt) to 1510..
Here is the code:
-John
That way they won't see more than about 4V each, so you won't damage them.
John
[Edit] New idea, I've got a big daddy motor that I can hook up, it will be able to cope with the high voltage, and it won't burn out the drivers because the drivers are rated at 25A and the motor draws about 1-2 amps.
-John
Err, I'd be rather nervous doing any project that had hardware that could throw 8V into 3.3V motors, and only the Magic Software Fairies were preventing that from happening ??
A "50% hardware watchdog" should be easy enough - a FF and a monostable ?
Hmm, thanks, but I got it working never the less It feels great, finally I can press forward and start work on the logic!
-John
BTW: Forum etiquette (perhaps even the rules) would really require that you choose a thread title that bears directly on the subject. You would agree that thread titles such as "Hi" and "Help" are not very descriptive or catalogable and neither is "It's me again...." even though some of us at this present moment understand the connection. The forum posts become a searchable (barely sometimes) database so thread titles are important.
-John
(Sorry for my somewhat sketchy schematic quality)
-John
You can change your own title anytime. Just go Edit Advanced, and the title text is an option.
I'll keep y'all posted.
When I turned the MCU and the HB on at the same time, it didn't work, when I turn on the prop, then wait for it to init, then turn in the HB's, then it works - why? And how would I fix it apart from having 2 switches on my robot, one for the motors, and one for the MCU. Also I tried turning on the HB's first, then the prop - which worked, but the motors turned really fast for about 1/4 second, then went back to the normal speed. My guess is, is that the init proccess of the chip somehow triggers the HB's - like the manual said it would.
Thanks,
John
Use two switches or one switch and a relay.
Well anyway, I figured as much, so I've got a plan to put 2 matching toggle switches on the top of the robot