Hi , I'm new in this forum , and to the pic programming too ...
I was trying to understand a code already written by an anonymous programmer to manage an ADC of a PIC ..
But there is that part of which function that I can't understand , particularly consisting a mathematical code ...
BTW It's basically a voltmeter measuring the voltage on a connected pot or sth
Here is the program ;
--------------------------------------------------------------------------------------------------------------
TRISA=000001
TRISB=0
TRISC=0
TRISD=0
@ DEVICE pic16F877
@ DEVICE pic16F877, WDT_on
@ DEVICE pic16F877, PWRT_ON
@ DEVICE pic16F877, PROTECT_OFF
@ DEVICE pic16F877, XT_OSC
'-------------------------------------------------------------------------------
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD RWREG PORTB
DEFINE LCD_RWBIT 2
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 1
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
'-------------------------------------------------------------------------------
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 100
'-------------------------------------------------------------------------------
ADCON1=001110
'-------------------------------------------------------------------------------
HAM var word
VOLT var word
MVOLT var byte
'-------------------------------------------------------------------------------
LOW PORTB.2
LCDOUT $FE,1
PAUSE 200
'-------------------------------------------------------------------------------
START:
ADCIN 0,HAM
CTRL:
IF ADCON0.2=1 THEN CTRL
LCDOUT $FE,1," HAM =",# HAM
HAM=HAM+1
VOLT=(HAM*/ 1250)/100
MVOLT=VOLT // 10
VOLT=VOLT/10
LCDOUT $FE,$C0," VOLT=",#VOLT,",",# MVOLT
PAUSE 500
GOTO START
------------------------------------------------------------------------------------
The part that I don't understand is the code scripted as below ;
HAM=HAM+1
Volt=(ham */ 1250)/100
Mvolt=Volt // 10
Volt=Volt/10
--------------------
NOW HERE ARE MY QUESTIONS ;
1. Where does this decimal "1" come from and why do we add it to the "ham" variable
2. Where does this 1250 , 100 come from ?
3. What are these operators written as "//" and "*/"
I'd be so appreciated if you could help me with these ....
Thanks in advance ...
Bookmarks