Git Product home page Git Product logo

talhaturac / potentiometer_control_pwm_duty Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 7.05 MB

Building Embedded Software Using the LAUNCHXL-F280025C Development Kit (Using Driverlib)

Makefile 0.61% C 98.89% Assembly 0.50%
adc adc-voltage-measurement c code-composer-studio cpp drivers embedded embedded-c embedded-systems interrupts launchpad launchxl launchxl-f280025c potentiometer texas-instruments tmsf28002x pwm pwm-driver tutorial tutorial-code

potentiometer_control_pwm_duty's Introduction


Logo

Building Embedded Software Using the LAUNCHXL-F280025C Development Kit

This project is developed to control the duty cycle of PWM signals with a potentiometer.
(using the EPWM_configureSignal() function)

Table Of Contents


About The Project

I am actively working on development kits from Texas Instruments and developing embedded software. In this post here, I wanted to share one of the projects I have done so that you can benefit from it. Enjoy!

Why are we here:

  • To create projects from Code Composer Studio IDE.
  • To be able to use the ADC unit, read and use this data.
  • To generate and configure PWM signals.
  • To be able to set the duty cycle ratio and other parameters of the PWM signal.

You can experiment by customizing the project code to your own TI development board. Or you can use the information shared here to create your own customizations that use the ADC unit and ePWM unit. The actual code is in the main.c file.


Built With

It was built using the C programming language, via Code Composer Studio IDE, with the LAUNCHXL-F280025C (C2000 MCUs family) development kit from Texas Instruments.


Description

Firstly, an empty CCS project file is opened. Required adjustments and configurations are made. After selecting the target path, i.e. the target device and connection type, the software is started. The reason why I do not share about these parts in detail is that they are available on the internet and TI's own resources.

The software is started by including the libraries on the main.c file. In this section, the included libraries are "driverlib.h" and "device.h". These files contain the drivers for the microcontroller and define the device-specific constants.

#include "driverlib.h"
#include "device.h"

The prototypes of the used functions are defined in this section. This enhances the readability and maintenance of the code.

// Function Prototypes
void    ADC_init();
void    ASYSCTL_init();
void    INTERRUPT_init();
void    PinMux_init();
void    TriggerEPWM_init();
void    EPWM2_init();
void    change_duty_ratio();
extern __interrupt void adcA1ISR(void);

This section contains the definitions of global variables used in the code, such as ADC results, duty ratio, and other variables.

// GLOBALS
uint16_t   adcAResult0;
float32_t  dutyRatio;
float32_t  d_value = 0;

This function contains the necessary steps to initialize EPWM2. It configures GPIO pins, resets PWM2 peripheral, and sets up synchronization.

void EPWM2_init()

This function is used to change the PWM duty ratio. It calculates the duty cycle of the PWM signal based on the ADC value and configures the PWM signal.

void change_duty_ratio(void)

This function configures EPWM1 as a trigger for ADC. It sets up timing and frequency parameters.

void TriggerEPWM_init(void)

This functions initializes and configures the ADC. It sets ADC sampling triggers, interrupts, and other settings.

__interrupt void adcA1ISR(void)
void ADC_init()
void INTERRUPT_init()

These function disables the temperature sensor output to the ADC.

void ASYSCTL_init()

This function sets up the configuration of analog pins.

void PinMux_init()

The main function initializes the device and performs necessary settings. It calls a function in an infinite loop to change the PWM duty cycle based on the ADC reading.

void main(void)

In order to test the results, a 330 ohm resistor and an LED lamp are connected in series between the GPIO2 pin and the 3.3V pin of the development board. The red end of the potentiometer is connected to 3.3V, the black end to the GND pin and the white pin to the A0/C15 pin. The connection and pinout reference of the development board can be found with F280025C LaunchPad™ quick quide resource.

Let's turn the potentiometer and see what happens!


Contact and Feedback

potentiometer_control_pwm_duty's People

Contributors

talhaturac avatar

Watchers

 avatar

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.