|
PWM with Measurement Computing Counter cards and Universal Library
We have implemented a PWM control using Universal Library controlling the 8254 counter chip on a PCI-DAS1200. You should be able to do the same using Softwire or Universal Library and any MCC board with a 8254 counter with three user counter channels. You could also use the 9513 counter chip boards in a similar way.
The Universal Library program simply sets up the counter channels which then run stand-alone on the board. The program needs to update one of the counter channels to change the pulse width, but having done so the counters then continue to run stand alone on the board. The program is used to initially set the counters modes, then only needs to update one counter to change pulse width. This means the PWM waveform is very solid with no jitter.
Set up
NB: We used the internal clock source as the master clock (You could use an external clock if you wished.) All the counters must be clocked by the same source. Only counter 4 of the PCI-DAS1200 can be software configured to use the internal clock. There is no direct access to the internal clock on the screw terminal panel however it is possible to access the internal clock by configuring counter 4 to use the internal clock (this is a setting which can be configured from Instacal.) The internal clock signal is then present on the OUT of counter 4, and this can be used as the main driving clock by wiring this pin to the external clock pin of the other counters. This is an indirect way for the other counters to use the internal clock.
| Counter number: | 8254 Mode: | Comment: |
| 4 | Mode 3 Squarewave | Squarewave mode just to access boards Internal clock. Internal clock is 10MHz and I set this counters COUNT register to 10 so OUT is 1MHz: seemed convenient... |
| 5 | Mode 2 Rate Generator | Gives a trig pulse at required period - this sets period of 1 PWM cycle |
| 6 | Mode 1 Hardware Retriggerable One-Shot | The length of the PWM LOW period is set by the loaded COUNT into this counter, This one shot 'LOW' pulse is triggered by the OUT of counter 4, |
Operation
1. Counter4 CLK input is driven by the Internal XTAL clock on the board (you set this connection in software in Instacal.)
2. Counter4 OUT feeds the CLK i/p of Counter 5 and 6 (you need to hard wire this- see wiring diagram.)
3. Counter 5 produces a trigger pulse periodically, you set the rate of this pulse by loading the required value into the COUNT register for this counter.
4. Counter 6 CLK input is driven by Counter 4 OUT (you need to hard wire this- see wiring diagram.)
5. Counter 6 is set to One shot mode, and it's OUT is normally high , but when it gets a rising edge i/p on it's GATE it's OUT goes LOW for a period determined by the value you have loaded into it's COUNT register.
6. The final PWM output is from Counter 6 OUT, you set the mark space ration by loading the required value into this counter's COUNT register.
7. NB: Counters 4 and 5 GATE need to be held high to enable these counters (you need to hard wire this- see wiring diagram.)
Wiring Diagram

Notes
If you would like to look at the SoftWIRE example, the latest version of SoftWIRE 5.1 can be downloaded free of charge from the Adept Scientific Downloads page:
http://www.adeptscience.co.uk/products/dataacqu/computerboards/softwire/
2.
|