Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC877A +Assembly+Voltage measurment ! Help Reqd!

Status
Not open for further replies.

UroBoros

Advanced Member level 2
Joined
May 5, 2004
Messages
642
Helped
19
Reputation
38
Reaction score
8
Trophy points
1,298
Location
Cochin - India
Activity points
6,463
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
 

pic877a adc program

Hello

Me too, but using PICBasic Pro
 

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
    Helpful Answer Positive Rating
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
    Helpful Answer Positive Rating
pic877a

hai
Thanks for the suggession.

Please..

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?

about the other option

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
 

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
    Helpful Answer Positive Rating
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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top