05-11-2021 04:25 AM
I took over the assignment of a previous researcher. He used this pwm amplifier to precisely control the dc motor, and I would like to know what the role of this pwm amplifier is at that time. Is it a role to amplify the signal made by myrio? Before this, signal gnd, +ref in, -ref in pins were connected.
05-11-2021 04:38 AM
Hi Kim,
@KimNaParkLee00 wrote:
I would like to know what the role of this pwm amplifier is at that time. Is it a role to amplify the signal made by myrio?
Yes.
05-11-2021 09:14 AM
@KimNaParkLee00 wrote:
I took over the assignment of a previous researcher. He used this pwm amplifier to precisely control the dc motor, and I would like to know what the role of this pwm amplifier is at that time. Is it a role to amplify the signal made by myrio? Before this, signal gnd, +ref in, -ref in pins were connected.
Yes, the DC motor current draw is probably too high to be driven directly from the MyRIO.
05-11-2021 11:04 PM
@PrepaidGiftBalance wrote:
I took over the assignment of a previous researcher. He used this pwm amplifier to precisely control the dc motor, and I would like to know what the role of this pwm amplifier is at that time. Is it a role to amplify the signal made by myrio? Before this, signal gnd, +ref in, -ref in pins were connected.
The solution for your problem (keep the motor running) is not PWM, but to set pin state in correct combination. Be aware that code you use is for all-NPN transistors H-Bridge. Your circuit is built with PNP - NPN combination, thus the control is different (NPN transistor is delivering current when saturated while PNP transistor is prohibiting current when saturated).
Try modify your code like this:
if (moveServo == 37)
{
digitalWrite(resistor1, LOW);
digitalWrite(resistor2, LOW);
digitalWrite(resistor3, HIGH);
digitalWrite(resistor4, HIGH);
}
else if (moveServo == 39)
{
digitalWrite(resistor3, LOW);
digitalWrite(resistor4, LOW);
digitalWrite(resistor1, HIGH);
digitalWrite(resistor2, HIGH);
}
Note that the order is important. Set one pair to LOW first before set the other to HIGH, otherwise you'll short the circuit between function calls.
Note: You can use PWM with analogWrite() function to control motor speed, but you need to slightly modify your circuit: put additional NPN transistor before ground (collector on H-Bridge, emitter on ground), connect it's base with PWM-capable Arduino pin via a limiting resistor.