0% found this document useful (0 votes)
10 views2 pages

Masala Interlock Current

Uploaded by

sandeep naik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Masala Interlock Current

Uploaded by

sandeep naik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//const int SW1 = 7; //o/p Switch

const int StartButton = 7; // Motor Start button


const int StopButton = 8; // Motor Stop Button
const int Relay1 = 12;
int flag = 0;
void setup() {
pinMode(StopButton, INPUT_PULLUP); // INPUT PIN D5
pinMode(StartButton, INPUT_PULLUP); // INPUT PIN D6
pinMode(Relay1, OUTPUT); // ENABLE AS OUTPUT PIN D12
digitalWrite(Relay1, HIGH);
Serial.begin(9600); //Start Serial Monitor to display current read value on
Serial monitor
}

void loop() {
digitalWrite(StartButton, HIGH);
digitalWrite(StopButton, HIGH);
//digitalWrite(Relay1, HIGH);
//int flag = 0;

if (digitalRead(StartButton) == LOW)
{
delay(5);
flag = 1;
Serial.print("SMPS\n");
}

if (digitalRead(StopButton) == LOW)
{
delay(5);
flag = 2;
Serial.print('flag\n');
}

unsigned int x = 0;
float AcsValue = 0.0, Samples = 0.0, AvgAcs = 0.0, AcsValueF = 0.0;

for (int x = 0; x < 150; x++) { //Get 150 samples


AcsValue = analogRead(A0); //Read current sensor values
Samples = Samples + AcsValue; //Add samples together
delay(3); // let ADC settle before next sample 3ms
}
AvgAcs = Samples / 150.0; //Taking Average of Samples

//((AvgAcs * (5.0 / 1024.0)) is converitng the read voltage in 0-5 volts


//2.5 is offset(I assumed that arduino is working on 5v so the viout at no
current comes
//out to be 2.5 which is out offset. If your arduino is working on different
voltage than
//you must change the offset according to the input voltage)
//0.185v(185mV) is rise in output voltage when 1A current flows at input
AcsValueF = (2.5 - (AvgAcs * (5.0 / 1024.0))) / 0.185;

Serial.print(AcsValueF); //Print the read current on Serial monitor


delay(50);
Serial.print("\n");
if (AcsValueF < 0.15) {
AcsValueF == 0;
Serial.print("zero'd\n");
}
if (((AcsValueF > 0.15) && (AcsValueF < 0.35)) && (flag == 1)) {
// if ((AcsValueF >0.15) && (AcsValueF <0.35)){
digitalWrite(Relay1, LOW);
//delay(50);
flag = 1;
Serial.print("INTERLOCKED\n");
}
else{digitalWrite(Relay1, HIGH);
Serial.print("dpooooo\n");}
if (AcsValueF < 0.15) {
AcsValueF == 0;
flag = 0;
Serial.print("zero'd\n");
}

You might also like