Voltages MORE than 5 Volts to be measured into Analog inputs?

OLDmarty

Senior Member
Hi All,

I was asked if i can use a picaxe to monitor that status of a 48V power supply (and maybe also 12V and 24V supplies too)

So, my initial thought was to feed the 48V into a simple voltage divider to then present 0-5V to the picaxe analog-input.
I figured the divider to be 100K and 10K in series between 48V and GND, with the divider 'tap' at the junction of the 2 resistors to feed into the analog input.

The 48V needs to be monitored in "at least" 100mV increments, so the resulting display would show something like 47.9V or 48.2V etc.

My initial calculations for a 48V is that 48V = 480 x 100mV "steps", and that 5volts (limit of picaxe analog-input) divided by 480 = 10.4mV per 'step'.

If i average the result to a nice round 10mV per division, that means 0 to 48V under test, equates to becoming 0 to 4.8V on the Analog-input.


If all goes to plan, the resulting 0-5V data value would be sent to a 7-segment display, probably via an LM7219 7-seg SPI driver chip etc.



Am i on the right track so far? and does it seem achievable for the picaxe to resolve 10mV steps accurately? or is this a bit too fine a tolerance?

Thanks in advance,
Marty.
 

Buzby

Senior Member
Hi Marty.

If you use READADC, which returns an 8 bit value, the maximum resolution will be 48v/256, which is 0.1875v, ie. 180mV.

Using READADC10 returns a 10 bit value, giving 48/1024, make the result 0.047, ie 47mV per step.

So you can't get 10mV resolution using the basic PICAXE instructions , no matter what scaling you use.

But all is not lost !.

It is very unlikely you need to measure accurately all the way down from 48 to 0v. Much more probable is you want to measure accurately between, say, 46v to 50v, ie 2v either side of your nominal 48v.

This can be done by raising the 'bottom end' of the reference voltage that the PICAXE uses, meaning READADC10 would give a resolution of 4v/1024, which is 4mV.

Some PICAXES support this mechanism ( -Vref ), but I can't remember which, I think it's the 28X2 and 40X2.

Cheers,

Buzby
 

OLDmarty

Senior Member
Cheers Buzby, i totally overlooked the 8bit/10bit A-D possible divisions, but i do get what you mean.

I may have to go with some other option, because if the 48V goes down to say 20V or lower, we need to see what it's doing.
I'm guessing we'll have to monitor the 48V in larger steps, and if the voltage is say 42.1, it'll either show 40, 42 or 44 depending which window of my A-D data is decoding it. A ballpark indicator will probably have to do.

Something to ponder ;-)
 

Buzby

Senior Member
Hi Marty,

There are a couple of methods I can think of to achieve what you need, ie 10mV resolution over a 50v range.

An external hi-resolution ADC, connected via I2C probably.

An automatic 'range switching' system ( like an auto-ranging multimeter ), which connects the Vref pins to different sources under software control.

It may be that we could put forward better solutions if we knew a bit more as to what the application is. Is it some kind of laboratory instrument ?.

Cheers,

Buzby
 

hippy

Senior Member
I may have to go with some other option
I am not sure why you think that is the case.

With the circuit set to read 48V with READADC10 each bit of the reading will represent roughly 0.05V. That should cater for your voltage readings to one decimal place all the way from 0V to 48V.

If you wanted to read to two decimal places you would have to increase to use at least a 14-bit ADC or go to some mechanism which can adjust Vref+ and Vref- and/or switch the circuit to measure the voltage to the best resolution possible.

There is a little scope for higher resolution at lower voltages anyway. A simple divide by ten setup can measure 50V with 0.05V resolution per bit. By switching to the 2.048V reference it should be possible to measure voltages below 20V to 0.025V resolution.
 
Last edited:

Buzby

Senior Member
Hi hippy,

I've just been looking at the PIC18(L)F2X/4XK22 datasheet, and an off the wall idea has sprung into my mind.

Could the CTMU module, which is used for PICAXE 'touch', be re-jiggered to use a big fixed capacitor, and measure the time to charge it depending on a voltage ?.

If the 'trip point' was set low on the charge curve the results should be reasonably linear.

This could maybe give a better resolution, but trade off speed.

Like I said, an off the wall idea.

Cheers,

Buzby
 

OLDmarty

Senior Member
Hi Marty,

There are a couple of methods I can think of to achieve what you need, ie 10mV resolution over a 50v range.

An external hi-resolution ADC, connected via I2C probably.

An automatic 'range switching' system ( like an auto-ranging multimeter ), which connects the Vref pins to different sources under software control.

It may be that we could put forward better solutions if we knew a bit more as to what the application is. Is it some kind of laboratory instrument ?.

Cheers,

Buzby
LOL, i was just looking at a microchip 1-channel 12 bit AD chip, it uses SPI.
 

OLDmarty

Senior Member
I am not sure why you think that is the case.

With the circuit set to read 48V with READADC10 each bit of the reading will represent roughly 0.05V. That should cater for your voltage readings to one decimal place all the way from 0V to 48V.
It looks like you divided 48 by 1024 to get .05v figure.

Don't you mean the 5V (max) into the 10bit ADC is 5V / 1024 = .005V per step??


To confirm, i planned to put the 48V thru a voltage divider to get it down to 0-5V, safe for the picaxe input.
 

Buzby

Senior Member
hippy is right.

It does not matter what scaling you use, 0.05 over 0-48v, or 0.005 over 0-5v, you can't get better than V/1024.

Your 10:1 resistor divider ( 48 down to 5 ) means each step within the range 0-5 represents a 10 times bigger step in the range 0-48.

48/1024 is the best you can get without some extra hardware, no matter what resistor scaling you use to get the voltage safely into the PICAXE.

It really might give us a better grasp of why you think you need such resolution over the full 0-48 range if you explained the application.

The vast majority of PSU monitors just check that a power rail is within limits, and don't need to know anything more if it's outside the window.

Cheers,

Buzby
 

AllyCat

Senior Member
Hi,

In principle this can be done with just a PICaxe and two precision (stable) resistors*. But there are numerous complications, the first being the definition of a "Requirements Specification". ;)

So far, only "Resolution" has been mentioned, but presumably there must be some requirement for "Accuracy"? That may well determine the ultimate approach; don't forget that the PICaxe's ADC is only as accurate as its (5 volt) supply rail (or the internal "Fixed Voltage Reference", if used).

This can be done by raising the 'bottom end' of the reference voltage that the PICAXE uses,
Only to a rather limited extent, at least according to the Microchip Data Sheet. The Reference Voltage is defined as VREF = (VREF+ minus VREF-) and should be at least 1.8 volts.

* It could all be done by using "Oversampling", i.e. adding together multiple READADC10 measurements, provided that there is an appropriate amount of "noise" present. I achieved the equivalent of up to 16-bit resolution for CALIBADC and much the same techniques could be applicable to an external voltage source. Also, my investigations into improving READINTERNALTEMP showed up some "interesting" characteristics of the FVR and DAC internal modules.

Cheers, Alan.

PS: Also note that your "10 : 1" divider resistors nominally give one eleventh of the input voltage. ;)
 

OLDmarty

Senior Member
hippy is right.

It does not matter what scaling you use, 0.05 over 0-48v, or 0.005 over 0-5v, you can't get better than V/1024.

Your 10:1 resistor divider ( 48 down to 5 ) means each step within the range 0-5 represents a 10 times bigger step in the range 0-48.

48/1024 is the best you can get without some extra hardware, no matter what resistor scaling you use to get the voltage safely into the PICAXE.

It really might give us a better grasp of why you think you need such resolution over the full 0-48 range if you explained the application.

The vast majority of PSU monitors just check that a power rail is within limits, and don't need to know anything more if it's outside the window.

Cheers,

Buzby
OK, it relates to industrial gear which is VERY labourous to pull open the power supply rack for internal measurements and monitoring, and it's not always the PSU at fault when things fall over, but voltages need to be confiremd to point us into the appropriate rack gear to replace/repair etc.

48.3V the gear reboots and locks up comms to its other gear. At around 47.5 the gear halts and around 30V and 20V certain other devices start dropping their brains. i'd been asked to monitor specific voltages, and just to 1 decimal place would be fine, such as 47.5V, no need for 47.53V etc.
It's legacy military-based gear that must stay in place for the timebeing, hence my psu monitor project to make life easier all around.

Anyhoo...
 

MartinM57

Moderator
I'm with AllyCat - define the required range, resolution and accuracy properly and then you/we/the collective can do the design.

The panel meters above are 1% (if you're lucky) and no decimal places, so I can't see how they can meet the (undocumented) requirements that at least mention 1dp of volts in 50v or so i.e. 0.02% :cool:
 

OLDmarty

Senior Member
Is it just one rail you need to monitor, or are there multiple ?

Either way, it might just be simpler to buy a few panel meters like these ( https://www.ebay.co.uk/itm/Digital-Mini-DC-5-120V-Voltmeter-LED-Panel-Display-Volt-Voltage-Meter-2-wire-UK/192317167420?hash=item2cc6ff173c:m:mjE-xkApCvo153nDaMuPq8g ), and wire them in a box for all to see.
Yeh, that's an alternate, but not for this task.

I have bags of picaxes and bags of 7seg displays that negate the need to keep buying more "things" ;-)

There are multiple voltage rails to monitor on the grander scale of things, but my OP is solely about getting 48V scaled down to be picaxe friendly.

Buying alternate products also doesn't answer the question about how to achieve this kind of thing in picaxe world, it would be nice to know for future use.

I'll opt for a 12bit AD chip that talks SPI to the picaxe to keep things simple & logical ;-)
 

OLDmarty

Senior Member
I'm with AllyCat - define the required range, resolution and accuracy properly and then you/we/the collective can do the design.

The panel meters above are 1% (if you're lucky) and no decimal places, so I can't see how they can meet the (undocumented) requirements that at least mention 1dp of volts in 50v or so i.e. 0.02% :cool:
Geez, what part of "i need to scale down 48V to 0-5V into a picaxe Analog input with 100mV resolution" didn't you understand?
My OP made the requirements quite clear. Did you read it? ;-)
 

Buzby

Senior Member
Two resistors will get your 48v down to 5v, and READADC10 will give then a resolution of 50mV over the full 0-48 range, which is good enough for 1dp on your display.

I'm not sure where I got your aim of 10mV from, must have had a senior moment.

Cheers,

Buzby
 

AllyCat

Senior Member
Hi,

Geez, what part of "i need to scale down 48V to 0-5V into a picaxe Analog input with 100mV resolution" didn't you understand? My OP made the requirements quite clear. Did you read it? ;-)
You specified the Resolution but not the Accuracy. Resolution to 100 mV is potentially very easy, Accuracy to better than 1% (500 mV) is not.

You've now mentioned 48.3 and 47.5 volts which implies quite a good level of Accuracy. But is that Absolute, or can you manually calibrate the threshold levels when fitted to the hardware? BTW how Accurate is the supply rail to the PICaxe (or whatever reference the auxiliary ADC uses)?

Could the CTMU module, which is used for PICAXE 'touch', be re-jiggered to use a big fixed capacitor, and measure the time to charge it depending on a voltage ?.
I doubt if the "touch" oscillator/circuit as such would give useful results, but certainly some of the Comparator/Counter/Timer modules could work well. In particular, the Analogue-Comparator + Timer1 + Timer1-Gate modules, all of which are available even in an 08M2. They could give better than 1mV Resolution (and probably with a better chance of equally-sized "steps" than the PIC's native ADC), but an absolutely horrible Accuracy.

Cheers, Alan.
 

OLDmarty

Senior Member
Original Post where all my figures come from.

It'll work, or it won't ;-)


Hi All,

I was asked if i can use a picaxe to monitor that status of a 48V power supply (and maybe also 12V and 24V supplies too)

So, my initial thought was to feed the 48V into a simple voltage divider to then present 0-5V to the picaxe analog-input.
I figured the divider to be 100K and 10K in series between 48V and GND, with the divider 'tap' at the junction of the 2 resistors to feed into the analog input.

The 48V needs to be monitored in "at least" 100mV increments, so the resulting display would show something like 47.9V or 48.2V etc.

My initial calculations for a 48V is that 48V = 480 x 100mV "steps", and that 5volts (limit of picaxe analog-input) divided by 480 = 10.4mV per 'step'.

If i average the result to a nice round 10mV per division, that means 0 to 48V under test, equates to becoming 0 to 4.8V on the Analog-input.


If all goes to plan, the resulting 0-5V data value would be sent to a 7-segment display, probably via an LM7219 7-seg SPI driver chip etc.



Am i on the right track so far? and does it seem achievable for the picaxe to resolve 10mV steps accurately? or is this a bit too fine a tolerance?

Thanks in advance,
Marty.
 

StefanST

New Member
Another option is to drop the 48V input voltage by a constant value.
The circuit on the picture reduces the input voltage by 45V. Then, ADC voltage will be 0..5V at 45..50V input.
The readAdc/readAdc10 command provides a 20mV/5mV resolution.



Another ADC input would be used to measure large differences. With 10:1 divider. you can measure 0..50V with resolution of 0.2V, resp. 0.05V, which is sufficient to identify the faulty source.
_PICAXE - 45V DROPb.png
 
Last edited:

newplumber

Senior Member
OLDmarty said:
Mixed answers keep telling me this won't work, or it will work, and so on, and so on.
Hi OLDmarty
Reading all the threads from the pros posted here ...it seems your question turns into 50K questions
so since i am simple :) (waving over here) I will say/print YES! it will work! but reading Allycat's info
it sounds like your readADC will show numbers but will they be within accuracy numbers?
IMHO build a demo type and if you don't have to dial 911 your on the right track :)

btw StefanST your picture doesn't show nothing...maybe its my puter
 

AllyCat

Senior Member
Hi,

Mixed answers keep telling me this won't work,
I don't think that anybody has said that 100 mV resolution "won't work", in fact I said it could be done with only a PICaxe and two resistors (with intentionally no reference to a regulated power supply, since it's not essential). BUT if you do want a high degree of Absolute Voltage Accuracy then some things do need to be done "correctly" (whichever ADC you use).

A voltage regulator is unlikely to be specified to better than +/- 1% (4.95 to 5.05 volts) and even if you use 1% tolerance resistors, you might be "unlucky" and get a total error of +/-3%. That's more than 1 volt in 48 volts. The simple solution is that you need a "calibration stage" which traditionally has been done with a potentiometer or variable resistor. But (IMHO) it's usually much better done in the software, for example as discussed in Marks' thread linked above. I nearly always use the ** operator, which can be extremely useful and powerful.

So, (assuming all the components you use have adequate stability) you need only to devise a suitable calibration strategy. For example, ideally use the same meter to calibrate your tester as was used to obtain the threshold voltages specified in post #11.

Cheers, Alan.
 

hippy

Senior Member
Why not opt for READADC10 and keep it simplest ? You haven't explained why that's not acceptable.
Mixed answers keep telling me this won't work, or it will work, and so on, and so on.
I don't really see anyone saying it won't work.

With READADC10 you are reading to a greater resolution than you are displaying. I don't see any benefit in adding extra hardware, having greater software complexity, to read to a greater resolution only to throw that extra resolution away. Any accuracy issues would affect both.

I would personally go for a pot adjustment and calibrate so a 50mV change gives a one bit change in reading. That is a lower resolution than READADC10 can deliver but it makes all the potential issues of accuracy losses during PICAXE maths go away ...

ReadAdc10 VIN_ADC, w0
w1 = w0 * 5
SerTxd( #w1, "0 mV" )
 

oracacle

Senior Member
While I don't have anything to interject in regards to accuracy, maths and if it is possible I will suggest that a zenner is used on the input to ground to help protect the picaxe from any high voltage spikes that may come of the PSUs.
 

inglewoodpete

Senior Member
Another option is to drop the 48V input voltage by a constant value.
The circuit on the picture reduces the input voltage by 45V. Then, ADC voltage will be 0..5V at 45..50V input.
The readAdc/readAdc10 command provides a 20mV/5mV resolution.



Another ADC input would be used to measure large differences. With 10:1 divider. you can measure 0..50V with resolution of 0.2V, resp. 0.05V, which is sufficient to identify the faulty source.
View attachment 21710
Thanks for the suggestion. It's a solution that will suit a project that I'm working on. Just need to get my hands on a TL431 in my next order.
 

Reloadron

Senior Member
If I had a 0 to 5.0 Volt ADC Input I would just use a 50:1 divider or simply use a 10K resistor between my 40 or50 VOLT INPUT AND TAKE THE WIPER OUT TO MY adc. sIMILAR TO THE BELOW IMAGES.
PICAXE Divider.png
tHE SENSED VOLTAGE IS 0 TO 50 vdc, The scaled voltage to the PICAXE ADC now becomes 0 to 50 Volts = 0 to % volts. Using an 8 bit ADC you get 2^8 or 1024 quantization levels of the 0 to 5 Volts. By comparison, an 8-bit (digital) number can only hold 256 discrete steps as an equivalent value. So if the range of the signal is 0 to 5Vdc, then 5V / 256 = 0.019V (= 19mV). The ADC must make an approximation and round values to match the available “steps”. So the best resolution we will see is 0.019 volts This assumes our divider is high quality and not very temperature sensitive. So what we have is the (analog input / 255) * 50 so we get a display of 0 to 50 Volts. By comparison, an 8-bit (digital) number can only hold 256 discrete steps as an equivalent value. So if the range of the signal is 0 to 5Vdc, then 5V / 256 = 0.019V (= 19mV). The ADC must make an approximation and round values to match the available “steps”. The only way to improve on this would be to use a for example 10 bit ADC or as mentioned that ADC 10 read function.

Since you just want to monitor a supply I would just use a voltage divider and in this case a pot.



Ron
 
Last edited:
Top