Arduino Forum

Using Arduino => General Electronics => Topic started by: Stoopalini on May 04, 2017, 05:32 pm

Title: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 04, 2017, 05:32 pm
Hello,

I've an idea I am trying to implement, and hoping the Arduino platform is capable of solving this problem.

I have a device (guitar effect pedal) which uses analog potentiometers to set parameter values, and I want to add the capability to store and recall presets for resistance values on the pins to which the analog potentiometers are connected. 

The POTS are measuring 80k across the sweep.  The pedal has 6 POTs, but I only need preset control over 2 of them.

Here is what I'm working with ...

(https://c1.staticflickr.com/5/4187/33607028904_198bd8a5d3_b.jpg)

(https://c1.staticflickr.com/5/4160/34318707531_fc573d0646_b.jpg)

... and I want to enable preset recall on the LEVEL and the DRIVE parameters.

The pedal operates on 9v power, either battery or external DC power supply.  I typically run it off the external power supply.

Here is a rough list of requirements I drafted up to help me define scope of what I am trying to do:

Quote from: My Requirements
  • Add ability to turn knobs and set desired parameters, then save current settings to memory for future recall through MIDI Program Change messages.
  • Control over DRIVE and LEVEL parameters as a minimum.  DRIVE, LEVEL, MID, and CHARACTER as a stretch goal
  • Retain ability to manually turn knobs and use the pedal without MIDI connected
  • Need to retain 9v DC power to the pedal.
  • Using an external control box for MIDI preset storage and control is a suitable solution, so long as the pedal can still be manually used without the external controller connected.
  • Pedal must retain last known state of parameter values when powered up, even without external MIDI controller connected.  Last known values can be physical position of the knobs if MIDI controller is not connected.
  • Would prefer to retain the original enclosure, but will transplant to a new enclosure if needed.

My 1st thought was to replace the two POTs with rotary encoders, and determine a way to enable those encoders to control a resistance circuit connected to the PCB inside the pedal. Then have an external box for MIDI interface, and have it send preset values to the resistance circuit.

But looking at all the Arduino projects and capability, I'm wondering if I can leave the existing POTs in place, and just re-reoute their signal into a Nano's analog inputs.  Then have code inside the Nano to enable the POTs values to be passed when no external MIDI controller is connected (therefore retaining normal use of the pedal), and also allow POT override when the MIDI controller sends a Program Change message; thus recalling preset values for the two circuits to which those POTS are connected.

There is enough room inside the pedal enclosure, on top of the POTs, to fit an Arduino Nano.  I'm thinking this could be for controlling the two resistance circuits.  Then have an external enclosure with some sort of MIDI interface, connected by an interface cable, for receiving PC messages and, in turn, sending messages to the Nano inside the pedal, overriding the POT values and setting specific values for the two resistance circuits.  The presets would be stored in the external MIDI controller in this type of scenario.  But if the NAno can do that as well, great!

I know Arduino also has a MIDI device, and I'm hoping this can be used for the external controller.

I hope what I typed makes sense, and appreciate any advice you guys can offer.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 04, 2017, 08:09 pm
A nano is nowhere near powerful enough to do the a/d and d/a to sufficient resolution and speed to handle the audio signals directly. You can buy electronically controlled potentiometers that can do the job,   There are MIDI libraries available for the arduino, and it could easily drive the electronic pots.

Allan.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 04, 2017, 09:09 pm
Hmm, I wasn't thinking I needed to do d/a and a/d conversion with this, but it brings up a good point as to if the audio signal is passing through the POTs directly, or if the POTs are just controlling other circuitry on board which in turn modify the audio signal.  I was assuming the latter, but need to find out.

I actually have a message into Tech21 asking for some details, and they've been pleasantly helpful thus far.  I'll ask them this question and see what they have to say.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 04, 2017, 10:26 pm
You can buy electronically controlled potentiometers that can do the job,   There are MIDI libraries available for the arduino, and it could easily drive the electronic pots.
By "electronically controlled POT", do you mean motorized POTs? 

I had thought about this too, but wasn't sure if the motorized POTs could feed the location signal back to the MIDI device for preset storage.  I had also read in another thread that determining initial position upon power up can be tricky.  Is this why I se "dual channel" motorized POTs in my searches?  One channel for the signal, and the 2nd channel to feed location info back to a controller?

Any suggestions on ones which might be good for this?  I dug into the pedal a little further, and the POTs being used are 100k.  They're marked "4B100K" under the chassis. 

So 1st step would be to get the POTs replaced with motorized ones, and then send them a basic signal to see how the pedal reacts to them moving under motor power.  Want to make sure I'm not injecting audio noise into the guitar's signal by placing little motors inside the pedal. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 04, 2017, 11:06 pm
Quote
By "electronically controlled POT", do you mean motorized POTs?  
No.
https://www.arduino.cc/en/Tutorial/DigitalPotControl (https://www.arduino.cc/en/Tutorial/DigitalPotControl)

Quote
Is this why I se "dual channel" motorized POTs in my searches?  One channel for the signal, and the 2nd channel to feed location info back to a controller?
Yes

Quote
Want to make sure I'm not injecting audio noise into the guitar's signal by placing little motors inside the pedal.  
You will not fit one inside the box they are about 7" long.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 04, 2017, 11:38 pm
Looking at the circuit board photo you posted, I'm almost certain that the pots handle the audio directly.  It's by far the simplest way.

Hence my earlier comments apply.

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 04, 2017, 11:51 pm
Funny, I searched on motorized POTs and quickly realized they are way too large for this.

Then I was just reading https://www.arduino.cc/en/Tutorial/DigitalPotControl (https://www.arduino.cc/en/Tutorial/DigitalPotControl), and when I finished, came back here to post again ... and there you are, pointing me in the right direction :)  Thanks!


So essentially, I can use 2 channels of an AD5204 as 2 digital potentiometers, with the Ax, Bx, and Wx pins of channels 1 & 2, connected to the A, B, and W pins on the pedal's PCB, which currently have the existing analog potentiometers connected.

Then connect the AD5204 to a Nano, as well as redirect the connection of the existing analog pots to the Nano.

Then have two modes within the Nano's programming: 

1) Manual mode, where the analog POTs are used to set the values of the digital POTs
2) Preset mode, where saved values are recalled and used to set the values of the digital POTs


Is this the right way to read an analog POT for this purpose:  https://www.arduino.cc/en/Tutorial/Potentiometer (https://www.arduino.cc/en/Tutorial/Potentiometer)


I understand I need to pickup the parts and start with small experiments to get comfortable with the coding, but want to be sure I pickup the right parts for the job.


After successfully getting something like the above working, I would then move on to the MIDI interface ... using MIDI Program Change messages as a trigger to recall presets for the digital POTs.

Thanks for the help ...
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 04, 2017, 11:57 pm
Looking at the circuit board photo you posted, I'm almost certain that the pots handle the audio directly.  It's by far the simplest way.

Hence my earlier comments apply.

Allan
Gotcha.  If they do handle the audio directly, would sending the audio signal through an AD5204 cause an issue?

Here's a pic of the other side of the board, removed from the enclosure:

(https://c1.staticflickr.com/5/4179/33613276774_ed5b4a90ec_b.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 05, 2017, 12:01 am
Nope.

 That'll be fine.

But building your multi - AD5204  circuit and interfacing it neatly will be a nice little project.
A small PCB  would be a good  way.

Or find out what the box actually does, and build a complete midi-controlled one of your own... might even be a market.  Looks like it can't be much more than simple filtering.

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 05, 2017, 01:54 am
The thing is that the AD5204 is a liner pot and things like volume need a log law pot. Can you see what pots the unit has, or measure them to see the law?

Their also tends to be a bit of a click when the pot changes value.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 05, 2017, 01:55 am
I was thinking the same thing, in that I should get a small rectangular PCB to mount the Nano and the AD5204 onto.  

One question about linking the Nano to the future MIDI interface:  Will I be able to use the USB port on the Nano to do bi-directional communication with this separate I/O device?  Or is the USB port limited to programming the Nano?

For the MIDI interface box, I was thinking another Arduino with a 5-pin DIN jack for receiving commands from the MIDI network, some way to store around 50 presets, ability to send preset information to the pedal's Nano, ability to receive information from the Nano inside the pedal for creating new presets, a mechanism for manually selecting preset numbers and storing current parameters, and some sort of visual indicator of selected preset number (small LCD I presume).  I'm not so concerned about designing this piece yet, I just want to plan ahead with respect to how I'll interface it to the Nano inside the pedal.

I'm hoping the two could transfer data to each other VIA the integrated USB ports and not require direct connection to the pins on the Arduino.  If I can do this, mounting it will be easier, as I can just notch the pedal's enclose to expose the USB port on the side.  If it has to be attached to pins on the board, it'll add complication to the pedal's enclosure.  


So for a shopping list, I've got:



Then I'll need someway to tap 5v off of the pedal's incoming 9v power supply.  I haven't thought through this yet though.  I'll need to step it down from 9v to 5v somehow, but considering the current is so low, I assume it'll be fairly simple?  Unless there's an Arduino board that'll accept 9vdc and be small enough to fit ...

Thanks again for your input, it's been a great help!
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 05, 2017, 02:03 am
The thing is that the AD5204 is a liner pot and things like volume need a log law pot. Can you see what pots the unit has, or measure them to see the law?

Their also tends to be a bit of a click when the pot changes value.
The only indication of the POT details is the marking "4B100K".  Not sure if they are linear or audio taper though.  If I'm using the existing analog POTs to drive the value though, will it matter?  The values would be set, and then left until the next preset was recalled, so no real sweeping of the value while in use.  The preset values would be based on the values the existing POTs are putting out.

I understand the taper will be different between the two, but thought if the analog POT was used to capture the value, and then that value was sent to the digital POT, that the value would be the same between the two.  Or does the conversion work based on % of sweep instead of a set resistance value?

So if the analog POT was placed where the H side has 75k, and the L side has 25k, would the Nano code be able to set the digital POT to be 75k and 25k as well?  Or, if due to the taper, these values translated into 85% sweep on the analog POT, would the 85% value be used to determine the digital resistance values, and since it's linear, would result in 85k on the H and 15k on the L?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 05, 2017, 08:24 am
ou can get aidio taper digital pots - see eg https://www.maximintegrated.com/en/app-notes/index.mvp/id/1828.


But.


You much experience do you have?

This is not quite a trivial project - it needs a pcb.

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 05, 2017, 10:34 am
The other thing you must check is that there is no voltage greater than 5V on those pot pins otherwise you need optical isolators on the controls.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 05, 2017, 03:02 pm
Thanks for the input guys. 

ou can get aidio taper digital pots - see eg https://www.maximintegrated.com/en/app-notes/index.mvp/id/1828.
Does the taper of the digital POTs make a difference here, since they're just being used to set a static value at a given time?  And that static value is determined by the analog POT?  Even the preset values would be determined by the analog POT's position when the preset is created. 


You much experience do you have?  This is not quite a trivial project - it needs a pcb.
I don't have experience with Arduino, but do have experience building other DIY type devices.  From building a programming interface for OBD-II automotive application, to building a 4 channel IR receiver to 12v trigger output device for home theater, to creating electric powered ride on vehicles for my kids using PWM controls for variable speed, electrostatic braking, lighting controls, etc ...

I did learn programming, although it was a few decades ago in languages no longer used.  I was a comp sci major back in the early 90's. 

I've been reading the instructables, and am starting to get an understanding of the Arduino code and how it logically flows.  I also have a brother who is a programmer by trade, and he has experience with the Arduino platform as well as PCB circuit building.  I'll be tapping into his knowledge here as well.

I'm typically the kind of guy who will dig in deep and learn what I need to for the goal I am trying to achieve.

The other thing you must check is that there is no voltage greater than 5V on those pot pins otherwise you need optical isolators on the controls.
Good point.  Considering the pedal uses a 9vdc power supply, it could be possible the voltage through the existing POTs exceeds 5v, but I doubt it does considering it's a guitar's audio signal passing through them. 

It looks like there are two TLC2264 amplifier IC's on the pedal's PCB, not sure if they're pre or post the 2 POTs I am looking to control though.  I'll have to hook up the pedal and check voltages while sending a clipped audio signal through it to check the max possible voltage that could be seen. 

I see from the AD5204 datasheet, the A, B and W pins max voltage is the Vdd, which in normal case should be 5v.  The datasheet says the Vdd absolute maximum ratings are -0.3v to +7v ... so it appears there is some tolerance there though. 

From a circuit design perspective, would it be the "right thing to do" to add optoisolators between the existing PCB POT pins and the AD5204 digital POT's A, B, W pins? They seem like fairly small chips, so space shouldn't be a concern ... but how they will impact the audio signal would be.  The last thing I want to do is ruin the great tone this pedal gives my guitar's audio signal. 

EDIT: I just put a meter on the POTs, and am seeing 4.3v across the "LEVEL" POT pins and ground, and 5.5v across the DRIVE POT pins and ground.  Considering this, do I need optoisolators, or could I use 5.5v as Vdd on the Arduino and AD5204, considering it is within the max specs?

And on another note:  Is there a good circuit design website/app which has the typical components available in the Arduino world for designing the Circuit and laying it out?  I've used these in the past, but having the available components in the tool's library is always a plus.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 05, 2017, 04:23 pm
The TLC2264s are quad rail-rail opamps.  Naturally their ouputs can't go below the -ve supply, so 1 of the 8 opamps is probably used to generate an artificial '0v' at about 1/2 the supply . so everything swings about  this - roughly +/- 4.5 v . That's how I'd do it. And that's where the dc of the pots will live.

Identify this 0v, and see if one end of the pots is connected to it - I bet most are.

Since the supply is floating ( a battery) there's no reason why you can't attach the arduino's 0v to this artificial 0v.

Since there are only plain opamps in the design, it's unlikely that it uses anything which is dc critical - just connect your digipots where the existing ones are . If worried, connect them with mediumish capacitors - with 100k impedance 10uF's would be fine.  I wouldn't bother with optos.  But ferrite beads on all the wires between the arduino and the audio stuff would be a good safety measure - ie making seperate analog and digital earths .  And if you want to power the arduino with the board's '0v' and it's +4.5 ( quite feasable) add a ceramic cap  on either side of the bead to digital and analog earths respectively.

I'd use a 8MHz pro mini for this, and remove the power LED to reduce power consumption - see Nick Gammon's exellent write-up on reducing power.

Good luck.

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 05, 2017, 04:57 pm
Great info, thanks so much! 

Related to your comment about the floating power supply (ie: the 9v battery):  Sometimes I power this with a battery, but 90% of the time I use a 9v wired power supply instead.  The pedal has a 9vdc jack on the side, which I connect an isolated lead from a TrueTone 1SPOT Pro into. 

Does that cause complication in using the pedal's artificial 0v and 4.5v to power the Arduino? 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 05, 2017, 05:10 pm
Nope.  Unless the -ve of the supply is earthed, which is unlikely - check with a DMM.

If it is it means that you'll have to programme  the in-circuit arduino with an isolated computer - eg a laptop - to avoid shorting out the audio's virtual earth. And since you're using a mains psu you needn't worry about power consumption, so ignore my comments on the pro-mini ( which, would, nevertheless, be a good solution.)

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 05, 2017, 05:18 pm
I'd use a 8MHz pro mini for this, and remove the power LED to reduce power consumption - see Nick Gammon's exellent write-up on reducing power.
I took a look at the Pro Mini specs, and saw this:

Quote
The Arduino Pro Mini can be powered with an FTDI cable or breakout board connected to its six pin header, or with a regulated 3.3V or 5V supply (depending on the model) on the Vcc pin. There is a voltage regulator on board so it can accept voltage up to 12VDC. If you're supplying unregulated power to the board, be sure to connect to the "RAW" pin on not VCC.

The power pins are as follows:

RAW For supplying a raw voltage to the board.
VCC The regulated 3.3 or 5 volt supply.
GND Ground pins.
So considering the bold statement, could I just connect the Mini directly to the incoming 9vdc jack on the side of the pedal and the integrated regulator will take care of stepping it down to 5v?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 05, 2017, 05:54 pm
Yes.... but....

If you do you MUST isolate the digipots running from the arduinos's +5 from the audio stuff with capacitors - 3 per pot - since their 0v will be 4.5 volts or so lower than the audio's '0v'.

And if any of those audio  pots ARE handling dc, they won't work. Check with a DMM.

Allan.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 05, 2017, 06:12 pm
I stuck a meter on the audio POTs and get a reading of 4.3v on one POT (each leg had the same reading) and 5.5v on the other POT (each leg had the same reading). 

Rotating the POTs did not seem to change the reading value.

I tested by placing the POS lead of the meter on the POT's leg, and the NEG lead of the meter on the battery's NEG pole. 

Is this what you mean by "handling DC"?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 05, 2017, 06:32 pm
Just thinking out of the box here: 

Is there such a thing as a Potentiometer which allows the shaft to be manipulated from the bottom, as well as having the standard knob on the top of the shaft?  Something like the shaft extending through the bottom plate, or a hole in the bottom plate with a hollow shaft POT for a coupler to be inserted?

If something like this exists, I could swap the two POTs for this type, then use micro servos on the bottom to provide automation control over their position.  and control the micro-servos with the Arduino. 

I could then use an external power supply as well, because the Arduino would not need to be powered up for manual operation of the pedal.

This would certainly simply things if it's possible. 

EDIT:  Oh, and BTW:  I read somewhere that the 'B' indicator on the POT means "linear taper", and an 'A' designation would mean "Audio taper".  So I took an OHM measurement of the POT sweep, and it appears they are liner, being that the reading was 1/2 the overall value when the shaft was turned 1/2 way.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 05, 2017, 10:53 pm
Phew....

well yes , I suppose it could be done. And you can buy dual concentric pots. Plus all the servos etc.....

hmmmm


But.

 I'd attach all your analog pots to analog inputs on the ARDUINO, and several modes ...

1- just reproduce the analog pot values on the digipots - ie 'straight through'
2 - store settings - perhaps triggered by a push button - preset 1,2,3 etc
3 - replay settings - again triggered by another button .

A display eg a 2x16 LCD would be a help in telling you where you are.

Plus.. just for fun - a sequencer which fades between given or indeed random presets  -  perhaps triggered by a microphone on the bass drum..........

could be ghastly - but rather fun? Stockhausen, Boulez etc, make way!

Or , of course, you could get the MIDI master to do all this.

Allan.

ps there are ways to suppress the clicks, but these add considerably to the complexity.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 05, 2017, 11:58 pm
The thought around the servo idea was to not interrupt the audio signal.  Plus, it would be rather cool to watch the knobs locate when a preset was recalled. 

I did hear back from Tech21, and they confirmed the audio signal does pass through the POTs. 

So using servos would negate the issue of the clicks, as well as the power isolation problem. 

I can't seem to tell which POTs could be turned from the bottom though.  I found these, and they seem small enough to work, but I don't know if that hole in the bott could be used with a shaft or coupler to turn it. 

https://www.amazon.com/gp/aw/d/B0169OP0XW (https://www.amazon.com/gp/aw/d/B0169OP0XW)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 06, 2017, 12:12 am
Back in the 70s I worked for a major console manufacturer - Neve in the UK, where we invented the modern automated mixdown system with 'flying faders'


They weren't cheap.

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 06, 2017, 12:37 am
Oh ya, flying faders are great!  I've used several consoles with them.  Also have used Presonus, who implemented scene recall without moving faders.   Talk about adding confusion! Especially when the sound engineer forgets to recall the positions. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 06, 2017, 09:22 pm
The flying faders had 2 tracks - one linear for the position, and one audio taper .  Penny and Giles made the faders, and we installed motor drives and control loops.

I often thought it might be possible with 2 LDR's, equally illuminated by a light source, to do a similar job.  A crude VGA. I never followed it up. Electrically a 4-quadrant multiplier such as a MC1495, or a discrete equivalent as used by DBX achieved  much the same. Or a balanced diode ring as in the Neve 2254 limiter compressor.

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 07, 2017, 12:36 am
Belt driven, right?  Pretty sure that solution is still in place today on the current consoles. 

For my project, I was thinking the POTs I linked to above would be good since they are dual.  1 for the audio signal and 1 for location data back into the arduino.  Basically, the same purpose you are describing with the two tracks.   

I know some servos can feed back location info, but I think I'd rather get it from the POT directly.  Besides, I can't seem to find single POTs that have the bottom plate open for a servo to connect. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 07, 2017, 08:50 am
Yes, they were belt driven.  More recently some use linear motors.

I you're going gown this route I suggest you buy them in - at Neve it took a team of 3 mechanical engineers several months to get the prototypes working well.

A general note... - why not use the electronic techniques covered above? 0.01% distortion isn't going to be noticable in your device, and it's an awful lot smaller, cheaper and simpler....

Allan.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 07, 2017, 05:31 pm
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 08, 2017, 03:30 am
I've been reading a bit more, and have a question related to controlling a digital POT with an analog POT through the Arduino Nano.

The existing analog POTs are 100k, and I was planning to connect then to the Arduino.  H as 5v, L as ground, and W as the analog input.  Then read the signal and map it over to the digital POT (I've ordered a couple MCP41100 chips). 

I think from a spec POV, I'm 90% ok here.  The 41100 spec sheet states the max voltage on the A, B, and W pins are Vcc +1v.  I measured 5.5v on the existing POT, and I'll be feeding the digi-pot 5v, so I should be good there. 

The 41100 is a 100k sweep, same as the analog ones; so I'm good there. 

What I'm concerned about is the 100k analog pot hooked up to the 5v, ground, and ADC input of the Arduino.  1st concern is if the 100k load will generate too much current for the Nano to handle.  2nd concern is if the reading will be accurate since the ADC input seems to be optimized for a 10k impedance input. 

I think this is leading me to the conclusion I need to replace the analog POTs with 10k ones, if I am to go the digi-pot route. 

And, it would also mean I cannot use the servo solution at all, since the dual POTs have both sweeps the same at 100k.  Unless there are dual rotary POTs out there with one sweep at 100k and the other at 10k. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 08, 2017, 04:04 am
The analog input of an atduinos is of very high impedance, so 100k pots are perfectly usable. Lower values are often recommended for very slighly better accuracy and better noise immunity.

Either 100k or 10k would be fine.

You can buy special pots with different tracks - I think bourns do them - but adding a servomotor would not be very easy.

Allan.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 08, 2017, 04:34 am
Great, thanks.  I ordered the parts today so I can begin experimenting. 

On another note:  is there a particular online circuit design tool which works well for Arduino layout?  I want to get things "on paper" from a design POV so I can begin experimenting when the parts arrive. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 08, 2017, 06:29 am
There are loads of schematic capture/PCB layout packages - if you search this site you'll find lots of recommendations.

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 08, 2017, 06:53 pm
I decided to try DigiKey's online tool, and here's my 1st stab at the diagram. 

I'm not sure if both DigiPOTs can share the same CS, SCK, and SI pins though.  The Arduino communicates through SPI, correct?  And I see in my reading that in the code, you have to define an address, or device number, for the DigiPOT, in order to send a command to it.  So does this mean they can share the same communication buss/pins, and the code is written to differentiate between the two?

Or do they each need their own pins for communicating the value to be written each one?

Thanks again for the assistance.


(https://c1.staticflickr.com/5/4163/34375166342_47648554da_b.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 08, 2017, 08:04 pm
You need a seperate cs to each controlled SPI device to select it

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 08, 2017, 09:33 pm
(https://c1.staticflickr.com/5/4162/34377956822_ea87349747_b.jpg)[/list]
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 08, 2017, 09:37 pm
The protocal requires acknowledges from the slave, so you need the MOSI

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 08, 2017, 09:43 pm
Do you mean MISO?  Or am I confused on the two terms (MISO and MOSI)?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 09, 2017, 10:14 am
Yes - sorry. But you need them both

Allan.

No big deal - just another wire.....

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 09, 2017, 01:30 pm
No big deal - just another wire.....
Right, but the MCP41100 (single POT version) doesn't have an SO pin.  I read through the datasheet a few times, and the MCP42xxx version (dual POTs) has an SO pin, but the datasheet only mentions it for daisy chaining devices together.  My MCP41100's will be here this week.

Maybe the Ack comes back through the SI pin?

MCP41100 Datasheet (http://ww1.microchip.com/downloads/en/DeviceDoc/11195c.pdf)

I think I'll use the parts I ordered to do my learning and testing, but have been looking into getting some 10 bit resolution POTs for the final implementation.  I understand this makes it challenging due to the difference in message lengths, and the Mega328's 8bit message length (so there's a need to send three messages instead of two, meaning one command message and two data messages), but the analog POT will be read with values of 0-1023, so for optimal control over the parameters in the pedal, I think I'll want to utilize that level of resolution forn the values being sent back to the DigiPOTs. 

Still learning and planning ... Hope to be testing soon
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 09, 2017, 08:20 pm
No - it's serial out for the next device in the daisy chain

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 09, 2017, 09:43 pm
So where does MISO happen then?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 09, 2017, 10:18 pm
for this device you don't need it. I hadn't looked up it's spec before my previous reply.....

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 10, 2017, 05:36 am
No problem at all, I really appreciate your help.  I feel like I accomplished something today!

For a test of my understanding, I setup a flashing LED, with speed of the flash controlled by a Potentiometer (POT1).  Simple enough.

Then I added a second potentiometer (POT2) to act as a memory location selection device (0 - 99), and added 2 buttons.  Button1 for storing the value, and button 2 for recalling.

So, when turning POT1, the speed of the flashing changes accordingly.  Then turning POT2 allows selection of a number from 0 -99 (using a divider and the (round) command).  Pressing Button 1 stores the value into an array using POT2's value (after normalizing it into the 0 - 99 scale) as the location.  Button 1 recalls the stored value from the array, and sets the LED flashing at whatever value it retrieved.

Then the LED stays flashing at the recalled rate until POT1 is moved (then it goes to real time) or until another preset is recalled.

Again, I truly appreciate all the help and input you've given me.  If you see anything I did wrong, or just inefficient, I'm open to learning more!

I'm still awaiting the DigiPOTs to be delivered so I can get to experimenting with SPI.

Here is the board and connections:

(https://c1.staticflickr.com/5/4155/34180546610_4666359450_b.jpg)

(https://c1.staticflickr.com/5/4181/34436038851_84b98c4d39_b.jpg)

And here is the code:

Code: [Select]


    // Pin Selects
int potvalPin = 3;    // select the input pin for value potentiometer
int potpresetPin = 1;   // select input pin for preset control potentiometer
int ledPin = 2;   // select output pin for the LED
int setPin = 7;  // Select input pin for button to set a preset
int recallPin = 5;   // select input pin for button to recall a preset

    // Variable Definition
int setbutton = 0;  // variable to store state of the preset set button
int recallbutton = 0;  // variable to store the state of the preset recall button
int potstoredval = 0; // variable to store the "value potentiometer" previous value for comparison
int potreadval = 0;       // variable to store the real time value from value potentiometer
int actualvalue = 0;  //  variable to store the current value
int preset = 0;     // variable to store preset number from preset potentiometer

    //Array Definition
int myPresets[100];   // create array to store presets

    // Initialize
void setup() {
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
  pinMode(setPin, INPUT);  // declare the presetsetPin as an INPUT
  pinMode(recallPin, INPUT);  // declare the presetrecallPin as an INPUT
  potreadval = 1023 - analogRead(potvalPin);  // read current value from the value pot
  actualvalue = potreadval;  // set current value to pot read value
  Serial.begin(9600);  // establish serial communication for monitoring
}

    //Main Code
void loop() {
  potreadval = 1023 - analogRead(potvalPin);  // read the value POT's real time position and store it
  setbutton = digitalRead(setPin);  // Read the set button's state
  recallbutton = digitalRead(recallPin);  //  read the recall button's state
  if(potreadval != potstoredval) RealTime();  // if the value POT has been turned, go into real time mode
  if (setbutton == HIGH) SetPreset();  //  if the SET button is pressed, go to subroutine to store the preset
  if (recallbutton == HIGH) RecallPreset();  //  if the RECALL button is pressed, go to subroutine to recall the value

  digitalWrite(ledPin, HIGH);  // turn the ledPin on
  delay(actualvalue);                  // stop the program for some time
  digitalWrite(ledPin, LOW);   // turn the ledPin off
  delay(actualvalue);                  // stop the program for some time
  
  Serial.print ("Actual Value (flashing) = ");
  Serial.println (actualvalue);
  Serial.print ("Pot Read Value = ");
  Serial.println (potreadval);
  Serial.print ("Pot Stored Value = ");
  Serial.println (potstoredval);
}

    // Realtime Mode
void RealTime() {
  Serial.println ("Start RealTime Subroutine");
  potreadval = 1023 - analogRead(potvalPin);    // read the value from the sensor
  actualvalue = potreadval;  // set flashing speed
  potstoredval = actualvalue;  // set previous value
}

    // Store Preset Mode
void SetPreset() {
  Serial.println ("Start SetPreset Subroutine");
  preset = round(analogRead(potpresetPin)/10.32);  // read preset POT position, and determine which preset between 0 - 99 it cooresponds to
  potreadval = 1023 - analogRead(potvalPin);  // read the value POT
  myPresets[preset] = potreadval;  // write the value of the value POT to the array, in the position of the value of the preset POT  
}

    // Recall Preset Mode
void RecallPreset() {
  Serial.println ("Start RecallPreset Subroutine");
  preset = round(analogRead(potpresetPin)/10.32);  // read preset POT position, and determine which preset between 0 - 99 it cooresponds to
  actualvalue = myPresets[preset];  //  set flashing value to the recalled value
}
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: CrossRoads on May 10, 2017, 06:48 am
(https://c1.staticflickr.com/5/4181/34436038851_84b98c4d39_b.jpg)
Pins in holes is going to give you flaky connections sooner or later (and sooner rather than later).
I'd suggest soldering in some male pins (extending down) so you can plug the ProMini clone into a breadboard, or solder in some female pins (from the top) that you can more securely plug wires into the header.
Or long tail female pins so you can both.
Couple of these on each set of pins, sand the mating faces so they sit nice & flush next to each other.
http://www.ebay.com/itm/10x-8-Pin-Female-Tall-Stackable-Header-Connector-Socket-for-Arduino-Shield-8P-/131704730537?hash=item1eaa36b3a9:g:jkAAAOSwqYBWnTbm (http://www.ebay.com/itm/10x-8-Pin-Female-Tall-Stackable-Header-Connector-Socket-for-Arduino-Shield-8P-/131704730537?hash=item1eaa36b3a9:g:jkAAAOSwqYBWnTbm)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 10, 2017, 06:58 am
I see you're using delay() for timing - that's OK for a simple hack, but may give you problems when you start to add such features as the MIDI interface.

Check out the 'Blink without delay' example in the IDE for a better approach

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 10, 2017, 02:32 pm
Pins in holes is going to give you flaky connections sooner or later (and sooner rather than later).
Most certainly the way I have them connected now will cause an issue if I left it like that long term.  I'll end up soldering it down after I've determine a mounting strategy for the board inside the effect pedal.  For now, this is just simple testing.

I see you're using delay() for timing - that's OK for a simple hack, but may give you problems when you start to add such features as the MIDI interface.

Check out the 'Blink without delay' example in the IDE for a better approach
I was thinking about this last night, due to the delay approach causing the "value POT" to be unresponsive and laggy when longer delays are set.  I wondered if using # of clock cycles would work, but the time differential strategy in the "Blink without delay" IDE example looks to be a good way to do it. 

Then the POT could be sensitive and change the timing even if the previously set interval hasn't elapsed yet.


Of course, the final purpose won't be timed event like this, but it's a good learning experience for me non-the-less.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 10, 2017, 03:29 pm
Just a quick note: 

When I updated the code to not use the "delay" command, it worked, although the "RealTime" subroutine was being triggered constantly.  At first I though it was related to the change from "delay" to time interval, but then figured out it was due to the analog pot being read having variance in the reading.  So the reading of the POT was floating around, sometimes even by less than 1, causing erratic behavior. 

I resolved it by putting a variance of +/- 2 in the comparison, but not sure if this is the right way to solve for this.

Code: [Select]
  if(potstoredval+2 <= potreadval || potstoredval-2 >= potreadval) RealTime();

where "potstoredval" = stored previous reading from the POT
          "potreadval" = current reading from the POT
          "RealTime" = subroutine/function to update the flashing speed

Does this variance of +/- 2 seem like good practice for components that may have some variance like this?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 10, 2017, 03:51 pm
So where does MISO happen then?
You only need that when you want to get information back from an SPI device. In the case of a digital pot their is nothing to read.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 10, 2017, 04:08 pm
You only need that when you want to get information back from an SPI device. In the case of a digital pot their is nothing to read.
Perfect, thanks.


Here's my next challenge:  Getting the preset stored values to retain when power is removed from the Arduino.  I see I can use the EEPROM, but only for 100,000 writes.  I'd like the pedal to be usable for years to come, and there's no telling how many times I'll update the preset values.

Does this mean FRAM is really the only option for me here?  Or is there a way to prevent the initialization routine from clearing out the memory blocks where the array is being stored?  ... and if so, I assume that means I need to define the memory location for the array to be stored within?


Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 10, 2017, 04:16 pm
I don't think you'll run out of 100,000 writes in your lifetime. Especially if you only rewrite when there's a change

And since the data you want to store is probably only a few bytes,  use say 50,000 writes in the first 100 bytes , then the next, and so on

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 10, 2017, 07:06 pm
Ok, that makes sense. 

Maybe I'm not understanding the 100k write limitation.  Is the limitation that you can only initiate a write command to the EEPROM 100k times, regardless of how much data or what blocks you are storing it in?  Or is the limitation related to each memory address only able to be written to 100k times each.

So if I have an array of 100 values, and I change array item #5 100k times, does it mean I can no longer write to that particular memory address but I can still write to others;  or does it mean I can no longer write to any memory address within the EEPROM?

Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 10, 2017, 09:16 pm
Made a little more progress on the logic.

I changed the flashing logic to use cycles.  Trying to get it to work with time based was proving problematic, so I just used a simple counter.  It seems to work well, although not sure how it'll change when there's more code for the program to cycle through.  

I changed Button 1 to be dual function, where a short press recalls the a preset determined by the position of POT2, and a long press stores the value of POT1 to a preset determined by position of POT2.

I repurposed button 2 to dump the array values onto the screen through Serial.print, so I can validate things are working.

Making the dual function button was a neat exercise.  I was able to program it where each command is only executed once, instead of multiple times while the button(s) are pressed.  This was me thinking ahead to minimize the writes to EEPROM when I move the array into that space.  Seems to work well coded like this, but of course, I'm open to suggestions for improvement.

I also changed the way things appear on the Serial Monitor, so I can make sense of what's happening.  

I tried to post the new code, but apparently it's too long for the forum limitation on characters per post.  IF interested, see it attached.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 10, 2017, 09:47 pm
Quote
So if I have an array of 100 values, and I change array item #5 100k times, does it mean I can no longer write to that particular memory address but I can still write to others;
Yes, in fact that 100K is just the minimum number that is guaranteed.

So suppose you save a variable 10 times a day every day. Then 100K will give you 27 years of operation.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 13, 2017, 07:10 am
Makes sense, thanks!  So EEPROM storage for the array it is.


I made some more progress lately.  I now have 2 potentiometers hooked up, to simulate the LEVEL and DRIVE POTs in the effects pedal, and two LEDs to stand-in for the DigiPots, which haven't arrived yet (due in on Monday).  I also removed the preset selection POT and button and replaced both with a rotary encoder with integrated button.

The functionality works by using the two POTs to change the values, then rotate the rotary encoder to select a preset number from 0 -99, and do a long press on the encoder's button.  That saves both POT values to the preset # in two arrays (one for each POT).  

For recalling presets, you rotate the rotary encoder to a preset # and short press the encoder button.

After recalling, if you move one of the knobs, the value changes of just that one POT, but not the other.  I did this thinking through the use case, where I'm playing guitar, and I recalled a preset ... but maybe the drive is just a bit too much, or the level needs to come up a bit.  I can adjust just one knob, then re-save the preset without having to redial in the other knob.  

I'm building a small breakout box which has the rotary encoder, and will also house a 2 digit, 7-segment display for displaying the preset # being selected by the rotary encoder.  The breakout box will connect to the pedal through some kind of interconnect ... maybe a CAT6e cable?  not sure yet.

I'm hoping I can use the USB port on the Nano for the midi input, so the pedal will be able to function even without the breakout box attached.  It will certainly work normally, by manually turning the knobs, but I'd like it to be able to do MIDI recall even without the breakout box connected.  Still need to research that piece. 


Here is what the proto looks like today.  The micro button on the left is just for debugging.  It dumps the array values on the screen through Serial.print ().

(https://c1.staticflickr.com/5/4179/34624176605_a0635a6108_b.jpg)


Here is the current version of my diagram.  Of course, the LEDs are standing in for the Digi-POTS, and I haven't drawn the display or the MIDI interface in yet either.  Like stated above though, I'm hoping I can use a USB to MIDI cable direct into the USB port on the Nano.  The segment displays will hopefully arrive next week. 

(https://c1.staticflickr.com/5/4173/33781510894_6dde431a20_b.jpg)


And the code is attached, if anyone is interested.  
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 13, 2017, 08:05 am
Quote
I'm hoping I can use the USB port on the Nano for the midi input,
Quote
I'm hoping I can use a USB to MIDI cable direct into the USB port on the Nano.
A USB to MIDI cable has MIDI 5 pin DIN sockets and so will not fit into a Nano. Even if it did fit it would not work. A Nano ( or any other Arduino ) expects, unsurprisingly, USB protocol on the USB socket.

Do you know the difference between USB host and USB client?

Your computer is a host and the Arduino a client. Something like a MIDI keyboard with a USB connector on it is a client. You can not connect USB clients together, you can only connect a client to a host. The different connectors on each end of a USB cable are designed to prevent you plugging two hosts or two clients together.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 13, 2017, 04:08 pm
A USB to MIDI cable has MIDI 5 pin DIN sockets and so will not fit into a Nano. Even if it did fit it would not work. A Nano ( or any other Arduino ) expects, unsurprisingly, USB protocol on the USB socket.
It was my understanding the MIDI protocol was actually just serial protocol, and could be read through the Serial bus of the Arduino.  and since the default serial 0 bus is tied to the USB port, I was hoping it would work there. If not, I'll need another solution.  Maybe a second Arduino inside the breakout box, communicating through serial to the Nano inside the pedal, is a better design?

Do you know the difference between USB host and USB client?
Yes, I understand the difference.  

I have an iConnectAudio4+ device acting as a central hub on my pedalboard, in which all the MIDI devices I use are connected through either 5 pin DIN, USB host jack, or USB client jacks.  Depending on the need, this can be 3-4 five pin DIN MIDI devices, as well as 2-3 USB host and client devices.  They're all sharing a common MIDI network.

Then I have a MIDI foot controller connected to the host jack on the iConnectAudio4+, acting as a central controller for patch controls.  The foot controller sends a sequence of commands out to the iConnect device, which in turn routs them to the appropriate devices through 5 pin DIN MIDI, or USB, or both.  

In your MIDI keyboard example, it may be connected to a physical USB client type jack, but is acting as a MIDI host, sending MIDI control data to some MIDI device or software.  

That said, MIDI devices connected through a USB host or a USB client type jack can send and receive MIDI commands in a MIDI network; although I only need the pedal to receive in this case.


The Arduino could easily be plugged into my iConnect device to become an additional MIDI device on the existing MIDI network, if the USB port could be used to bring MIDI serial data in.  I just don't know if the Arduino can be coded to read MIDI commands through the onboard USB port.  I would think it could, considering it's tied to Serial 0.  


Or, maybe I think I understand it and I'm really confused??
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 13, 2017, 06:39 pm
It looks like the MidiUSB.read() function from the MIDIUSB library does exactly what I'm looking for ... Read midi info from the USB port. 

https://www.arduino.cc/en/Reference/MIDIUSB (https://www.arduino.cc/en/Reference/MIDIUSB)

Am I misunderstanding something here?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 13, 2017, 08:14 pm
Quote
It was my understanding the MIDI protocol was actually just serial protocol, and could be read through the Serial bus of the Arduino.
Yes it can, but the computer sending it normally thinks it is sending to a MIDI HID not a serial port. Sometimes you can have a helper application inside the computer to do this conversion. A good one is called hairless.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 13, 2017, 08:27 pm
Gotcha.  It has to be able to function without being connected to a PC though.

I think I'll just use this instructable instead to send the MIDI messages in through the RX pin.  I can place a 1/8" TR or TRS jack in the effect pedal, and make a conversion cable to adapt the TR/TRS side to a female 5 pin DIN jack on the other end of the cable.  Then just connect the nano to the existing MIDI network. 

http://www.instructables.com/id/MIDI-TO-ARDUINO/ (http://www.instructables.com/id/MIDI-TO-ARDUINO/)

So the pedal could be used:

1) Normally without any external devices connected.
2) With the adapter cable to plug into a MIDI network for automated preset recalls.
3) With the break-out box connected for creating presets as well as manually recalling them.


Thanks for your help .... off to order a TRS jack, cable end, and female 5 pin DIN end.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 13, 2017, 10:09 pm
Quote
It has to be able to function without being connected to a PC though.
OK that means there are no USB cables involved, that is fine.

Quote
I think I'll just use this instructable instead to send the MIDI messages in through the RX pin.
Well an instructables with a schematic, there's a rarity. It only takes three lines of code to send a MIDI note on message.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 13, 2017, 10:39 pm
Do you happen to know the lines of code to use to read and store program change messages incoming to the Arduino?

I think I'll add ability to the rotary encoder to set the MIDI channel #, then need the Arduino to read PC messages being sent to that channel and store the PC command in a variable. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 13, 2017, 11:45 pm
Quote
store program change messages incoming to the Arduino?
Store them where? Do you want them in a variable? How many do you want to store? Are they to be stored in the EEPROM?

As to read a program change MIDI message ( i assume you mean a control change ) is a three byte message, so if you are using a libiary you just set up the function to handle CC messages. If you are doing it "by hand" then you pars it like the normal note on message.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 14, 2017, 01:05 am
Store a single PC message in a variable.  It's for recalling the presets of the POT values. It does not need to persist or be in EEPROM for storing on power off or reset. 

I mean Program Change messages (PC) not Control Change (CC) messages. 

In most guitar pedal implementations, PC messages are used for presets, while CC messages are used for individual parameters.  I'm really only concerned with PC messages at this time.

I'm finding info on how to read incoming CC messages, mostly because libraries have this down, but not seeming to find library info on how to read incoming PC messages. 

To be fair, I haven't had a ton of time to look into it yet though, and I will do so ... just thought I'd ask.  If I did it by hand, I'm assuming it's probably interrupt based (like the code I used for the rotary encoder), but really don't know yet. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 14, 2017, 03:12 am
I found this bit of info, so it helps me to understand the decoding needed to identify MIDI PC messages meant for the effect pedal. 

Quote from: https://www.cs.cmu.edu/~music/cmsip/readings/MIDI%20tutorial%20for%20programmers.html
The MIDI message used to specify the instrument is called a "program change" message. It has one STATUS byte and one DATA byte :

Status byte : 1100 CCCC
Data byte 1 : 0XXX XXXX

where CCCC is the MIDI channel (0 to 15) and XXXXXXX is the instrument number from 0 to 127. Similarly to MIDI channels, you will often see that the instrument numbers in synthesizers and in GM lists, are numbered from 1 to 128 so you also need to add or subtract 1 for the conversion.
So I can use the rotary encoder to allow selection of the desired midi channel, then save the selected channel (1-16) in EEPROM and use it to compare against the CCCC from the Status Byte. If the CCCC equals the channel number selected and stored, then take the data byte, convert it to decimal, and recall the POT values stored in the array position which equals the decimal. 

So now I understand the concept, I just need to figure out how to write code to do it. 

Any idea if there's a library with a function that makes reading the midi messages, filtering by PC (or CCCC), and then reading the data byte that proceeds for those that are matched/filtered?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 14, 2017, 05:41 am
OK the program control is just a two byte message
Quote
1100nnnn    0ppppppp    Program Change. This message sent when the patch number changes. (ppppppp) is the new program number.
So all you have to do is to look for 0xC as the most significant nibble of the first byte of the message, with the channel number being the least significant nibble, the next byte in the message is the number you need to store.

In this MIDI libiary https://github.com/FortySevenEffects/arduino_midi_library/ (https://github.com/FortySevenEffects/arduino_midi_library/)

The callback function you want is:-

void handleProgramChange(byte channel, byte number);
from page Call back functions (https://github.com/FortySevenEffects/arduino_midi_library/wiki/Using-Callbacks)

Their is an example of using call back functions in the example folder.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 14, 2017, 02:56 pm
Perfect, thanks so much!

So I put this at the beginning:

Code: [Select]
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
int MIDIch = 1;  // Variable for storing MIDI channel for incomming MIDI Program Messages to be read


This in void setup; :
Code: [Select]

  MIDI.begin(MIDIch);  // Start MIDI with MIDIch as the Channel to listen on


This in void loop; :
Code: [Select]

  MIDI.setHandleProgramChange(MIDIProgramChange);  // Call MIDIProgramChange function when a PC message is received over MIDI


and defined this as a function:

Code: [Select]

void MIDIProgramChange(byte channel, byte number)  //  Run this function whenever a Program Change MIDI message is received
{
   // Do whatever I want when a program change message is received
}



It's passing "verify" with no errors, but I don't have the cable built yet to plug MIDI into the arduino.  I should have it done for tomorrow though.  Also need to integrate my opticoupler into the proto ...

Quick question though:  Since MIDI.begin(x) uses "x" as the argument for MIDI channel, does that mean I don't need to check the MIDI channel in my "MIDIProgramChange" function, as it will only be called when a MIDI program change is received in the serial buffer with a match to the channel defined by "x" in MIDI.begin?

I suppose it's probably good practice to check it anyway, but this helps me further understand how it's all working.



On another note:  Last night I spent about an hour getting the Digi-POTs working, and all appears to be good there.

Seems like the only 2 pieces left are the MIDI interface and a visible display.

Really appreciate your assistance Mike ...
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 14, 2017, 05:07 pm
Apologies for all the questions, but I have another one related to Serial. 

I understand the nano only has one serial uart, and it's connected to both the USB port and the RX/TX pins.  And I can't do both MIDI and USB (i.e.: Serial.print for debugging) at the same time. 

Based on this, I'm thinking I should use "software serial" for MiDI, and use one of the digital pins instead of RX. 

I searched for "MIDI" software serial examples, but didn't find anything. 

Is there any particular reason this wouldn't work, or really slow down the code?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 14, 2017, 11:00 pm
Quote
Quick question though:  Since MIDI.begin(x) uses "x" as the argument for MIDI channel, does that mean I don't need to check the MIDI channel in my "MIDIProgramChange" function, as it will only be called when a MIDI program change is received in the serial buffer with a match to the channel defined by "x" in MIDI.begin?
Yes.

Using software serial for debugging is the best way to do it. MIDI is too fast and software serial blocks when looking for an input. Not to sure it will go that fast either.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 14, 2017, 11:22 pm
Ok, thanks. 

I was able to get MIDI into the board today, and when I send program changes to it, I see the RX light flash, but it's not doing what I would expect. 

One thing is happening which I don't expect:  When MIDI data is received, it intermittently triggers functions which are setup to trigger based on readings from the analog potentiometers.  Maybe I need some component in the analog POT circuit to isolate them?

What's not happening is a recall of the values based on the PC# received. 

Here is the code I'm using.  I'm trying to get the PC number (1-128) stored into the "preset" variable. 

Code: [Select]


#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();

void setup() {
MIDI.begin(MIDI_CHANNEL_OMNI);
}

void loop() {
  MIDI.setHandleProgramChange(MIDIProgramChange);
}


void MIDIProgramChange(byte channel, byte number)  {
   preset=(number);
   RecallPreset();
}


With the above, the "preset" variable isn't updating with the PC #.  Can i even use "number" to refer to the PC message?  I wasn't sure it would work, but thought I'd give it a try.

The "RecallPreset" function recalls values for the Digi-POTs, using the "preset" variable as the array location to recall values from .... this works when recalling presets with the digital encoder but not when receiving a MIDI PC message.

Will the "preset=(number);" work to store the PC # into the variable, or is it coming in in binary, or HEX, and I need to convert it to DEC before storing in a variable?

I even tried placing a "MIDI.read();" line in the main loop, but it didn't seem to make a difference.


EDIT:  oh, and here's a current picture of the proto board:

(https://c1.staticflickr.com/5/4177/34498926492_543e114bb0_b.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 15, 2017, 12:12 am
The "set program handler" call has to be in the setup function not the loop.

You need to call  MIDI.read(); in the loop function otherwise the serial buffer with the messages in is never looked at.

Look at the examples that come with the libiary.

in the program handler why is number in brackets?

Quote
The "RecallPreset" function recalls....
Why is this function not in the code you posted, it can't be checked if you don't put in in. You need to post all your code.

Quote
Will the "preset=(number);" work to store the PC # into the variable, or is it coming in in binary, or HEX, and I need to convert it to DEC before storing in a variable?
All numbers in a computer are in binary, decimal and hex are only a convenient way for humans to look at them. There is no need to convert anything to anything.

Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 15, 2017, 03:05 am
The "set program handler" call has to be in the setup function not the loop.

You need to call  MIDI.read(); in the loop function otherwise the serial buffer with the messages in is never looked at.

Look at the examples that come with the libiary.
Hmm, I'm certain I was looking at an example and the handler was in the loop, but as you already know, the examples with the library show it in setup.  I'll move it now and test later tonight after the kiddos go to bed.

in the program handler why is number in brackets?
I think I had started with an expression after the equal, and then limited it down to just the variable.  I'll remove the brackets.  Out of curiosity ... do they cause an issue?

Why is this function not in the code you posted, it can't be checked if you don't put in in. You need to post all your code.
The code is too big to fit into a post due to the 5000 char limitation of this forum.  I've posted the code as a file, in it's entirety, a few times ... but they shows 0 downloads.  So I figured it might be better to just post the snippets I am having issue with.  This function works consistently, so I wasn't concerned about the function itself, but thought I would explan what I am doing with the "preset" variable after trying to set it to the PC number. 

I attached the full code to this post, but here's the function as well:

Code: [Select]

    // Recall Preset Mode ---------------------------------------------------------------

void RecallPreset() {

  Serial.println ("Start RecallPreset Subroutine");

  actualvalue = myPresets[preset];  //  set Level POT value to the recalled value
  actual2value = myPresets2[preset];  //  set Drive POT value to the recalled value
  setbuttonstate = 0;  // reset buttonstate to 0

DriveDigiPOTValue = actual2value/4;
DriveDigiPOTWrite(DriveDigiPOTValue);
LevelDigiPOTValue = actualvalue/4;
LevelDigiPOTWrite(LevelDigiPOTValue);

    Serial.println ("Preset Recalled");
    Serial.println ("");
    ScreenWrite();
}

    // End Recall Preset Mode ---------------------------------------------------------------




All numbers in a computer are in binary, decimal and hex are only a convenient way for humans to look at them. There is no need to convert anything to anything.
Understood ... In previous programming languages, I've had to convert binary to HEX to DEC for particular usage.  I wasn't sure if I would have to do something similar here.

Thanks again ... I'm amazed you stay so active in these forums!  In all my searches for information, you tend to show up in just about every post with great knowledge! 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 15, 2017, 05:14 am
Ok, I got it working.  I made the changes you pointed out, and then also had to disable the "Serial.begin();" line I had in there to enable serial monitoring for debugging purposes. 

After that, I'm now able to send MIDI PC messages to the Arduino, and it recalls the values from the arrays and applies those values to the Digi-POTs. 

I think I'm ready to test integrating the Digi-POT H, W, L pins to the pedal's circuitry now.  Although previously in this thread, there were some comments about isolating the power supply of the Arduino with the power supply of the pedal.

For this initial testing, I'll just run the pedal off a 9v battery, but will need to dig into the power integration soon so I can use it with my pedal boards power supply. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 15, 2017, 11:27 am
Well done so far  :)

Quote
I'll remove the brackets.  Out of curiosity ... do they cause an issue?
No but it is an indication that you didn't understand something.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 16, 2017, 06:27 am
So far so good ....

Made a little more progress today, but on the hardware side this time.  I need to get it down to a reasonable size to fit inside the effect pedal.

Here's the current state.  I was able to get everything on the board, so just need to add the MIDI input jack and the breakout box I/O jack to it. 

The bottom side has jumper wires soldered in for the connections.  Certainly a circuit board would be preferable, but this will work for this project.

(https://c1.staticflickr.com/5/4166/34558109241_b16368053a_b.jpg)

Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 16, 2017, 09:50 pm
I hooked up the Arduino to the effect pedal today and gave it a test.  When the pedal is operating on a 9v battery, and the Arduino off a 9v to 5v DC power converter supply (the power supply came with my arduino accessory kit), it works as designed.  Albeit, the guitar signal has noise injected, but it works to adjust LEVEL and DRIVE VIA the Digi-POTS, and saving & recalling presets is functional.

When I connect the effect pedal to the same wall wart feeding the 9v to 5v converter feeding the Arduino (using a Y adapter for effect pedals), the noise is so bad I can't even hear the guitar signal anymore.

Here is the power converter I was using.  I had the 5v output from this converter wired into the 5v and GND pins on the Arduino.

(https://c1.staticflickr.com/5/4163/34317263740_6687b12555.jpg)

So, functionality wise, the design is working to: control, save, and recall the two parameters; so it seems I need to start work on the power supply solution.

I assume I should place ferrite beads on the 6 lines going from the Digi-Pots to the effect pedal PCB, but not sure how to spec out which ones to buy. And can I use 1, or maybe 2?  Or do I need 6 (one for each wire)?  Any help here would be great!

Also, not sure how to determine where I should be tapping into the power within the pedal for feeding the Arduino.  Is it worth trying to feed 9v into the VIN pin, by splitting the 9v power from the wall wart plugged into the effect pedal?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 16, 2017, 10:03 pm
Quote
When I connect the effect pedal to the same wall wart feeding the 9v to 5v converter feeding the Arduino (using a Y adapter for effect pedals), the noise is so bad I can't even hear the guitar signal anymore.
Sounds like you have grounding problems. Have you connected the grounds together of the two systems?

The problem with effects peddles is that they often have what is called "ground lift" resistors fitted. This means that the signal ground for the audio is not at the same potential as the ground for the electronics of the peddle.
I faced that problem when I built a common power supply for five assorted peddles for my son. In the end I had to make a separate mains power supply for each peddle built into a box.

Without a schematic for the peddle it is hard to be definitive as to what to do. The simplest solution might be to have two isolated power supplies and opto isolate the digital pots, but I appreciate that is not the most elegant of solutions.

Quote
I assume I should place ferrite beads on the 6 lines going from the Digi-Pots to the effect pedal PCB,
I don't think that will do anything for you.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 16, 2017, 10:54 pm
Remember my earlier comments on the floating earth which i suspect  your pedal employs..  so I suspect you'll need a floating psu.

What does the noise sound like ? Hum ? hiss ? warbling?

Allan.

Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 16, 2017, 11:07 pm
Sounds like you have grounding problems. Have you connected the grounds together of the two systems?
I used a Y splitter cable on the power source, with one side going to the effect pedal and the other side going to the 9v to 5v converter.  I assume this means they're sharing the same ground?

The problem with effects peddles is that they often have what is called "ground lift" resistors fitted. This means that the signal ground for the audio is not at the same potential as the ground for the electronics of the peddle.
I faced that problem when I built a common power supply for five assorted peddles for my son. In the end I had to make a separate mains power supply for each peddle built into a box.
Yes, I completely understand this.  I have a TrueTone 1SPOT power supply on my pedal board, because every lead on it is an isolated lead.

Without a schematic for the peddle it is hard to be definitive as to what to do. The simplest solution might be to have two isolated power supplies and opto isolate the digital pots, but I appreciate that is not the most elegant of solutions.
Understood.  I was hoping to find a solution that didn't require 6 more opticouplers though :(


Remember my earlier comments on the floating earth which i suspect  your pedal employs..  so I suspect you'll need a floating psu.

What does the noise sound like ? Hum ? hiss ? warbling?

Allan.
Ya, I remember ... I was hoping you'd chime in. 

The noise sounds like buzzing/hum.

I just tested with two 9v batteries.  One powering the effect pedal, and the other powering the Arduino setup by attaching the positive lead to VIN and the negative lead to GND.  This produced a whisper quiet signal and works great! 

Just need to figure out how to get this type of performance when using 9vdc power from the power supply.

Thanks guys, really appreciate your help.  I'm very pleased with the results thus far!
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 16, 2017, 11:18 pm
As another test, I tried a battery powering the Arduino setup, and the 9vdc wall wart on the effect pedal, and it's also quiet. 

So does this mean I need to configure a floating power supply connection for the Arduino setup?  How can I accomplish that by tapping into the 9v alread going into the effect pedal ... or is that even possible?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 16, 2017, 11:31 pm
Quote
So does this mean I need to configure a floating power supply connection for the Arduino setup?
Yes it looks like it.

Quote
How can I accomplish that by tapping into the 9v alread going into the effect pedal
Sadly you can't. By definition if it is already going to one piece of equipment it can't float with respect to another.

Maybe you could use an isolated DC to DC converter but they do produce noise, they are expensive and they might inject more noise than you have at the moment.

Read about them here https://www.digikey.co.uk/en/product-highlight/r/recom-power/book-of-knowledge (https://www.digikey.co.uk/en/product-highlight/r/recom-power/book-of-knowledge)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 16, 2017, 11:49 pm
Sadly I concur with Grumpy_Mike - I don't think there's a neat fix for this.

2 wallwarts are a pest, but not terribly expensive.


Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 17, 2017, 12:04 am
What makes a floating power supply, floating?  Could I build a small board to accept 9v from the power socket of the pedal, and create an additional floating power supply just for the Arduino?  

I run 7 pedals off the 1SPOT power supply I have now, but it uses isolated leads for every jack.  What goes into building an isolated lead?  Could I use the 9vdc coming in to the pedal to create an additional isolated lead for the Arduino?


2 wallwarts are a pest, but not terribly expensive.
Agreed.  If I need to plug two power supplies into the effect pedal when it's done, one for the pedal and one for the digital controls, then so be it ...

Out of curiosity, I just plugged the effect pedal and the Arduino into two separate leads on my 1SPOT power supply.  It definitely was not as noisy as sharing the same wall wart, but also definitely not as quiet as using two batteries.  

It's probably worth mentioning I also have the setup sitting on my desk, right next to a laptop that seems to have the cooling fan running constantly.  So some of the noise is probably being injected through EMI, especially with the effect pedal's PCB just sitting loose (ie: not in the metal pedal enclosure) on the desk top.

(https://c1.staticflickr.com/5/4178/34703922995_604c35e3a2.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 17, 2017, 12:22 am
Isolated means no electrical connection between the parts. Deriving an isolated supply from another requires an isolated dc-dc convertor as GM suggests.

EMI may be a problem, but it's not your major one. Cooling fans don't make much electrical noise. The PC processor etc DOES - but not in the audio range.

Sorry

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 17, 2017, 12:44 am
Gotcha. Googling "isolated DC to DC Converter" is coming up with lots of results.  Is there an IC I could use for this, or is it more complex than that?

I'm finding things like "fly-buck converters"

For example, the Texas Instruments LM5160-Q1  (http://www.ti.com/product/lm5160-q1)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 17, 2017, 12:55 am
My feeling is that this is a bit like your investigation into motor-driven pots....yeah, you could do it, but it's a lot of hard work which inessential to your project.

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 17, 2017, 05:20 am
I spoke to a buddy who is an electrical engineer at Flextronics, and also has a business making pedals and custom guitar circuitry.  He recomemded to try upping the input voltage to 12v, and using a 7809 voltage regulator for supplying 9v to the pedal's PCB and a 7805 to supply 5v to the Arduino.  It might not be enough, but for a couple of dollars, certainly worth trying. 

Parts are ordered, and I should have them in a couple days. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 17, 2017, 07:02 am
Quote
He recomemded to try upping the input voltage to 12v, and using a 7809 voltage regulator for supplying 9v to the pedal's PCB and a 7805 to supply 5v to the Arduino. 
I can't see how this would help with the problem at all from what you have described.

Quote
Googling "isolated DC to DC Converter" is coming up with lots of results.  Is there an IC I could use for this, or is it more complex than that?
It is not just an IC but a method of designing the circuit and normally involves a transformer. You can buy ready made isolated DC-DC converter modules, the main consideration / cost being how much current you want to draw from it. Your peddle should not take too much current.

Much cheaper is two mains supplies which are isolated from each other by default. That is to say that all mains power supply are isolated from the mains and so will be isolated from each other. If you only want one lead then connect it to two converters inside the box.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 17, 2017, 10:54 am
OK - if you're determined to do it with one wallwart, the enclosed should work ..

Values for R3 and R4 might be a bit high - check for 5v across the arduino ( use the 5v pin) .

They must be equal.


regards.....


Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 17, 2017, 11:09 am
Just to make things a bit clearer....

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 17, 2017, 11:27 am
or if you want to be posh...  the opamps must be rail-rail ...

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 17, 2017, 11:40 am
Well it might work but it is not isolated is it.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 17, 2017, 11:43 am
Nope - but it positions everything round the centre-point of the audio electronics supply , so should be OK.

If one could identify the internal '0v' , you could use a couple of 2.5v references (TL431's?) round that to get the arduino's 5v - that would be a better approach.

But I think it'll work.

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 17, 2017, 02:54 pm
Thanks for this Allan.  I'm stuck on one wall wart due to wanting the design to be usable for other pedals as well.  This is mainly my "proof of concept" to design a solution for adding MIDI to any effect pedal which uses analog POTs to control parameters.  Most pedals use 9vdc, although some use 12v and even 18v.  I'm keeping the scope here to the 9v ones though. So having the circuit not require an additional power supply is very desirable.

I have the resistors and the diode, but I don't have an opamp on hand right now to put this together.  I can certainly order one though.  

The diagram makes sense to me, except for the following connection points:  

(https://c1.staticflickr.com/5/4192/34714253505_591e5fb718.jpg)



Thanks again, this is very appreciated.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 17, 2017, 03:10 pm
The diagram you post is probably the easiest - the opamp is my guess at what's inside the pedal - you don't need another one! Note the box saying 'pedal audio electronics' . All inside that is my guess.

Points 1 and 2 are the (guessed)  internal  mid-rail supply generated within the pedal - it's '0v' reference.. They're not really floating, as they're derived from the 9v supply.

3 and 4 are the internal + and - supply rails within the pedal. 5 and 6 are as you say.

My diagram pedal3 in the next post makes these points clearer - but you can get away without the external opamps.

All you need are the bits ouside the pedal - the 2 digipots, 2 resistors , a 5v zener diode, and of course the arduino . You may be better using 2 220's or even 100's - I'm not sure of the arduino's consumption.
Adust so you get a steady 5v across the arduino.
Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 17, 2017, 03:51 pm
Ahh, ok ... got it.  I thought that represented the pedal enclosure, but I understand now you mean the existing electronics on the pedal's PCB.

So essentially, it's dropping the voltage from 9vdc to ~5vdc by splitting the drop between the 9vdc + and -, thereby keeping the center, well, centered.   If that statement makes sense, then I guess I understand the concept here.

I'll also venture a guess that after I add a display (currently planning for a two or four character 7 segment display), I'll need to recheck the voltage due to the increased load, right?

I'll give it a go and let you know.

Thanks again!
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 17, 2017, 04:06 pm
I think you've got the idea...  good luck.

LED displays take a fair bit of current - maybe a LCD?

Allan.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 17, 2017, 04:11 pm
My diagram pedal3 in the next post makes these points clearer - but you can get away without the external opamps.

Sorry, I just saw this.  Don't know how I missed it.

Could I use a single LM358P (dual opamp) for both sides?

LM358P Datasheet (http://www.ti.com/lit/ds/symlink/lm358.pdf)

LED displays take a fair bit of current - maybe a LCD?
I looked at an LCD, but am space constrained.  I really only need 2 characters to display the preset number.  Do you know of a small LCD which plays nicely with Arduino?  I saw the 128x128 ones, but they're too big.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: CrossRoads on May 17, 2017, 04:19 pm
If you only need 2 digits, how about a small 2-digit seven segment display?
Sparkfun carries this little 4-digit bubble display, I use 2 of them on this 8-digit display board
(http://www.crossroadsfencing.com/BobuinoRev17/Arduino.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 17, 2017, 04:23 pm
1/  You don't really need opamps  - it just takes the guesswork out of finding r3,4 values.
2/ A LM358 won't quite do - you need  a rail-rail opamp.
3/ If you intend to use high current displays, opamps would be a good idea - but be sure they've got enough drive capability. 

LED display - the worst case is displaying '88', with 14 segments on. Allowing 5mA each that's 70mA - more than most opamps can handle..

But, of course, you could drive them directly from the supply with suitable drivers.....

I'll have a ponder...

Allan.

Just saw your post , crossroads - neat little displays.  But this is (I think) next to his pedal - 4-6 feet away? so perhaps too small - and of course the reading angle is limited.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 17, 2017, 04:24 pm
If you only need 2 digits, how about a small 2-digit seven segment display?
Sparkfun carries this little 4-digit bubble display, I use 2 of them on this 8-digit display board
(http://www.crossroadsfencing.com/BobuinoRev17/Arduino.jpg)
Ya, that's very similar to what I was planning.  a 2 digit, 7 segment display, which operates on SPI.  The problem is I can't find a 2 digit one.  I found some 4 digits ones though.

Do you know of a 2 digit, 7 segment display, that works with SPI?  One design constraint is I only have 8 wires to go between the Arduino and the breakout box, which is where the rotary encoder with push button and the display goes.  

Rotary encoder/push button needs 5 wires: Vcc, GND, 1 data wire for button, 2 data wires for rotary encoder.
7 Segment display, with SPI, needs 5 wires, but only 3 additional:  (Vcc and GND shared with rotary encoder) then SCK, CS and SI.  
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: CrossRoads on May 17, 2017, 04:29 pm
Here are 4 different sizes of 2-digit displays, 0.3, 0.4, 0.56, 0.8 inch:
http://www.kingbrightusa.com/category.asp?catalog_name=LED&category_name=KC2%2DDigit+7%2DSegment+Thru%2DHole+Display&Page=1 (http://www.kingbrightusa.com/category.asp?catalog_name=LED&category_name=KC2%2DDigit+7%2DSegment+Thru%2DHole+Display&Page=1)
Add MAX7219 to make it SPI.
It's available SMD & thruhole, I don't about SMD except from Digikey/Mouser
https://www.digikey.com/products/en/integrated-circuits-ics/pmic-display-drivers/729?k=max7219 (https://www.digikey.com/products/en/integrated-circuits-ics/pmic-display-drivers/729?k=max7219)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 17, 2017, 04:32 pm
1/  You don't really need opamps  - it just takes the guesswork out of finding r3,4 values.
2/ A LM358 won't quite do - you need  a rail-rail opamp.
3/ If you intend to use high current displays, opamps would be a good idea - but be sure they've got enough drive capability. 

LED display - the worst case is displaying '88', with 14 segments on. Allowing 5mA each that's 90mA - more than most opamps can handle..

But, of course, you could drive them directly from the supply with suitable drivers.....

I'll have a ponder...

Allan.
Ok, I'll give it a shot without the opamps 1st.  The diodes I have are rectifier diodes, so I'm ordering some 1N4733a diodes.  I figure I'll add some opamps to the order, just to have them on hand if I need them.  If the LM358 doesn't work, can you suggest one that would?

As you can tell, I'm a bit over my head when it comes to power supplies ... but learning. 

Just saw your post , crossroads - neat little displays.  But this is next next to his pedal - 4-6 feet away? so perhaps too small - and of course the reading angle is limited.
Exactly.  The device will be on my pedal board, on the floor, while I am standing.  Typically in a poorly lit environment as well.  And to boot, I am color blind :P (my 10 year old daughter has to help me with resistor identification LOL)  This is why I was looking for a 2 digit, standard size, 7-segment display.  But a small LCD would work too, if I can find one that fits. 


BTW:  Can I just say the "one post per 5 minute" rule on this forum is extremely annoying....?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 17, 2017, 04:41 pm
Here are 4 different sizes of 2-digit displays, 0.3, 0.4, 0.56, 0.8 inch:
http://www.kingbrightusa.com/category.asp?catalog_name=LED&category_name=KC2%2DDigit+7%2DSegment+Thru%2DHole+Display&Page=1 (http://www.kingbrightusa.com/category.asp?catalog_name=LED&category_name=KC2%2DDigit+7%2DSegment+Thru%2DHole+Display&Page=1)
Right, I actually have some 1/2" ones on the way already.  It's the SPI interface I was struggling with.

Add MAX7219 to make it SPI.
It's available SMD & thruhole, I don't about SMD except from Digikey/Mouser
https://www.digikey.com/products/en/integrated-circuits-ics/pmic-display-drivers/729?k=max7219 (https://www.digikey.com/products/en/integrated-circuits-ics/pmic-display-drivers/729?k=max7219)
Great, thanks!  I should be able to fit this into the breakout box.  Any idea on the mA draw of the MAX7219 and 2 7 segment displays? 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 17, 2017, 04:59 pm
A beefier psu capable of at least 100mA is enclosed.

Note use of a TLC2262 opamp

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 17, 2017, 06:43 pm
Fantastic, thanks Allan!

In trying to determine total mA draw, from what I can tell, I would have:



so if I'm understanding this correctly, I shouldn't really be pulling anymore than 60mA, and therefore 100mA capacity will be just fine.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 18, 2017, 05:36 am
Quick update before I head to bed ... it's finally free from the breadboard!  

The 1/8" jack is the MIDI input, D2 and D3 are the rotary encoder inputs, D7 is the rotary button's input, A2 and A3 are the analog POT inputs, then the six wires on the left side are the Digi-POTs outputs.  

The two bare wires sticking out of the side at the RX0 and RST pins are from the RX0 pin and the MIDI input signal.  I have a "normally closed" momentary switch I connect to it, so I can hold the switch to disable the MIDI while I upload new code to the Arduino.

The power supply parts should be here tomorrow, so hopefully by the end of the weekend, I'll have it fitted into the enclosure.  

My plan right now is to cut a hole in the pedal enclosure's side so the USB jack is accessible, drill a hole for the 1/8" jack on the other side of the pedal, fit an RJ45 jack somewhere on the pedal's enclosure for connecting the breakout box, and then drill another very small hole with the momentary button mounted behind it, so I can use a pin to push the MIDI serial disconnect when an update is needed.

(https://c1.staticflickr.com/5/4185/34343025990_e83d06aa09.jpg)


(https://c1.staticflickr.com/5/4186/34343026640_f37bc92eea.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 18, 2017, 06:28 pm
A beefier psu capable of at least 100mA is enclosed.

Note use of a TLC2262 opamp

Allan
I received the power supply components today, just one question:  Are the R1 and R2 470ohm resistor values critical?  Unfortunately I don't have any 470 values, and to run some in series would be 5 resistors (220 + 220 + 10 + 10 + 10). 

I have 10, 100, 220, 330, and then 1k plus.  Hopefully, I can use 330 or 1k, as I'd like to keep it small.  But if I need to string some in series, can I get away with just 2 of the above values?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 18, 2017, 08:03 pm
Abolutely not!

as I earlier suggested , so long as the two are the same it'll be OK. Suggest 330's. Not too much higher as most zeners are specc'd at 5-10 mA

Allan

Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 18, 2017, 08:10 pm
Ok great ... thanks.  And just to be clear, I'm going with the "pedsup" design you posted last, for the 100mA capability. 

I ordered the parts yesterday, but unfortunately I missed the fact that one transistor is a NAP (BC337) and the other a PNP (BC327), and I had just ordered the BC337 ones. I just placed another order though for mounting hardware, header pins, etc ... so I added some BC327's to it.  I also added some 470ohn resistors, just in case it was critical. 

I did get the 7-segment display today though, so at least I have something to work on while waiting :)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 19, 2017, 12:33 am
I got my display in today, and I got it working ... although it's causing some strange behavior.  I think it's related to the level of current it's pulling.

I got an Adafruit 4 character, 7 segment display with backpack.  I have it connected to 5v, GND, and then the SDA lead to A4, and the SCL lead to A5. 

I'm displaying the preset number on the display using the Adafruit_LEDBackpack library.

The display is working, but if I display anything greater than "1", the readings from my analog potentiometers (attached to A2 and A3) start to fluctuate wildly. 

When those readings change, it triggers a function to update the values in the program, so these 2 functions (one for each analog POT) are triggering constantly.

How can I stabilize the power system with the 7 segment display attached?  Do I need to look at trying to stabilize the draw the display is creating, or do I need to go after the analog POTs and somehow stabilize them?

The analog POTs have 5v on H, GND on L, and the wipers are connected to A2 and A3.

For testing purposes, I currently have the Digi-Pots setup with 5v on H, GND on L, and the wipers connected to LEDs.  The other side of the LEDs run through a 1k resistor to ground.

I even tried disconnecting the LEDs to see if they were causing the issue, but the functions continue to run constantly so long as the 7 character display is attached.

To verify the issue, I displayed "0", and let both functions repeat constantly (watching in serial monitor).  Then I disconnected the GND wire to the display, and everything stabilized; but of course I lost the display.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 19, 2017, 12:45 am
What psu are you using for these tests?

The ardiuno 5v has a limited current capability if powered from an external higher voltage via vin...


Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 19, 2017, 02:05 am
Further reading tells me that chips like the MAX7219, and similar, cause fluctuations in the 5v reference signal, and that must be what's happening.  So the analogReads of the POTs are moving around because the 5v is fluctuating.  

To test it, I ran the ardunio off of USB, and then used my 5v power supply to power the breakout box with the display and rotary encoder in it.  I connected the 5v from the breakout box to the 5v of the separate power supply, and then connected the GND of the separate power supply to the GND of the arduino.  

This worked, and the problem is gone.  

So is there anything I can do to help with the noise?  pull up resistors on the SDA and SCL lines maybe?  Or capacitors in the 5v feed to the display?  I would try these just to see, but I'm not sure how to size the resistors and/or caps properly.


I was typing the above when you replied .....


What psu are you using for these tests?

The ardiuno 5v has a limited current capability if powered from an external higher voltage via vin...


Allan
I'm just plugged into the USB port on my computer.  So not feeding in through Vin or the 5v pin.  Direct to the USB port.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 19, 2017, 03:03 am
Ok, so maybe this won't be an issue. 

I just tested, using a 9vdc wall-wart through a 7805 transistor, and hooked the output of the 7805 up to the Arduino's 5v pin, as well as the display breakout box.  And it's stable like this. 

So it appears it's probably related to being powered off the USB port.  When I've measure the USB port voltage in the past, it's always around 4.5v - 4.6v.  Maybe it's not enough, or it can't keep up when the display is connected?

So when I build the power supply you designed for the device, I may just add a 7805 into the 9v supply lead, dedicated to feeding power to the breakout box.  Just to further isolate the LED driver chip from the Arduino's 5v reference signal. 

I guess the past couple days of learning about power supplies is starting to pay off :)

Later tonight I may try dual 7805's:  one for the breakout box, and one for the Arduino.  Then also have the effect pedal Y'ed into the same wall-wart ... just to see if it helps with the audio noise.  I doubt it, but I've got the parts, so worth experimenting. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 19, 2017, 05:57 am
Quote
through a 7805 transistor
A 7805 is not a transistor it is a voltage regulator. You must use them with a capacitor on the input and the output.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 19, 2017, 02:35 pm
A 7805 is not a transistor it is a voltage regulator. You must use them with a capacitor on the input and the output.
Thanks .... I knew it was a voltage regulator, but mistakenly thought it was a transistor. 

I tried using one with a .1uf ceramic capacitor at the output and a .047uf ceramic at the input, but I still get the fluctuation in the 5v reference signal when the display is connected.

I know the .047uf value one should be .33uf, but I had these caps left over from a previous project so gave it a shot.  I have some .22uf electrolytic caps here too.  Should I try placing one in parallel to the output?

The rest of the components for the power supply Allan recommended will be here today, so maybe this testing is all a moot point anyway ... although I am learning quite a bit through the process.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 19, 2017, 08:23 pm
I got the power supply circuit laid out today.  470ohm resistors was butting out around 4.4v.  I tried 330ohm, and it was around 4.7.  I ended at 220ohn resistors, and it's at 4.95v.

This is without any load though.  So after I get a chance to connect it to the Arduino, I'll test again.  The big test will be if the noise is removed ... I'll know soon enough!


Thanks so much Allan!  Really appreciate you drafting this up for me.

Here is what I built:

(https://c1.staticflickr.com/5/4200/33915902364_182d61c171.jpg)


And here is how it laid out on the breadboard.  Now I just need to get it soldered up so it'll fit inside the pedal.

(https://c1.staticflickr.com/5/4182/34718171406_5e6c4d18b7.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 19, 2017, 09:00 pm
The load should make almost no difference up to >100mA load.

The voltage change you see is down to the highish dynamic resistance of a zener.

A TL431 would be better.

But it'll do.  +/- 10% is good enough .

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 19, 2017, 11:02 pm
Well, the circuit completely removed the noise!  

The display still causes wild fluctuation in the analog POT readings though.  So I put a 7805 in parallel to the incoming 9v (with some .1uf capacitors), and connected the breakout box's 5v lead to it (the button on the rotary encoder and the display are both running off of it) and it resolved the issue.

So it's quiet and stable now!  

Basically I did this, using the 9v supply POS and NEG leads:

(http://www.researchcell.com/wp-content/uploads/2011/08/7805-Voltage-Regulator-Circuit-Diagram.jpg)

Would it be a better idea to try and solve the issue without the regulator though?  Maybe an electrolytic cap between the 5v and GND buses?  Or should I just stick with the 7805 and use it for just the display?


I've also been working on the display.  I have it coded to show the analog POT values when turning one of them, and give an indication if the current value is above or below the currently recalled preset value.  So when recalling a preset, if I want to make a fine adjustment, I can turn the knob and get visual feedback as to where the saved value is.

I plan to work on having the Digi-POTs not change value until the analog POT crosses over the currently recalled value.  So if I'm doing this live on stage, it doesn't blast at 100% if I move the knob with the POT located at 100% but the recalled value is only 30% or so.  This will also help protect against any electrical anomalies which may cause the POT readings to go erratic again.

(https://c1.staticflickr.com/5/4155/34760498885_41379414ed.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 19, 2017, 11:41 pm
Where is the ground on your 7805 regulator connected?

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 20, 2017, 12:11 am
To the ground of the wall wart.  I assumed I would need to use that one since the one at the Arduino has been shifted. 

Did I get this right?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 20, 2017, 03:33 am
Doesn't that mean that the ground of your arduino and the -ve of the wallwart are connected together? - in which case the arduino's 5v  is no longer in the middle of the 9v supply, but has it's -ve at the wallwart's -ve.



If so, it misses the whole point of my 'centred' psu..

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 20, 2017, 03:43 am
Hmm, I'm not sure?  Should I try something different?

When I move the ground of the 7805 to the ground output of the PSU, the analog pot readings go wild again.  It's pretty rock solid going off the 9v and ground of the wall wart though.

I do know the centered PSU did clean up the noise in the audio signal.  So while the ground config may negate some of the intended benefits of the PSU, it is accomplishing the primary goal of getting rid of the noise in the guitar audio signal.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 20, 2017, 05:52 am
Started mounting it inside the pedal tonight.  Got far enough to do a test fit, and it fits great!

Obviously I still have the long wires attached I was using for the breadboard, and I'll shorten them for the final soldering; but I wanted to make sure I didn't need to make any further adjustments to the mounting points and routing inside.

I'll use the battery compartment for the PSU, MIDI serial bypass switch, and I plan to mount a RJ45 jack on the side for connecting to the breakout box.  Looks like everything will fit!

The 1/8" jack is for the midi in (you only needs pins 4 and 5 from the midi cable for input), and I made sure the USB was accessible as well, so I can continue improving the code even after it's complete and functional.

(https://c1.staticflickr.com/5/4178/34604258572_fbf9cdaa33.jpg)


(https://c1.staticflickr.com/5/4159/34604258382_3f820dd487.jpg)


(https://c1.staticflickr.com/5/4227/34604258172_0b61f5561e.jpg)


(https://c1.staticflickr.com/5/4272/33924248844_2ab442c792.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 20, 2017, 11:30 am
Looks jreat I- didn't think you'd get it all in.

You shouldn't need the 555.  Are you using current limiting resistors with you LED dsiplay ? - otherwise you'll take far too much current ...

 A medium capasitor (?100u) across the zener may help...

Allan

Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 20, 2017, 03:43 pm
Looks jreat I- didn't think you'd get it all in.

You shouldn't need the 555.  Are you using current limiting resistors with you LED dsiplay ? - otherwise you'll take far too much current ...
Do you mean 7805 instead of 555?  No, I am not using current limiting resistors.  I did some reading on current limiting resistors (Sparkfun Tutorial (https://www.sparkfun.com/tutorials/219)), and then found the datasheet for the controller on the backpack used to drive the LEDs (HT16K33 Datasheet) (https://cdn-shop.adafruit.com/datasheets/ht16K33v110.pdf).  But I don't see anything on the sheet related to forward voltage or forward current.  I assume this is because the datasheet is for the chip and doesn't take into account the LEDs it's driving.

So I went and found, what I believe, is the datasheet for the LED display itself (4 character, 7-segment display datasheet (https://cdn-shop.adafruit.com/datasheets/BL-Q39A-42.PDF)), and it shows forward current as 30mA but doesn't show forward voltage.  

The schematic (https://learn.adafruit.com/adafruit-led-backpack/downloads) doesn't seem to show a limiting resistor on the backpack itself.  

Then I found This Tutorial Page (https://learn.adafruit.com/all-about-leds/forward-voltage-and-kvl) which give some basic info on the LEDs.  So if I use 2v as the forward voltage, 5v as the source voltage, and 30mA as the forward current, I come to 100ohms.  The tutorial says to double the value for determining the limiting resistor ...

so I should place a 200ohm resistor in series with the 5v feeding the LED backpack?

A medium capasitor (?100u) across the zener may help...
I do have some 100uF 50v capacitors here.  I'll try placing one on the leads of the zener diode.  

Thanks Allan!
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 20, 2017, 07:27 pm
Sorry ....... 7805 of course/


This is a bare display. You need a  series R - eg 390R - in each of the cathode lines. Otherwise you'll take too much current - bet that's why you're having problems.

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 20, 2017, 08:20 pm
This is what the backpack and raw display look like. 

(https://www.modmypi.com/image/cache/data/electronics/adafruit/880/DSC_0019-800x609.jpg)

The display is mounted on the other side, and then the pins soldered on the side in the pic. 

Are you saying I need to desolder it, and place 390R resistors between the backpack pin holes and the display pins? 

Or can I use a resistor on the 5v line feeding the backpack instead? 

Maybe I should reach out to Adafruit for support and see what they say ....

Out of curiousity, what's the downside to using the 7805 to give 5v to the display? 

The ground for the 7805 is connected to the 9v source ground, but the ground for the display is connected to the Arduino' ground.  So I don't think the 2 grounds are connected, since nothing else is using the 9v supply ground except the 7805 and the PSU you designed for me.

Ive got a busy day today, but when I have time, I'll sketch out how it's all connected. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 20, 2017, 09:48 pm
The holtek device seems to have internal current limiting on it's row drivers, so resistors not required.

I'm still confused though - I await your drawing.

Allan.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 21, 2017, 02:42 am
I had some time to draw it out.  I hope you can read this.  If the image isn't readable, I also attached it to this post as a JPG attachment. 

So the ground from the 9v PSU never gets to the arduino, or the breakout box. 

(https://c1.staticflickr.com/5/4270/33976986353_5aaf3a4291.jpg)



Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 21, 2017, 05:49 am
Ok ... as a test, I moved the 5v lead going to the "Display and Encoder" box to the 5v signal coming out of "Allan's PSU", but put a 330ohm resister in series with it ... and this cleaned it up.  It's rock solid like this.

Also interesting ... I put a meter across the output of the 7805 and the ground coming from "Allan's PSU", and it read 3v.  I suppose this makes sense, considering the ground is shifted coming out of the PSU.  The Adafruit Display's datasheet says it'll operate on a 3.3v Arduino, although with a dimmer display.

So maybe the lower voltage is what is causing it to be stable?  I measure 4.95v coming out of the PSU, and measure 4.68 after the 330ohm series resistor.  I measured this with just the number "1" on the display.

With "108" being shown on the display, I get a reading of 4.23v with the 330ohm resistor.
With a 470ohm resistor, and "108" on the display, I get a reading of 4.07v

It's worth noting I also added a 100uF cap to the zener diode leads, and it's still there.  I tested after adding this, and the readings were still fluctuating when the display was connected to the PSU's output.  

So what do you think, leave the cap in the PSU and install a 470ohm resistor, inside the breakout box, in series with the backpack's Vcc line?
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 21, 2017, 06:02 am
Thanks...

Can you measure, with respect to the 9v supply gnd:

- The arduino gnd
- the arduino +5
- the 7805 +5 out

Is the display bright?

regards

Allan.

just read your new post...

The 3v you measure is exactly as I'd expect.
does your mod ( display via 330 to the arduino +5) mean the 7805 output isn't connected?
When you say you measure 4.96 from the psu, which one do you mean? there are 3!
Having done the mods, is the display bright? The 330 will seriously limit the display current.
I suspect much of the noise comes from the high-frequency internal multiplexing of the display.
Try adding >100uF across the output of my 5v psu, driving the display + from that, and disconnecting  the 7805..

A

Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 21, 2017, 06:32 am
does your mod ( display via 330 to the arduino +5) mean the 7805 output isn't connected?
Correct.  I removed the 7805 when I tested with a 330ohm in series between the Arduino's (or the Allan's PSU) 5v and the Vcc wire going into the breakout box.

When you say you measure 4.96 from the psu, which one do you mean? there are 3!
LOL ... I mean 4.96v coming out of "Allan's PSU" :)

Having done the mods, is the display bright? The 330 will seriously limit the display current.
Yes, it's plenty bright.  I even have the code set to dim the brightness to it's lowest setting, and it's still plenty bright for my purposes.  This will typically be on a dimly lit stage as well.

I suspect much of the noise comes from the high-frequency internal multiplexing of the display.
Ya, a few google searches tells me these chips are known for injecting noise into the 5v supply line. Solutions for cleaning it up seems to differ depending on the specifics of the project though.  There doesn't seem to be a "one size fits all" type solution for it.

Try adding >100uF across the output of my 5v psu, driving the display + from that, and disconnecting  the 7805..
So do you mean adding another 100uF capacitor, at the "Allan's PSU" output leads?  So connected directly to the 5v and ground coming out of the PSU?  Or do you mean to somehow add the cap so it's just working on the power being fed to the display?  Like adding the cap inside the breakout box, between the Vcc and ground pins in there?

Here's how I have the PSU wired up currently, without the 7805.  Notice the 100uF added at the front end, tied to the zener's leads.  So add another one of these to the end?

(https://c1.staticflickr.com/5/4197/33980321303_c2bc565e21.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 21, 2017, 07:52 am
Try across the +ve and -ve of the display..

Allan
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 21, 2017, 02:23 pm
I just tried placing a 100uF cap between the Vcc pin and GND pin of the LED display, and it still fluctuates.  Just to be clear, I removed my series resistor from the Vcc line when I tried this.


Sorry, I'm just seeing the below. must have missed it earlier:

Can you measure, with respect to the 9v supply gnd:

- The arduino gnd
- the arduino +5
- the 7805 +5 out

9v supply gnd -to- arduino gnd = 2.0v
9v supply gnd -to- arduino +5v = 1.91v
And as you know, when the 7805 was in the circuit, it was measuring 3v


I tried a 100ohm resistor in series, instead of a 330 or a 470, and I thought it was stable with it ... but it seemed to intermittently fluctuate every once in a while.  So then I tried a 220ohm resistor, and it seems to be stable with it.

So, 220, 330, and 470 all seem to stabilize the 5v bus.  Is there any particular reason to not use a series resistor here?  The rotary encoder's button and the display both seem to function fine with the resistor in place. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 22, 2017, 12:27 am
A thought.

The TLC opamps, though rail-rail, don't have a very strong pullup on their outputs.

Try adding a 680 ohm between Q1 ( BC337) 's base and collector to improve  the +ve drive

Allan.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 22, 2017, 12:51 am
I actually have the PSU soldered down to a board already, with it's inputs coming from the effect pedal's internal 9v and GND input terminals.  

I have a 2 pin header for the output, which goes to the arduino and the breakout box.  I also have a 6 pin and a 7 pin header on order, which will go on the PSU board as well ... for ease of connecting and disconnecting everything.

Then the final connection point is an externally accessible RJ45, which will go on the end of the PSU board, for plugging in the breakout box, after it's all said and done.  


So one 9v wall-wart, plugged into the pedal, is now feeding everything.  

I did end up soldering a 220 ohm resistor inside the breakout box, located in series on the 5v line connected to the Vcc of the backpack LED display board.  It is definitely stable like this, as I've been playing the guitar through it and testing out the sound and preset functionality.  

I can certainly deconstruct some of the board to add the 680 ohm resistor across the base and collector of Q1 like you suggest, but is there some reasn as to why a resistor in series with the Vcc line of the display's control chip isn't a good idea?

I also still have the PSU made up on the breadboard, so I can certainly test it there too .. but I'll have to remove the 220ohm resistor from within the breakout box to really know if it fixes it.  

(https://c1.staticflickr.com/5/4189/34808677185_cd12c0f724.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 22, 2017, 05:40 am
I was able to test placing 690ohms across the BC337's collector and base.  I bypassed the 220ohm series resistor, and then used a 470ohm plus a 220ohm resistor (in series) to bridge pins 1 and 2 of the BC337. 

In this config, the analogRead() from the 2 analog POTs were still fluctuating rapidly.

So I went back to using the 220ohm resistor in series with the 5v line feeding the display backpack chip (HT16K33), and it's stable again.

Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 22, 2017, 11:21 am
It sunds like the series R to the display is sufficent decoupling / current limiting to do the job.

Still a mystery to me, but so long as it works......

Could you post a final circuit diagram?

Allan......
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 22, 2017, 04:12 pm
Here is how it's configured now.  I didn't draw out all the Arduino interconnects with the Digi-POTs and Opticoupler, just because it would get pretty messy.

I've also attached it as a JPG, just in case the forum scales this down too much to see it.  

(https://c1.staticflickr.com/5/4243/34012667813_3c2d9c3e39.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 22, 2017, 04:23 pm
Well, it all looks ok....just surprised that the display runs OK with that series 220R - .....

Allan.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 22, 2017, 06:53 pm
Ok, great.  Thanks for taking a look at it.  I definitely would not have been able to get this far without you Allan! You too Grumpy Mike ... I truly appreciate both of your input!


I made some more progress on the mounting.  I now have 3 standoff posts under the Arduino board, to prevent it from moving around and to ensure the USB jack stays firmly placed; especially when inserting a cable.  I still think I need something lateral, on the end with the MIDI input 1/8" jack though ... in case I (or someone else) really jams a USB cable in ... as it stands, it'll probably bend the connection points on that side if pushed too hard laterally.

When everything is hooked up, a 9v battery connected to the effect pedal battery leads does power everything, but I think I need to sacrifice that functionality due to space.  Besides, this will be installed on my pedal board, and will always be powered.

So .... the PSU board will go in the battery compartment, and will double as an interface board for the headers and RJ45 jack to mount.  I want to be able to disconnect the Ardiono and remove it without soldering, so I'm using header pins and connectors. 

I haven't made the standoffs for the PSU board yet, as I'm waiting for the RJ45 breakout board to be delivered so I can determine the proper height.

The headers should arrive tomorrow, so I can finish up the interconnects from the Arduino board to the PSU board.  The RJ45 breakout boards should be here tomorrow too.  So hopefully, over the next couple of days, I can have this wrapped up from the hardware perspective.

From a code perspective, I still need to make a few tweaks to the display code.  I want to add an indicator to show when the currently applied values are different than recalled preset values ... probably a decimal point lit up.  And then I need to move the array into EEPROM so the presets will be stored when power is disconnected.  

I debated on adding code so an expression pedal could be used over midi, to control DRIVE or LEVEL, but that can always be done later if I so choose.

I thought about your idea Allan, of having a mode where it's cycling through a few of the presets to give a sort of tremolo effect ... and I could add that later too, although sometimes switching POT values does cause an audible click ... so cycling through several presets quickly may be too noisy with the clicks. 


Here's the current state:

(https://c1.staticflickr.com/5/4200/34661964802_74536036bb.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 22, 2017, 11:13 pm
Well done  :)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 23, 2017, 02:03 am
Thanks Mike, still a ways to go, but getting close :)

Related to the click/pop generated when the Digi-POTs change value:  Is there a reasonable way to remove or reduce the effect?   

Earlier in this thread (I've read it through a few times), it was recommended to put some capacitors between the Digi-POTs H, L, and W pins and the pedal's PCB connection points.  Would this take care of the popping? 

I assume it's a result of the value maybe dropping to zero between the switch in values?  Or am I off on this assumption.

If it's not reasonably remedied, I won't worry too much about it; as the typical use case for this is switching presets when playing live and not turning the knobs.  So the click/pop would be very short and most likely burried in the band mix.   

But, if simply adding 6 small caps would fix it, I can do that easily when I mount the header pins onto the PSU board. 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Grumpy_Mike on May 23, 2017, 07:16 am
Yes you could try a cap, between the wiper and the ground end of the pot. Try a 0.1uF to start with.
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 23, 2017, 05:47 pm
Ok, thanks Mike.  The rest of my components are due to arrive today, so the soldering iron will be coming out then, and I'll try it.

.... Attaching my latest code build here.  I cleaned it up quite a bit, but I'm certain there are lots of opportunities for increased efficiency.  I'd bet there are things I'm doing in the code which use  more processor cycles than what is necessary.

Are there tools, or other resources, to use for analyzing the code to determine where it can be made more efficient?  Or maybe I could pay one of you fine gentlemen VIA PayPal to have a gander .... ;)  

Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 25, 2017, 05:30 am
I was able to get the interconnects soldered up today, and tested with my OHM meter to ensure complete signal path .... but didn't have time to get holes cut for the RJ45 jacks yet.  Hopefully I can get that done tomorrow and perform a real test.

Should be easy to test some caps across the Digi-POT wiper terminals too, considering the header pins and clips.  Once it's all mounted and verified functional, I'll give it a shot.

(https://c1.staticflickr.com/5/4197/34033565194_0c668458a8.jpg)


(https://c1.staticflickr.com/5/4251/34876981855_7a1808c866.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: allanhurst on May 25, 2017, 11:07 am
If the digipot (~100k) is carrying audio, 100n between wiper and ground gives a lowpass filter with the wiper half-way at

2 x pi  / ( 5e4 x 100e-9 )  or about 1200 Hz... bit low. I'd start with 10n.

There are ways to de-click , but they are a bit more complicated. Or you could use a vga and control it with ( filtered high frequency ) PWM...

Allan 
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 25, 2017, 02:30 pm
The Digi-POTs are carrying audio, so I am concerned about created a low or a high pass filter here if it is within the audio range of the guitar signal (ie: ~30Hz - 20kHz).

Can you explain how the click/pop is being generated?  Is it a shunt to ground, creating DC noise, during the switching maybe?  And if so, wouldn't I want a high pass filter at very low Hz in the signal path?

I had a similar issue in my home theater setup, running an Adcom amp along with an Emotiva processor.  The Adcom is a direct coupled input design, and the Emotiva shunts the output to ground during any mute process.  This created an audible click due to DC being generated on the signal path.  To solve that, I built a high pass filter centered at 2Hz, and stuck it on the amp's input. 

Could I do something similar here, on the pedal's audio output, to filter out the click?  If indeed it is the same root cause of course ...

Thanks guys ...
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 25, 2017, 08:24 pm
Dare I say the soldering is done?!  

It's all closed up, and working great!  During play, there's absolutely no buzzing or injected noise whatsoever.  When the gain is turned up really loud (louder than I'll typically run it), there is some clicking when turning the Drive and Level knobs, but other than that, it is completely silent.

Now back to the software improvements.  For my own sense of organization, here is the list of things I'm looking to improve in the code:




And, here is how it sits now:

(https://c1.staticflickr.com/5/4225/34078502653_5742914d0d.jpg)


(https://c1.staticflickr.com/5/4197/34078502383_59674f71af.jpg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 25, 2017, 11:47 pm
Just a quick video to show the functionality:

https://www.youtube.com/watch?v=lLgwHvSHCxg (https://www.youtube.com/watch?v=lLgwHvSHCxg)
Title: Re: Virtual, variable resistors, with saved presets recallable by MIDI
Post by: Stoopalini on May 26, 2017, 07:24 pm