Using div32 to get decimal numbers
Ladies and Gentlemen,
I have a small problem: I need to display the volume of water that is being fed by a flow transducer to PIC16F877A.The transducer outputs square pulses at 65 pulses per litre,meaning 1 pulse= 0.0154 litres.I can successfully read 65pulses/litre and display on LCD sreen.However,I need more accuracy than that,so I need to count at resolution of 1l1pulse per litre.Now the problem is the floating points.
I need help using Div32 to count and display
Thank you
Clinton
Using div32 to get decimal numbers
Thank you Alain
I'll try the coding
Using div32 to get decimal numbers
I have written the code as follows below,but the output is so fast,I think its giving me millilitres rather than litres...How do I modify it
W VAR BYTE
W1 var WORD
W2 VAR WORD
W3 VAR WORD
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
W=0
W1=0
W3=0
PAUSE 1000
MAIN:
IF PORTC.2=1 THEN
W=1
FOR W = 0 TO 65
NEXT W
W1= W1 + (W/65)
W2= ((W1 // 65) *10000)/65
W3= DIV32 100
LCDOUT 254,1
LCDOUT DEC W1, ".", DEC W3, "L"
ENDIF
GOTO MAIN