Recently, I made a big structure for my solar panel and solar collector, and I used two 230V single-phase AC motors. The only way I can control the motors is using relays. I added some limit switches in series to the motors, and they are normally closed. I built the circuit so the electronics part has finished. I started the coding and I got stuck with main part, where the motor controlling happens. I used 4 photoresistors, and I looked for the differencies between them, and the motors will move according to them. Now the problem is that you don't have the same control over the motors, like a servo or a stepper motor. You can't tell the motor how far does it has to go. You can only turn them on or off with digitalWrite. But how can I make a function for that controlling? I searched on the internet for these types of controlling, but I only found functions with servos.
It's probably best to replace the motors with servos, unless you have them clutched and overrunning isn't a problem. There is no way to "control" the travel accurately. You can overrun them using a clutch, physical limits, and on intervals that are timed in millis() like blinking an LED...
Ok, so here is the wiring. The brown is the live and the blue is the neutral. The points marked "W2" and "V1" are where the wires have to be connected. The "V2" is the earth, and the others are for additional points for the factory wiring.
A note here is that if you close the relay the motor will spin. when you open the relay the motor may keep spinning and slow down. the solar array may overshoot a bit. this is not a bad thing. if it overshoots by a few degrees, then in a few minutes, the rotation of the Earth will have the Sun dead center and before long, the array will need to be advanced again.
I would assume you have the motor with some heavy gearing so that you might need many motor rotations to move the array a little bit.
I don't quite understand the problem... If there is a significant difference between the LDR readings, you move the corresponding motor until the difference is gone.
Now the problem is that you don't have the same control over the motors, like a servo or a stepper motor. You can't tell the motor how far does it has to go.
You don't have to tell the motor how far to go, you keep sampling the LDRs as you power the motors.
Getting them to stop when the LDRs give a signal that optimises the PV direction.
The controller is fast enough to do this.
You are basically making the AC motors into servo motors and using the LDRs as the position feedback.
The setpoint being the equal sensor signal from the LDR sensing pair.