- Mon Nov 23, 2015 6:02 am
#34758
Hi, the following advice is a bit rough and ready but should get you up and running, you can refining later if you need to.
I see 3 problems:
1. The output is centred around a 2.5 V offset.
Given that a silicon diode has a forward volt drop of 0.7V. If you put 3 diodes in series between the ACS712 VIOUT that should remove 2.4V of the offset.
VIOUT -->|- -->|- -->|- ADC
Signal diodes would be better than the bigger power type.
There will still be some offset but this can be coded out. Or you can reduce the 5V supply to the ACS slightly to get rid of this (the 0A current of 2.5V is half of the supply voltage to the ACS, if the supply voltage was 4.8V the offset would be 2.4V the same as the diodes).
You now have an output voltage from the ASC of 0V -> 1.1V which reflects the original output of 2.4V -> 3.5V (0 -> 5A) at a resolution of about 25mA per bit. You state the fan draws about 400mA on full load, but because it is AC the peek current will be higher closer to 600mA, which whilst, not brilliant will give you a 24 bits difference between off and full power.
2. The voltage output of the ASC reflects both positive (2.5V -> 3.5V) and negative (2.5V -> 1.5V) current flow as you are measuring AC.
Using the diodes to reduce the offset you have got rid of most of the negative current flow measurement. The problem now is that because the output is at best, the positive half of a sine wave when you measure has a big effect on the accuracy of the result.
The 2 methods that jump to mind are;
Use a capacitor to store the output from the ACS with a resistor to discharge the capacitor (this would be more accurate and may be a good final solution).
The one I would go with for first attempts: Take lots of measurements and discard the ones you don’t want to find the peek current. Something like this:
Loop to take 100 readings.
“current read” = read voltage from ADC pin.
If “current read” > “previous read”
Then “previous read” = “current read”
Back to start of loop.
Depending on the type of speed control the results will vary.
3. The resolution is poor.
The answer is something like this, if you really need to know how fast you fan is running it a 1024 bit resolution.
https://www.sparkfun.com/products/8883Sorry if this is a bit fragmented – I must have been disturbed 20 times whilst typing it.