On 3/6/2010 6:18 PM, yamanoor sairam wrote: > Hello Mr. Marcel, I must thank you for your kind help. The opamp is > working perfectly. I am sorry that I didn't have prior experience > working with opamps. As you had suggested, I set a power supply of > 900mV from DC RPS as an input to the BNC connector. I adjusted the > offset voltage such that the output from pin 7 is exactly zero. When > I reduced my input to zero, the output voltage goes to 4.139V. >Hence, > I have a span of 4.139V for 900mV. My next issue is building a > program for this span. I have built a logic and I would like to know > whether it is correct. 4.139V is the 848th step in an ADC where 5V is > the reference. So the 900mV span varies in 848 steps i.e > 1.0625mV/step. > So I wrote a code as follows in mikroC. adc_value = > adc_read(0); // I am reading from AN0 converted_value = (long) > adc_value ; mv_value = 900 - (float)(1.0625*converted_value);// I am > converting it into a 0-900mV scale mv1_value = (long)mv_value; // I > am removing the decimals I am using the mv1_value to be printed on > the LCD. I am getting junk characters displayed on my LCD. Is this > the correct method to do it or is there an efficient way of doing > this at hardware level or in terms of software level. > > Sairam Your math numbers look correct - your 900mV to 0V input span produces and output span of 4.139V and your 10 bit A/D gives just over 1mV per bit. That looks correct. I don't know why the result on your LCD is wrong. Now all you have to do is find the bugs in your code! What I usually do at this point is back up to the raw a/d readings and try to output those to the display. If that works, start working through your calculation code, sending partial results to the display. Eventually you should find where the problem lies. If you still have problems, try posting at the mikroC forums. There are many very helpful people there. Good luck and let us know what you find out! -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist