- Current sensor chip: ACS712ELC-05B
- pin inserted 5V power supply,on board power indicator;
- Can measure plus and minus 5A current,corresponding simulation output 185mV/A ;
- When testing no current though,the output voltage is VCC/2; (2,5V ~ 2500mV)
- PCB board dimension: 31(mm)x13(mm)
- NOTE: ACS712 is based on the principle of Hall detectionon,please try to avoid the magnetic field affect when using it.
Zdroje:
http://forum.arduino.cc/index.php?topic=265094.0
http://www.cnx-software.com/2016/01/23/acs712-module-measures-currents-30a-1-dollar/
http://www.dustynrobots.com/academia/research/digital-signal-processing-and-filtering-motor-current-sensing/
int currentPin = A0;
// constants
float volt_per_amp = 185; // resolution according to hardware page
// variables
float currentRaw; // the raw analogRead ranging from 0-1023
float currentVolts; // raw reading changed to Volts
float currentAmps; // Voltage reading changed to Amps
void setup() {
Serial.begin(9600);
}
void loop() {
currentRaw = analogRead(currentPin);
currentVolts = currentRaw *(5000.0/1024.0);
currentAmps = (currentVolts-2500)/volt_per_amp;
Serial.println(currentAmps);
}
Přidání filtru průměrnou hodnotou
Z obrázku je vidět, že je linka méně "chlupatá".
int currentPin = A0;
// constants
float volt_per_amp = 185; // resolution according to hardware page
// variables
float currentRaw; // the raw analogRead ranging from 0-1023
float currentVolts; // raw reading changed to Volts
float currentAmps; // Voltage reading changed to Amps
void setup() {
Serial.begin(9600);
}
void loop() {
float average = 0;
for(int i = 0; i < 15; i++) {
currentRaw = analogRead(currentPin);
currentVolts = currentRaw *(5000.0/1024.0);
currentAmps = (currentVolts-2500)/volt_per_amp;
average = average+currentAmps;
delay(1);
}
Serial.println(average/15);
}