| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

Functions | Macros | Variables
LT1054_voltage_mode_buck_DC_ctrl.ino File Reference

Go to the source code of this file.

## Functions
static void | setup ()
static void | loop ()
static void | setPwmFrequency (int pin, int divisor)
| Divides a given PWM pin frequency by a divisor. More...

## Macros
#define | fixed 0
#define | closed_loop 1
#define | verbose

## Variables
const int | analogInPin = A0
const int | analogOutPin = 3
static float | vout = 3.3
static int | setpoint = int (vout * 1024.0 / 5.0)
static int | feedback = 0
static int | outputValue = 0
static int | error = 0
static int | integral = 128
static uint8_t | state = closed_loop

## Function Documentation

## ◆ loop()

static void loop | ( | void |  | ) |
| static

Definition at line 81 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## ◆ setPwmFrequency()

static void setPwmFrequency | ( | int | pin,
|  | int | divisor
| ) |  |
| static

Divides a given PWM pin frequency by a divisor.

The resulting frequency is equal to the base frequency divided by the given divisor:

- Base frequencies: o The base frequency for pins 3, 9, 10, and 11 is 31250 Hz. o The base frequency for pins 5 and 6 is 62500 Hz.
- Divisors: o The divisors available on pins 5, 6, 9 and 10 are: 1, 8, 64, 256, and 1024. o The divisors available on pins 3 and 11 are: 1, 8, 32, 64, 128, 256, and 1024.

PWM frequencies are tied together in pairs of pins. If one in a pair is changed, the other is also changed to match:

- Pins 5 and 6 are paired on timer0
- Pins 9 and 10 are paired on timer1
- Pins 3 and 11 are paired on timer2

Note that this function will have side effects on anything else that uses timers:

- Changes on pins 3, 5, 6, or 11 may cause the delay() and millis() functions to stop working. Other timing-related functions may also be affected.
- Changes on pins 9 or 10 will cause the Servo library to function incorrectly.

Thanks to macegr of the Arduino forums for his documentation of the PWM frequency divisors. His post can be viewed at: http://forum.arduino.cc/index.php?topic=16612#msg121031

Definition at line 212 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## ◆ setup()

static void setup | ( | void |  | ) |
| static

Definition at line 71 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## Macro Definition Documentation

## ◆ closed_loop

#define closed_loop 1

Definition at line 59 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## ◆ fixed

#define fixed 0

Definition at line 58 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## ◆ verbose

#define verbose

Definition at line 69 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## Variable Documentation

## ◆ analogInPin

const int analogInPin = A0

Definition at line 56 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## ◆ analogOutPin

const int analogOutPin = 3

Definition at line 57 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## ◆ error

int error = 0
| static

Definition at line 66 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## ◆ feedback

int feedback = 0
| static

Definition at line 64 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## ◆ integral

int integral = 128
| static

Definition at line 67 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## ◆ outputValue

int outputValue = 0
| static

Definition at line 65 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## ◆ setpoint

int setpoint = int (vout * 1024.0 / 5.0)
| static

Definition at line 62 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## ◆ state

uint8_t state = closed_loop
| static

Definition at line 80 of file LT1054_voltage_mode_buck_DC_ctrl.ino.

## ◆ vout

float vout = 3.3
| static

Definition at line 61 of file LT1054_voltage_mode_buck_DC_ctrl.ino.