Maker Pro
Maker Pro

ADC programming help

nepow

Jul 18, 2011
99
Joined
Jul 18, 2011
Messages
99
I need some help please using an ADC input to check battery charging top off levels with respect to air temperatures (compensation)
0.4 represents a measured temperature / voltage level which I move into a label NUMA placed into a defined variable register location as below

MOVLW .4 (sample voltage = 1.44v)
MOVWF NUMA
++++++++++++++++++++++++++++++++++++++++++++++++++
Further on in my program I want to retrieve the value held in NUMA and subtract it from a battery voltage level as below. I'm not sure how to go about doing this as the result I get is not as expected i.e. 0.4 represents a voltage of 1.44v but my ADC samples a result of 1.55v. I'm using PIC 12f675 and MPLAB ASM. A sample of the subtraction code shown below. My programming skills are not good so some guidance would be appreciated
Thanks in advance.

MOVLW NUMA
SUBWF BATTERY VOLT_,0
BTFSS 3,0
GOTO XXXXX
GOTO XXXXX
 

shumifan50

Jan 16, 2014
579
Joined
Jan 16, 2014
Messages
579
It is clear as mud what you are trying to do. You can not arbitrarily decide that 0.4 represents 1.44V and then observe the ADC reads it as 1.55V.
 

nepow

Jul 18, 2011
99
Joined
Jul 18, 2011
Messages
99
It is clear as mud what you are trying to do. You can not arbitrarily decide that 0.4 represents 1.44V and then observe the ADC reads it as 1.55V.
Thank you for your reply..
I'll try and explain what i'm trying to do. I'm using AN,0 and AN,1 (10 bit resolution) AN,1 input is monitoring max and min battery charge levels.. cut off point = 14.4v on the battery which is presented as 1.4v at the ADC input (decimal 0.3 in code) 14.4 volts is the recommended charge cut off point for a temperature of 20 deg C as the ambient temperature starts to rise the charge cut off has to be reduced, this is where AN,0 is going to be used by monitoring the batteries temperature and converting into a representative binary code and storing in a tempary file (Batt_Temp) I then wish to move this value into the battery cut off AN,1 and by subtraction alter the desired cut off point with respect to the batteries temperature. As the temperature rises above or below 20 degC the charge cut off point changes accordingly. I have an Oshonsoft PIC simulator which I use to test my programs, it allows me to input various voltage levels between 0v > 5v on the ADC's directly through the simulator so I know 1.4v input to AN,1 = 14.4v this is my existing program using ADC convertion with my 1.4v (0.3) level currently fixed value. So I'm looking at using AN,0 to monitor and store results in a file labeled (Batt_Temp) and then use this file within AN,1 to control the charge cut off point. I need help and advice to guide me with
programing code where I can use the results from the output file AN,0 (Batt_Temp) and put into ANA,1 so as to cut off the charge point dependant on battery temp. Lastly my bit of code posted was an example section of the method of analogue convertion I use. (numa) should read (Battery_Temp) 0.4 is the decimal equivalent of the voltage levels at AN,1 input ( 0v <>5v) Hopefully this will clarify what I'm trying to achieve. Kind Regards
 
Top