This is only a temporary code to read control commands from the serial monitor:
s stop all the servos
c order the roof to go in higher position
u order the roof to go to the lower position
e emergency system stop
t to test distance in next development step
d display active/inactive
I read one character and discard any other one to avoid repetition.
Hi,
I assume you have the gnd of the Mega and the gnd of the servo supply connected together?
Do you have a DMM?
Have you monitored the voltage at the power input of the Mega?
How are you powering the Mega, 5V to the 5V pin or 7V or higher through the DC socket?
This sounds more and more like a power supply problem.
We need a schematic, even if you only show a few servos but note the connections to the others.
Is this where the problem occurs, or can the roof be moving up or down anywhere when
Sorry for the delay, but I cannot send more messages yesterday (I am a new rookie in the forum).
I use the maximum Baud Rate to avoid delay when using debug, but the problem happens also
at lower speed.
I include a simple schema of the connections and a general view of the model.
As you can see GND from the Arduino and the power supply are connected together.
I check the VCC at the power supply output and it is stable around 5,6V
The Arduino get the power from the USB for now.
The power supply a maximum of 10A and each servo as a peak consumption of 300 mA, so 3,6A in total, enough with my power supply.
When the problem occurs the roof could be moving up or down. the big issue is when the roof is in "up" state, as the Arduino Arduino is frozen and does not read the state of the microswitches to stop the roof when it reachs the higher position. I cannot even send the emergency command to stop the servomotor for the same reason: the sketch is frozen. My
only option is to cut the servos power supply.
I read about increasing the SoftwareSerial Rx buffer could solve overload problems #define _SS_MAX_RX_BUFF 256 // RX buffer size //BEFORE WAS 64
and I will try this afternoon.