18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Control Circuits<br />

Listing 11-2. Demonstrates gain control of op amp.<br />

10 REM A=address of output port<br />

20 A=0E400H<br />

30 DO<br />

40 FOR I=0 TO 7<br />

50 XBY(A)=I<br />

60 PRINT “Gain = ”,I<br />

70 PRINT “Press any key to continue...”<br />

80 G=GET<br />

90 DO : G=GET : UNTIL G0<br />

100 NEXT I<br />

110 WHILE 1=1<br />

120 END<br />

to output adds stability, as recommended by the LF13006/7’s data sheet. I found that the<br />

capacitor did keep the op amp’s output from oscillating at certain gain settings.<br />

<strong>The</strong> LF13006/7 also has two matched, uncommitted resistors of about 15K each, which you<br />

can use as you wish.<br />

Listing 11-2 steps through the available gains. You can verify circuit operation by connecting<br />

a signal such as a sine-wave output of a signal generator to VIN, and monitoring VOUT with<br />

an oscilloscope. To use the full range of gains, the signal at pin 3 must be quite small. For<br />

example, if your input is 100 millivolts peak-to-peak, at a gain of 128 the output is 12.8<br />

volts.<br />

Controlling a Stepper Motor<br />

Figure 11-4 shows an 8-bit output port controlling a four-phase unipolar stepper motor.<br />

Applying power to the motor’s four phases, or coils, in sequence causes the motor to turn.<br />

<strong>The</strong> port uses a 74HCT374 latch addressed at 0E400h. If you use a 74LS374, add 10K<br />

pullups to the outputs, to ensure that logic-high inputs to U3 and U5 meet the specified<br />

minimum of 3.5V.<br />

You can choose from several modes of operation for the motor, with each using a different<br />

sequence of pulses. <strong>The</strong> frequency and sequence of the pulses determine the speed of the<br />

motor.<br />

In the circuit shown, after you write values to the port to set the speed and operating mode,<br />

the motor continues to run automatically, using the selected parameters. This frees the<br />

<strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong> 191

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!