Skip to content

Commit c18585e

Browse files
committed
disable default stagger; use 2.5ms stagger for servos
1 parent 6c8a16e commit c18585e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

examples/pioasm_pulsegroup.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(
102102
pin_count,
103103
period=0.02,
104104
maxval=65535,
105-
stagger=True,
105+
stagger=False,
106106
auto_update=True,
107107
): # pylint: disable=too-many-arguments
108108
"""Create a pulse group with the given characteristics"""
@@ -239,12 +239,19 @@ def advance(self, delta):
239239

240240
if __name__ == "__main__":
241241
pulsers = PulseGroup(board.SERVO_1, 18, auto_update=False)
242+
# Set the phase of each servo so that servo 0 starts at offset 0ms, servo 1
243+
# at offset 2.5ms, ...
244+
# For up to 8 servos, this means their duty cycles do not overlap. Otherwise,
245+
# servo 9 is also at offset 0ms, etc.
246+
for j, p in enumerate(pulsers):
247+
p.phase = 8192 * (j % 8)
248+
242249
servos = [servo.Servo(p) for p in pulsers]
243250

244251
sine = np.sin(np.linspace(0, 2 * np.pi, 50, endpoint=False)) * 0.5 + 0.5
245252
print(sine)
246253

247-
signals = [CyclicSignal(sine, i / len(servos)) for i in range(len(servos))]
254+
signals = [CyclicSignal(sine, j / len(servos)) for j in range(len(servos))]
248255

249256
t0 = adafruit_ticks.ticks_ms()
250257
while True:

0 commit comments

Comments
 (0)