I'm new to the forums, and new to Arduino. I'm a 3rd year Electrical Engineering Student, and I'm working on a personal project, that requires a dc motor. For this purpose, I have an LMD182000 H-bridge. I'm new to PWM, and I've got a question.
It's my understanding that the PWM input on the H-bridge controls the motor speed. The higher the duty cycle, the higher the speed. If I only want the motor to go full speed in either direction, can I simply tie this pin to an output on the microprocessor, and write it "HIGH", and then when it needs to stop, write it "LOW"? or am I trying to oversimplify this?
Thanks, I look forward to being a part of the Arduino community!
Indeed, you can modulate the pulses to unlimited width if you want. With some PWM modes (pins 3, 9, 10, 11) the extreme values 0 and 255 passed to analogWrite () are equivalent to using digitalWrite(). For pins 5,6 which use timer0 I’m not sure if that’s true as the PWM mode has 257 theoretical levels.
Its commonly the case that you want to prevent pulses that are too narrow anyhow, so you might want code like this:
#define SMALLEST 3
void myAnalogWrite (int pin, int value)
if (value < SMALLEST)
digitalWrite (pin, LOW) ;
else if (value > 256 - SMALLEST)
digitalWrite (pin, HIGH) ;
analogWrite (pin, value) ;
When controlling a big motor its much nicer to the motor and power supply to ramp up the drive though, this can reduce the peak currents considerably.