0
\$\begingroup\$

I'm trying to drive a haptic transducer from an ESP32-S3 at some low frequency suitable for tactile feedback on a wearable device.

At first I tried attaching the ESP32 PWM to the transducer with just a transistor and changing the frequency - this produced some sound proportional to the tone changes I expected (tone steps not represented in this code sample,) but way too high and very faint.

Then I got a class D amplifier circuit with the following MicroPython code. Again, I got very faint high tones, but I'm not sure it wasn't just the electronics humming in both setups, not the transducer at all. I expect the thing to be buzzing like my phone haptics, more or less. What am I missing, please?

schematic

simulate this circuit – Schematic created using CircuitLab

from time import sleep
from machine import Signal, Pin, PWM

apb_clk_hz = 1000.0
freq_hz = 200.0

duty = int((freq_hz / apb_clk_hz) * (2**10))

p = PWM(Pin(10), freq=int(apb_clk_hz), duty=duty)
print(p)

sleep(5)
p.deinit()

and print(p) gives

PWM(Pin(10), freq=1000, duty=204, resolution=14, (duty=19.92%,
    resolution=0.006%), mode=0, channel=0, timer=0)
\$\endgroup\$
2
  • \$\begingroup\$ Have you tried lower frequencies? Lower frequencies are easier to feel. \$\endgroup\$
    – Mattman944
    Dec 9, 2023 at 17:23
  • \$\begingroup\$ I have tried lower frequencies (various freq/duty combinations), but I don't think I have it wired/coded right at all. Just no idea what to experiment on next. Like, is it wrong to tie the grounds together? Is the 5v's G (labeled 5v "-") supposed to be like -5v that I don't know about rather than ground? Is it wrong to have a PWM input from esp32 to a class-d amplifier (HiLetgo PAM8403)? \$\endgroup\$ Dec 9, 2023 at 18:01

1 Answer 1

1
+50
\$\begingroup\$

Your haptic device is a voice coil; basically a speaker without the cone fabric. It is a coil wound on a tube centered over a permanent magnet. When you apply a current in one direction, the coil moves, pushing a diaphragm. The opposite current will move the coil (and diaphragm) in the other direction.

Most haptic devices operate at less than 100 Hz. You are going for "feel" rather than sound. So you need the lower frequency. But you only have a short stroke distance, so running at a low frequency you will simply drive the device back and forth between its mechanical limits.

To deliver a strong response at low frequency, you will need to add a mass to the moving surface. You would size the mass so that the resonant point is close to the frequency at which you will operate.

For best efficiency, the current drive should be in both directions, balanced. Any DC current component will result in loss as heat. I might try an H bridge, although the approaches you describe would still give you a less efficient result. For most efficiency, your driver would have feedback to adjust to the resonant frequency.

Good luck!

\$\endgroup\$
4
  • \$\begingroup\$ Thanks! I have tried a bunch of low frequencies with low freq/duty combinations. I should be able to feel something if I hold this in my hand (carefully) right? I don't think I have it wired/coded right at all. Is it wrong to tie the grounds together? Is the 5v's G (labeled 5v "-") supposed to be like -5v that I don't know about rather than ground? Is it wrong to have a PWM input from esp32 to a class-d amplifier (HiLetgo PAM8403)? \$\endgroup\$ Dec 12, 2023 at 3:59
  • \$\begingroup\$ Could you add a diagram? It's pretty easy on this site. \$\endgroup\$ Dec 12, 2023 at 16:23
  • \$\begingroup\$ PWM could be your problem if it's not filtered. I'd put an RC filter between the PWM output and the amplifier input. There is no negative voltage required for the amplifier. I'm not an ESP32 programmer but I might just try a square wave output with no PWM at about 100 Hz. \$\endgroup\$ Dec 12, 2023 at 18:15
  • \$\begingroup\$ There's a diagram in the original question, no? Also, the ESP32-S3 doesn't have a DAC to make such a waveform directly. I need to find a known-good analog audio output - crazy I don't have one readily available anymore! \$\endgroup\$ Dec 12, 2023 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.