Hi,
I'm building an ebike.
The motor for the bike is a 24V, 250Watt brushed DC motor running off a 24V lithium battery.
I'm controlling the motor with the circuit attached.
The circuit has been cobbled together from snippets found on the net. Probably not good design practice. However, it seems to work, despite the fact it looks like a ratsnest on matrix board.
If I try this code:
the motor runs but pulses visibly.
However, using this code, the motor runs much more smoothly:
Why is this? The second piece of code has the same duty cycle and (approximately) same frequency.
Is there a recommended pwm frequency for the motor size I'm using? I'm going to control the motor speed by polling pin4 (c.3). This pin connects to a momentary switch on the bike handlebars. Each time I push the switch the motor speed increases from (for example) 10% to 50% and then to 100%. Another momentary switch connected at pin3 (c.4) resets the motor to 0% speed. I haven't figured out this bit yet. I think I'll do some reading on interrupts unless someone has a better idea.
Lastly, could my circuit be the cause of the motor pulsating? Is there anything wrong with?
Thanks in advance.
Brendan
I'm building an ebike.
The motor for the bike is a 24V, 250Watt brushed DC motor running off a 24V lithium battery.
I'm controlling the motor with the circuit attached.
The circuit has been cobbled together from snippets found on the net. Probably not good design practice. However, it seems to work, despite the fact it looks like a ratsnest on matrix board.
If I try this code:
Code:
start:
pwmout 2, 199, 400 ;50% duty at 5000Hz
goto start
However, using this code, the motor runs much more smoothly:
Code:
start:
high c.2
pauseus 10
low c.2
pauseus 10
goto start
Is there a recommended pwm frequency for the motor size I'm using? I'm going to control the motor speed by polling pin4 (c.3). This pin connects to a momentary switch on the bike handlebars. Each time I push the switch the motor speed increases from (for example) 10% to 50% and then to 100%. Another momentary switch connected at pin3 (c.4) resets the motor to 0% speed. I haven't figured out this bit yet. I think I'll do some reading on interrupts unless someone has a better idea.
Lastly, could my circuit be the cause of the motor pulsating? Is there anything wrong with?
Thanks in advance.
Brendan
Attachments
-
36.6 KB Views: 16