pleasedontcode

# Plasma Controller rev_03

Jan 17th, 2026
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: # Plasma Controller
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2026-01-17 16:47:03
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* buat progres THC_rotary bisa di kontrol  dengan */
  21.     /* web server melalui wifi */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24.  
  25.  
  26. /* START CODE */
  27.  
  28. // System Requirements: THC (Torch Height Controller) system with plasma cutting control
  29. // Main Arduino sketch for ESP32 THC remote control system
  30. // Includes timer setup, interrupt handling, and initialization of all subsystems
  31.  
  32. #include "globals.h"
  33.  
  34. // ===== Timer Callback Function =====
  35. // Triggered by esp_timer every 10ms to set the Do flag for periodic tasks
  36. void onTimerCallback(void* arg) {
  37.   Do = true;
  38. }
  39.  
  40. // ===== Timer Setup Function =====
  41. // Configures the ESP32 high-resolution timer to interrupt every 10ms
  42. void Setup_Timer2() {
  43.   // Setting structure for the timer
  44.   esp_timer_create_args_t timer_args = {
  45.     .callback = &onTimerCallback,
  46.     .name = "my_periodic_timer"
  47.   };
  48.  
  49.   // Create the timer
  50.   ESP_ERROR_CHECK(esp_timer_create(&timer_args, &timer_handle));
  51.  
  52.   // Start the timer. It will repeat every 10,000 microseconds (10ms)
  53.   ESP_ERROR_CHECK(esp_timer_start_periodic(timer_handle, 10000));
  54. }
  55.  
  56. // ===== Arduino Setup Function =====
  57. // Called once when the microcontroller starts
  58. void setup() {
  59.   // Initialize serial communication for debugging
  60.   Serial.begin(115200);
  61.   delay(1000);
  62.  
  63.   // Initialize all subsystems
  64.   Setup_LCD();
  65.   Setup_Encoder();
  66.   Setup_THC();
  67.   ReadProg();
  68.  
  69.   // Initialize the timer for periodic interrupt
  70.   Setup_Timer2();
  71. }
  72.  
  73. // ===== Arduino Main Loop =====
  74. // Continuous loop that executes after setup()
  75. void loop() {
  76.   // Check encoder button for menu navigation
  77.   checkButton();
  78.   // Process menu selection based on encoder button
  79.   checkMenu();
  80.  
  81.   // Update LCD display
  82.   doLCD();
  83.  
  84.   // Process THC logic (arc voltage control and torch height adjustment)
  85.   doTHC();
  86.  
  87.   // Read arc voltage from ADC
  88.   ArcV = analogRead(arcVoltagePin);
  89. }
  90.  
  91. /* END CODE */
  92.  
Advertisement
Add Comment
Please, Sign In to add comment