Having dabbled recently with PWM (Pulse Width Modulation) for motor control, it struck me that maybe the same technique can be applied for pulsing the Lavet stepper motor in the analog clock.
Just a recap. The Lavet stepper motor within the analog clock is design to function at ~1.5V. However, the output on the ESP8266 and ESP32 is 3.3V, and in ESPCLOCK3, the ATtiny85 is powered at ~3V. For reasons I don't fully understand, the pulse width needs to be as long as 100ms in this case, otherwise the clock will not tick reliably. This also leads to high power draw, because higher voltage + longer pulse width. In contrast, the original clock signal is 32ms pulse width at ~1.5V (which can go as low as ~1.1V since it is running on a normal AA battery).
So in ESPCLOCK3, a diode bridge is introduced, where 2 diodes in each direction drops the 3V output by the ATtiny85 down to ~1.8V (3V - 0.6V x 2), which worked remarkably well in reducing the power draw and making the clock tick with 100% reliability.
Much like PWM in DC motor control, the idea is to eliminate the diode bridge and instead output a PWM modulated pulse signal, which should reduce the effective voltage to the clock.
// Pulse given tickpin - 40ms duration = 20 x (1.25/2ms) PWM => 62.5% duty cycle ~ 2V #define X_TICK_PIN(pin) \ I_MOVI(R0, 20), \ M_LABEL(_PULSE_##pin), \ X_GPIO_SET(pin, 1), I_DELAY(10000), \ X_GPIO_SET(pin, 0), I_DELAY(16000-10000), \ I_SUBI(R0, R0, 1), \ M_BGE(_PULSE_##pin, 1)
// Decide which pin to tick X_RTC_LOAD(TICK_PIN, R0), M_BGE(_HANDLE_TICKPIN2, 2), // Pulse tick pin 1 X_TICK_PIN(TICKPIN1), X_RTC_SAVEI(TICK_PIN, 2), I_HALT(), M_LABEL(_HANDLE_TICKPIN2), // Pulse tick pin 2 X_TICK_PIN(TICKPIN2), X_RTC_SAVEI(TICK_PIN, 1), I_HALT()
What would the code equivalent for X_TICK_PIN be if I want to drive the clock using PCA9685 https://www.nxp.com/products/power-management/lighting-driver-and-controller-ics/ic-led-controllers/16-channel-12-bit-pwm-fm-plus-ic-bus-led-controller:PCA9685 via ESP32 ?
ReplyDeleteApologies, but I am not mighty familiar with the PCA9685. But it's just a standard PWN signal. As long as you can program it to output a PWN signal on one of its pins, you can play around with the duration and duty cycle of the signal. It doesn't take long to find the approximate duration/duty-cycle to use for a particular clock. It takes longer to home in on the right values for reliable operation. Sometimes slippages will occur after 10 or 20 minutes, so it is not sufficient to let the clock run for only a few minutes.
DeleteWill try that next week. Was being lazy and trying to get the conversion of your X_TICK_PIN code to more standard PWM code :)
Delete