Search Code

الیکٹرو الیکٹرو کرنٹ کی پیمائش Arduino کے لیے Allegro ACS758 کرنٹ سینسر اور LCD1602 کے ساتھ

الیکٹرو الیکٹرو کرنٹ کی پیمائش Arduino کے لیے Allegro ACS758 کرنٹ سینسر اور LCD1602 کے ساتھ

یہ پروجیکٹ ظاہر کرتا ہے کہ Allegro ACS758 کرنٹ سینسر کا استعمال کرتے ہوئے کرنٹ کی پیمائش کیسے کی جائے اور ریڈنگز کو Arduino سے منسلک LCD1602 اسکرین پر کیسے دکھایا جائے۔ ACS758 ایک ورسٹائل سینسر ہے جو 200 ایمپئر تک کرنٹ کی پیمائش کرنے کی صلاحیت رکھتا ہے، جو اسے مختلف ایپلیکیشنز کے لیے موزوں بناتا ہے۔

ACS758-sensor-0

یہ پروجیکٹ سرکٹ میں کرنٹ کے بہاؤ کی نگرانی کا ایک عملی طریقہ فراہم کرتا ہے، جو مختلف ایپلیکیشنز کے لیے اہم ہے، بشمول:

  • آلات میں بجلی کی کھپت کی نگرانی
  • بیٹری مینجمنٹ سسٹم بنانا
  • الیکٹرک موٹر کنٹرولر ڈیزائن کرنا
  • کرنٹ پر مبنی سیکیورٹی سسٹم بنانا

یہ گائیڈ آپ کو ضروری ہارڈویئر، وائرنگ، کوڈ اور لائیو ڈیموسٹریشن کے بارے میں رہنمائی فراہم کرے گا۔

ہارڈویئر پنز

ACS758-sensor-6-pins

ہارڈویئر/اجزاء

اس پروجیکٹ کو بنانے کے لیے آپ کو درج ذیل اجزاء کی ضرورت ہوگی:

  • Arduino Uno (یا مطابقت رکھنے والا)
  • Allegro ACS758 کرنٹ سینسر (مخصوص ماڈل نمبر زیادہ سے زیادہ کرنٹ کی پیمائش کا تعین کرے گا؛ کوڈ کو اس کے مطابق ایڈجسٹ کرنا یقینی بنائیں۔ (ویڈیو میں 00:14 اور 03:18 پر))
  • LCD1602 ڈسپلے بغیر I2C ماجیول کے، LCD میں 12 تاریں ہیں
  • کنیکٹنگ تاریں
  • پاور سپلائی (5V)
  • لوڈ (کرنٹ کی پیمائش کی جانچ کے لیے)

وائرنگ گائیڈ

Arduino wriing for ACS758 with LCD1602 with 12 wries (no I2C)
Arduino wriing for ACS758 with LCD1602 with 12 wries (no I2C)

LCD1602 کی وائرنگ ایک علیحدہ ویڈیو میں بیان کی گئی ہے (ویڈیو میں 01:24 پر)۔ اس پروجیکٹ کے لیے اہم کنکشن درج ذیل ہیں (ویڈیو میں 01:24 پر):

  • ACS758: VCC کو 5V سے، GND کو GND سے، سگنل آؤٹ (پیلی تار) کو Arduino کے A0 سے جوڑیں۔
  • ACS758 سینسر کی دو اہم تاریں لوڈ کے ساتھ سیریز میں منسلک ہیں (ویڈیو میں 02:09 پر)۔

کوڈ کی وضاحت

Arduino کوڈ دو اہم حصوں پر مشتمل ہے: ایک ACS758 سینسر کو سنبھالنے کے لیے اور دوسرا LCD1602 کے ساتھ تعامل کے لیے۔ کوڈ کے صارف کے قابل ترتیب حصے درج ذیل ہیں:


#define VIN A0 // Arduino پن A0 کو وولٹیج ان پٹ (V in) کے طور پر متعین کریں
const float VCC   = 5.0;// سپلائی وولٹیج 5V یا 3.3V۔ اگر PCB استعمال کر رہے ہیں تو صرف 5V سیٹ کریں۔
const int model = 2;   // ماڈل درج کریں (نیچے دیکھیں)
float cutOffLimit = 1.00;// ریڈنگ کٹ آف کرنٹ۔ 1.00 یعنی 1 ایمپئر

model متغیر کو استعمال شدہ مخصوص ACS758 ماڈل کے مطابق سیٹ کرنے کی ضرورت ہے (ویڈیو میں 03:18 پر)۔ ماڈل نمبر میپنگ کے لیے کوڈ کے تبصروں کا حوالہ دیں۔ cutOffLimit متغیر ظاہر کیے جانے والے کم سے کم کرنٹ کا تعین کرتا ہے (ویڈیو میں 03:48 پر)۔ غیر اہم ریڈنگز کو فلٹر کرنے کے لیے اس قدر کو ایڈجسٹ کریں۔

لائیو پروجیکٹ/ڈیموسٹریشن

ویڈیو ظاہر کرتی ہے کہ لوڈ سے گزرنے والے کرنٹ کی پیمائش کے لیے ایممیٹر کو کیسے جوڑا جائے (ویڈیو میں 02:18 پر)۔ کوڈ LCD1602 اور سیریل مانیٹر دونوں پر کرنٹ اور وولٹیج کی ریڈنگز دکھاتا ہے (ویڈیو میں 07:02 پر)۔ ڈیموسٹریشن ظاہر کرتی ہے کہ لوڈ کرنٹ تبدیل ہونے پر ریڈنگز کیسے متحرک طور پر اپڈیٹ ہوتی ہیں (ویڈیو میں 07:14 پر)۔ یہ اس بات پر بھی روشنی ڈالتی ہے کہ جب کرنٹ مخصوص حد سے نیچے آجاتا ہے تو "No Current" ظاہر ہوتا ہے (ویڈیو میں 07:59 پر)۔

ابواب

  • [00:06] تعارف
  • [00:34] ضروری شرائط
  • [01:24] وائرنگ کی وضاحت
  • [02:18] کرنٹ کی پیمائش کا ڈیموسٹریشن
  • [02:57] کوڈ کی وضاحت
  • [07:02] لائیو ڈیموسٹریشن
  • [08:18] نتیجہ

تصاویر

ACS758-sensor-6-pins
ACS758-sensor-6-pins
ACS758-sensor-0
ACS758-sensor-0
Arduino wriing for ACS758 with LCD1602 with 12 wries (no I2C)
Arduino wriing for ACS758 with LCD1602 with 12 wries (no I2C)
109-Allegro ACS758 current sensor with LCD1602 for Arduino
زبان: C++
/*
 * 
 * Arduino Sketch for Allegro ACS758 Current Sensor with LCD1602 
 * This sensor can measure current at a range of up to 200A.
 * It operates with 3.3V or 5V.
 * This sketch requires you to watch the following two videos before using this code:
 * 1- ACS758 Sensor https://www.youtube.com/watch?v=SiHfjzcqnU4
 * 2- LCD1602 Display https://www.youtube.com/watch?v=S4ya3Q7uhJs
 * 
 * 
 * Written by Ahmad Shamshiri on Tuesday, June 22, 2018 at 17:57 in Ajax, Ontario, Canada
 * for Robojax.com
 * View the video instruction for this code at https://youtu.be/Co-DrCa2slk
 * This code has been downloaded from Robojax.com
 */
#define VIN A0 // define the Arduino pin A0 as voltage input (V in)
const float VCC   = 5.0;// supply voltage 5V or 3.3V. If using PCB, set to 5V only.
const int model = 2;   // enter the model (see below)

float cutOffLimit = 1.00;// reading cutoff current. 1.00 is 1 Amper

/*
          "ACS758LCB-050B",// for model use 0
          "ACS758LCB-050U",// for model use 1
          "ACS758LCB-100B",// for model use 2
          "ACS758LCB-100U",// for model use 3
          "ACS758KCB-150B",// for model use 4
          "ACS758KCB-150U",// for model use 5
          "ACS758ECB-200B",// for model use 6
          "ACS758ECB-200U"// for model use 7   
Sensitivity array is holding the sensitivity of the ACS758
current sensors. Do not change.          
*/
float sensitivity[] ={
          40.0,// for ACS758LCB-050B
          60.0,// for ACS758LCB-050U
          20.0,// for ACS758LCB-100B
          40.0,// for ACS758LCB-100U
          13.3,// for ACS758KCB-150B
          16.7,// for ACS758KCB-150U
          10.0,// for ACS758ECB-200B
          20.0,// for ACS758ECB-200U     
         }; 

/*         
 *   Quiescent output voltage is a factor of VCC that appears at the output       
 *   when the current is zero. 
 *   For bidirectional sensors it is 0.5 x VCC.
 *   For unidirectional sensors it is 0.12 x VCC.
 *   For model ACS758LCB-050B, the B at the end represents Bidirectional (polarity doesn't matter).
 *   For model ACS758LCB-100U, the U at the end represents Unidirectional (polarity must match).
 *   Do not change.
 */
float quiescent_Output_voltage [] ={
          0.5,// for ACS758LCB-050B
          0.12,// for ACS758LCB-050U
          0.5,// for ACS758LCB-100B
          0.12,// for ACS758LCB-100U
          0.5,// for ACS758KCB-150B
          0.12,// for ACS758KCB-150U
          0.5,// for ACS758ECB-200B
          0.12,// for ACS758ECB-200U            
          };
const float FACTOR = sensitivity[model]/1000;// set sensitivity for selected model
const float QOV =   quiescent_Output_voltage [model] * VCC;// set quiescent Output voltage for selected model
float voltage;// internal variable for voltage
float cutOff = FACTOR/cutOffLimit;// convert current cut off to mV
 //************ END of ACS785 Settings
 
//******************** Start of LCD1602
// January 21, 2018 14:25
// original source https://www.arduino.cc/en/Tutorial/HelloWorld
// include the library code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // Robojax.com ACS758 Current Sensor with LCD1602 
    Serial.begin(9600);// initialize serial monitor
    Serial.println("Robojax Tutorial");
    Serial.println("ACS758 Current Sensor");
    Serial.println("with LCD1602 display");    
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
    lcd.clear();
  lcd.print("Robojax");
  lcd.setCursor (0,1); // go to start of 2nd line 
  lcd.print("ACS758 Current Sensor");  
  delay(2000); 
  lcd.clear();
}

void loop() {
  // Robojax.com ACS758 Current Sensor with LCD1602 

  float voltage_raw =   (5.0 / 1023.0)* analogRead(VIN);// Read the voltage from sensor
  voltage =  voltage_raw - QOV + 0.007 ;// 0.007 is a value to make voltage zero when there is no current
  float current = voltage / FACTOR;
  if(abs(voltage) > cutOff ){
    Serial.print("V: ");
    Serial.print(voltage,3);// print voltage with 3 decimal places
    Serial.print("V, I: ");
    Serial.print(current,2); // print the current with 2 decimal places
    Serial.println("A");
  //start of loop Robojax code ACS758 with LCD1602 and I2C
  lcd.clear();
  lcd.setCursor (0,0); // set to line 1, char 0  
  lcd.print("Current: ");
  lcd.setCursor (9,0); // go to start of 2nd line
  lcd.print(current);
  lcd.setCursor (15,0); // go to start of 2nd line
  lcd.print("A");

  lcd.setCursor (0,1);    
  lcd.print("Sense V: ");
  lcd.setCursor (9,1); // go to start of 2nd line
  lcd.print(voltage);
  lcd.setCursor (15,1); // go to start of 2nd line
  lcd.print("V");   
 
 //end of loopcode Robojax code ACS758 with LCD1602 and I2C


    
  }else{
    Serial.println("No Current");
  lcd.clear();    
  lcd.setCursor (0,0);    
  lcd.print("No Current");    
  }


  delay(500);
  // Robojax.com ACS758 Current Sensor with LCD1602 
}

آپ کو جن چیزوں کی ضرورت ہو سکتی ہے

وسائل اور حوالہ جات

فائلیں📁

دیگر فائلیں

  • Alegro ACS Current Library
    Arduino library for Allegro ACS current sensor modules. Provides functions to read current measurements from ACS712 and similar sensors.
    robojax_Alegro_ACS_Current_library.zip 0.02 MB