\ ********************************************************************* \ DAC simple usage \ Filename: DACusage.txt \ Date: 22 apr 2022 \ Updated: 22 apr 2022 \ MCU: ESP32-WROOM-32 \ Forth: ESP32forth all versions 7.x++ \ Copyright: Marc PETREMANN \ Author: Marc PETREMANN \ GNU General Public License \ ********************************************************************* DEFINED? --DACusage [if] forget --DACusage [then] create --DACusage 25 constant PIN_DAC1 26 constant PIN_DAC2 \ for example: set GPIO25 to 1 Volt PIN_DAC1 77 dacWrite \ 77 * 3,3 / 255 = 1. \ r must be in interval 0..3.3 \ leave n in interval 0..255 : VtoN ( r -- n ) 100e F* F>S 2550 * 3300 / ; \ example: \ 2.65e VtoN . \ display 204 : VtoDAC ( pin volt -- ) VtoN dacWrite ; \ example: \ PIN_DAC1 2.65e VtoDAC \ volt in interval 0..3.3 : vDAC1 ( volt -- ) VtoN PIN_DAC1 swap dacWrite ; \ example: \ 2.8e vDAC1 \ triangular signal generation : triangularSignal ( --) 256 for aft 10 ms PIN_DAC1 r@ dacWrite then next ;
Legal: site web personnel sans commerce / personal site without seling