'----------------------------------------------------------------- ' Copyright 1997 MCS Electronics ' this example uses library version 1.08 [14 sept 1997] '----------------------------------------------------------------- 'Application Note 3 : controlling the X9CMME 'The X9CMME is a digital potentiometer chip From Xicor http://www.xicor.com ' 'Chip pin Function '1 /INC increment input '2 U/D up/down input '3 VH potmeter high terminal '4 VSS Ground '5 VW potmeter wiper terminal '6 VL potmeter low terminal '7 /CS chip select/enable '8 VCC power (+5V) 'The chip used is the X9C103 'The chip can be used to dim a lights or a VCO or .... '----------------------------------------------------------------- Dim Pulse As Byte 'byte to hold number of pulses Dim Up As Bit 'counter direction flag Cls 'clear lcd ' ----- define aliases ----- Incr Alias P1.1 'pin 1 of IC Ud Alias P1.0 'pin 2 of IC Cs Alias P3.2 'pin 7 of IC '-------now init the chip to make sure it's value is 0 Set Cs 'disable chip Set Incr 'ready for clock pulse Reset Ud 'count down Reset Up 'count down Pulse = 100 : Gosub Sendpulse 'make sure value is 0 Do Set Ud 'count up Set Up 'set flag too Pulse = 100 '100 pulses maximum Gosub Sendpulse 'send pulses Wait 1 'wait 1 second Reset Ud 'count down Reset Up 'counting up flag Pulse = 100 '100 pulses Gosub Sendpulse 'send pulses Wait 1 'wait 1 second Loop End '-------- subroutine to send pulse to chip 'Input : pulse holds the number of pulse to generate 'Otput : none Sendpulse: Dim Count As Byte 'varianle for counter Reset Cs 'enable chip Cls 'clear lcd 'we must use a bit variable to test the direction since we can only examine 'the state of the Px.x flag if it is used as an input and we are using it as an output. If Up = 0 Then Lcd "Counting down" 'display direction Else Lcd "Counting Up" End If For Count = 1 To Pulse 'for all pulses Home Lowerline 'set cursor home at line 2 Reset Incr 'generate pulse Delay 'wait a little Set Incr 'high again Lcd "Value : " ; Count 'display value Next Set Cs 'disable chip and store value Return