circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

Issue 102 January 1999
The PCL3013 Step/Servo Motor Controller in Action



WHAT CAN THE PCL3013 DO?

A lot. I wasn’t able to test everything, but more on that later.
This device has a large number of dedicated I/O lines to support more than the typical switches associated with a motion stage. For example, slow-down switch inputs help prevent the high-speed end-of-travel crashes that happen even when end-of-travel limit switches are present.
The amount of general-purpose I/O varies, depending on the bus width of the micro. Since the ’HC11 bus is 8 bits wide, the 8 bits that would otherwise be used to support a 16-bit bus become general-purpose I/O. There are three other general-purpose I/O lines.
Now it’s time to generate some code and exercise this device a little. But first, I want to say a word about notation.
When referring to registers in this device, they are specified by number (e.g., R1 for register 1). Many registers have preregisters that hold data until a start command is issued. Then the data is transferred to the working register.
First, decide what mode you wish to operate in. Four bits in the operation mode buffer are dedicated to mode. In this case, I wanted to do some simple jogging just to get started. The PCL3013 jogs when in continuous mode 1, and the direction is defined by another bit in the operation mode buffer.
Initially, I tried loading only R1 (FL pulse rate register) with a the low-speed stepping rate and R4 (multiplication factor register) with a suitable multiplier. This technique works, but only out of reset. If it was stopped, it wouldn’t start again until it was reset.
The manual cautions you to keep the high-speed stepping rate R2 (FH pulse rate register) larger than R1. Since I wasn’t using R2, I didn’t think it needed to be loaded. But as soon as I loaded a valid number into it, the unit worked fine.
With data in both R1 and R2, I was able to use two of the seven start commands. Sending 10h to the command register results in low-speed jogging at the rate determined by R1 (and R4), and sending 11h results in high-speed jogging at the rate determined by R2 (and R4). The ’HC11 code used to do this jogging test is shown in Listing 1.

Listing 1This code tests the ability to operate the PCL3013 in continuous mode 1. After executing the code, start commands 10h and 11h and the immediate-stop command 9h may be issued from the monitor program.

Once the ’HC11 has written into the appropriate registers, I used the monitor program to send start and stop commands. Although there are three different stop commands, for this test, the only valid one is 9h, which produces an immediate stop.
A small note regarding code is appropriate here. For the features of the PCL3013 discussed in this section, code was created and the feature exercised. Because the feature is of more concern than the code, I only provide you with one example (see Listing 1). In the following section, I’ll discuss features that were not exercised.
If a value is loaded into R3 (acceleration/deceleration rate register), you can make starts using 13h. Now the motor accelerates linearly with the acceleration time determined by a formula involving R1, R2, R3, and the 19.66-MHz clock.
By using a fairly large value in R3 and the existing numbers in R1, R2, and R4, I was able to get an acceleration time in the 2-s range. When the motor started, it was clearly accelerating. Similarly, when the Ah stop command was used, the deceleration was obvious.
This unit has the ability to do S-curve acceleration as well. The choice between linear and S acceleration is made with a bit in the control mode buffer.
When a comparison was made using the two types but keeping the same acceleration time, I couldn’t tell the difference by just watching and listening to the motor start and stop. The difference has to be more noticeable when the motor is driving a motion stage.
Two flavors of relative moves are available: preset mode 1 and 2. In preset mode 1, the relative move distance is loaded into R0 (output pulse register) as an unsigned number from 0 to 268,435,455. The move direction is established by bit 4 of the operation mode buffer.
In preset mode 2, the relative move distance is again loaded into R0 but this time as a signed number from
–134,217,728 to 134,217,727. Bit 4 of the operation mode buffer has no effect on this mode.
Using either of the relative move modes, you can issue multiple start commands, causing multiple moves as would be expected when making relative moves. Actual position is kept in R9 (up/down counter register), and it too can be configured to use signed or unsigned values by toggling bit 28 of R6 (environmental condition register 1). As I said, this is a powerful device and it has lots of registers.
To make absolute position moves, use preset mode 3. If multiple start commands are issued after a move, they are ignored as expected since the device is in the desired position after the first move command.
If your application requires time delays, the PCL3013 can do that too by selecting the timer mode in the operation mode buffer. The description of this feature in the manual was difficult to understand at first because nowhere is any mention made of producing a time delay.
The PCL3013 produces a time delay based on the contents of R0 and the current stepping rate as determined by R1, R2, and R4. For example, if a low-speed start command is used, the stepping rate is determined by R1 and R4, so the delay time is based on that rate and the number in R0.
When I first looked at the manual for the PCL3013, I was surprised that there didn’t seem to be any program memory. Other devices I have used could store complete motion programs of various lengths. Eventually I learned that the PCL3013 features a different approach with similar results.
Data for the next move can be written into preregisters while the present move is in progress. On completion of the current move (which can be signaled via one of a large collection interrupt sources or determined by polling one of the many status bits), a start command can be issued for the next move. Since the necessary data is all present, only the start command needs to be written. And, you can do one better if you wish.
If bit 4 of the control mode buffer is set, the unit automatically starts the next operation if it is in "settled" status. To be settled, the registers for the next move must have had valid data written to them at some point, and a start command must have been issued prior to the current move finishing. If those conditions exist, the PCL3013 continues on to the next move as soon as it finishes the present one.
Of course, the host micro still has to keep track of what’s happening in the PCL3013. For example, it can’t write any data other than what will be used next. The PCL3013 won’t stack a collection of data to be used for several moves in advance.
Would you like to microstep? The PCL3013 is good at that, too. Select the number of microsteps per step anywhere from 1 to 256 by entering the number you want minus 1 into bits 24 to 31 of R7 (environmental condition register 2).
I didn’t use a microstepping drive to test this. Using a 100-step/rev motor and setting up for 10 microsteps per step, a move distance of 100 produced 10 revs. This calculation would be correct if a microstepping drive using 10 microsteps per step fed the motor. The only thing I found a little strange is that the PCL3013 keeps track of full steps rather than microsteps.
There are two 28-bit comparator registers, R10 and R11, which can be used in various comparison scenarios to implement tasks. For example, you can compare R10 against R0 or R9. Or compare R11 against R0 or R9. Or compare R10 and R11 against R0 or R9.
The selection between R0 or R9 is made with bit 22 of R7. By setting bits 20 and 21 in R7, you can change the low- and high-speed stepping rates when the comparison condition is met. I tested this by doing on-the-fly speed changes. It works fine.
The comparison condition is specified in bits 16–19 of R7. Here’s where you indicate that the comparison is equal to, less than, or greater than the specified counter value.
You also indicate here if the comparison uses just R10, just R11, or both. If you wish, you can produce a hardware interrupt as a result of a comparison condition being satisfied.
Of course, I saved the best for last. In continuous mode 2, pulses from an external encoder can be used to cause the motor to step. When I read about this feature, my first thoughts were about slaving one system to another or electronic gearing.
Oddly, the manual discusses this feature under the manual pulser input heading. I tested it using a manually rotated encoder to cause motor movement. If the pulse rate from the external encoder exceeds the high-speed stepping rate established with R2 and R4, operation becomes erratic. But, the manual warns that this will happen.
A variation on this feature is implemented with preset mode 4. Here, an absolute position is moved to by rotating an external encoder. No matter which way the encoder is rotated in this mode, the motor moves toward the absolute position specified as long as the encoder is producing pulses.