아두이노 전류센서 ACS712 사용해보기 (전류 측정 / 전류 감지)

메이커 2018-09-17 (월) 23:49 5년전 17348  

전류센서의 원리


전류를 검출하는 방법으로는 다음의 세가지가 있습니다. 

 

1) 고유 저항값을 가진 전선에서 V = IR에 따라서 전류에 비례하는 전압을 통한 SHUNT(션트) 방식

2) 자기유도현상을 이용하는 C/T (CURRENT TRANSFOMER) 방식

3) 그리고, 자기장의 세기에 따라서 전압이 변하는 홀 효과를 이용한 홀 센서 (Hall Sensor)가 있습니다. 

 

홀센서의 원리


자기장 내에서 전하가 움직이면 로렌츠의 법칙을 따르는 힘이 전하에 작용하여 전하가 이동방향의 수직으로 힘을 받습니다.

이 원리에 의해 전 휴가 흐르는 도체에 자기장이 가해지면 도체 내부를 흐르는 전하가 진행 방향에 수직으로 힘을 받아 도체의 한 쪽으로 치우쳐 흐르게 됩니다.

 

이렇게 전하가 한 쪽으로 치우침으로 인해 전하가 몰려있는 곳과 그렇지 않은 곳 사이에 전위차가 발생하는 현 Hall Effect,  즉 홀효과라고 합니다.

 

이것을 이용하여 자기장의 세기 또는 방향을 측정하거나, 전류센서에서 홀효과를 이용한 홀센서가 쓰입니다.

 

4eb8db95a0a4ce915caee4aba559ad37_1537194
 

 

ACS712 교류/직류 전류 센서 (홀 효과 이용)

ACS712는 전류를 측정한 결과를 전압으로 출력 해 주는 센서입니다. 전류 측정 대상으로는 교류, 직류 상관없이 측정이 가능합니다. 제품의 버전 별로, 30A / 20A / 5A 의 전류를 측정 할 수 있습니다. 

 

4eb8db95a0a4ce915caee4aba559ad37_1537195 

 

 

 

 

 

4eb8db95a0a4ce915caee4aba559ad37_1537194

 

위 그래프는 30A 제품 기준으로 출력 전압과 전류의 그래프입니다. 아무것도 흐르지 않는 0A 에서는 2.5V가 출력이 되고 있습니다.

 

사용하는 방법으로는 다음과 같이 측정하고자 하는 전선을 자른 후, 잘린 양쪽을 ACS712를 통하게 연결합니다.


4eb8db95a0a4ce915caee4aba559ad37_1537195
4eb8db95a0a4ce915caee4aba559ad37_1537195

4eb8db95a0a4ce915caee4aba559ad37_1537195


아두이노 소스코드 

 #define CURRENT 20

// CURRENT 의 20 대신 30A 나 5A제품의 경우, 30 또는 5를 적어 주시면 됩니다.

 

void setup() {

  Serial.begin(9600);

}

 

void loop() {

  float volt = analogRead(A0) * (5.0 / 1024);

  float current = (volt - 2.5) * (CURRENT / 2);

  Serial.print("volt: \t");

  Serial.print(volt);

  Serial.print("  current: \t");

  Serial.print(current);

  Serial.println();

  delay(100);

}


4eb8db95a0a4ce915caee4aba559ad37_1537195


자기유도현상을 이용한 교류 측정


4eb8db95a0a4ce915caee4aba559ad37_1537195

 


도선의 주위에서 자기장이 변화하면 도선에서 전압이 발생 하는 원리입니다.

 

이러한 원리를 자석은 아니지만 시간에 따라 크기와 방향이 변하는 교류전원이 발생시키는 자기장에도 적용이 가능하여서

 

교류 전류 센서에서도 사용됩니다.

 

다음과 같이 측정하는 전선을 자른 후, 센서 안쪽으로 넣습니다. 

4eb8db95a0a4ce915caee4aba559ad37_1537195
 

그리고, 아두이노 소스코드는 다음과 같습니다. 

 

 const unsigned int numReadings = 200; //samples to calculate Vrms.

 

int readingsVClamp[numReadings];    // samples of the sensor SCT-013-000

int readingsGND[numReadings];      // samples of the <span id="result_box" class="" lang="en"><span class="hps">virtual</span> <span class="hps alt-edited">ground</span></span>

float SumSqGND = 0;            

float SumSqVClamp = 0;

float total = 0; 

 

 

int PinVClamp = A0;    // Sensor SCT-013-000

int PinVirtGND = A1;   // <span id="result_box" class="" lang="en"><span class="hps">Virtual</span> <span class="hps alt-edited">ground</span></span>

 

void setup() {

  Serial.begin(9600);

  // initialize all the readings to 0:

  for (int thisReading = 0; thisReading < numReadings; thisReading++) {

    readingsVClamp[thisReading] = 0;

    readingsGND[thisReading] = 0;

  }

}

 

void loop() {

  unsigned int i=0;

  SumSqGND = 0;

  SumSqVClamp = 0;

  total = 0; 

   

  for (unsigned int i=0; i<numReadings; i++)

  {

    readingsVClamp[i] = analogRead(PinVClamp) - analogRead(PinVirtGND);

    delay(1); // 

  }

 

  //Calculate Vrms

  for (unsigned int i=0; i<numReadings; i++)

  {

    SumSqVClamp = SumSqVClamp + sq((float)readingsVClamp[i]);

 

  }

   

  total = sqrt(SumSqVClamp/numReadings);

  total= (total*(float)2/3); // Rburden=3300 ohms, LBS= 0,004882 V (5/1024)

                             // Transformer of 2000 laps (SCT-013-000).

                             // 5*220*2000/(3300*1024)= 2/3 (aprox)

   

  Serial.println(total);

  delay(1500);  

}

 

유사 센서들로는 다음이 있습니다.  (www.mechasolution.com)

 




4eb8db95a0a4ce915caee4aba559ad37_1537195
4eb8db95a0a4ce915caee4aba559ad37_1537195
 

 

 

메카리워즈 Image Map


모바일 버전으로 보기