
Alton_RD_Odsep (Customer) asked a question.
I am trying to find truly comprehensive in-depth documentation and tutorials on how to use the PWM. I understand generally that you write values to certain internal registers in the device to control it. I want to see a full map of every single integer and Boolean register for the P1-04PWM, with good examples of what each one of these does, and also a proper example of how to correctly implement these into a ladder rung, what happens at the outputs when certain values are written, and examples of what I would see on an oscilloscope looking at the outputs with certain example settings.
There might be something already available, but my search-fu isn't good enough to locate it yet.
Ideally I'd like to see some good examples of using this to clock a stepper motor (connect to the step input).
If I can make it behave, especially to write to the correct tag (we old school programmers call them registers) to start and stop the pulse train, to change the frequency up and down, or if there is support to give it a pulse count (e.g. if the stepper has 220 steps per revolution and I want to quickly spin it 40 revolutions to move something back to the home position, it would output 8,800 pulses and then stop). I don't know if it supports one-shot behavior like that or not, or if there is a clean workaround.
We got one ordered to set up in the "sandbox system" to experiment with, but hopefully I can move it to the actual system and make the stepper a little simpler to control.
Worst case, I could probably use a pair of back to back cross-connected timer relays in a ladder to function like a slow oscillator, which would then just flip-flop (toggle) at so many milliseconds, and then use that to turn the steps on / off using an I/O point on the P1-15TD1 to bit-bang the clock signal out. That workaround would eliminate the PWM but provide some very precise control such as "move clockwise n steps and stop unless the home switch is encountered, then stop then".
"If I can make it behave, especially to write to the correct tag (we old school programmers call them registers) to start and stop the pulse train, to change the frequency up and down, or if there is support to give it a pulse count (e.g. if the stepper has 220 steps per revolution and I want to quickly spin it 40 revolutions to move something back to the home position, it would output 8,800 pulses and then stop)."
The PWM module is not suited for stepper positioning control, only velocity mode control.
If you want accurate positioning and to do the things you mentioned here for getting to an accurate home position then you want to use a PS-AMC# module instead of a PWM module.
To use the PWM though, use a ramp instruction with the tag for the instruction output being the tag you set in the hardware for the PWM channel. Leave Duty cycle at 50% always, since you really want frequency adjustments not pulse width adjustments. The input to the ramp is your frequency value for the PWM output (how many steps per second it should be running at). The ramp makes the frequency of the output move up and down in a smooth way so the stepper doesnt receive a sudden, jarring change and lose its magnetic field.
You can also use a scale instruction in the ladder and set it up so that the input of the scale is an RPM or other easier to use value, and the output is scaled to the necessary PWM frequency, which goes to the ramp instruction input tag.
You can use the PWM and ladder logic programming to start and stop the stepper movement, and get a vaguely accurate position. It will not be perfect or at an exact step count though, unless the stepper is moving quite slowly and your scan time remains very fast (small program).
I was thinking along the lines of using the combination of a timer and a physical home position sensor to essentially stop the stepper when the conveyor is back at its "home, ready to reload" position. Normally the stepper would be unlikely to move faster than about 120 to 300 RPM even when reversing the empty conveyor.
One trick to measure the scan time I thought of, is to intentionally structure a pair of rungs in a task that just flip a spare I/O line on and off, and then look at the output with an oscilloscope. While not really precise, it would tell me if the ladder scan time (latency) is fast enough or not to avoid excess overshoot. That could be useful to determine if "bit-banging" the stepper clock is feasible.
So the ramp input is what sets the frequency. That was what it vaguely seemed like it might be. With that in mind, I'm thinking maybe the PWM might actually be pretty useful even though the positioning is kind of coarse. In the ladder, I could specifically use a physical "home" and "overtravel limit" proximity sensor pair to just de-assert the stepper motor enable and stop it when encountered.
The stepper is actually a pseudo-stepper. It is a ClearPath SD type motor, which internally is a fairly powerful servo with its own programmable control (via a USB cable). You define a bunch of things like steps per revolution, torque and acceleration / deceleration limits, and it has a 101 page manual that details everything at that end of the system from the very fundamental basics (like how legendary Green Bay Packers coach Vince Lombardi would start off each new season with "Gentlemen, this is a football.") all the way to advanced techniques and fine-tuning for the machine's unique inertia and other parameters. Once programmed and the parameters written into its internal flash memory, you just apply power, and 24v inputs at about 1.5 ma or so for Enable, Step, and Direction.
That lets ladder logic simply turn Enable on and off to start and stop the motor, and its internal control logic can handle acceleration and braking, and even if it takes a few pulses to catch up, it won't lose its magnetic field and will eventually reach the position according to its internal position encoder that the number of steps received should have put a real stepper at.
So, for small, slow movements as it moves a conveyor to feed material, the PWM frequency could be set fairly low and a virtual timer relay in the ladder logic could move it an approximate distance and pause, based on the frequency and time delay, while the logic also monitors for other things that could affect how fast it meters material in.
Essentially the "stepper" drives a sprocket and chain that is connected to the conveyor. The device can deliver about 50 inch-pounds of torque in a form factor of a stepper with 1/10th its maximum torque. Since the conveyor can be easily moved by hand, even when fully loaded, at a speed in excess of the highest anticipated feed rate, using the enable as a start / stop control is probably going to work quite nicely.
The direction signal is pretty straightforward. So it might be practical to just leave the clock signal running from the PWM, because the stepper has its own acceleration / deceleration internal control logic, being an actual servo inside that mimics a stepper.
It might be far simpler to use the PWM as the step clock, and start / stop / reverse the motor using the direction and enable signals?