This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM3358: pwm signal control

Part Number: AM3358

Beaglebone Black

SDK : ti-processor-sdk-linux-rt-am335x-evm-03.03.00.04-Linux-x86-Install.bin

Device Tree : am335x-boneblack.dts


pwm Control commands are as follows:
echo 0 > /sys/class/pwm/pwmchip0/export
echo 2000000 > /sys/class/pwm/pwmchip0/pwm0/period
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable

When the following command is executed, the PWM signal is always output.
echo 500000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle

How do I control the number of pulse output? For example, output 1 pulses at a time, or output 2 pulses at a time ??

I hope you can help me.

Thank you.

  • Hello Andre,

    FYI, SDK 3.03 is fairly old, so you might get limited support if I can't replicate your results on a more recent SDK.

    Could you clarify what you mean by "control the number of pulse output"?

    Regards,
    Nick
  • Hello Nick,

    The configured beaglebone black pin is EHRPWM1A, as shown in the figure below.

    The control commands are as follows:

    echo 0 > /sys/class/pwm/pwmchip0/export
    echo 2000000 > /sys/class/pwm/pwmchip0/pwm0/period
    echo 500000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
    echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
    The following figure shows the output of the pulse on the EHRPWM1A pin.
    It can be seen from the above figure that the pulse is continuously output.
    Now control the number of pulse outputs, output 1 or 2 pulses.   How to operate? 
    Best Regards
    Andre

  • Hello Andre,

    What are you trying to do with these pulses? If you only want to send one or two pulses, it would probably make more sense to use a GPIO or a PRU output (if precise waveforms are needed).

    The PWM is typically used in situations where you want a long train of pulses - e.g., to control screen brightness by changing the width of the pulses, or to control motor speeds. If you want to send a single pulse out of the PWM after you receive an input signal from outside of the AM335x, then you can use the trip-zone submodule within the PWMSS in order to set up that single pulse. However, off the top of my head I do not know if any examples where you would send (for example) exactly 4 pulses out of the PWM and then stop.

    Regards,
    Nick
  • Hello Nick,

    I am sorry to say that the above question is not clear.

    I want to control the stepper motor with pwm. Control principle: One pulse corresponds to one step of the stepper motor.
    For example: I output 4 pulses, the stepper motor rotates 4 steps; outputs 10 pulses, and the stepper motor rotates 10 steps.

    How can I configure the output of pwm in this case ?
    Is there any introduction to the use of the trip-zone submodule in PWMSS?

    Regards,
    Andre
  • Hello Andre,

    Ahh, ok. I think stepper motor control would be a bit complex for the PWMSS. I expect the PRU to be a better fit for your use case.

    Take a look at this High Performance Pulse Train Output (PTO) with PRU-ICSS TI Design. Note that the design is from 2015, so the exact software would probably need to be tweaked. If that project seems to be what you are looking for, feel free to post follow-up questions on this thread. There are also some older stepper motor designs for the PRU listed in PRU Projects, but note that TI does not support those designs.

    Regards,

    Nick

  • Hello Nick,

    Thanks for your advice.
    I refer to PRU-ICSS.

    Regards,
    Andre