2017-01-11 15:28:10 +01:00
# Sigma-delta Module
| Since | Origin / Contributor | Maintainer | Source |
| :----- | :-------------------- | :---------- | :------ |
2019-01-16 23:31:09 +01:00
| 2017-01-13 | [Arnim Läuger ](https://github.com/devsaurus ) | [Arnim Läuger ](https://github.com/devsaurus ) | [sigma_delta.c ](../../components/modules/sigma_delta.c )|
2017-01-11 15:28:10 +01:00
This module provides access to the [sigma-delta ](https://en.wikipedia.org/wiki/Delta-sigma_modulation ) component. It's a hardware signal generator that can be routed to any of the output GPIOs.
The signal generation is controlled by the [`setprescale()` ](#sigma_deltasetprescale ) and [`setduty()` ](#sigma_deltasetduty ) functions.
## sigma_delta.close()
Reenables GPIO functionality at the related pin.
#### Syntax
`sigma_delta.close(channel)`
#### Parameters
- `channel` 0~7, sigma-delta channel index
#### Returns
`nil`
## sigma_delta.setprescale()
Sets the prescale value.
#### Syntax
Fix bit, bthci, can, encoder, eth, i2s docs (#3432)
* Fix bit, bthci, can, encoder, eth, i2s docs
* Fix bit, mqtt, qrcodegen, sigma-delta, sodium, time docs.
* Add object name in http.md
2021-05-19 21:02:49 +02:00
`sigma_delta.setprescale(channel, value)`
2017-01-11 15:28:10 +01:00
#### Parameters
- `channel` 0~7, sigma-delta channel index
- `value` prescale 1 to 255
#### Returns
`nil`
#### See also
[`sigma_delta.setduty()` ](#sigma_deltasetduty )
## sigma_delta.setduty()
Sets the duty value.
#### Syntax
`sigma_delta.setduty(channel, value)`
#### Parameters
- `channel` 0~7, sigma-delta channel index
- `value` duty -128 to 127
#### Returns
`nil`
#### See also
[`sigma_delta.setprescale()` ](#sigma_deltasetprescale )
## sigma_delta.setup()
Routes the sigma-delta channel to the specified pin. Target prescale and duty values should be applied prior to enabling the output with this command.
#### Syntax
`sigma_delta.setup(channel, pin)`
#### Parameters
- `channel` 0~7, sigma-delta channel index
2017-05-13 11:51:22 +02:00
- `pin` IO index, see [GPIO Overview ](gpio.md#gpio-overview )
2017-01-11 15:28:10 +01:00
#### Returns
`nil`
#### Example
```lua
sigma_delta.setprescale(0, 128)
sigma_delta.setduty(0, 0)
sigma_delta.setup(0, 4)
```