projects:electronics:panelmeter

Panel Meter Interface

94 Ohms coil resistance

5K Ohm resistor @ 5V = 1mA

Pin No.SymbolFunction
1VddSupply (2.7 to 5.5V)
2CSChip Select
3SCKSerial Clock Input
4SDISerial Data Input
5LDACSync input
6SHDNHardware shutdown
7AVssAnalog ground
8VoutADACa Output

PIC Assembly Code

SPIclk	macro
	BSF		PORTC,SCK
	BCF		PORTC,SCK
endm
 
	;Setup direction
	BCF		TRISB,RB1	; RB1 as Output
	BCF		TRISC,SCL	; SDO as Output
	BCF		TRISC,SDA	; SCK as Output
 
	;Set initial pin states
	BSF		PORTB,RB1	;Chip Select, active low
	BCF		PORTC,SCK
	BCF		PORTC,SDO
 
myloop
	movlw	0xF0
	movwf	DAC,A
	movlw	0x00
	movwf	DAC+1,A
	CALL	SPIclkout
	CALL	Delay
	goto	myloop
 
; =================
; === Functions ===
; =================
SPIclkout
	BCF		PORTB,RB1	; Clear CS (Active low)
	BCF		PORTC,SDO	;	0
	SPIclk
	SPIclk
	SPIclk
	BSF		PORTC,SDO	;	1
	SPIclk
	MOVLW	0x08
	MOVWF	Temp,A
SPIloop
	BTFSS	DAC,7
	BCF		PORTC,SDO	;	0
	BTFSC	DAC,7
	BSF		PORTC,SDO	;	1
	SPIclk
	RLNCF	DAC,F,A
	DECFSZ	Temp,F,A
	goto	SPIloop
 
	MOVLW	0x04
SPIloop2
	BTFSS	DAC+1,7
	BCF		PORTC,SDO	;	0
	BTFSC	DAC+1,7
	BSF		PORTC,SDO	;	1
	SPIclk
	RLNCF	DAC+1,F,A
	DECFSZ	Temp,F,A
	goto	SPIloop2
 
	RLNCF	DAC+1,F,A
	RLNCF	DAC+1,F,A
	RLNCF	DAC+1,F,A
	RLNCF	DAC+1,F,A
 
	BSF		PORTB,RB1	; Set CS high
	return
  • projects/electronics/panelmeter.txt
  • Last modified: 2014/11/13 10:50
  • by 127.0.0.1