DIYstompboxes.com

DIY Stompboxes => Digital & DSP => Topic started by: any on June 08, 2021, 07:34:40 AM

Title: Joining a 5v and a 3.3v input pin
Post by: any on June 08, 2021, 07:34:40 AM
Ok, as somewhat rambled on in my build thread for the Arduino 'Tap Express' thing, I can seem to find a conclusive answer for this issue,
nor can i find conclusive information on whether the Line6 3.3v logic is 5v tolerant.

I started by creating a resistive divider on the Arduino input pin via a standard 'resistive divider' calculator.
Thing is it didn't do at all what I expected, the voltage came out way lower than the calculator.

I thought it was also due to using bus power over usb, so hooked up a 9v DC supply but a standard resistive divider setup gave
unexpected results. (not the same as calculated)

So next I just hooked up the multi meter and reconfigured resistance until I got about 3.5v
After messing around for a while with a divider, I just ended up with a single 100k resistor to ground on the Arduino input pin.

Can I assume (?) 3.5/3.6v is "safe" to hook up to the Line6 Logic, anyone done something similar?
Also, would there be any potential drawbacks to using this resistor to ground to lower the voltage on the Arduino input?
I mean, everything seems to work ok, as in I can still get the input to recognise the taps, or could it be prone to issues?

Picture is just for no reason other then showing how it's all crammed onto 15x15 holes.  :icon_biggrin:
 
(https://i.postimg.cc/ThyDC7xQ/Screen-Shot-2021-06-08-at-11-33-12-PM.png) (https://postimg.cc/ThyDC7xQ)
Title: Re: Joining a 5v and a 3.3v input pin
Post by: ElectricDruid on June 08, 2021, 08:27:20 AM
The voltage dividers not working as expected pretty much has to be down to loading. What's the effective resistance of the input pin? Come to that, what's the effective resistance of your meter?!

My experience with digital inputs on uPs has been that they're usually pretty well protected against over-voltage (by diodes to the power rails which limit inputs to Vdd+0.6V) but that you have to watch for over-current situations, since those will fry the protection diodes. For this, you need a resistor in series with the input to ensure the current can't get too high even with whatever the largest likely input voltage is. I've fed 20V into a 5V input like this with no adverse effects!
Title: Re: Joining a 5v and a 3.3v input pin
Post by: any on June 08, 2021, 02:32:36 PM
Also, the pin is configured as input_PULLUP on the Arduino, does that mean it already has a 20k resistance between the input and 5v?

Cheers
Title: Re: Joining a 5v and a 3.3v input pin
Post by: ElectricDruid on June 08, 2021, 05:24:16 PM
Also, the pin is configured as input_PULLUP on the Arduino, does that mean it already has a 20k resistance between the input and 5v?

Effectively, yes. In practice, it won't be implemented on the chip as a simple resistor (probably a current source from what I understand) but for our purposes, we can treat it like a "normal" pull-up. So yeah, if the pin has a pull-up, that's going to throw any voltage divider calculations out by a mile.

What exactly are you trying to do? You were talking about feeding some signals to a Line6 pedal that uses 3.3 or 3.6V, but now we're talking about Arduino inputs? Sorry, I'm getting a bit lost.
Title: Re: Joining a 5v and a 3.3v input pin
Post by: any on June 08, 2021, 05:49:02 PM
Also, the pin is configured as input_PULLUP on the Arduino, does that mean it already has a 20k resistance between the input and 5v?

Effectively, yes. In practice, it won't be implemented on the chip as a simple resistor (probably a current source from what I understand) but for our purposes, we can treat it like a "normal" pull-up. So yeah, if the pin has a pull-up, that's going to throw any voltage divider calculations out by a mile.

What exactly are you trying to do? You were talking about feeding some signals to a Line6 pedal that uses 3.3 or 3.6V, but now we're talking about Arduino inputs? Sorry, I'm getting a bit lost.

Sorry if it was unclear, here's the gist of it.

This particular version of what I'm building will be built into the Line6 M5 so it's always connected.
The Line6 M5 already has a 'tap' footswitch for the tempo, so my intention is to 'leech' the signal going low
(I've checked, and the tempo on the Line6 is set by a 3.3v pin tapped to ground) on the Line6 footswitch
by splicing the tempo input for the Arduino onto the same (Line6 tap footswitch) line.

That way I get the same tempo for both circuits off a single footswitch, or at least, that's the plan.  :icon_biggrin:

So I just want to make sure that splicing the 5v line from the Arduino onto the 3.3v Line of the Line6 doesn't
fry anything on the Line6 side.
Title: Re: Joining a 5v and a 3.3v input pin
Post by: FiveseveN on June 08, 2021, 07:46:30 PM
The signal is pulled to 3.3 V by the M5, so why would you need INPUT_PULLUP?
When you were talking about dividers I thought the point was to output a 0-3.3 V signal from the Arduino to an ADC on the M5 and got confused when you mentioned inputs.
A 5 V input will accept any voltage from 0 to 5 V, which of course includes 3.3 V. Current doesn't flow out of the input (unless you add things like pullup resistors) and hardly any into it, so the thing generating the 3.3 V signal doesn't care what it's attached to.
Now whether the Arduino will register that 3.3 V as a HIGH is a separate matter: the datasheet says the threshold is 0.6 * VCC = 0.6 × 5 = 3 V, so it should be fine.

If you have to send signals the other way (5 V output to 3.3 V input), then you would use a resistive divider.
For more complex communication between devices on different rails use a proper bidirectional level shifter IC.
Title: Re: Joining a 5v and a 3.3v input pin
Post by: any on June 08, 2021, 07:56:07 PM
The signal is pulled to 3.3 V by the M5, so why would you need INPUT_PULLUP?
When you were talking about dividers I thought the point was to output a 0-3.3 V signal from the Arduino to an ADC on the M5 and got confused when you mentioned inputs.
A 5 V input will accept any voltage from 0 to 5 V, which of course includes 3.3 V. Current doesn't flow out of the input (unless you add things like pullup resistors) and hardly any into it, so the thing generating the 3.3 V signal doesn't care what it's attached to.
Now whether the Arduino will register that 3.3 V as a HIGH is a separate matter: the datasheet says the threshold is 0.6 * VCC = 0.6 × 5 = 3 V, so it should be fine.

If you have to send signals the other way (5 V output to 3.3 V input), then you would use a resistive divider.
For more complex communication between devices on different rails use a proper bidirectional level shifter IC.

Thanks, well that's the thing, both inputs (M5 and Arduino) are pulled high and active when pulled low. So in their idle state they are both at their respective logic high.
Just want to make sure any current flowing from the Arduino's input doesn't damage the Line6's input.
Obviously I only want to tap the tempo once for both circuits, hence tying the inputs together on the same switch.

Cheers,
Title: Re: Joining a 5v and a 3.3v input pin
Post by: potul on June 09, 2021, 02:39:13 AM
But you can disable the input pullup in Arduino by configuration. This way you avoid any conflict between the pullup of the M5 and the arduino.
Title: Re: Joining a 5v and a 3.3v input pin
Post by: FiveseveN on June 09, 2021, 03:57:16 AM
both inputs (M5 and Arduino) are pulled high
But you haven't answered why you think this must be so.
Like I said, anything over 3 V is HIGH (https://www.arduino.cc/reference/en/language/variables/constants/constants/) for the Arduino, so it will be HIGH unless the button is pushed, by the grace of the M5's pullup. There is no need for "their respective logic high".
Title: Re: Joining a 5v and a 3.3v input pin
Post by: ElectricDruid on June 09, 2021, 07:50:27 AM
I think Potul and FiveSeven are right. If you disable the pull-up on the Arduino input pin, you should be safe to just tie the two pins together, and then a hang a switch to ground off it for tapping the tempo.

With the Arduino pull-up enabled, you've got a problem, because it's trying to drag the Line6 input up to a level it won't like.
Title: Re: Joining a 5v and a 3.3v input pin
Post by: any on June 10, 2021, 12:23:22 AM
Yep, i did a face palm :icon_lol:

I thought in my novice wisdom that the only way to get an input pin to trigger on a low would be to specify it as input_pullup. I now understand that it is totally fine to just specify it as input and have it high (by the 3.3v from the line6) is totally fine. I’ll have to confirm this in practice (haven’t actually hooked it up yet) but it makes total sense now. Yay for logic.
Title: Re: Joining a 5v and a 3.3v input pin
Post by: any on June 11, 2021, 07:13:18 AM
Heh, and then i realised why the arduino input needs to be pulled up and can’t rely on the Line6 Tap button to pull it up. When performing a ‘preset select’ it also pulls the tap button low, potentially throwing off the tempo, so i have to prevent the Arduino input from going low during this action. I used a spare switch on the 4066 to temporarily disconnect the Arduino pin during that action, but without a pullup itwould still go low when disconnected.

So i guess i’m back to using input_pullup with an added resistor to ground to get the required 3.3v...
Title: Re: Joining a 5v and a 3.3v input pin
Post by: ElectricDruid on June 11, 2021, 09:00:31 AM
When performing a ‘preset select’ it also pulls the tap button low

Why does it do this, and can you not just disable this action?
Title: Re: Joining a 5v and a 3.3v input pin
Post by: any on June 11, 2021, 04:27:42 PM
When performing a ‘preset select’ it also pulls the tap button low

Why does it do this, and can you not just disable this action?

Dont think so, the M5 switches to the preset menu by pressing ‘tap’ and ‘fx’ simultaneously.
So as long as the Arduino’s tempo pin is connected it will go low as well. It only switches to presets directly over midi (as opposed to the preset select menu) so i’ll have to emulate the ‘double footswitch’ buttonpress. Bit of a unique tight spot I’m working myself in to eh? ;-))

Might just add the resistor to ground to the Arduino input_Pullup enabled pin to make it a resistive divider and take the plunge as i did get it at close to 3.3v and the tap button still worked fine.
Title: Re: Joining a 5v and a 3.3v input pin
Post by: FiveseveN on June 11, 2021, 05:18:33 PM
Bit of a unique tight spot I’m working myself in to eh? ;-))
I don't know if I've grasped all the intended functionality of your project, but looking at the M5's MIDI implementation now it looks like you can do everything that way, no modifications to the M5 required. Phil says (https://line6.com/support/topic/4796-midi-beat-clock-out-in-m5/?tab=comments#comment-31519) it also sends the appropriate tap tempo CC so you have the bidirectional communication you're looking for.
Title: Re: Joining a 5v and a 3.3v input pin
Post by: ElectricDruid on June 11, 2021, 06:17:16 PM
Why does it do this, and can you not just disable this action?

Dont think so, the M5 switches to the preset menu by pressing ‘tap’ and ‘fx’ simultaneously.
So as long as the Arduino’s tempo pin is connected it will go low as well. It only switches to presets directly over midi (as opposed to the preset select menu) so i’ll have to emulate the ‘double footswitch’ buttonpress. Bit of a unique tight spot I’m working myself in to eh? ;-))

Oh, ok. I'd understood it was the *Arduino* that was pulling the input low, and that's the firmware that you have control over. Clearly if it's the M5 that's pulling it low, that's something you have to live with or work around since we can't easily alter that firmware. Ouch! Like you say, a tight spot.

Quote
Might just add the resistor to ground to the Arduino input_Pullup enabled pin to make it a resistive divider and take the plunge as i did get it at close to 3.3v and the tap button still worked fine.

I'd have to consider the consequences of this a bit to decide if I think this is ok or not. The internal pull-up is most likely a current source, not an actual resistor, so it's not immediately obviously to me how that responds. Those better versed in such things might be able to offer more informed advice.
Title: Re: Joining a 5v and a 3.3v input pin
Post by: any on June 11, 2021, 07:57:58 PM
Bit of a unique tight spot I’m working myself in to eh? ;-))
I don't know if I've grasped all the intended functionality of your project, but looking at the M5's MIDI implementation now it looks like you can do everything that way, no modifications to the M5 required. Phil says (https://line6.com/support/topic/4796-midi-beat-clock-out-in-m5/?tab=comments#comment-31519) it also sends the appropriate tap tempo CC so you have the bidirectional communication you're looking for.

Well, yes and no... you can call up the preset list over midi, just individual preset numbers directly. But that said for my M9 i’m going to implement midi alongside of the ldr to expression pedal and it’ll be external.
Title: Re: Joining a 5v and a 3.3v input pin
Post by: amz-fx on June 16, 2021, 09:23:15 AM
Logic level voltage conversion can be performed with a simple mosfet transistor.

Here are some good examples:

https://circuitdigest.com/tutorial/bi-directional-logic-level-controller-using-mosfet

Best regards, Jack
Title: Re: Joining a 5v and a 3.3v input pin
Post by: any on June 21, 2021, 11:54:09 PM
Ok, well... good news and bad news.

Good news first? Line6 M5 (and likely M9, M13 etc..) are 5v tolerant.  :D
Why do I know? well I accidentally connected them and nothing blew up.. heh
Tap tempo button works fine on the Line6 with the 5v spliced in AND sets tempo for both
simultaneously. So that's good.

Bad news is I'm probably making a real rookie mistake here, but the CD4066 is not doing what I
wanted it to do... sound familiar?

I just wanted to use the switch to shunt the 5v from the tap button and the 3.3v from the effect on/off to ground.
But that's not happening? I'm getting about a .2v voltage drop when the switch is closed.
(so to be clear 5v supply to the 4066. 5v on one side of a switch, ground on the other, supplying a 5v 'high' signal to the switch control)

I've tried to find a post/article that explains why this doesn't work, but all i can find are these
'button hack' tutorials that have the same setup so what am I missing here?

Image is how I wired it up, but that's clearly wrong... lol

(https://i.postimg.cc/9rjwJBCm/whatimtryingtodo.gif) (https://postimg.cc/9rjwJBCm)
Title: Re: Joining a 5v and a 3.3v input pin
Post by: potul on June 22, 2021, 01:41:06 AM
Ok, well... good news and bad news.

Good news first? Line6 M5 (and likely M9, M13 etc..) are 5v tolerant.  :D
Why do I know? well I accidentally connected them and nothing blew up.. heh
Tap tempo button works fine on the Line6 with the 5v spliced in AND sets tempo for both
simultaneously. So that's good.

Bad news is I'm probably making a real rookie mistake here, but the CD4066 is not doing what I
wanted it to do... sound familiar?

I just wanted to use the switch to shunt the 5v from the tap button and the 3.3v from the effect on/off to ground.
But that's not happening? I'm getting about a .2v voltage drop when the switch is closed.
(so to be clear 5v supply to the 4066. 5v on one side of a switch, ground on the other, supplying a 5v 'high' signal to the switch control)

I've tried to find a post/article that explains why this doesn't work, but all i can find are these
'button hack' tutorials that have the same setup so what am I missing here?

Image is how I wired it up, but that's clearly wrong... lol

(https://i.postimg.cc/9rjwJBCm/whatimtryingtodo.gif) (https://postimg.cc/9rjwJBCm)

without seeing what is connected to these 3.3v and 5v it's difficult to troubleshoot. What type of switch are you using (SPST or SPDT). If you want to be able to "shunt" it, you need to have a the 5v and 3.3v coming from a pull up resistor, and the switch to be "floating", otherwise you will be trying to short the power supply
Title: Re: Joining a 5v and a 3.3v input pin
Post by: any on June 22, 2021, 03:09:56 AM
Ok, well... good news and bad news.

Good news first? Line6 M5 (and likely M9, M13 etc..) are 5v tolerant.  :D
Why do I know? well I accidentally connected them and nothing blew up.. heh
Tap tempo button works fine on the Line6 with the 5v spliced in AND sets tempo for both
simultaneously. So that's good.

Bad news is I'm probably making a real rookie mistake here, but the CD4066 is not doing what I
wanted it to do... sound familiar?

I just wanted to use the switch to shunt the 5v from the tap button and the 3.3v from the effect on/off to ground.
But that's not happening? I'm getting about a .2v voltage drop when the switch is closed.
(so to be clear 5v supply to the 4066. 5v on one side of a switch, ground on the other, supplying a 5v 'high' signal to the switch control)

I've tried to find a post/article that explains why this doesn't work, but all i can find are these
'button hack' tutorials that have the same setup so what am I missing here?

Image is how I wired it up, but that's clearly wrong... lol

(https://i.postimg.cc/9rjwJBCm/whatimtryingtodo.gif) (https://postimg.cc/9rjwJBCm)

without seeing what is connected to these 3.3v and 5v it's difficult to troubleshoot. What type of switch are you using (SPST or SPDT). If you want to be able to "shunt" it, you need to have a the 5v and 3.3v coming from a pull up resistor, and the switch to be "floating", otherwise you will be trying to short the power supply

Ha, Excuse my incompleteness... the 5v comes from an arduino pin with input_PULLUP and the 3.3v is a pin from the line6 M5. They (both lines) are also connected to spst ‘soft touch’ footswitches to make the same connection with a physical switch.

All it’s supposed to do is emulate pressing both of the physical buttons simultenously.
Title: 4066 Switching logic not very logic?
Post by: any on June 22, 2021, 06:26:59 AM
Ok, so I hope this updated picture is clearer as to what I've done, and what I'm trying to do.

When i press the button connected to the arduino (not shown here) the following happens:
- the Arduino pin connected to 12 on the 4066 (control D) goes low (digitalWrite LOW) to disconnect the tap input
(the tap input uses input_PULLUP so will stay high when disconnected. (That's the plan anyway...)
- 100ms Delay
- after that the Arduino pin connected to 13 and 5 on the 4066 (control A and control B) goes HIGH to ground both the
tap and effect switch (imitate the 'simultaneous' two button press for preset select on the M5)
-100ms Delay
After that back in reverse order.

But yeah, voltages only drop like 0.2v instead of down to 0... so no worky worky hahaha!
I'm sure I'm just going about it the wrong way, so hit me with some wisdom.

(https://i.postimg.cc/NyLxMsPP/whatimtryingtodo2.gif) (https://postimg.cc/NyLxMsPP)
Title: Re: Joining a 5v and a 3.3v input pin
Post by: potul on June 22, 2021, 12:57:58 PM
Ok, I see it now. I don't know why it doesn't work,... I would experiment with some resistors to ground first to see if you can pull down these inputs. Do you know the values of the pull up resistors?

On the other hand, this looks overcomplicated.... Can't you do it with some diodes, a level converter, or even using a Zener to prevent the 5v going to the Line6, and avoid the CD4066 ?
Title: Re: Joining a 5v and a 3.3v input pin
Post by: amz-fx on June 30, 2021, 09:36:38 AM
(https://i.postimg.cc/yNnpv4T8/bi-logic.gif)

regards, Jack
Title: Re: Joining a 5v and a 3.3v input pin
Post by: potul on July 01, 2021, 06:42:53 AM
Thanks Jack for the nice converter. I might use it in a project I'm building.

I must admit it took me some time to understand how the Arduino pin was able to pull down the "low voltage circuit". I had to google and found the Phillips AN97055. And then I realized of the diode inside the mosfet....
Title: Re: Joining a 5v and a 3.3v input pin
Post by: Ice-9 on July 08, 2021, 07:48:22 AM
If you need to have more than just 1 level shifter then it easier to use a single chip level shifter, I use the Texas Instruments TXS0108EPWR which has 8 level shifters in one IC. Very simple to use 3.3v  and 5V power to the chip. Very neat compared to multiple mosfet/resistor level shifters.