MIDI to solenoids but with velocity

Hi all,

I have built midi to solenoid circuit from this page (MIDI Glockenspiel) and I am using that sketch and it all works fine. I was wondering is it possible to instead note on/off use velocity. It would probbably mean changing drive circuit aswell?

MIDI_Glock.ino (3.75 KB)

Getting a solenoid to strike with variable force is very tricky. One way might be to drive it with a PWM signal and alter the duty cycle according to the force you want. Have a try first with one solenoid using a PWM capable pin. Their is no need to change the driver circuit.

I'm not skilled with coding and have little or no idea at all how to achieve that :frowning:

mirzaarudino:
I'm not skilled with coding

Then you have something to work on.
Nobody starts out as a skilled coder, you have to do some research, try to understand examples, look at other people's code, and then try to adapt this code to your needs.

Pieter

Variable velocity with a solenoid is easier - just adjust the drive pulse width, and use a zener or resistive snubber
(not a simple diode), in order for the current to fall rapidly at the end of the pulse.

Yeah... I'd start by experimenting with pulse width. No MIDI, just a variation of the Blink Example. For example, 1ms on and 1 second off probably won't move the solenoid at all, and it certainly won't move it enough to strike the bar. So, just experiment with different on-times to find the minimum that makes a sound and the minimum-pulse that makes full-loudness.

If that works, you can map MIDI velocity to pulse-time.

The solenoids will vary so you may have to compromise or make a separate "map" for each one.