控制DS1804采用8051兼容微控制器-Controlli

[09-13 17:04:14]   来源:http://www.88dzw.com  控制技术   阅读:8106

文章摘要:After power-up, there are two ways to increment or decrement the part. The first method only changes the value of the potentiometer wiper position. The second changes both the value of the wiper and writes the current value to the non-volatile register.Changing the wiper position without writing to

控制DS1804采用8051兼容微控制器-Controlli,标签:计算机控制技术,工厂电气控制技术,http://www.88dzw.com

After power-up, there are two ways to increment or decrement the part. The first method only changes the value of the potentiometer wiper position. The second changes both the value of the wiper and writes the current value to the non-volatile register.

Changing the wiper position without writing to the non-volatile register is accomplished by the following:
  1. Adjust the up/down select input to high for increment or low for decrement.
  2. Enable the chip by asserting the CS signal (active low).
  3. Pulse INC low n-1 times to in/decrement the part n times.
  4. Assert INC low again (the part in/decrements one more time on the falling edge of INC).
  5. Disable the chip by de-asserting CS.
  6. De-assert INC to complete the write.
To change the value of the wiper and write the final wiper position to the nonvolatile register, complete the following sequence:
  1. Adjust the up/down select input to high for increment or low for decrement.
  2. Enable the chip by asserting the CS signal (active low).
  3. Pulse the increment signal low n times to in/decrement the part n positions.
  4. Disable the chip by de-asserting CS.
  5. Wait 10ms for present wiper position to be written to NV register.
Another simple, useful routine stores the current value of the wiper position into the NV register. Pulsing CS low while increment remains high stores the current value of the wiper into the NV register. After CS is de-asserted, the controller should wait for 10ms to elapse for the NV register to be written with the present wiper position.

8051 Software for Controlling a DS1804

There are millions of different routines that could be used for adjusting the wiper position and writing to the NV register of a DS1804; however, the easiest method requires only four routines. These routines initialize the DS1804, increment the chip one wiper position, decrement the chip one wiper position, and write the current wiper position to the NV register. These routines are provided in Appendix A, and are called Init1804, Increment1804, Decrement1804, and WriteNVreg. The Increment1804 and Decrement1804 routines can be placed in a loop to in/decrement the DS1804 n times, and once the desired wiper location is reached it can be written to the NV register by calling the WriteNVreg routine. If it is desirable to in/decrement the DS1804 n times without writing the loop in the main program, a short routine could be written that receives n from the stack or the accumulator and implements the loop's function.

The downfall of using only four functions occurs when the overhead of selecting Up/Down and CS during each adjustment slows operation down too much for the application at hand. Thus, two additional functions are included that demonstrate in/decrementing the chip (five intervals each way) with a single selection both the direction and chip select inputs. These routines are called Increment1804x5 and Decrement1804x5.

In addition to the routines described above, three other routines reside in the software to generate timing. They are called wait16us, wt and wait3sec. These function provide a fixed 1.6µs delay, a variable delay that is selected by the values stored in R5, R6, and R7, and a fixed 3-second delay that is used in the main program.

Main Program Sequence

  1. Disables all interrupts.
  2. Toggles LED on P1.0 to signify beginning of execution.
  3. Initializes the DS1804 by setting all three DS1804 inputs high and waiting 50ms.
  4. Waits 3 seconds, toggles LED. The 3-second delay allows the power up value of the DS1804 to be read with a multi-meter, and the LED indicates when changes are occurring.
  5. Increments the DS1804 in 5 interval bursts, a total of 25 positions. A 3-second pause has been added between each of the 5-interval bursts to allow a multi-meter to monitor the changes. The LED will toggle as the changes to the wiper occur.
  6. Waits 3 seconds, toggles the LED, and decrements the DS1804 5 intervals.
  7. Writes the NV register to the current value.
  8. Waits 3 seconds, toggles the LED, and increments the DS1804 1 interval.
  9. Waits 3 seconds, toggles the LED, and decrements the DS1804 1 interval.
  10. Completes execution with an infinite loop.

上一页  [1] [2] [3]  下一页


Tag:控制技术计算机控制技术,工厂电气控制技术控制技术

《控制DS1804采用8051兼容微控制器-Controlli》相关文章