28X2 ADC Internal Voltage Reference

#1
Hi
I have made a model elevator for a school project. Its running a 28x2 from a 5V USB power supply.

I have connected the negative pin of my motor H-Bridge to a negative pin of the Picaxe and also to negative via a 1 ohm resistor in parallel with a capacitor, creating a potential divid sort of thing.
This allows me to sense the loading on the motor and adjust the PWM to cater for different weight loadings on the elevator carriage.
For example, if no load then it will run at about 80%, if there is load it will run at full high, and if it is overloaded it will return to the ground floor.
This works accurately about 70% of the time but due to the slight fluctuations and very close (range of about 5) ADC10 debug values it isn't very accurate.
The load sensing is happening in the first second of travel when the motor is in PWM to simulate accelerating, I think this also brings the debug values down.

My current debug values are above 23 for overload, above 21 for loaded and anything below that is no load
I tried calibadc10 but that just took the values to around 220 with the same small range.
To my understanding this brings the Vref + down to 1.2V
As i have already built the PCB is there a way to bring the Vref - up a bit with software rather than adding an external voltage reference pin?

I will update later with some voltage readings for different loads, however I did take a reading at the potential divide when I had a similar test circuit on breadboard. Unfortunatly I had only tested with full speed (high command) and the potential divide voltage readings were 0.091 for no load, 0.165 for when loaded and 0.212 when I fully stoped the elevator.

Any advice appreciated
Thanks
Josh
 
#2
I have encountered that same problem when sensing current using a low-value resistor. My suggestion is to add an op-amp that can track voltages rail-to-rail, configured as a non-inverting amplifier, to amplify the small voltage generated across the 1-ohm resistor. A carefully selected capacitor in the amplifier's feedback loop will also reduce commutator noise from the motor, the main source of the bad ADC readings. My favorite op-amp for this is the MCP6021 from Microchip. Note that the MCP6021's power supply range is 2.5 to 5.5 volts, so is well suited to interfacing to a microcontroller.
 
#4
Hi Josh,

Welcome to the forum? BTW it appears the new forum software doesn't directly show the number of member posts, IMHO a sad omission.

To my understanding this brings the Vref + down to 1.2V
No, as hippy says, the CALIBADC command performs a completely different function. However, IIRC, it doesn't fully restore the PICaxe ADC/FVRs to their previous states, so you may indeed then get "different" values.

The simplest way to increase the ADC resolution is to use the "1 volt" FVR (nominally 1.024 volts) as the ADC reference (and of course use READADC10 to divide it into 1024 voltage steps of around 1 mV each). "Officially" the FVR1024 is not recommended (by Microchip) to use with the ADCs, but in practice it seems to work well enough, particularly to enhance low-value measurements.

Then, as IP suggests, you probably need a filter capacitor across the ADC input (to ground) and I would then add together multiple measurements (perhaps 10) to average and increase the result.

Cheers, Alan.
 
#5
Cheers for replies. After posting I played around with ADD CONFIG and FVR and managed to get the 1.024 vref working, values now range from about 80 to 120. I currently have a 470uF capacitor that helps a lot with fluctuations but still not perfect. Averaging seems to be the way to go. If I have time I’ll try find a bigger capacitor.
 
#8
Hi,

Yes, it's nearly always worth putting a resistor of say 1 kohm in series with any input pin (if only in case it gets "accidentally" turned into an output by the software). Then, 100 nF up to a few uF (on the pin) should be sufficient, combined with adding together a few consecutive measurements to smooth and increase the value.

Cheers, Alan.
 

hippy

Technical Support
Staff member
#9
I couldn't figure out the exact circuit from the original post, but if the capacitor is in series with the current sensor resistor it will be tracking the PWM somewhat. Thus what voltage is read will depend on whether the PWM signal is driving the motor or not.

Given it's a loading sensor for an elevator it might make sense to use a diode so the capacitor is a peak load indicator. Something like -

Code:
V+ >-------------.
              .--^--.
              |     |----.
              |  H  |   (O)   Motor
              |     |----'
              `--.--'
          Diode  |
Vi <---.---|<|---{
     __|__      .|.
     ==.== C    |_| R
       |         |
0V ----^---------'
 
#10
Hi,

A 1 ohm R might not build up enough voltage drop to exceed the forward voltage of a diode (say 600 mV). Also the "peak" might take a long time to die away (no pull-down resistor), so I'd just use a 1 k in the position of the Diode.

Cheers, Alan.
 
Top