Changing the polarity on an school model electric motor.

March 29, 2023, 11:55

sharioken

Hi, I´m working on a project were i have to create a new control method to change the polarity on a motor without using a commutator. I already implemented a bridge circuit and that part works fine. I just wanna now how i could get the program to activate and deactivate my relays after exactly half of a rotation

oops.se

This is normally done with MOSFET bridges as relays is to slow.

sharioken

Hmm okay, but how does the code have to look like if i want to keep my H-Bridge output on high until the other anker passes my Photoelectric barrier, then it has to switch back to low and so on.

oops.se

What have you done to search for an answer?

sharioken

I´ve searched the internet for a few hours and tried a few codes like: int SensorAnalog = A1; int Relais1 = 6; int Relais2 = 4; bool trigger = false; void setup() { pinMode(Relais1, OUTPUT); pinMode(Relais2, OUTPUT); pinMode(SensorAnalog, INPUT); } void loop() { int wert = analogRead(SensorAnalog); if (wert <= 300 && !trigger) { digitalWrite(Relais1, HIGH); digitalWrite(Relais2, HIGH); trigger = true; } else if (wert <= 300 && trigger) { } else if (wert > 300 && trigger) { digitalWrite(Relais1, LOW); digitalWrite(Relais2, LOW); trigger = false; } } i just tried to combine thinks because i couldn´t find any simular thinks :/

sharioken

But they all don´t keep the bridge active until the second anker activates them again

oops.se

Use enclose code with backticks, then its formatted properly. And without a wiring diagram ...