1. Project description
We often need to use the ADC function when designing projects using microcontrollers. However, as we all know, microcontrollers are very fragile. Once the sampled (after voltage division) voltage exceeds 3.3v, it will instantly stop working. After burning 4 or 5 expensive microcontrollers, I thought it was necessary to use an external ADC, and this project was born.
2. The hardware design
uses ADS1115. This chip can provide 16-bit precision sampling at a speed of 860 times/s on IIC, and can be configured with 4 single-ended inputs or two differential input channels. And it has a built-in programmable gain amplifier with a gain of up to 16x to help improve the overall range of smaller signals. In addition, the ADS1115 can work on a 2-5V power supply and can measure 0-6v voltage, which is nearly doubled compared to the 0-3.3v measurement range that comes with the microcontroller.
In addition, the sampling rate can be programmed from 8 times/s to 860 times/s. The operating current in continuous mode is only 150uA, and the power consumption is very low. Through the lead-out pin, the IIC address can be selected, and any one of the four addresses in 0X48-0X4B can be selected. According to this feature, four modules can be connected to one IIC to achieve 16 single-ended inputs, which greatly reduces the pin occupation of the microcontroller (if the internal ADC of the microcontroller is used, not only the MCU needs to have 16 built-in ADCs, but also 16 of the microcontroller pins must be occupied) IO port, causing a waste of performance) At the same time, the internal ADC of the microcontroller is mostly 10 bits, and the sampling accuracy is small. This module can well solve the above pain points.
3. Physical demonstration (application example)
combined with Raspberry Pi and joystick module can realize the direction control of the joystick. The demonstration video is as follows
. 4. The sample code
is only the Arduino code to verify the normal operation of this module, not the above joystick code. Can be transplanted to STM32 for verification.