Skip to content

PWM control of LED has been added to the ADCC Data Streamer Example, of the MCC Melody ADCC Example Component (Callbacks Implementation). LED brightness is varies with POT-Meter and ADC samples are visualized using the Data Streamer every 100ms.

License

Notifications You must be signed in to change notification settings

microchip-pic-avr-examples/pic18f57q43-adcc-data-streamer-pwm-callbacks-mcc

Repository files navigation

MCHP

MCC Melody ADC Data Streamer PWM Example - Callbacks Implementation (PIC18F57Q43)

The ADC Data Streamer PWM example, of the MCC Melody ADCC Example Component, is used in the Callbacks implementation and displays ADCC samples visualized with the Data Streamer. An Analog-to-Digital Conversion measurement is taken every 100 ms on the selected analog channel, also toggling an LED and Debug GPIO.

A PWM1_16BIT component is added to this example. For more information, check out the "PIC® PWM Use Case: Gradually Brightening LED" use case from the How to Use the PWMx_16BIT PLIB Driver section in MCC Melody API reference for PIC16F/18F. It shows how adjusting the potentiometer influences the brightness of the PWM, which is mapped to a % of the range of the ADC value.

So, as the pot meter is adjusted, the brightness of the PWM is adjusted, mapped to a % of the range of the ADC value.

Video Building This Example

Video Building this Example

Video: Introducing MCC Melody Example Components (while building the Polled version of the Timer Toggle LED example).

MCC Melody Example Components

Example Components are a tight integration of learning material directly into MCC. This allows users to conveniently place configuration instructions side-by-side to the components they are configuring. For more information, refer to the MCC Melody Example Components Introduction.

Note: The image below shows the completed configuration of the ADCC Data Streamer Example (Callbacks implementation), to which a PWM1_16BIT component has been added.

MCC Melody Example Components

Complete projects, available in MPLAB® Discover or GitHub, are specific to a board and microcontroller. However, the current project could be recreated on a range of supported microcontrollers by following the steps in the example component.

To explore what an example component is, as well as the difference between example and implementation, see MCC Melody Example Components - The Basics.

Example Components are related to MCC Melody Design Patterns for Control Flow, which shows different standard ways to organize main.c and other application-level files, such as Polling, Interrupt and Callback, or State Machine Design Patterns. Users might be familiar with each of these patterns, but...

  • What support does MCC Melody provide for each?
  • What are the recommended ways of building on the MCC Melody generated code? 

Software Used

  • MPLAB® X IDE 6.20.0 or newer (MPLAB® X IDE 6.20)

  • MPLAB® XC8 2.46.0 or newer (MPLAB® XC8 2.46)

  • MPLAB® Code Configurator (MCC) Plugin Version 5.5.1 or newer (Tools>Plugins>Installed, search: "MCC")

  • ADC Converter with Computation (ADCC) Example Component 1.0.0 or newer

  • MCC Core 5.7.1 or newer

  • MCC Melody Core 2.7.1 or newer (Communicates with the MCC core, providing views and other functionality for MCC Melody)

MCC Core Version

Hardware Used

Setup

The instructions required to recreate this example are listed below, under Configuration Instructions.

ADCC Data Streamer, Callbacks implementation

The following additional steps are required for this example.

Note: The timer period is changed to 0.02s, i.e., 20 ms.

PIC PWM use-case: Gradually Brightening LED

The Pins configuration are shown below:

PIC PWM use-case: PIN congiguration instructions

Operation

The image below shows the ADCC Basic Printf example running, using the MPLAB Data Visualizer.

After implementing the settings, similar results to the below image will be shown.

Running the ADCC Basic Printf Example

The image below shows the example running on the Curiosity Nano Explorer board.

Running the ADCC Basic Printf Example with PWM on the Curiosity Nano Explorer

Data Visualizer Setup

  1. Click the Data Visualizer icon icon to open the MPLAB Data Visualizer.
  2. Under the Variable Streamers tab (on the left hand side), click the Import ds file button to import a .ds file.
  3. From your project root, navigate into mmc_generated_files/data_streamer/ directory.
  4. Click the data_streamer.ds file to select it.
  5. Then click the open button button, to load the ds file.

Loading the ds file

The data_streamer Properties window will open up, displaying the loaded adcResult and adcSampleCount variables.

  1. Click the save button button, to load this data streamer configuration.

ds file loaded

  1. Click the no source button button.

  2. Select your board from those available.

    Note: If your board is not recognised by the MPLAB Data Visualizer, go to the Device Manager (Windows) to determine the COMx number.

  3. Click the settings gear icon icon to bring up the COMx Settings.

  4. Set the baud rate to 115200, then click out of the window to close the settings.

  5. Click the Time Plot icon icon to plot all variables.

Data Streamer Config

  1. Click the Connections button.
  2. Under Debug GPIO, click the Add to time plot icon icon, to add to the time plot.

Debug I/O Time Plot

For more example components, open the stand-alone Content Manager CM_icon in MCC.

Standalone_CM

About

PWM control of LED has been added to the ADCC Data Streamer Example, of the MCC Melody ADCC Example Component (Callbacks Implementation). LED brightness is varies with POT-Meter and ADC samples are visualized using the Data Streamer every 100ms.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published