![]() |
Forum Index : Microcontroller and PC projects : MX170 Measuring Voltage Below 0V
Author | Message | ||||
OA47 Guru ![]() Joined: 11/04/2012 Location: AustraliaPosts: 986 |
Is there a simple way to get a measurement of a voltage that ranges from 0 to -0.5V with respect to GND on the MX170 analog input? OA47 |
||||
phil99![]() Guru ![]() Joined: 11/02/2018 Location: AustraliaPosts: 2640 |
A voltage divider from Vin to 3V3 with Ain at the junction. If both resistors are equal Vmeasured = Vain * 2 - 3.3 For greater resolution use 3k3 from Ain to 3V3 and 500R from Ain to Vin and adjust the formula to suit. Caution, if Vin goes lower than -0.5 Ain will be negative. Vmeasured = Vain * 3300 / (3300 - 500) - 0.5 ....I think... You will need to check the arithmetic. Edited 2023-01-13 11:17 by phil99 |
||||
Bowden_P Senior Member ![]() Joined: 20/03/2019 Location: United KingdomPosts: 162 |
Hi OA47, I assume you are using a Micromite ! If you hang a potential divider between the +3.3v rail and your 0 to -0.5v source, where the resistor ratio is 6.6:1, the midpoint will move from +0.434V for a 0V input to 0V for a -0.5V input. The measured voltage can be scaled to match the expected input via MMBASIC. Suitable resistor values could be 68k and ( 10k+300R ) for instance. ( 6.602:1.) Vin = (Vmeas - 0.434)*1.152 - if I've done my sums right !! With best regards, Paul. Edited 2023-01-13 11:27 by Bowden_P Nothing so constant as change. |
||||
tgerbic Regular Member ![]() Joined: 25/07/2019 Location: United StatesPosts: 66 |
Don't remember if the A2D works to 3.3V or 5V. If 3.3V then you could use the invert input to an opamp with a x6 gain. You would be able to measure -0.5V to 0V as 0 to 3V into the MX170. Fixes your negative voltage problem and scales it up to a value that gives a lot of voltage resolution. Just adjust the math of the calculations by -6x to get the actual voltage. If there is some concert the voltage will go lower than -0.5V, just scale the gain value to make sure the full range fits between 0 and 3V. Alternately pick a gain that will give you 4096 steps for your maximum voltage to make the math easy. Regards |
||||
OA47 Guru ![]() Joined: 11/04/2012 Location: AustraliaPosts: 986 |
Thankyou shedders for jogging my grey cells. I have used voltage dividers on the micromites many times before but always between Vcc and GND so my brain was in a rut. I have some solar battery chargers using the MMBasic mx170 chips and an ILI9341 displays and as I was making some modifications to incorporate a desulfer mode in the units. While there I was interested in roughly monitoring the charging current without too much circuit modification. The circuits have a 0.42 Ohm resistor in series with the solar negative input that is linked to the base/emitter of a transistor. As the voltage approaches and exceeds 0.6v the transistor turns on and controls the regulator to restrict the current flow to the battery. I thought I would use a spare AIN to monitor this voltage across the 0.42 Ohm resistor and get an estimate of the charging current. I used 2 100K resistors (high values to limit any interaction of circuits) one to the solar input and the other to 3v3. I was aware that the control circuit takes some of the initial current so I measured the idle voltage across the 0.42 Ohm resistor at 0.253 volts and used the following code to display a bar graph and value in milliamps: I=(Pin(2)-0.253)*-1000 All has been working well over the past days and current measurements with the meter confirm that the monitoring is working OK. OA47 |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5089 |
Hi OA47, A obvious way to extend the measurement range of the ADC is using a voltage divider. If you pre-bias the voltage divider from 3.3V you can also shift the measurement range. You can calculate using math. A very simple method to create a voltage range of +/-3.3V is the use of 2 identical resistors (say 10k). +3.3V --------10k---------+ INPUT --------10k---------+-----GP26 (analog input). This will be sufficient to cover your requirement for small negative voltages. The ADC output +3.3V = +3.3V +1.65V = 0V 0V = -3.3V So you have to scale accordingly... Volhout PicomiteVGA PETSCII ROBOTS |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |