How to measure voltage above Reference Volt using MSP430? - msp430

I am learning to use MSP430 FR5994 for microcontroller development.
I wish to measure an external voltage using the built in ADC, the external voltage is in the range of 2.2V to 3.3V. The reference voltage set for the board is 1.2V (I can't use AVCC as the reference).
May I ask how should I measure the value of this voltage?

Related

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

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.

How many amp can arduino take

Im currently trying to get an electric signal from arduino, its 5v and 1amp that i get from a powersupply.
I want to input that signal into an arduino pin, lets say pin 4.
The main powersource from my arduino is via usb, but the 5v signal is from an external device.
I just want to know the number of time that signal became active, like a switch.
As far as i know arduino can take only .04amp from 5v.
Is there anyway i can reduce the current?
Anyway to obtain the value of a resistor to make it less dangerous for my arduino?
Your question is a very common application for Arduino!
You can give your Arduino some additional protection by placing a 10kOhm resistor between the Arduino analog pin you wish to use and the positive voltage output of the power supply.
If you're worried that the voltage could increase above 5V, you can protect your arduino with a simple voltage divider using two resistors. There's a detailed tutorial for this approach here: https://startingelectronics.org/articles/arduino/measuring-voltage-with-arduino/ Here's a simplified circuit diagram with a voltage divider that reduces voltage 11 fold - making voltages up to 55V safe to measure (where the battery could be replaced by your power supply):
For your code, you can use analogread() to read the voltage of the pin. If you wired it correctly, it should return near 0 when the powersupply is at 0, and 1026 or thereabouts if it is at 5v (or whatever the maximum value your voltage divider is designed for). Here is an example to get you started :
https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/
If you need any support with your code to count the number of times the voltage goes high, post that as a separate question along with the code you have so far.

Is it possible to hard code the AREF instead of using a pin?

Is it possible to hard code the reference value instead of using the pin 21 (AREF) on the ATMEGA168?
Since the majority of ADC principles rely on comparision of voltage, current or charge you always need a physical reference that cannot be bypassed by hardcoding. In this case a reference voltage is needed. On the ATmega 168 you can either use the external reference pin AREF, or the controllers power supply voltage AVcc, or a built-in 1.1 V voltage reference diode 'Vref`.
You can set the reference source by programming ADMUX (ADC multiplexer selection register) as stated in the ATmega48/88/168 data sheet page 261:
//using avrgcc:
//select internal 1.1 V ADC reference
ADMUX |= 0b11000000;

Turn on light (bulb) with Arduino UNO and PIR Sensor

im trying to turn on the light (bulb) with my arduino UNO and one module with 4 relays. I can do it with one LED but with an bulb i can't. I have connected the wires like in the photo:
http://i.stack.imgur.com/GUuAS.jpg
I need a 1k ohm resistor or the module include it??
Here the bulb that I have:
http://i57.tinypic.com/10dbp90.jpg
Thanks!!!
In your wiring picture it appears that the only source of power is what the Arduino is getting from the USB cable. The purpose of a relay is typically to control the flow of a higher voltage source (such as multiple small batteries in series, a larger battery, or a wall outlet) using a lower voltage control signal (e.g. one of your Arduino's GPIO pins). The maximum current from VCC to ground that can be draw without damaging your Arduino is 200 mA (source). Power = voltage * current (p = i * v) and VCC is 5V. This means the total amount of power your Arduino can supply is 1 watt. This is likely significantly less than the amount of power required to turn on your light bulb.
The purpose of the resistor in the LED circuit is to limit the current going through the LED. This is more commonly done when the LED is connected directly to a GPIO pin in order to prevent more current from being drawn from a pin than the amount that will damage that pin. From the same source as the current limit from VCC, the limit for a GPIO pin is only 40 mA. I would recommend seeing if you can power your light bulb with a battery. You could then use this same size battery as the power source for your relay board.

Does Ardunino serial need a common ground

I have a device running off a different power supply, that I'm trying to talk to serially, it has TX and RX lines, GND and 2.7+ line, its quite grunty so It has its own PS.
I'm getting some odd results at the moment, so wondering if I need to use a common GND between the Arduino GND and the PS GND and the device GND.
Does serial require a common voltage reference point?
Its a mega 2560 R3
All signals require a reference voltage. Ground is what provides this reference for single-ended signals such as those used by a UART.
UART signals are composed of low-level and high-level signals.
The receptor, at the other end, to be able to understand your UART signal, must be aware of what is that low-level and high-level signals.
So you must put your UART GND to the GND of the receptor, and the high-level voltage must correspond to the TTL input level of your receptor.
For example, if the high-level of your UART is 2.7v, and your receptor input-level is 5v, you could encounter bad level detections sometime, because 2.7v could be detected as a low-level input.
For the low-level inputs, this is no problem because 0v is always 0v.
Sorry but... didn't you break your 2.7V device? Besides using a common ground, like Ignacio pointed out, when you have to interface something to something else you should ALWAYS check what are the correct voltage levels expected.
So did you check that the high voltage levels and low voltage levels are fulfilled? I think not. Because:
Arduino Uno (i just have the 328P datasheet on hand, so i'll use this) has an Atmega328P powered at 5V. The datasheet says that the Vih parameter (the minimum voltage sensed as a "high" value) is 0.6Vcc, which means 3V. So if you send him a 2.7V signal.... You are doing something wrong.
The 2.7V device has probably an absolute maximum voltage allowed on any pin of Vcc+0.3V. This means that the maximum voltage for each pin is 3V; if you go above this current starts flowing through the protection diode and... you blow your device. Now you are giving it 5V, so.... Puff...
If the above criteria are not fulfilled you have to put between the two circuits something. Which is
a resistor divider if you have to make the voltage lower (just two resistors) and a couple of transistors to make it higher
Opto-isolators (and you can keep the grounds separated)
Voltage translators (such as TXS0102)
other...

Resources