# ESP32 - Complex Waveform Generator V3 #### Installing and Using the ESP32 Complex Waveform Generator V3 Application Screenshot of web interface
[![image-1683400232715.png](https://stanslegacy.com/uploads/images/gallery/2023-05/scaled-1680-/MX4zLcrWYrUJauHX-image-1683400232715.png)](https://stanslegacy.com/uploads/images/gallery/2023-05/MX4zLcrWYrUJauHX-image-1683400232715.png)[![342755495_606076878142350_7100434860017235921_n.png](https://stanslegacy.com/uploads/images/gallery/2023-05/scaled-1680-/G1uYZlR7805tiMpU-342755495-606076878142350-7100434860017235921-n.png)](https://stanslegacy.com/uploads/images/gallery/2023-05/G1uYZlR7805tiMpU-342755495-606076878142350-7100434860017235921-n.png)
### Prerequisites To use this application, you need to have the Arduino IDE installed on your computer. You can download the Arduino IDE from the official website: [https://www.arduino.cc/en/software](https://www.arduino.cc/en/software) 1. **ESP32 Development Board**: You'll need an ESP32 development board, such as the popular ESP32-DevKitC or ESP32-WROOM-32D. These boards typically come with Wi-Fi and Bluetooth capabilities and a variety of GPIO pins for interfacing with peripherals. 2. **Rotary Encoders**: To adjust the waveform parameters, you will need a total of 7 rotary encoders. You can use KY-040 rotary encoder modules or any other type of incremental rotary encoder with built-in push buttons. Ensure that the rotary encoders you choose have a CLK, DT, and SW (push button) pinout. 3. **Breadboard and Jumper Wires**: A breadboard and jumper wires are required to make the necessary connections between the ESP32 development board and the rotary encoders. 4. **Power Supply**: You will need a power supply to power the ESP32 development board. This can be a USB power supply, a battery, or any other suitable power source that meets the board's voltage and current requirements, such an ATX Supply from a computer. 5VDC 1A minimum is recommended to prevent brownout conditions while interacting with a driver circuit. 5. **Oscilloscope (optional)**: To visualize the generated waveform, you can use an oscilloscope. Connect the output pins (channel1OutputPin and channel2OutputPin) from the ESP32 development board to the oscilloscope's input channels. #### Installing required libraries
1. **ArduinoJson**: To install the ArduinoJson library, follow these steps: a. Open the Arduino IDE. b. Click on `Tools` in the menu bar, then `Manage Libraries`. c. In the Library Manager window, search for "ArduinoJson" in the search bar. d. Find "ArduinoJson by Benoit Blanchon" in the search results and click on the `Install` button. 2. **ESP32Encoder**: To install the ESP32Encoder library, follow these steps: a. Open the Arduino IDE. b. Click on `Tools` in the menu bar, then `Manage Libraries`. c. In the Library Manager window, search for "ESP32Encoder" in the search bar. d. Find "ESP32Encoder by Gil Mora" in the search results and click on the `Install` button.
#### Uploading the Application
1. Download the source code for the [ESP32 Complex Waveform Generator V3](https://bitbucket.org/cbake6807/esp32-complex-waveform-generator-v3/src/master/) application or copy it to a new file in the Arduino IDE. 2. Connect the ESP32 development board to your computer using a USB cable. 3. In the Arduino IDE, select the appropriate board and port under `Tools` > `Board` and `Tools` > `Port`. 4. Click on the `Upload` button (right-facing arrow icon) in the Arduino IDE to compile and upload the application to the ESP32 development board.
#### Hardware Setup
1. Wire the rotary encoders and other components according to the pin assignments defined in the source code.
ESP32 PinEncoder ConnectionEncoder Function
14Pulse Encoder CLKPulse count
13Pulse Encoder DTPulse count
35Width Encoder CLKPulse width
34Width Encoder DTPulse width
19Spacing Encoder CLKPulse spacing
18Spacing Encoder DTPulse spacing
23Off-time Encoder CLKOff-time
22Off-time Encoder DTOff-time
27Width Mod Encoder CLKWidth modifier
26Width Mod Encoder DTWidth modifier
15Spacing Mod Encoder CLKSpacing modifier
32Spacing Mod Encoder DTSpacing modifier
33Off-time Mod Encoder CLKOff-time modifier
4 Off-time Mod Encoder DTOff-time modifier
2Output Channel 1Output waveform
5Output Channel 2Output waveform
2. Make sure the connections are secure and verify the CLK/DT pins for each encoder are wired correctly, and that each encoder turns in the correct direction relative to the respective parameter change.
#### Using the Application
1. Power on the ESP32 development board. 2. Use the rotary encoders to adjust the following parameters: - Pulse count - Pulse width - Pulse spacing - Off-time - Width modifier - Spacing modifier - Off-time modifier 3. The application will generate a complex waveform based on the adjusted parameters. 4. Connect the output pins (channel1OutputPin and channel2OutputPin) to an oscilloscope to visualize the generated waveform. 5. Open the WebApp/index.html page in a browser. 6. Fine-tune the parameters using the rotary encoders to achieve the desired waveform shape and characteristics.
#### Next Steps For Utilization
- Build ESP32 CWG - VIC Driver circuit(s) - [https://stanslegacy.com/books/chris-bake/page/esp32-cwg-driver-amplification](https://stanslegacy.com/books/chris-bake/page/esp32-cwg-driver-amplification) - Cell Construction - [https://stanslegacy.com/books/ethan-crowder/page/resonant-cavity-related](https://stanslegacy.com/books/ethan-crowder/page/resonant-cavity-related)
#### Troubleshooting
1. If the waveform does not match the expected output, verify the wiring connections and ensure the rotary encoders are functioning correctly. 2. If the application does not upload to the ESP32 development board, double-check the board and port selection in the Arduino IDE. 3. If the rotary encoders behave unexpectedly (e.g., adjusting one parameter affects another), check the CLK/DT pin assignments and wiring. 4. Click the PInout button to fetch the currently defined GPIO pins from the ESP32 directly and confirm they are wired correctly. [![image-1683400997931.png](https://stanslegacy.com/uploads/images/gallery/2023-05/scaled-1680-/0KZXcho6wJLP4Onh-image-1683400997931.png)](https://stanslegacy.com/uploads/images/gallery/2023-05/0KZXcho6wJLP4Onh-image-1683400997931.png)
For further assistance or to report any issues, contact the application's support team or refer to the community forums.