How does it work?
AN to PWM 2 Click is based on the LTC6992CS6, a voltage-controlled PWM generator from Analog Devices. This device is chosen because it keeps its output clocking at all times, and it offers glitch-free, a first cycle-accurate startup within 500μs of Power-On. The output of the this Click board™ can source or sink up to 16 mA, and it has a linear response, so applying a voltage in a range of -2.5 to 2.5V on its input, will result in generating the PWM pulse train with duty cycle linearly proportional to the input voltage. The output PWM signal is brought to the INT pin of the mikroBUS™ socket to enable fast and precise duty cycle measurement using the interrupt routines.
The LTC6992CS6 has a MOD pin which represents pulse-width modulation input where is necessary to bring an analog signal. To bring the corresponding signal to that pin, this Click board™ uses an analog circuitry made of OpAmp AD8616ARZ from Analog Devices. In the first part of the circuit, amplifier OPA1 attends to adjust the input signal through a reference voltage of 2.5V by the MCP1525 from Microchip and applied input voltage in a range of -2.5 to 2.5V. The next part of the circuit is the voltage divider and amplifier OPA2 which has the function of a buffer, after which the signal required by the MOD pin of the LTC6992CS6 is obtained.
The output frequency can range up from 3.81Hz to 1MHz and is controlled via the AD5171, a 64-position (OTP) digital potentiometer from Analog Devices, which programs the LTC6992CS6’s internal master oscillator frequency. The output frequency is determined by this master oscillator and an internal frequency divider programmable to eight settings from 1 to 16384. It communicates with MCU using the standard I2C serial interface that operates at clock rates up to 400 kHz and represents the most accurate way to set the frequency. It’s also left the possibility to adjust the frequency via resistors RH and RL by placing resistors of appropriate resistance.
This Click Board™ is designed to be operated only with a 5V logic level. A proper logic voltage level conversion should be performed before the AN to PWM 2 Click is used with MCUs with different logic levels. More information about the LTC6992CS6’s functionality, electrical specifications, and typical performance can be found in the attached datasheet. However, the Click board™ comes equipped with a library that contains easy-to-use functions, and a usage example that can be used as a reference for the development.
Specifications
Type
ADC
Applications
Can be used for heater control, PWM servo loops, LED dimming, signal isolation, and other duty cycle control applications.
On-board modules
AN to PWM 2 Click is based on the LTC6992CS6, a voltage-controlled PWM generator from Analog Devices.
Key Features
Low power consumption, good temperature stability, wide frequency range, low frequency error, and more.
Interface
I2C
Feature
No ClickID
Compatibility
mikroBUS™
Click board size
M (42.9 x 25.4 mm)
Input Voltage
5V
Pinout diagram
This table shows how the pinout on AN To PWM 2 Click corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).
Onboard settings and indicators
Label | Name | Default | Description |
---|---|---|---|
LD1 | PWR | – | Power LED Indicator |
AN To PWM 2 Click electrical specifications
Description | Min | Typ | Max | Unit |
---|---|---|---|---|
Input Supply Voltage | -2.5 | – | +2.5 | V |
Output Current | – | ±20 | – | mA |
Output Frequency | 3.81 Hz | – | 1 | MHz |
Software Support
We provide a library for the AN to PWM 2 Click on our LibStock page, as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Library Description
The library contains basic function for sets frequency and gets interrupt pin state.
Key functions:
uint8_t antopwm2_get_int_state ( void )
– Gets interrupt pin statevoid antopwm2_set_freq ( uint8_t freq )
– Set Frequency
Examples description
The application is composed of three sections :
- System Initialization – Initializes the INT pin required to measure.
- Application Initialization – Initializes the driver, timer on 1us and frequency
- Application Initialization – Initializes the driver, timer on 1us and frequency
void application_task ( ) { uint8_t drdy; char rsp_data; drdy = UART_Rdy_Ptr( ); if ( drdy != 0 ) { rsp_data = UART_Rd_Ptr( ); switch ( rsp_data ) { case '+' : { // Reset flags period_flag = 0; idle_high_cnt = 0; idle_low_cnt = 0; period_cnt = 0; while ( period_flag != 1 ); idle_high_cnt /= 10; idle_low_cnt /= 10; if ( ( idle_high_cnt != 0 ) && ( idle_high_cnt != 0 ) ) { tmp_value = calc_percentage( idle_high_cnt ); FloatToStr( tmp_value, demo_text ); mikrobus_logWrite( "> Idle [HIGH]: ~ ", _LOG_TEXT ); mikrobus_logWrite( demo_text, _LOG_TEXT ); mikrobus_logWrite( " %", _LOG_LINE ); tmp_value = calc_percentage( idle_low_cnt ); FloatToStr( tmp_value, demo_text ); mikrobus_logWrite( "> Idle [LOW]: ~ ", _LOG_TEXT ); mikrobus_logWrite( demo_text, _LOG_TEXT ); mikrobus_logWrite( " %", _LOG_LINE ); tmp_value = calc_voltage( idle_high_cnt ); FloatToStr( tmp_value , demo_text ); mikrobus_logWrite( "> Voltage: ~ ", _LOG_TEXT ); mikrobus_logWrite( demo_text, _LOG_TEXT ); mikrobus_logWrite( " mV", _LOG_LINE ); mikrobus_logWrite( "--------------------------------", _LOG_LINE ); } mikrobus_logWrite( "--- Please, enter the command [ + ].", _LOG_LINE ); break; } } } }
Additional Functions :
- calc_percentage( ) – Represented data as a percentage
- calc_voltage( ) – Voltage calculation
- timer_init_1us( ) – Sets timer on 1us
The full application code, and ready to use projects can be found on our LibStock page.
Other mikroE Libraries used in the example:
- I2C Library
- Conersions Library
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.
mikroSDK
This Click board™ is supported with mikroSDK – MikroElektronika Software Development Kit. To ensure proper operation of mikroSDK compliant Click board™ demo applications, mikroSDK should be downloaded from the LibStock and installed for the compiler you are using.
For more information about mikroSDK, visit the official page.