Forum

FFT to PulseModulation - Higher Volume = Faster Pulse

Hey everyone,

I rarely ask questions on this majestic vvvvorum since most questions can be answered by searching ;) Im a lurker.

Im trying to translate FFT Values from 4 Pianos to 4 Electromagnets.

The magnets are triggered with a mosfet via Arduino. The magnet strengh can be controller via Pulse Modulation. The faster the Pulse ( or a constant 1 ) the stronger the magnetic field. So i need loud sounds in any frequency to be translated into a fast Pulse, lower volume = slower pulsing

The music is a piece by john cage, so theres really many random notes. Very high, very low sounds that slowly descent into silence.
I used the Meannode to get an average value for all tonal frequencies.

I have had no possibility to test this with the magnet yet, but will be able to test it later today.

The main Problem is the fact that the “period” on the LFO im triggering to creat the pulse is constantly changing. I have added another LFO with a queue node to keep it from changing all the time.

Im not sure if a LFO is the right choice to create a Pulse fast enough for a magnet, but im not aware of alternatives and would welcome help on this :)

FFT_PulseModulation.v4p (14.9 kB)

to get the volume of the sound, use the RMS node. and the LFO can get as fast as your framerate… what pulse speed do you need?

Hey tonfilm. Thanks for you reply ive been butchering you 4Channel FFT Nodes already. The decay and Multiplier values will give me a good chance of adjusting the FFT analysing to each piano input. RMS Seems to work very well too.

Atm im at a 0.0001 LFO Pulse. With this Interval it will not pulse but turn the magnets completly on. Im not sure if this is caused by the framerate limit or if this is how the magnets usually react.

If I change the Background FPS on the Mainloop node, will this effect the pulse speed i can send into the Arduino board?
What would be the maximum Background FPS I could set up?

the Background fps only takes effect when vvvv is not the application in the foreground, means another application (for example notepad) is selected in the taskbar. i think this is not what you are looking for.

use the timing node to check how fast vvvv runs at the moment. as soon as you open a DX9 renderer it will drop to 60fps unless you set the presentation interval of the renderer to immediately.

i think you have to program the arduino to generate the pulse wave and then just send a value from vvvv to tell it how fast it should do that.

Be sure to use AnalogOuts on the Arduino, if you don’t need too many of them and if you want to have an easy job doing this. Emulating PWM in vvvv can be done with Kalle’s PWM module but, at least in my experience it’s not the way to go with an Arduino and its DigitalOuts (the resulting PWM on the Arduino just isn’t fast enough to be of real use), the PWM part must be running on the Arduino.
Failing to provide as many built-in PWM Outputs as needed, you could go for either a bigger board (the Mega offers more), a Wiring board, or employ your own custom sketch for turning DigitalOuts to PWM (tricky), or use some smart shift register solution (http://www.elcojacobs.com/shiftpwm/) or, even better, hook up a PWM chip like TLC5940 (http://code.google.com/p/tlc5940arduino/). The latter is recommended. See also karistouf’s ArtNet arduino set v2 in the contributions section.

For starters (and maybe solutions), check BasicMata Arduino Interface or ArduinoFirmata to make vvvv talk to the Arduino. Thanks to the folks behind these modules, btw.! A future project of mine needs some 100 PWM Outs, 12V @ 1A load each. So far, quite demanding, at least for me. So, post your results here.

hey, thanks for the input, ive been able to get it running yesterday evening :)

Tonfilm:

Sadly i have no idea how to programm anything on Arduino.
What i would need to do is programm something like an LFO onto the arduino for each input and let it send PWM Out by only giving it the LFO Period speed via VVVVirmata.

If i have 60FPS on VVVV would i get a max Pulsespeed of 1Second/60Frames = 0.0166~ ? I will try if this pulsespeed is fast enough to do the job and then reconsider programming/sketching the Arduino for it.

Patrick:

i have got it running by sending Analog pulses to the pwm outputs of the Arduino with VVVVirmata.

If the PWM part would be calculated on the Arduino board i would need 4 regular Inports & 4 pwm ports, which are available on the Arduino. Sending for example 0.0003 Pulsespeed value to the Board and let it translate it into a pulse in that speed.https://vvvv.org/sites/default/files/imagecache/large/images/FFT_PulseModulation_2012.10.12-11.28.58.png

Basically, you want high RMS to generate high voltages (0 - 5V). The AnalogOuts on the Arduino provide (PWM’ed) voltages between 0 - 5V (in theory), that’s what you need for your magnets or a circuit/network driving them. When your Arduino features as many factory analogue Ins & Outs as you need for your project, what do you need additional PWMs for? Send your mapped values to a vvvv-Arduino setup of your choice (see my post), that’s all.
Maybe I am just terribly misunderstanding you.

There’s no point in doing the PWM part in vvvv, unless you’ll find a highly effective Arduino patch which let’s you. I doubt that’s feasible. Have a look at http://softsolder.com/2009/02/21/changing-the-arduino-pwm-frequency/ or http://softsolder.com/2009/03/04/arduino-fast-pwm-faster/ for some calculus (which, alas, are a bit beyond me).
I’d love to be proven me wrong here and offered up a working solution though, really, that would help me too. In any case, the best PWM you can get with an Arduino is in conjunction with a TLC5940.

well, it is possible to do pwm in vvvv

I helped building an early prototype of http://dreipuls.de/product/rima/ for a trade fair and streamed pure on-or-off-bits for some 120 individual leds. That meant calculating 8 packets or more each vvvv frame and sending it to a custom programmed atmega.

wasn’t the smoothest blending naturally, but not totally punk either.

Which hardware did you use for that project?

it was basically dreipuls’ prototype lamp:
atmega on a custom board and a whole bunch of ics in modules to address and decode the LEDs status. connection was by usb, which proved to be a pain.

If you don’t mind, please be more specific about the Atmega, the ICs and the PWM part (if done inside of vvvv).

If smooth dimming, latency and scalability are paramount, my research (so far) boils down to a chain of a microcontroller board of your choice, be it Wiring/Arduino/whatever interfaces well with vvvv, one or more TI TLC5940 (they can be daisy-chained and provide 16 outputs each) and maybe some circuitry to drive higher loads (the latter may be ignored for now).

Our great @karistouf developed the ArtNet Arduino Set (see contributions), allowing an ArtNet connection/communication between vvvv and an Arduino equipped with a standard Ethernet shield. The TLC5940 can be driven this way. Pretty much the way to go on a large scale approach.

Any detailed thoughts and hints appreciated on that matter (and generally, of course). Given an affordable solution for a multi PWM controller, that can be directly accessed in vvvv, we might as well fuggedaboutthat completely. Alas, there’s no such thing (yet).

sorry, cannot be more specific. just wanted to make the point, that it is not totally out of the question to do pwm directly in vvvv.

Thanks for your input guys. Really cool work btw.

So for now im able to trigger all 4 magnets with Vvvvirmata. Im not able to dimm their power with my pulses properly but this has to do for now.

Ive never programmed anything for arduino and so i wont be able to program something quick to send a frequency value to arduino and let it do the pwm for me. Should have opened this thread much earlier since my deadline is next week. ;) Maybe i will try to get it to work properly after the concert…

The 4 magnets are all working, being triggered and all, and Kalle LFO (pwm) is doing some nice pulsing to the ferofluids. I will post some pictures of my results.

cheers!

Any reason for not using the AnalogOuts your Arduino provides?

Just an idea: Use the output of multichannel soundcard instead of arduino, generate waveform inside simple software synth VSTi. For amplification maybe just two large audio amplifiers? How strong are your magnets?