How to wire an A/D converter to measure within a specific voltage band so as not to waste measurement resolution - raspberry-pi4

I am trying to use a MCP3008 A/D converter (see https://ww1.microchip.com/downloads/en/DeviceDoc/21295d.pdf) with a RaspberryPi to digitize an audio signal generated by some legacy audio chip.
From what I understand I could just power the MCP3008 with 3v3 (VDD) to ease connection to the RaspberryPi (or I could use higer VDD up to 7V but then I'd have to use an additional levelshifter to interface with the Raspberry). The MCP3008's reference voltage for analog input signals cannot be higher than VDD+0.6V (e.g. 3.9V or 7.6V for the mentioned scenarios.).
According to the specs of the soundchip that I want to sample the relevant peak-to-peak voltage change is only 3V but the signal seems to ride at a 6V DC level. (I imagine that means that the signal moves within the 4.5V to 7.5V range.. is that assumption correct?)
I could obviously use some voltage divider to scale the input voltage to whatever maximum reference voltage the MCP3008 will tolerate. But I would always waste most of the measurement range 0 - 4.5V due to the fact that it is never used by the original audio signal.
Is there anything I can do to make sure that a respective A/D converter (it might be a different model than the one mentioned above) uses its measurement resolution to digitize
the signal specifically within the relevant voltage range? (i.e. with a 10-bit converter a 4.5V
signal should translate into 0 and a 7.5V signal into 0x3ff).
PS: I wonder if it might be a viable approach to use a Z-diode to cut off some part of the DC level and then measure the "overflow" portion of the voltage over a 10k resistor that I'd put after the Z-diode. Or are there any reasons why this might not work well for my application?

Use a high pass filter to remove the DC bias.
Given that you are working with audio you need to be careful not to remove audio data.

Related

Single stage transistor amplifier

i already know how to work with already biased transistor but now i am struggling when it comes to designing one starting with these values, am using a voltage divider bias for the single stage. given these values, how do we go from there? voltage gain =100 VCC =18v and beta=120 and RL=1k also i need a way to find the emitter bypass capacitor and input and output coupling capacitor.

How to get correct values from Arduino sensors

I am using 6 different sensors which are working simultaneously, but I got a problem in the readings from LM35 temperature sensor and MQ-7 Carbon Monoxide sensor. The values are changing depending on the power source.
How can I fix this problem? I'm planning to use a Sony power bank to feed my system but I am getting the wrong values especially from the temperature sensor.
Make sure that your power source is stable and continuous (i.e. make sure that your power bank is working fine and check its current output if its compatible with Arduino)
Make sure that your sensors are wired correct and working fine, try with different LM35 and MQ-7 sensors, if you have that chance.
Make sure that you are supplying your circuit with correct voltage and current, sensors may work unstable if you are supplying them directly from Arduino pins (because maximum current limit of the pins onboard may not be enough for your circuit), try an external power source such as MB102 power module.
Although, it's not a coding problem my suggestion is you can use signal conditioning to solved this. Search about low pass filter and high pass filter to filtering frequency in output sensor.
The simple method is using voltage divider, like this:
Vout = (R1/R1+R2) * Vin
R1 is your sensor, and R2 is resistor.

Displaying battery percentage with arduino

I would like to know if there is any way to display the battery level of an arduino running off a rechargeable battery. Is there some piece of equipment or certain code I could use with an LCD? To be clear I'm looking to display the battery percentage not the voltage.
I'm using an adafruit proto board with a servo shield
Thanks in advance.
I don't know why you are avoiding the simple solution (resistor bridge into an analog input). Create a map in EEPROM to act as an interpolation table and re-scale it occasionally. Taking the voltage from that analog input and mapping it through your interpolation table will give you a percentage battery remaining for the LCD. (most batteries I have interacted with slowly decrease in output voltage as their percentage remaining drops and the slope/ curve is usually fairly repeatable)

How to read multiple Analog sensor

I am using Arduino UNO board. I have 24 analog channel which gives me 0~5v analog out put. Now my problem is I have only 5 analog channel. I wanted to read value from each channel for every 2 min and then switch to other channel. Can anyone suggest me in Hardware how can get analog value ?
I am planning to use 8:1 multiplexer or 16:1 multiplexer . Will it is correct way of doing it. Can you suggest other way of doing it in hardware ?
74HC4051,74HCT4051,ADG708,MD14051B,
IC I am planning to Use.dep[end on so,s1,s2 just switch the channel
As a start, you might need to know that even Arduino Uno also have internal MUX. In my experience of reading multiple analog channel, this is the approach that I take. However by taking this approach, I suggest you to recheck the analog value so adding MUX will not generate any error or bias.
This could be done by comparing the output of measurement with the MUX and output of measurement without the MUX. I used 74HC4051 and it works brilliantly, just make sure not to leave any pin floating. The only disadvantage of this method is that you will need to use some I/O to control the MUX, but if that is not an issue for you, then go ahead.
Any other method could be more complicated. It would require your analog channels to correlate with each other, and you need to find a way method to combine multiple analog channel into a single channel.
e.g: if your aim is to compare two analog value, instead of measuring the value and comparing the value in software, you could make use of op-amp comparison circuit to compare the value for you and take the comparison result instead.
Use the photon-pixel coupling method, it is a new approach in science for sampling an unlimited number of sensors in parallel.
Basically, each sensor output is an LED. If you have 10000 sensors, the output of all of them is inserted in a LED array, a LED matrix as the authors say. After that, the LED array is filmed by a video camera and the images are processed in real time by a computer. A software reads one pixel from each LED from the LED array and converts it to numerical values. So, your LED array will be converted in a matrix (with 10000 elements) filled with numbers that can be processed as you wish in your software. I don't know if I was explicit but you can read their article here: https://www.sciencedirect.com/science/article/pii/S2215016119300901
Note that classic multiplexing is serial, this approach is parallel.
The photon-pixel coupling method is truly ingenious because it solves two main problems in engineering: an unlimited number of sensors and their parallel sampling at video rate frequencies. Just imagine, we can read as many sensors as we wish. What I wander is if we can adapt the photon-pixel coupling to Arduino. I am new in the world of microcontrollers but I know Arduino can support a cam, so it should be possible.
If you are a PhD student then:
P.A. Gagniuc, C. Ionescu-Tirgoviste, R.G. Serban, E. Gagniuc. Photon-pixel coupling: A method for parallel acquisition of electrical signals in scientific investigations. MethodsX, 6:968-979, 2019.
To read more analog channels than inputs you have, an analog multiplexer is a good option. All the ones you suggested will work, but personally, I like the Analog Devices ICs for analog circuits, so I would take the ADG708, but this is just a personal preference.

Arduino and External Peripherals

I am a CS guy getting started with Arduino. This is probably a very basic electronics question but from going over the arduino tutorials everything is connected to the arduino with a resistor.
Well since i am following the tutorials i know what type of resistor i should use but what i do not know is why i should use one? and What type of resistor to pick i am to do something which is not covered in a tutorial.
The resistor simply serves to limit the current into or out of a pin in case something goes awry. If your AVR decides to output high on a pin that something else wants low (or vice-versa), large, damaging currents can occur if not limited by some resistance. The current limit for AVRs is about 20 milliamps, and given that the voltages are usually 5V, something larger than 250 ohms "would work".
To give a margin of safety, 1-10k is a great choice; for digital signals it seldom matters unless you're into very high-speed applications (beyond the AVRs capability anyways). For analog inputs, a similar resistor would also be advisable, as the amount of current the ADC takes to sample is negligible when your resistor is in the few kilo-ohm range.
The underlying principle that you want to learn is Ohm's Law, which describes the relationship between voltage, resistance, and current in a circuit.
Resistors are used to
limit current,
devide voltage
protect against over voltage
pull-up, pull down
current to voltage conversion
etc ...
1) limit output current, the absolute max current per IO is 40mA, a typical LED works on ±2V 20mA.
the resistance value can by calculated by (5V - 2V)/(0.02A)=150Ω usually a 220Ω resistor is used, because: it consumes less power, there doesn't flow 20 milliamps, and there is no notable difference in emitted light.
2) if you have a analog voltage that variates between 0 and 10 Volts, you 'll need a voltage divider of 1/2. pick by example z2 10k and calculate z1 by 10k*(Vin,max/5V -1). take a value of resistance higher than the original calculated. and recalculate the new Vout.
3) place a resistor of 10k in series between the analog input of the arduino and the 'to measure voltage'
3) if you have to measure a analog current, you place a resistor to ground and the analog input, calculate the resistor by Z=5V/amps.
4) if you connect a button to the arduino, you 'll need to place a pull up or a pull down resistor. if you 're not using a resistor, the input is floating and can take any value (high or low). or you can enable the internal weak pull up. by pinMode(xx,INPUT); digitalWrite(xx,HIGH);. and disabeling by digitalWrite(xx,LOW); by default the pull-up is disabled.

Resources