Code Monkey home page Code Monkey logo

microchip-pic-avr-examples / avr128db48-constant-current-driver-using-opamp-mplab-mcc Goto Github PK

View Code? Open in Web Editor NEW
1.0 4.0 1.0 255 KB

This MCC based MPLAB X IDE example shows how to use the Analog Signal Conditioning (OPAMP) peripheral to implement a constant-current driver using just one external resistor. The constant current amperage setting can be adjusted using firmware control.

License: Other

Makefile 3.44% C 93.20% Assembly 3.36%
cip curiosity-nano direct-current low-bom melody op-amp resistor-ladder signal-conditioning d-a-converter operational-amplifier

avr128db48-constant-current-driver-using-opamp-mplab-mcc's Introduction

MCHP

Constant-Current Driver Using the Analog Signal Conditioning (OPAMP) Peripheral

A new feature introduced in the AVR® DB MCU is the Analog Signal Conditioning (OPAMP) peripheral. In this example, the OPAMP is used as a constant-current driver using a single external resistor. It can be used to drive a load such as LEDs, with constant current and not constant voltage. The OPAMP peripheral also provides the ability to adjust the current setting under firmware control. The configuration for this example can be seen in the figure above. For more information about setup and code, see the application note.

Related Documentation

Software Used

Hardware Used

Peripherals Configuration using MCC

Added Peripherals

  • Add the OPAMP Driver under Device Resources tab

OPAMP_driver

  • The Builder tab shows the system, with the added OPAMP block

Builder

  • Click on the OPAMP block, to enable the OPAMP driver configuration Easy View and configure as shown below

Builder

  • Click on Generate in the Resource Management tab to generate the source code

Builder

Setup

  • Connect the load, such as an LED, between PD2 (OP0OUT) and PD3 (OP0INN) as shown in the schematic above

  • Connect a resistor, R3, from PD3 (OP0INN) to GND. The value of R3 determines the amperage of the constant current. For instance, using R3 = 205Ω will yield a current of 1mA with this example implementation. See the application note for more information on how to configure R3 to produce a constant current with a specific amperage.

  • To change the constant current level value in firmware with MCC, click on the MCC button in MPLAB X and click on the OPAMP peripheral under Project Resources. In the OPAMP tab, under Easy Setup find and click on the OP0 tab. Use the drop down menu on the MUXWIP: Multiplexer for Wiper Multiplexer setting to change the amperage of the constant current according to the table below

MUXWIP Selection of Current Value

Operation

  • Connect the AVR128DB48 Curiosity Nano to a computer using a USB cable

  • Download the "*.zip" file or clone this repository to get the source code

  • Open the avr128db48-constant-current-driver-using-opamp-mplab-mcc.X project in MPLAB X

  • Click the clean and build button to compile the code Builder

  • Click the make and program button to program the device Builder

  • If no tool has been chosen, a window will open, select the AVR128DB48 Curiosity Nano evaluation kit. The tool can also be chosen in the project settings.

Summary

After going through this example you should have a better understanding of how to set up the OPAMP peripheral as a constant current driver with a specific amperage for a load.

Also, If more precise control of the current value is required, the MCU’s digital-to-analog converter (DAC) can be internally connected to the non-inverting (+) input of the op amp, see the application note for more information

avr128db48-constant-current-driver-using-opamp-mplab-mcc's People

Contributors

aku-work avatar carlehe avatar egilro avatar runarsauremicrochip avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

uttambasu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.