Hardware Reference
In-Depth Information
Figure 9-2. A milliampere meter showing 40% deflection
To get a more accurate reading, you could put a potentiometer or Trimpot in series
with a lower-valued resistor and adjust for full deflection (with GPIO set to high).
Alternatively, you could take a voltage reading of the GPIO output when set to high
and calculate the 1% resistor value needed. At the time I took the photo for Figure 9-2 ,
I measured 3.275 V when the GPIO was set high while supplying current to the
milliampere meter (through a 3.3 kW 10% resistor). Using that for the basis for
calculations, you could use a 3.24 kW 1% resistor.
Hardware Based CPU Percent-Busy Display
The same pwm command can be used as a CPU percent-busy command when started with
no command-line arguments:
$ ./pwm
CPU Meter Mode:
1.4%
The percent of CPU that is busy will be repeatedly shown on the same console line.
Simultaneously, the hardware PWM ratio is being changed. This will cause the meter
deflection to indicate the current CPU percent-busy reading. The pwm command itself
requires about 0.6% CPU, so you will never see the meter reach zero.
The CPU percent is determined in a cheesy manner, but it is simple and good
enough for this demonstration.
 
Search WWH ::




Custom Search