Post your best Lua script examples here

User avatar
By trackerj
#11574 ESP8266 CBDB Module with MCP4726 12 Bit DAC generating some standard waveforms for testing DAC output accuracy:

6  - Function Generator - Run Program - 6.jpg


Set 0.5V Output:
1 - Function Generator - Set 0.5V - 1.jpg
Fixed 0.5V set


Square Wave Function:
2 - Function Generator - squareWave - 2.jpg
Squarewave waveform


Sawtooth Function:
3 - Function Generator - sawtoothWave - 3.jpg
Sawtooth waveform


Sinusoidal Function:
5 - Function Generator - sinWave - 5.jpg
Sinusoidal waveform


For reference :
http://www.esp8266-projects.com/2015/03/mcp4726-12-bit-i2c-dac-driver-for_7.html

Video:
User avatar
By quantalume
#11668 What is the maximum rate that you can update the DAC? If you wanted to produce the smoothest-possible sawtooth with a 12-bit DAC at 60 Hz, for example, it would require 60 X 4096 X 2 = 491520 updates per second. This is beyond the capabilities of LUA, not to mention the device settling time and even the I2C spec itself.
User avatar
By trackerj
#11706
quantalume wrote:What is the maximum rate that you can update the DAC? If you wanted to produce the smoothest-possible sawtooth with a 12-bit DAC at 60 Hz, for example, it would require 60 X 4096 X 2 = 491520 updates per second. This is beyond the capabilities of LUA, not to mention the device settling time and even the I2C spec itself.


MCP4726 DAC is quite capable with a Settling Time of 6 μs and I2C High-Speed (3.4 Mbps) mode. LUA is the weakest link if you want, but the idea here was to generate some standard waveforms just to be able to proper test driver implementation and the DAC output characteristics.