PIC877A +Assembly+Voltage measurment ! Help Reqd!

Status
Not open for further replies.

UroBoros

pic877a

Hai

I want to measure 0 to 50Volts DC using ADC of PIC877A
Using Assembly!

Please suggest the easiest way to avoid complex mathematical libraries.

Any examples?

Thanks
Picstudent

metal

Full Member level 6

Hello

Me too, but using PICBasic Pro

IanP

asm. measure 0 volt

First of allyou have to reduce the range from 0-50 to 0-5. This can be done by a 2-resistor voltage divider.
PIC has 10-bit ADC so each bit will "weight" 4.883mV, and because the input was devided by 10, you will have to multiply this result by 10. So each bit in practice wille equal to 48.83mV.
If you have enough room in program memory you can create a look-up table for all 1024 combinations and just read the value in volts from that table.
If not, you will have to implement multiplication by 48.83 ..
Regards,
IanP

UroBoros

Points: 2

C-Man

voltage mearument

In theory you need a 9 : 1 voltage divider to measure 50 V. 50 / 10 * 1 -> 5V also take into account that the PIC ADC's need a low input impedance so you will need an opamp as a buffer.

The ADC has 10 bits resolution which gives a maximum value of 1024.

If you do a little "trick" with the voltage divider by using 9 * 1.024 : 1 divider you get a very easy to obtain ADC result ...

So using 92 K (82K + 10K) : 10 K and using the left justified result of the ADC (which is nothing more than getting the result * 64) and simply "dividing" this result by 128 (7 times shift to the right) should result in 500 (exactly 501.47 ...) as your result you can use a potentiometer of 220 ohms in series to the 92K resistor to "fine tune" your result.

hope this helps and best regards

UroBoros

Points: 2

UroBoros

pic877a

hai
Thanks for the suggession.

Each division is 48.83 mv .Upto that it is ok.

For look uptable of 1024 locations some setting with PCLATH is required .For long tables. I have seen a document somewhere about that. Can you provide link for that?
look up table can return 8 bit data only. Please elaborate witin your time constraints. or any example links?

How to multiply by 48.88? until now in similer situation I will multiply by 488 and discard or round the last digit! and l place decimal points( With loss of accuracy).
But hw to do it precisly? Floating point?

PIcstudent

IanP

assembly implement multiplication

As the result will can be displayed as 19.99V, the lookup table will be 4 * 1024 bytes long, so for each 10-bit value after conversion you will read 4 consecutive bytes from the lookup table ..
The beauty of a lookup table is that not only you don't need to use multiplication but you don't need to convert from binary to decimal (in case you would like to display the value in the latter format).

This PIC has 14.3kB of Flash and that is more than you need.

I don't think there is "floating point" maths available ..

Multiplication can be realized by adding the same number for as many times as required .. but if you go this way you will also need division and, possibly, binary-decimal conversion..

Regards,
IanP

UroBoros

Points: 2

metal

Full Member level 6
pic voltage measurment

Hello

Thanks for te info you have provided, any way, does any body has any idea of how to implement the previous solutions using PICBasic Pro compiler.

Thanks

Status
Not open for further replies.