2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
[![Arduino CI](https://github.com/RobTillaart/FunctionGenerator/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
|
|
|
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/FunctionGenerator/blob/master/LICENSE)
|
|
|
|
[![GitHub release](https://img.shields.io/github/release/RobTillaart/FunctionGenerator.svg?maxAge=3600)](https://github.com/RobTillaart/FunctionGenerator/releases)
|
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
# FunctionGenerator
|
|
|
|
|
|
|
|
Arduino library to generate wave forms (nummeric) for a DAC
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
TODO.
|
|
|
|
|
|
|
|
## Interface
|
|
|
|
|
|
|
|
### Constructor
|
|
|
|
|
|
|
|
- **funcgen(float period = 1.0, float amplitude = 1.0, float phase = 0.0, float yShift = 0.0)**
|
2020-11-27 05:16:22 -05:00
|
|
|
All parameters can be set in the constructor but also later in configuration.
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
### Configuration
|
|
|
|
|
|
|
|
- **void setPeriod(float period = 1.0)** // seconds
|
|
|
|
- **float getPeriod**
|
|
|
|
- **void setFrequency(float freq = 1.0)** // Hertz
|
|
|
|
- **float getFrequency()**
|
|
|
|
- **void setAmplitude(float ampl = 1.0)** // -
|
|
|
|
- **float getAmplitude()**
|
|
|
|
- **void setPhase(float phase = 0.0)** // phase of period
|
|
|
|
- **float getPhase()**
|
|
|
|
- **void setYShift(float yShift = 0.0)** // shift in amplitude, zero point.
|
|
|
|
- **float getYShift()**
|
|
|
|
|
|
|
|
### Wave forms
|
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
t is time in seconds
|
2021-01-29 06:31:58 -05:00
|
|
|
- **float sawtooth(float t)**
|
|
|
|
- **float triangle(float t)**
|
|
|
|
- **float square(float t)**
|
|
|
|
- **float sinus(float t)**
|
|
|
|
- **float stair(float t, uint16_t steps = 8)**
|
|
|
|
- **float random()**
|
|
|
|
- **float line()**
|
|
|
|
- **float zero()**
|
2020-11-27 05:16:22 -05:00
|
|
|
|
|
|
|
Line() and zero() are functions that can be used
|
|
|
|
to drive a constant voltage from a DAC and can be
|
|
|
|
used to calibrate the generator / DAC combination.
|
|
|
|
|
|
|
|
## Operational
|
|
|
|
|
|
|
|
See examples.
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
## TODO
|
|
|
|
|
|
|
|
ideas for the future...
|
|
|
|
|
|
|
|
- example with DAC. 8 12 16 bit.
|
|
|
|
- example with potmeters for 4 parameters
|
|
|
|
- RC function
|
|
|
|
- Trapezium
|
|
|
|
- Sawtooth reverse?
|
|
|
|
- play "recording"
|
|
|
|
|
2016-12-17 14:57:37 -05:00
|
|
|
|