Shop OBEX P1 Docs P2 Docs Learn Events
Example of external input to Propeller for PWM control — Parallax Forums

Example of external input to Propeller for PWM control

Hello,

Anyone know of any examples for the Propeller for "external input to Propeller for PWM control"?
I need to know how to setup/configure/construct the Propeller to accept and use the "control input"
to vary the PWM width.

I did search the site first: (PWM control, external PWM control, external hardware PWM control).

Thank You

Comments

  • jmgjmg Posts: 15,140
    bteddy wrote: »
    Anyone know of any examples for the Propeller for "external input to Propeller for PWM control"?
    I need to know how to setup/configure/construct the Propeller to accept and use the "control input"
    to vary the PWM width.

    More info would help.
    What exactly is "control input", and what PWM Frequency/Duty range/granularity (step size) do you need ?
    There are Prop examples for servo-PWM, and more general PWM examples in OBEX

    This may help ?
    http://obex.parallax.com/object/480 PWMx8 Provides up to 8 channels of fast PWM output per cog, generated by the Propeller's video circuitry.
    http://obex.parallax.com/object/755 Inverter (ie 3-phase) PWM generator for driving AC motors.
    http://obex.parallax.com/object/794 PWM_32_v4 - Control up to 32 independent PWM signals.
    http://obex.parallax.com/object/244 Frequency Synthesis/PWM X8: up to eight from 1 cog. single outputs can stably reach as high as 842KHz.
    http://obex.parallax.com/object/243 Frequency Synthesis/PWM X31 output can stably reach as high as 320KHz. maximum frequencies Max-Hz ~ 4000 * MHz / channels.


  • Sorry, I am new to this so the vocabulary is not there.

    I have a stepper motor I need to control by Propeller.

    The Propeller is to provide signals for direction of steps, # of steps, speed of steps in (full step, half step, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256) done by PWM.

    PWM will vary width of pulses by signal from hardware constant current-chopper, current derived from half-bridges.

    dm6In.png

    Thanks
  • jmgjmg Posts: 15,140
    edited 2019-05-27 06:25
    bteddy wrote: »
    .. The Propeller is to provide signals for direction of steps, # of steps, speed of steps in (full step, half step, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256) done by PWM.

    PWM will vary width of pulses by signal from hardware constant current-chopper, current derived from half-bridges.
    If your chopper is already a constant-current design, that sounds like it needs an Analog drive signal, which sets the chopper reference level.
    Thus you need the Prop to generate Analog Sine and Cosine signals, of varying step rates. What step rates do you need ?

    A search does find this
    https://forums.parallax.com/discussion/136061/code-to-do-1-16th-microstepping-with-a-propeller
    https://forums.parallax.com/discussion/136024/doing-microstepping-with-the-propeller
    https://forums.parallax.com/discussion/137283/blog-software-based-microstepping-driver

    and maybe this ?
    https://forums.parallax.com/discussion/comment/1463505/#Comment_1463505

    http://forums.parallax.com/discussion/121470/a-sine-wave-dds-in-pasm-comments/p1
    some scope shots here
    https://forums.parallax.com/discussion/comment/902674/#Comment_902674

    and this looks quite mature/optimised example, from Beau
    https://forums.parallax.com/discussion/comment/1105768/#Comment_1105768
  • OK, I think I am missing something.

    From what I have read, the circuit (in my second post) only reads the voltage from the "current sense" resister and compares it to a reference voltage.

    The output (ramp wave) from it (the current sensing circuit) is feed into PWM to control the pulse width, which in turn controls the current.
    Concept-of-Generation-of-PWM-signals.png

    swmp-scheme-for-proposed-spwm-method.jpg?resize=564%2C369&ssl=1

    The Propeller will generate stepped Sine/CoSine from step/dir input and the input from the (current sense) circuit.

    Which is what I need to know how to configure/setup.
    The output from the "current sense" circuit goes where?

    What is done with the signal in the Propeller?

    Thank you

  • jmgjmg Posts: 15,140
    bteddy wrote: »
    The Propeller will generate stepped Sine/CoSine from step/dir input and the input from the (current sense) circuit.
    Not quite.
    Yes, the Propeller can `generate stepped Sine/Cosine from step/dir input`, and that feeds what you call Reference Voltage above. This defines the desired motor pole current.
    However, the sawtooth/triangle does not come from the Prop at all, usually that would be from a current a tracking schmitt, and that sawtooth is the inductor ripple current.
    Examples are here
    http://homepage.divms.uiowa.edu/~jones/step/current.html
  • OK, you just said what I said, except.
    The sawtooth comes from the timer in the Propeller which should be turned on/off by the "current sense" circuit OR when the timer matches the output compare register (value set by "current sense" circuit). (How?)
    "In the simplest PWM mode, the timer repeatedly counts from 0 to 255. The output turns on when the timer is at 0, and turns off when the timer matches the output compare register. The higher the value in the output compare register, the higher the duty cycle. This mode is known as Fast PWM Mode.
    The following diagram shows the outputs for two particular values of OCRnA and OCRnB. Note that both outputs have the same frequency, matching the frequency of a complete timer cycle."

    pwm2.gif
  • Under "Overview of the Constant Current Drive System"
    https://www.avrfreaks.net/sites/default/files/vexta_5_phase.pdf

    The section on the right is what I am talking about.

    The block diagram labeled "pulse-width control circuit" is what I am trying to do.
  • kwinnkwinn Posts: 8,697
    edited 2019-05-27 13:05
    The PWM pulse coming from the comparator in your third post is the feedback signal to the Propeller. You can use the Prop counter to measure the pulse width and use that for controlling the Prop output PWM signal.

    Edit: Just make sure that signal is 3.3V or current limited to protect the Prop input pin.
  • Pulse coming from the comparator in your third post is the feedback signal to the Propeller. You can use the Prop counter to measure the pulse width and use that for controlling the Prop output PWM signal.

    Great, I have seen lots of examples of PWM to create wave forms but none showing (that i see/understand) showing Propeller generating wave form controlled by external signal.

    Please, (hardware and software) Examples of:

    "Pulse coming from the comparator is the feedback signal to the Propeller."

    AND

    "Use the Prop counter to measure the pulse width and use that for controlling the Prop output PWM signal."


    Thank you
  • jmgjmg Posts: 15,140
    bteddy wrote: »
    Under "Overview of the Constant Current Drive System"
    https://www.avrfreaks.net/sites/default/files/vexta_5_phase.pdf

    The section on the right is what I am talking about.

    The block diagram labeled "pulse-width control circuit" is what I am trying to do.

    Your linked pdf says this :
    "The current flowing to the motor windings, detected as a voltage through a current detecting resistor, is compared to the reference voltage. Current control is accomplished by holding the switching
    transistor Tr2 ON when the voltage across the detecting resistor is lower than the reference voltage (when it hasn't reached the rated current), or turning Tr2 OFF when the value is higher than
    the reference voltage (when it exceeds the rated current), thereby providing a constant flow of rated current"

    Notice that is a closed loop control system, that only needs a single input, the reference voltage.

    If you want to microstep, that would be at least sine + cosine and two copies of this feedback circuit (or more, depending on your motor choice, that document also mentions pentagon drive, or 5 sources).

    It is not necessary or required that the Prop read the drive into Tr2, as the waveform Voltage - Current Relationship in Constant Current Chopper Drive shows that self-regulates.
    You might decide to check that, if you wanted to confirm circuit operation in diagnostic code, but it is not needed for the control loop operation.

    Usually you buy a stepper driver that has the current/voltage rating suitable for your motor.
    One example ±1.5 A 50 V.
    https://www.allegromicro.com/en/Products/Motor-Driver-And-Interface-ICs/Brush-DC-Motor-Drivers/A4973.aspx
    Note this says
    The peak load current limit is set by the user’s selection of an input reference voltage and external sensing resistor. The fixed off-time pulse duration is set by a user-selected external RC timing network.
    It gives a sense pin max of 0.5V, and a Ref Pin range of 0V~1.0V, and a gain of 2.0
    Thus you scale the sense resistor for 0.5V at full scale current, and you need provide a 0..1V ranged sine & cosine signal to 2 or more of these drivers.
  • OK, again my question is about the Propeller nothing else.
    Everyone wants information for everything outside of my question and are explaining
    those things and ignoring the question.

    There is an output from a comparator (How it does it, why it does it. Is irreverent.) IT goes to the Propeller (GPIO). It is used to turn the SPWM waveform on and off to vary the average on time(duty cycle) to make the sinewave look like this(the stepped sine):
    sine3.jpg

    Good note from Kwinn.
    Kwinn:Make sure that signal is 3.3V and/or current limited to protect the Prop input pin.

    my question was always only, I would like examples please, of how to take the comparator output signal on a GPIO pin on a propeller and use it to vary the width(duty cycle) of the steps of the Propeller internally generated sine wave before it leaves the Propeller. change it from a analog sine into a stepped sine
Sign In or Register to comment.