iam new in assembly language pic progrmming and i used pic 16f877a crystel frequancy is 20mhz.I write the program for adc reading (pin RA1 battery voltage )
and my problam is how check the battery voltage below 11v and 10v(ie 1f ((adc<=614)&&(adc>=408)) ).please help me?
Your code is very difficult to follow as you have used hex values instead of the supplied names.
Some suggestions,
Put the config line back in the code.
Change all the hex values to the register names.
Give cblock a value like 0x20.
Location 188h doesn't even exist!
hard ware side to iam do it sir. i used resister devider to read battery voltage .battery voltage 20v (charger on time 14v,but any problam in charger i think 20v)pic get 5v
To read 0-20V with the pic use a 27K and 9.1 K resistor (1/4 divider) across the voltage and tap the adc from the junction of the resistors.
that gives u 0-5V on the adc representing 0-20V across the divider. Then you can run your code and display the volts.
For more precision you can also use a potentiometer, get a 50K trimmer and adjust it to read 10K on one side and 40K on the other. That gives a 1/5 divider. Ground the low side pin. Hi volts on the opposing pin.
Adc from the centre pin. Your asm code may need to X5 here...a simple matter of 2 rlf and a addwf.
You need to consider the source impedance, those values are much too high - although if you're only using a single analogue input, and don't need to read it too fast, it should be OK.
Check this project: PIC-based Digital Voltmeter (DVM) :Embedded-Lab
It is a digital voltmeter project and shows how to measure an input voltage greater than 0 through a PICmicro ADC channel. If you have problem writing code in assembly, you can write in C (I am hoping that you know C).
- Raj
Check this project: PIC-based Digital Voltmeter (DVM) :Embedded-Lab
It is a digital voltmeter project and shows how to measure an input voltage greater than 0 through a PICmicro ADC channel. If you have problem writing code in assembly, you can write in C (I am hoping that you know C).
- Raj
On the spec sheet it says "suggested maximum input impedance = 10k ohms". 9.1k is cutting it darn close. If your sampling slower though this shouldn't be an issue.