DC Motor Speed

Simo7007

New Member
Novis question:confused:

If I want to control the speed of a DC motor, slow, fast. What switch/dial do I use to regulate the power so I can slow it down?
 

nick12ab

Senior Member
A common approach is to use a MOSFET or transistor. This MOSFET/transistor is then controlled using the pwmout command to set the speed.

If it is desired to be able to make the motor rotate the other way then a H-bridge can be used. A H-bridge can be made from 4 individual transistors or a motor driver like the L293D can be used.

Remember that the speed of a DC motor isn't regulated - if you need to regulate the speed then a regulated motor like a stepper or three-phase motor can be used or you can use a rotary encoder connected to the DC motor to measure the speed then adjust the PWM duty cycle to reach the desired speed.
 

Simo7007

New Member
I have wrote a code
Code:
symbol motor = 1symbol analogport = 4
symbol analogreading = b0
symbol offperiod = b1


    do
        readadc analogport, analogreading
        analogvalue = analogvalue / 20
        high motor
        pause analogvalue
        low motor
        offperiod = 12 - analogvalue
        pause off-period
    loop
But, I get an error,

Code:
  analogvalue = analogvalue / 20  ^


Error: Unknown symbol - analogvalue
 

Dippy

Moderator
Have you declared "analogvalue" ?
If you haven't then the PE is simply letting you know that it doesn't know what "analogvalue" is...

As to the rest of your novice query... you haven't really supplied us with any proper context.
Post your schematic and post your complete code.
Then the rest of us can see what this "switch" and/or "dial" is.
 
Top