Micro Maestro Error mid-script

I have put together a system that consists of the micro maestro 6 channel, paired with the 5 cm distance sensor (also pololu brand). I have soldered the Vin to the + side of the servo power with the intention of running the whole board and servo off of one power supply. (see images)


I am powering everything via a 5 V 6 A power supply. The highish current is due to the servo being a 40 kgcm servo.

I programmed the board via the following script, which translates as i understand it to
read button a (which is the sensor)
if the button reads low, then run through sequence a, else loop
if the loop is activated then set change servo position from 6400 to 3200, hold for 6 seconds, then set servo position back to 6400 (the 3 delays of 2000ms was just me troubleshooting possible line timeouts, which was unsuccessful)

code follows:

begin
		button_a if sequence_a endif
repeat

sub button_a
		1 get_position 500 less_than
		return

sub sequence_a
		6400 0 servo 6 0 acceleration 1000 delay
 	3200 0 servo 2000 delay 
		2000 delay 
		2000 delay 
		6400 0 servo 3 0 acceleration 2000 delay
		return

long story short, the code runs perfectly fine whilst plugged in via USB, however when i unplug the USB and run on internal storage, then the code terminates mid sequence, almost as if it encounters an error. i never get any error message on the error terminal when plugging back in either. Could this be because of me powering everything together from 1 power supply? I plan to have this running 24/7 as a dustbin open at home so that the servo connects via links to open the bin without me having to push any levers or lifting the lid myself

Hello.

If it runs fine while connected to USB, then I suspect it is a power issue. The Maestro’s minimum operating voltage is 5V, so even a bit of noise with a 5V supply could be enough to cause problems. If you have access to an oscilloscope, I recommend monitoring the voltage on VIN to get a better idea of what’s going on. If not, you could try removing the jumper wire between VIN and the servo power rail and using a separately supply to power VIN as a test to see if that fixes the problem.

If that is the problem, you might be able to fix it by adding some capacitance. Otherwise, if you want to power it all from one source you might consider switching to a 6V supply (and powering the distance sensor from the Maestro’s 5V pin). Alternatively, you could use a step-up regulator to power the Maestro’s VIN pin with a more appropriate voltage.

Brandon