• Hardware
  • Digital/Analog Ins vs. Ground/Negative

Hi there,

I'm sorry this question might come across as very confused; bela is my first foray into electronics!

Do the digital/analog I/Os function as a negative/ground terminal? Obviously they complete a circuit, but is it also always necessary to connect the circuit to the GND pin?

Many thanks

Yes you always need to connect the ground in your circuit. For instance, in order to blink an LED, one side must be connected to ground, the other side to a resistor and to the digital output:

  • A number of example wiring diagrams, related to the C++ examples is available here
  • wiring diagrams and Puredata examples here ( you have to go into examples/13-workshop/ once you uncompress the zip archive)
  • wiring diagrams and Supercollider examples here

Brilliant, many thanks for your help Giulio!

I made a mistake in my original question: I was only referring to digital ins (not outs). But just to alleviate my confusion:

When connecting a push button switch (for instance, in the 'digital-input' wiring example), why isn't the circuit as simple as 3.3v-->resistor-->switch-->digital in (with the switch simply closing the circuit to digital in)?

In other words: why is it necessary to connect to ground as well as connecting to digital in?

I'm just eager to understand, so I don't end up damaging the digital inputs out of ignorance!

The question you have to ask is: what happens when the button is not pressed?

In your case, when the button is not pressed, the switch is an open circuit and therefore the digital in pin is disconnected. In this case, what is the voltage at the digital input going to be? It may be anywhere between LOW and HIGH, there is no way of telling that, because the pin is set as an input, which means it has a high impedance, and at the same time it is "floating", that is it is not referenced to ground. In this case the system may be unstable and your reading may be 0 or 1 in a totally random way.
By providing a "pull-down resistor" (i.e.: a resistor from the digital input to ground), then you make sure that the voltage at the pin is going to be 0V when the switch is open (button not pressed). You can then connect the digital input through the switch directly to 3.3V (no need for the resistor you had in your example).
The circuit is therefore going to be:
alt text

Note how:
- when the switch is open R1 makes sure that digital in is 0V (LOW)
- when the switch is closed digital in is connected straigt to 3.3V (HIGH)
- when the switch is closed, 3.3V is connected to ground through R1. R1 therefore limits the current flowing between 3.3V and ground. R1 has to be of a large enough value that there is not too much current flowing through it (as this current has no useful purpose in the circuit), however the value needs to be small enough that it is not comparable to the input impedance of digital in, otherwise it may not work properly as a pull-down. 10k is most of the times a reasonable value.

In order to make sure you do not damage the digital inputs: make sure you NEVER connect them to any point in the circuit that has more than 3.3V!

Thanks so much Giulio, this is massively helpful - that should clarify everything.

Just to double check: I'm sending two momentary push button switches each into their own digital in - I simply want to detect 'click on/off'. Would this circuit be appropriate?

alt text

Many thanks

yes. You will read a 0 when the button is not pressed and a 1 when it is pressed.

6 days later

Hi there,

I have a question further along the same thread.

Basically, I'm having a lot of trouble understanding the effect that feeding a signal into Bela's digital or analog I/Os will have on the voltage, current, and resistance of an external circuit.

This might be basic electronics, but I've been reading around for days and I'm really struggling with an answer!

Basically I'm building a simple circuit with a piezo and two momentary push-button switches, so I'll need to use two digital ins and 1 analog in.

Can you direct me to any source of information where I can understand exactly what happens at Bela's input pins, and how that affects the rest of the external circuit in terms of voltage, current and resistance?

Thanks again for all of your help!

    The digital and analog inputs are "high-impedance".

    The datasheet for the system on chip (which handles the digital inputs) does not give a value for the input impedance (or I could not find it, feel free to search for it), but it's probably safe to think of a few hundred kilo ohms.

    The analog inputs are connected straight to the input of an opa4348 JFET operational amplifier. The datasheet gives an input impedance of 1013 ohms.

    papa_sangre Can you direct me to any source of information where I can understand exactly what happens at Bela's input pins, and how that affects the rest of the external circuit in terms of voltage, current and resistance?

    Practically speaking, this should mean that the input impedance is "large" and therefore the effect of the inputs on your circuit should be minimal, that is: there is a very small current going through the inputs, therefore currents (and consequently voltages) on the circuit should not be affected.

    What are you interested in, specifically?

    Ok great, many thanks Giulio - I'll continue with the understanding that the inputs (both digital and analog) have a negligible influence on an external circuit, in terms of current and voltage.

    Specifically, I'm trying to design a circuit sending signals from two momentary push button switches and a piezo element into puredata in Bela. It should be dead simple, but I get more confused with each step.

    I'll have to seal and waterproof the whole system, and then depend on it for a long time, so I want to be sure I have a solid understanding of every element of the circuit, and the digi/analog inputs have been the biggest area of uncertainty for me.

    I'll get back to work and hopefully won't hit another wall! Thanks again for the help, looking forward to sharing the results soon.

    Along the same thread:

    If I were to power my components with a battery, only sending the output signals into Bela's inputs (that is, not relying on Bela's power or ground), could that be problematic in any way?

    alt text

    That would not work, because the voltage at "Digital in" would not be referenced to the Bela's ground, therefore the Bela would not see any voltage change at the pin. You need to connect the "-" of the battery to the Bela's ground for it to work.

    Also, make sure the battery never exceeds 3.3V or you may fry the BeagleBone. Something that would help with that is to swap the polarity of the battery in your diagram, thus having the 10k resistor in series with the "+". This way, if the battery slightly exceeds 3.3V, the current through the pin will be limited by the resistor and the chances of burning the chip are going to be lower. (Make sure the Bela's ground is always connected to the "-" of the battery!!). Of course in this configuration the input would normally read "HIGH" and it would go "LOW" as you press the switch, which is the opposite of what is happening in the circuit you posted.