External analogue voltage reference help

Post here first, or if you can't find a relevant section!
Post Reply
justinjools
Posts: 41
Joined: Thu May 02, 2024 11:10 am

External analogue voltage reference help

Post by justinjools »

Hi, I have set up this circuit using LM4040 -10v voltage reference to use with ADC for measuring control voltage input for a digital oscillator design (using design from BHH link below). I have the power and voltage reference circuits working correctly supplying -10V. I am using Arduino Nano for testing for now but target MCU is STM32F11 - so guidance in using the STM32 is what I need.

I have tested pitch control voltage input from Beatstep Pro controller directly to ADC0 pin on Arduino. This works fine and I get different voltages for each note. But when I send the control voltage directly through the MCP6002 opamp it gets no signal - I'm guessing this is because it requires the -10v VREF to boost the signal.

So this how it should work: CV1 pitch input + -10v VREF through MCP6002 to ADC pin.

I have been following this circuit. MCP6002 opamp is used for circuit protection.

Do I need to do connect the AREF to STM32 board and do anything special in software? I saw reference to this here: https://tronixstuff.com/2013/12/12/ardu ... -aref-pin/

Circuit reference:
https://blog.thea.codes/designing-big-honking-button/

------------------------------------------------------------------
These are the calculations from designing-big-honking-button, if interested.
The MCP600 opamp:
(-10v * 82kΩ / 510kΩ) = 1.608v out

"This means whatever input is coming into CV in is added to 1.608v.

That fixed voltage plus the CV in ends up in the range of 0v to 3.3v for the input range of -2v to +2v. Applying the same transfer function for the minimum and maximum input voltage and summing them with the fixed voltage from the regulator shows this:"

-(-2v * 82kΩ / 100kΩ) = 1.64v so 1.64v + 1.608v = 3.248v

-(2v * 82kΩ / 100kΩ) = -1.64v so 1.64v - 1.608v = 0.032v
---------------------------------------------------------------------
Attachments
BHH_VREF.jpg
BHH_VREF.jpg (70.56 KiB) Viewed 3434 times
GonzoG
Posts: 491
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: External analogue voltage reference help

Post by GonzoG »

There is no STM32F11. There are F0, F1, F2, F3, F4, F7 series.
If you plan to use stm32duino for this, then forget about using analogRead(). It's slow. You'll need to use HAL.

Arduino's Vref pin is there to get higher resolution with lower voltages. Arduino Uno/Nano are 5V MCUs. STM32 is 3.3V MCU.

As to voltage reference, STM32 works differently. There is no internal/external Vref like on ATMega. There is Vref pin where you connect reference voltage, but on chips with smaller number of pins it's usually not available and connected internally to Vcc.
ag123
Posts: 1898
Joined: Thu Dec 19, 2019 5:30 am
Answers: 30

Re: External analogue voltage reference help

Post by ag123 »

that circuit is an opamp integrator
https://en.wikipedia.org/wiki/Op_amp_integrator

you have made an assumption you would place a -ve input voltage from the other pin, u'd need to know what you are doing there.
it didn't matter if i assume you are using stm32f411 etc, if you do not understand your circuit and how it works, placing a stm32f411 and / or a gpio pin into the op amp wouldn't necessarily make any difference.

in fact you can omit the other negative input and peg the + voltage to vdd/2 and do your circuit simulations or even actual circuit to see what you get.
a tutorial is here
https://www.electronics-tutorials.ws/opamp/opamp_6.html
justinjools
Posts: 41
Joined: Thu May 02, 2024 11:10 am

Re: External analogue voltage reference help

Post by justinjools »

Hi Guys,

First of all I did mean STM32F411 MCU I am using, for now testing with Arduino Nano because the serial monitor works easily.

The circuit I am following is from https://blog.thea.codes/designing-big-honking-button/ you can read about it here if interested. I have read and understand what the circuit does and it is to provide a stable and correct voltage range for CV in. A summary here, below.

My question is really quite simple. Is anything else required to set in software using STM32? Or will this circuit work as is?

CV in
The most clever part of Big Honking Button's circuitry is the CV input. This is an analog input. The SAM D21 has several ADC inputs and they all operate from 0v to 3.3v. So this input needs to handle the nominal -2v to +2v range and scale it to 0v to 3.3v. It also needs to deal with voltages outside of that range, since in Eurorack CV can vary anywhere from -10v to +10v.

The circuit used in Big Honking Button is adapted from Mutable Instrument's designs. It consists of a active summing amplifier that's configured to both scale and offset the input voltage. Here's the schematic:
Post Reply

Return to “General discussion”