16F877 ADC using the Allegro ACS754 Current Sensor
Ok I am going to show my lack of electronic knowledge on this one... here goes. I'm using an 16F877 to read an Allegro ACS754 I've got it working to a degree using some simple code to get the ADVAL. That part is not a problem. The problem I am seeing is the same problem I read about in this thread Just so I could see some real current other then a light bulb I am using a 1600 watt hair dryer which I am attempting to read how much current it is using. When I turn it on the current follows the AC and my reading goes from 128 (This is equal to 2.5vdc which the ACS754 puts out with no current) to 161 which after calculations 12.8amps which if this thing is really putting 1600watts give or take a few it's probably right anyway.... The math seems right so far. What I am having a problem with is as I said the same as the other person. The current is rising and falling with the AC so I am not getting a steady reading. I have used the MAX command to get this far but I just can't seen to figure out how to get or keep track of a reading that is not fluctuating with the wave of the AC. I didn't see that the person who was trying to do the same thing with the 877 and 754 ever came up with a solution.
As always any help would be appreciated.
Thanks
David
Trial and error and possible solution
I've been trying allot of different approaches to my problem not wanting to give up and certainly not going to wait for someone to drop code in my lap. I came up with this routine that seems to be pretty stable.
Code:
mainloop:
Gosub getx ' Get x value read ADC return value in 'x'
x = x - 128
vmin = vmin min x ' Get min value
WHILE VMIN <> 0
GOTO MAINLOOP 'stay here until the cross road of 0
WEND
vmax = vmax max x
resv = vmax * 3906
resv = div32 1000
READING = 1
VALUE = resv
gosub average 'send calculated amps to darryl's average routine
resv = value
cnt = cnt + 1
if cnt >= 120 then 'get 120 averaged readings then display the amps
Serout2 so,baud,[27,"[2;7H", dec5 resv]
cnt = 0 'reset the counters and
vmax = 0
VMIN = 1
endif
Pause 10 ' Do it about 10 times a second
Goto mainloop
This seems pretty stable so far and switching between the hair dryers hi and low settings I can clearly see the amps switch between 5.8 ish and 12.8 ish give or tak an ish he he he. I've got a call into a friend to see if he's got a real accurate amp meter that I can test and see how accurate this ACS754 is. I'll keep you posted.
If anyone else has any ideas about this code or possibly see something wrong with my code or has a better idea please let me know.
Thanks
David
Going to try the recified output...
Quote:
Originally Posted by
amgen
You could rectify the output and add filter (resister/capicator) and have a DC voltage related to the AC current. Still would have the offset voltage, about 2 volts which you subtract out anyway. 10 micro-farad and 100K ohms will smooth output.
don
Don, Thanks I will give that a try. I'll let everyone know how that turns out.