Translate

Membuat Alat Monitoring Daya Arus dan Tegangan AC Menggunakan AVR ATMEGA16 Software BASCOM AVR Sensor Tegangan ZMPT101b Sensor Arus SCT-013 KWH METER

Membuat Alat Monitoring Daya Arus dan Tegangan AC Menggunakan AVR ATMEGA16 Software BASCOM AVR Sensor Tegangan ZMPT101b Sensor Arus SCT-013  KWH METER


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk memonitoring arus dan tegangan AC untuk monitor daya dan KWH Meter rumah. alat ini dilengkapi dengan sensor tegangan AC zmpt101b dan sensor arus AC SCT-013 dengan mikrokontroller ATMega16 + Software BASCOM AVR. untuk lebih jelasnya berikut adalah komponen dan programnya.




a. Minimum System ATMega16




b. Sensor ZMPT101B




c. Sensor Arus SCT-013




d. LCD 16x2







e. Program Bascom AVR

$regfile = "m16def.dat"
$crystal = 12000000

Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Cursor Off
Cls

Dim Dataadc1 As Integer
Dim Dataadc2 As Integer

Dim V As Single
Dim X As Integer
Dim Vint As Integer
Dim Adcv As Integer
Dim Adci As Integer

Dim Vac As Single
Dim Iac As Single

Dim Vacx As String * 5
Dim Iacx As String * 5


Start Adc

Mulai:
X = 0
Adcv = 0
Adci = 0

Do

Dataadc1 = Getadc(0)  'ambil data tegangan
Dataadc2 = Getadc(1)  'ambil data arus

'ambil data max tegangan
If Dataadc1 > Adcv Then    

Adcv = Dataadc1

End If

'ambil data max arus
If Dataadc2 > Adci Then    

Adci = Dataadc2

End If

Incr X
Waitms 1
Loop Until X > 1000      'ambil 1000 data dan compare max 


Vac = Adcv - 514.0  'kalibrasi tegangan AC
Vac = Vac / 0.5864

Iac = Adci - 251.0   'kalibrasi arus AC
Iac = Iac / 8.0925

Vacx = Fusing(vac , "#.##")
Iacx = Fusing(iac , "#.##")

Locate 1 , 1
Lcd "v= " ; Vacx ; "    "

Locate 2 , 1
Lcd "I= " ; Iacx ; "    "

Waitms 200

Goto Mulai





f. VIDEO HASILNYA









Mengakses dan Membandingkan Dua Sensor Compass / Magnetometer GY-271 QMC8553L dan HMC8553L GY-273 Menggunakan ARDUINO Sensor Rotasi dan Arah Mata Angin

Mengakses dan Membandingkan Dua Sensor Compass / Magnetometer GY-271 QMC8553L dan HMC8553L GY-273 Menggunakan ARDUINO Sensor Rotasi dan Arah Mata Angin


       Pada kesempatan yang berbahagia kali ini saya akan menjelaskan mengenai bagaimana cara mengakses sensor compass atau magnetometer untuk mengetahui arah rotasi dan arah mata angin, sensor yang akan dipakai yaitu GY-271 dan GY-273 dengan tampilan interface menggunakan lcd 16x2. untuk lebih jelasnya berikut adalah program dan komponennya. 




a. Arduino Uno





b. Sensor GY-271 qmc8553l




c. Sensor GY-273 hmc8553l




d. LCD 16x2 + I2C






e. Program Arduino IDE GY-271

#include <Wire.h> //I2C Arduino Library
#include <LiquidCrystal_I2C.h>

#define addr 0x0D //I2C Address for The HMC5883
LiquidCrystal_I2C lcd(0x27,16,2);

void setup() {
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  
  Serial.begin(9600);
  Wire.begin();


  Wire.beginTransmission(addr); //start talking
  Wire.write(0x0B); // Tell the HMC5883 to Continuously Measure
  Wire.write(0x01); // Set the Register
  Wire.endTransmission();
  Wire.beginTransmission(addr); //start talking
  Wire.write(0x09); // Tell the HMC5883 to Continuously Measure
  Wire.write(0x1D); // Set the Register
  Wire.endTransmission();
}

void loop() {

  int x, y, z; //triple axis data

  //Tell the HMC what regist to begin writing data into


  Wire.beginTransmission(addr);
  Wire.write(0x00); //start with register 3.
  Wire.endTransmission();

  //Read the data.. 2 bytes for each axis.. 6 total bytes
  Wire.requestFrom(addr, 6);
  if (6 <= Wire.available()) {
    x = Wire.read(); //MSB  x
    x |= Wire.read() << 8; //LSB  x
    z = Wire.read(); //MSB  z
    z |= Wire.read() << 8; //LSB z
    y = Wire.read(); //MSB y
    y |= Wire.read() << 8; //LSB y
  }

  // Show Values
  Serial.print("X Value: ");
  Serial.println(x);
  Serial.print("Y Value: ");
  Serial.println(y);
  Serial.print("Z Value: ");
  Serial.println(z);
  Serial.println();

  lcd.setCursor(0,0);
  lcd.print("");
  lcd.print(x);
  lcd.print("/");
  lcd.print(y);
  lcd.print("/");
  lcd.print(z);
  lcd.print("      ");

  delay(500);
}





f. Program Arduino IDE GY-273

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_HMC5883_U.h>
#include <LiquidCrystal_I2C.h>

/* Assign a unique ID to this sensor at the same time */
Adafruit_HMC5883_Unified mag = Adafruit_HMC5883_Unified(12345);
LiquidCrystal_I2C lcd(0x27,16,2);

void displaySensorDetails(void)
{
  sensor_t sensor;
  mag.getSensor(&sensor);
  Serial.println("------------------------------------");
  Serial.print  ("Sensor:       "); Serial.println(sensor.name);
  Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" uT");
  Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" uT");
  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" uT");  
  Serial.println("------------------------------------");
  Serial.println("");
  delay(500);
}

void setup(void) 
{
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  
  Serial.begin(9600);
  Serial.println("HMC5883 Magnetometer Test"); Serial.println("");
  
  /* Initialise the sensor */
  if(!mag.begin())
  {
    /* There was a problem detecting the HMC5883 ... check your connections */
    Serial.println("Ooops, no HMC5883 detected ... Check your wiring!");
    while(1);
  }
  
  /* Display some basic information on this sensor */
  displaySensorDetails();
}

void loop(void) 
{
  /* Get a new sensor event */ 
  sensors_event_t event; 
  mag.getEvent(&event);

  /* Display the results (magnetic vector values are in micro-Tesla (uT)) */
  Serial.print("X: "); Serial.print(event.magnetic.x); Serial.print("  ");
  Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print("  ");
  Serial.print("Z: "); Serial.print(event.magnetic.z); Serial.print("  ");Serial.println("uT");

  //lcd.setCursor(0,0);
  //lcd.print(""); lcd.print(event.magnetic.x,1); lcd.print("/");
  //lcd.print(""); lcd.print(event.magnetic.y,1); lcd.print("/");
  //lcd.print(""); lcd.print(event.magnetic.z,1); lcd.print("   ");Serial.println("uT");

  // Hold the module so that Z is pointing 'up' and you can measure the heading with x&y
  // Calculate heading when the magnetometer is level, then correct for signs of axis.
  float heading = atan2(event.magnetic.y, event.magnetic.x);
  
  // Once you have your heading, you must then add your 'Declination Angle', which is the 'Error' of the magnetic field in your location.
  // Find yours here: http://www.magnetic-declination.com/
  // Mine is: -13* 2' W, which is ~13 Degrees, or (which we need) 0.22 radians
  // If you cannot find your Declination, comment out these two lines, your compass will be slightly off.
  float declinationAngle = 0.22;
  heading += declinationAngle;
  
  // Correct for when signs are reversed.
  if(heading < 0)
    heading += 2*PI;
    
  // Check for wrap due to addition of declination.
  if(heading > 2*PI)
    heading -= 2*PI;
   
  // Convert radians to degrees for readability.
  float headingDegrees = heading * 180/M_PI; 

  
  Serial.print("Heading (degrees): "); Serial.println(headingDegrees);

  lcd.setCursor(0,0);
  lcd.print("Sudut: "); lcd.print(headingDegrees); lcd.print("      ");

  delay(500);
}






g. VIDEO HASILNYA








Membuat Alat Kendali Pintu Pagar Otomatis Menggunakan Arduino dan Remote 433 MHz Motor Driver IBT2

Membuat Alat Kendali Pintu Pagar Otomatis Menggunakan Arduino dan Remote 433 MHz Motor Driver IBT2


            Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat digunakan untuk membuat buka - tutup pintu pagar otomatis dengan menggunakan remote wireless RFLINK 433MHz. alat ini dilengkapi oleh driver motor IBT2 dan lcd 16x2 sebagai interfacenya. untuk lebih jelasnya berikut program dan daftar komponen utamanya.




a. Arduino Mega




b. Module Remote RFLINK 433MHz




c. Driver Motor IBT2






d. Program Arduino IDE

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);

int sw1 = 6;
int sw2 = 7;
int sw1x = 0;
int sw2x = 0;

int pwm1 = 8;
int pwm2 = 9;
int relayin = A0;
int relayinx = 0;
int mark = 0;

void setup() {
  // put your setup code here, to run once:
  lcd.begin();
  lcd.clear();
  lcd.noCursor();

  pinMode(sw1,INPUT_PULLUP);
  pinMode(sw2,INPUT_PULLUP);
  pinMode(relayin,INPUT_PULLUP);

  pinMode(pwm1,OUTPUT);
  pinMode(pwm2,OUTPUT);
}

void loop() {

sw1x = digitalRead(sw1);
sw2x = digitalRead(sw2);
relayinx = digitalRead(relayin);

  lcd.setCursor(0,0);
  lcd.print("SW1= ");
  lcd.print(sw1x);
  lcd.print("  SW2= ");
  lcd.print(sw2x);

  lcd.setCursor(0,1);
  lcd.print("Relay= ");
  lcd.print(relayinx);


//buka pagar
if((relayinx == 0)&&(mark == 0)){
 bukapagar();  
}

//tutup pagar
if((relayinx == 1)&&(mark == 1)){
 tutuppagar();  
}

delay(200);  
}

void bukapagar(){

analogWrite(pwm1,100);  
analogWrite(pwm2,0);  

sw1x = digitalRead(sw1);

if(sw1x == 0){
analogWrite(pwm1,0);  
analogWrite(pwm2,0);
mark = 1;
return; 
}
  
bukapagar();  
}

void tutuppagar(){

analogWrite(pwm1,0);  
analogWrite(pwm2,100);  

sw2x = digitalRead(sw2);

if(sw2x == 0){
analogWrite(pwm1,0);  
analogWrite(pwm2,0);
mark = 0;
return; 
}
  
tutuppagar();  
}






e. VIDEO HASILNYA