Controlling A Digital Potentiometer with VVVV & Lattepanda

Hi all,

I have a project where it’d be useful to control some electronics from my computer via a digital potentiometer. My plan is to send an OSC message from my main computer to VVVV on my Lattepanda, then convert the data via the inbuilt arduino into something that my digital pot can process using the SPI interface.

I’m fairly new to the arduino side of things, and I’m not really sure what the simplest way to implement this is. There are tutorials online describing how to communicate with digital pots over SPI, but I’m not sure how best to get OSC data into the arduino program from my main rig. I’d rather do as much in VVVV as possible since that’s what I’m familiar with.

I’ve noticed that VVVV has nodes for writing I2C data, but not SPI. If it’s simpler, it shouldn’t be too hard for me to find some different digital pots that communicate over I2C instead.

Does anyone have experience with this kind of thing?

Hi, I don’t think that SPI should represent a problem, given this scheme

OSC (Main PC) > VVVV (Lattepanda) <> I2C <> MCU <> SPI <> Digital Potentiometer

As I imagine this, whatever the protocol used to communicate between vvvv and mcu, you would connect multiple cables between MCU board and digipot, and you would communicate from MCU to digipot via SPI.h library (e.g.).
So I2C and SPI, although communicating with the same MCU, should refer to different circuits; you should consider the MCU in the middle, able to manage both protocols.

You should have all the relevant pins free to use for both protocols.

Please post the link to digipot docs, too.

Hi featherfurl,

the simplest way is indeed to find an I2C digital potentiometer.
Then you can talk to it directly from VVVV running on LattePanda (via its onboard Arduino).

Check the I2C tutorial in the latest Alphas.

The thing is that Firmata protocol supports only I2C at the moment.

Hope this helps!


p.s. The other option (a bit advanced): you’re talking from VVVV to LattePanda’s Arduino (directly via RS232 or via Firmata protocol) and have some code on Arduino side that talks to an SPI Digi Pot.

Well there’s also this. Could be the source of that girlpower, though.

You could access the pins directly from vvvv, via dynamic plugin (or VL, probably). The example just a bit down, it’s pretty straightforward (I had a very quick look, though)

Hi @h99!

There is no need for a dynamic plugin or VL, the nodes are already there:
FirmataBoard (Devices), I2CRead (Firmata), I2CWrite (Firmata) nodes are talking to an Arduino via Firmata protocol. Just be sure to use the Alpha, the I2C nodes are fixed there.

These new Firmata Basics patches in the girlpower are based on the LattePanda Doc’s VisualStudio examples and tested on LattePanda.


@robotanton Don’t have hardware around to understand, nor right now a way to check the alpha, so I had to check docs. Honestly I thought little in Lattepanda terms and more in Arduino standalone terms, with my answer, so a quick peak to docs made my ideas more clear (I indeed thought that the page could be the source of girlpower).

Anyway I think that if it’s not already in girlpower patches, it should be mentioned that in this way you’ll need little to none arduino sketching.

Thanks for the helpful replies!

I reckon I’ll just get some i2c pots for now, but looking into effective ways to communicate between VVVV and code running on the arduino will probably be a good idea in the future.

For interest’s sake, here’s the datasheet for the SPI based pot I have now, and here’s a guide describing how to control it directly from an arduino.

As I said, I have no hardware to test something. However, I have a not requested tip. You may find that delay() is somehow “blocking” the flow. When you call delay() the MCU will literally do nothing more than count the ms: until it’s done there’s no pin reading, writing, no serial stuff, nothing.
So you can write a function like this:

void wait(unsigned long timeToWait){ unsigned long t = millis(); while(millis() - t < timeToWait){ //Do you need to do something while timeToWait? Do it here //Else just remove these comments}; }

It’s very important to use ulong vars, as sketch won’t have timing rollover issues (it could run indefinitely, and you’ll have no other things to do to manage rollover). You would have found this anywhere on the web, nothing special about it; nonetheless, maybe it will save you a few time.

What hardware do you want to connect to your digipot?

You usually can’t have very high currents, be sure to first look at your maximum current and voltages and that the digipot can handle it.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.