killing serial port with L289N, simple relay, 12v plus kills loop()
greetings dallas , "huh?"
using elegoo uno, don't remember brand of l289n controller. driving off-the-shelf autozone relay power 70n electromagnet. code below drives electromagnet 1 time through loop(), can see output stops serial communication - there should several additional text output lines. makes port unrecognizable on pc.
the electromagnet holds , leds light according above code. serial monitor displays:
solenoidtest1
1
enter milliseconds hold
doing: solenoid() green hold 2000
start solenoid(),
i think code makes sense, circuit magnet. there 2 accelerometers , 12v brushless motor, 12v circuit 100' of cable pushbutton , 3 large indicator lights , works fine when pull electromagnet out & remove code it. code above intended show forum problem in isolation.
thanks comments,
chuck
using elegoo uno, don't remember brand of l289n controller. driving off-the-shelf autozone relay power 70n electromagnet. code below drives electromagnet 1 time through loop(), can see output stops serial communication - there should several additional text output lines. makes port unrecognizable on pc.
code: [select]
char pgmname[] = "solenoidtest1";
int i, j, k;
int working, holdingup, loopcount;
int solenoidmilliseconds = 5000;
byte greenled = 8;
byte yellowled = 12;
byte lenable1and2 = 5;
void setpins(){
pinmode(greenled,output);
pinmode(yellowled, output);
pinmode(lenable1and2, output);
digitalwrite(lenable1and2, low);
} // end setpins()
void setup() {
serial.begin(9600);
serial.println(pgmname);
setpins();
working = 0;
loopcount = 0;
}
void loop() {
loopcount++;
serial.println(string(loopcount));
error1:
serial.println("enter milliseconds hold");
while (!serial.available()){ ;}
delay(50);
while(serial.available())
{
solenoidmilliseconds = serial.parseint();
if(serial.read() != '\n')
{
if(solenoidmilliseconds > 10000){
working = 0;
goto error1;
}
}
serial.println("doing: solenoid() green hold "+ string(solenoidmilliseconds));
solenoid();
delay(1000);
serial.println("doing: solhold() solrelease() yellow");
solhold();
delay(solenoidmilliseconds);
solrelease();
}
} // end of loop()
void solenoid()
{
serial.print("start solenoid(), ");
digitalwrite(lenable1and2, low);
digitalwrite(greenled, high);
holdingup = 1;
digitalwrite(lenable1and2, high); //energize
delay(solenoidmilliseconds);
digitalwrite(lenable1and2, low); //release
holdingup = 0;
digitalwrite(greenled, low);
serial.print("done solenoid(), ");
} // end solenoid
void solhold(){
serial.print("start solhold(), ");
digitalwrite(lenable1and2, low);
digitalwrite(yellowled, high);
holdingup = 1;
digitalwrite(lenable1and2, high); //energize
serial.print("done solhold(), ");
}
void solrelease(){
serial.print("start solrelease(), ");
digitalwrite(lenable1and2, low); //release
holdingup = 0;
digitalwrite(yellowled, low);
serial.print("done solrelease(), ");
}
the electromagnet holds , leds light according above code. serial monitor displays:
solenoidtest1
1
enter milliseconds hold
doing: solenoid() green hold 2000
start solenoid(),
i think code makes sense, circuit magnet. there 2 accelerometers , 12v brushless motor, 12v circuit 100' of cable pushbutton , 3 large indicator lights , works fine when pull electromagnet out & remove code it. code above intended show forum problem in isolation.
thanks comments,
chuck
sounds current through pin. how current coil on relay use? have internal protection diode well? coil on relay 5 volt?
Arduino Forum > Using Arduino > Project Guidance > killing serial port with L289N, simple relay, 12v plus kills loop()
arduino
Comments
Post a Comment