On Sat, Oct 17, 2020 at 8:45 PM Nicklas SB Karlsson <nk@nksb.online> wrote:

>
> > The theory is that if the PWM signal is high the H-Bridge is switched to
> say turn the motor clockwise.  If the PWM signal is low
> >> the H-Bridge is switch to turn the motor counter clockwise.  Therefore
> with 50% the motor is first asked to turn one way and then
> >> the other.  That results in the motor essentially being locked in place.


The above is not the way it works.   No one would design anything like
that.   But let's say you did.  What would happen?   The motor would
vibrate and slowly rotate and have close to zero torque

There are two cases where PWM is used (1) as a control signal and (2) as a
control pin on an h-bridge

Case 1 is closest to the abve description but it is implemented
differently.  The PWM signal is used to generate an analog voltage.
Usually, the duty cycle is used to determine how long a capacitor is
charged.  But always the result is the PWN is converted to a voltage.
 Then there s a variable resistor that is used to encode the servo position
and it creates a voltage based on position.    The controller inside the
servo tries to make the voltages the same.     In no case is the mother
directly driven by the PWM.   For servo control, the PWM is used as a kind
of quasi-digital signal.

Case 2 If we are talking about Polulu motor drivers then the chips all have
control pins to place the motor in forward or reverse or brake or freewheel
modes.   You have to read the data sheet every chip uses a slightly
different convention.    Then there is another Pin called PWM   It is bet
to think of this as controlling if the power supply is connected or not.
How it is connected depends on some other pins.   You can think of PWM is
controlling the power supply voltage, but not the direction or if the
supply is even connected to the motor.

How to et this up in LCNC:

I see two different ways to go.

(1) use some kind of single-board computer like the "Blue Pill" (STM32) or
an Arduino or "whatever" as a servo controller.  It would drive the motor
to a speed as commanded by LCNC.  The motor encoders would connect to the
single board computer and  the single-board computer would run a PID loop
to control velocity.   How does LCNC communicate with the small computer?
  ANy why you like, PWM (case 1) or and analog voltage or a command sent
over a serial link such as i2c, SPI, USB, CAN bus, Ethernet, RS232,....
 I've implemented this using commands over USB many times.   The "blue
pill" is the cheapest and by far the best value and the Arduino is the
easiest to get working.  The advantage is that because the PID loop is
running on a microcontroller it can be very fast and very stable.   You can
also put the homing logic on the microcontroller

(2) the other way is a HAL module.   It could communicate with the
Polulu drive over a parallel port.  You need a pin on the port for every
pin on the driver.  A PID loo is run in HAL that controls both the
direction pins and the PWM duty cycle.    The advantage here is that you
don't need a single-board computer.  Using this method PWM duty cycle
controls motor torque but not motor direction.




-- 

Chris Albertson
Redondo Beach, California

_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to