I have managed to control a DC motor using the pwm module on the 16f877a. I tried to vary the duty cycle and it worked flawlessly although at 20% or less duty cycle the motor would not even turn.
Now I want to control the direction of rotation of the motor based on user input. So I am using a small mechanical switch. It gets power from a 5V supply to simulate the logical high and logical low states.
So when the switch is "on" the output is a logical high or 5V. But when the switch is in the "off" state it does not output a logical low. Instead there is no measurable output what so ever... I believe logical low would be 20% to 25% of logical high. But in this case the switch output 0% in the "off" state.
Is there any alternate method I can use to perform the same or is there any modification I can make to the existing circuit to make it output a logical low?
Is it any different from a normal resistor? If I am to buy it from a shop, what do I ask the shop keeper for, so that he knows I want a 'pull down' resistor and not someother resistor? And what ohms?
It is just a resistor. Terms like pull up, pull down, and current limiting refer to the way it is used.
Use a 10K resistor between the input pin and ground, that will keep the input low as long as the switch is open. The switch goes between the input pin and +5. When the switch is closed the pin goes high.
You can also do a pull up. Use the 10K resistor between the pick input and +5. The switch is tied to ground. When you close the switch the voltage at the pin goes low.
If you get the motor to turn at 20% duty cycle you are doing well. Below that the friction and other loses use up the energy and the motor will not turn.
Are you reversing the motor with an h-bridge?
desijays said:
Hello,
Is it any different from a normal resistor? If I am to buy it from a shop, what do I ask the shop keeper for, so that he knows I want a 'pull down' resistor and not someother resistor? And what ohms?
Is it any different from a normal resistor? If I am to buy it from a shop, what do I ask the shop keeper for, so that he knows I want a 'pull down' resistor and not someother resistor? And what ohms?
hi,
You have not said which port on the PIC you have the switch, some port pins have weak internal pull up resistors that can be enabled by the program.
For a hardware resistor solution, I would suggest a 4K7 or 10K resistor, fom +5V to the port pin, if you plan to pull the port input Low.
This would give a resistor current of 1mA or 0.5mA, enough to 'wet' the contacts on most switches.
hi,
You have not said which port on the PIC you have the switch, some port pins have weak internal pull up resistors that can be enabled by the program.
For a hardware resistor solution, I would suggest a 4K7 or 10K resistor, fom +5V to the port pin, if you plan to pull the port input Low.
This would give a resistor current of 1mA or 0.5mA, enough to 'wet' the contacts on most switches.
I am using port D on the PIC. I think I'll try the hardware solution though. Are you talking about port B, when you mentioned 'some port pins have weak internal pull up resistors'?
And yes, I do follow 75%. When I try it out, I'll understand 100%.