Skip to content

This application note shows how to use the ADC featured in the tinyAVR® 2 devices to measure current and monitor battery charge. The demo shows an implementation of a simple circuit where various nodes are connected to the ADC.

License

Notifications You must be signed in to change notification settings

microchip-pic-avr-examples/attiny1627-current-measurement-and-battery-monitoring-mplab-mcc

Repository files navigation

MCHP

Current Measurement and Battery Monitoring With AVR® Devices

The following project shows how to use the Analog-to-Digital Converter (ADC) featured in the tinyAVR® 2 devices to measure current and monitor battery charge, through a discussion of the underlying theory and a demo application. The demo shows an implementation of a simple circuit where various nodes are connected to the ADC for taking certain measurements. Furthermore, by using MPLAB® Data Visualizer the relevant data can be presented live.

This example does not include an actual battery, and the circuit can be changed to match the user’s needs without altering the underlying concepts regarding the overall functionality of the presented case.

Related Documentation

Software Used

Hardware Used

Peripheral Configuration Using MCC

Added Peripherals

Added Peripherals

Pin Manager

Pin Manager

Pin Manager Grid View

Real-Time Counter (RTC)

Real-Time Counter

Sleep Controller

SLPCTRL

Setup

  • Connect the two shunt resistors, R1 and R2, in series between the voltage source and VTG
  • Connect a wire from between the voltage source and R1, to PB5
  • Connect a wire from between R1 and R2, to PA6
  • Connect a wire from between R2 and VTG, to PA7
  • Connecting the load:
    • Connect D1 and R3 in series between PC0 and the node between R1 and R2
    • Connect D2 and R4 in series between PC1 and the node between R1 and R2
    • Connect D3 and R5 in series between PC2 and the node between R1 and R2

Connection Diagram

Operation

  • Connect the ATtiny1627 Curiosity Nano to a computer using the USB cable
  • Download the zip file or clone the example to get the source code
  • Open the .X file with MPLAB® X IDE
  • Set the attiny1627-current-measurement-and-battery-monitoring-mplab-mcc project as main project. Right click the project in the Projects tab and click Set as Main Project.
  • Program the project to the board: right click the project and click Make and Program Device
  • Open MPLAB® Data Visualizer from within MPLAB® X IDE
  • Load the .dvws configuration file plot_config
  • Start streaming data by clicking the play button
  • By pressing the button on the Curiosity Nano, the LEDs light up one by one each time the button is pressed, resetting if pressed when all three are lit. The change in currents and voltages can be observed in the graphs in MPLAB® Data Visualizer.

Summary

This example shows how to perform simple current measurement and battery monitoring using the ADC featured in tinyAVR® 2 microcontrollers.

About

This application note shows how to use the ADC featured in the tinyAVR® 2 devices to measure current and monitor battery charge. The demo shows an implementation of a simple circuit where various nodes are connected to the ADC.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published