Network of ICs 317 & 7805 limited high DC voltages 60 VDC upto 5 VDC for the whole circuit working.
Here 16*4 LCD used , optocoupler 817 used to derive FET ,48 Vdc Relay used ,
Codes below
// By Engineer Obaidullah Khan Kakar 28/2/2018
#include <LiquidCrystal.h>
#define NUM_SAMPLES 30
#define DIV_1 58.13465
#define DIV_2 58.07185
#define DIV_3 58.0718
#define DIV_4 58.07185
#define V_REF 4.991
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sum[4] = {0};
unsigned char sample_count = 0;
float voltage[4] = {0.0};
char l_cnt = 0;
#define led 8
#define led 9
#define led 10
int sensorPin = A2;
int sensorPin1 = A3;
int sensorPin2 = A4;
unsigned int sensorValue = 0;
unsigned int sensorValue1 = 0;
unsigned int sensorValue2 = 0;
void setup(){
lcd.begin(16, 4);
lcd.print("KSF ELECTRONICS");
delay(700);
lcd.clear();
lcd.print("obaidkakar");
lcd.setCursor(0,1);
lcd.print(".blogspot.com");
delay(800);
lcd.clear(); // clear screen
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
Serial.begin(9600);
}
void loop()
{
while (sample_count < NUM_SAMPLES) {
for (l_cnt = 0; l_cnt < 4; l_cnt++) {
sum[l_cnt] += analogRead(A2 + l_cnt); // input were given to lcd
}
sample_count++;
delay(40);
}
// calculate the voltage for each channel
for (l_cnt = 0; l_cnt < 4; l_cnt++) {
voltage[l_cnt] = ((float)sum[l_cnt] / (float)NUM_SAMPLES * V_REF) / 1024.0;
}
lcd.setCursor(0, 0);
lcd.print("DC1 ");
lcd.print(voltage[0] * DIV_1, 1); // pin A2
lcd.print("VDC ");
lcd.setCursor(0, 1);
lcd.print("DC2 ");
lcd.print(voltage[1] * DIV_2, 1); // pin A3
lcd.print("VDC ");
lcd.setCursor(0, 2);
lcd.print("CUTOFF ");
lcd.print(voltage[2] * DIV_3, 1); //pin A4
lcd.print("VDC ");
sample_count = 0;
for (l_cnt = 0; l_cnt < 4; l_cnt++)
{
sum[l_cnt] = 0;
}
sensorValue = analogRead( sensorPin);
sensorValue1 = analogRead( sensorPin1);
sensorValue2 = analogRead( sensorPin2);
delay(400);
if(sensorValue>168) digitalWrite(8, LOW);
delay(800);
if(sensorValue>168) digitalWrite(9, HIGH);
delay(800);
if(sensorValue<164) digitalWrite(9, LOW);
delay(800);
if(sensorValue<164) digitalWrite(8, HIGH);
delay(400);
lcd.setCursor(0, 3);
if(sensorValue>168) lcd.print("DC1 BATT CONECT ");
if(sensorValue<164) lcd.print("DC2 BATT CONECT ");
}
No comments:
Post a Comment