Pages: [1]   Go Down
Author Topic: Speed control with toy motor controller  (Read 994 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am in the process of building a motorized robot.  To do so I bought a motorized toy from a local thrift shop.  It has two motors which run the wheels.  I first thought I'd have to get a motor shield to control the motors.  However, when I disassembled it I found it had motor controller circuitry and each of the two motors can be rotated forward and back by simply applying power to the board and then applying a signal to one of four input wires from the radio control module (which I removed).

So this means I can control the fwd, back, left, right movement of the toy by simply setting the state of these four control inputs.  Sounds good right?  The problem is that the speed this toy goes is way to fast for my purposes.  I need to slow it down a bit.  However, there's no speed control, it's either on or off. 

My thought was that by modulating the signal to these control inputs I can control the motor speed.  So instead of a constant "high" signal to the FWD control line I could send it a square wave.  The size of the peaks in the square wave would control the speed, i.e. wider peaks = faster speed. 

This comes to my question.  What would the code look like on the Arduino to send a signal like this out of one of the digital (or analog) outputs?  I suppose I could do some sort of looping code where a delay is adjusted shorter or longer to control the on time for the square wave.  However, this sounds a little strange to me and I was wondering if there is a function within a servo library or something similar I could use for this.

Hope this isn't too confusing.  Thanks in advance for reading!

Alex
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 5551
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am in the process of building a motorized robot.  To do so I bought a motorized toy from a local thrift shop.  It has two motors which run the wheels.  I first thought I'd have to get a motor shield to control the motors.  However, when I disassembled it I found it had motor controller circuitry and each of the two motors can be rotated forward and back by simply applying power to the board and then applying a signal to one of four input wires from the radio control module (which I removed).

So this means I can control the fwd, back, left, right movement of the toy by simply setting the state of these four control inputs.  Sounds good right?  The problem is that the speed this toy goes is way to fast for my purposes.  I need to slow it down a bit.  However, there's no speed control, it's either on or off. 

My thought was that by modulating the signal to these control inputs I can control the motor speed.  So instead of a constant "high" signal to the FWD control line I could send it a square wave.  The size of the peaks in the square wave would control the speed, i.e. wider peaks = faster speed. 

This comes to my question.  What would the code look like on the Arduino to send a signal like this out of one of the digital (or analog) outputs?  I suppose I could do some sort of looping code where a delay is adjusted shorter or longer to control the on time for the square wave.  However, this sounds a little strange to me and I was wondering if there is a function within a servo library or something similar I could use for this.

Hope this isn't too confusing.  Thanks in advance for reading!

Alex


Basically, just use PWM control via analogWrite() - note that only certain digital i/o pins can be controlled via analogWrite() - so review the Ardunio docs...
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Basically, just use PWM control via analogWrite() - note that only certain digital i/o pins can be controlled via analogWrite() - so review the Ardunio docs...

Thanks, that's just what I needed.  I knew there was something like that out there.
Logged

Pages: [1]   Go Up
Jump to: