pleasedontcode

# Plasma Height Controller rev_04

Jan 17th, 2026
18
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 Height Controller
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2026-01-17 16:53:04
  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.  
  27.  
  28. /* START CODE */
  29.  
  30. // System Requirements: THC (Torch Height Controller) system with plasma cutting control
  31. // Main Arduino sketch for ESP32 THC remote control system
  32. // Includes timer setup, interrupt handling, and initialization of all subsystems
  33.  
  34. #include "globals.h"
  35.  
  36. // ===== Timer Callback Function =====
  37. // Triggered by esp_timer every 10ms to set the Do flag for periodic tasks
  38. void onTimerCallback(void* arg) {
  39.   Do = true;
  40. }
  41.  
  42. // ===== Timer Setup Function =====
  43. // Configures the ESP32 high-resolution timer to interrupt every 10ms
  44. void Setup_Timer2() {
  45.   // Setting structure for the timer
  46.   esp_timer_create_args_t timer_args = {
  47.     .callback = &onTimerCallback,
  48.     .name = "my_periodic_timer"
  49.   };
  50.  
  51.   // Create the timer
  52.   ESP_ERROR_CHECK(esp_timer_create(&timer_args, &timer_handle));
  53.  
  54.   // Start the timer. It will repeat every 10,000 microseconds (10ms)
  55.   ESP_ERROR_CHECK(esp_timer_start_periodic(timer_handle, 10000));
  56. }
  57.  
  58. // ===== Arduino Setup Function =====
  59. // Called once when the microcontroller starts
  60. void setup() {
  61.   // Initialize serial communication for debugging
  62.   Serial.begin(115200);
  63.   delay(1000);
  64.  
  65.   // Initialize all subsystems
  66.   Setup_LCD();
  67.   Setup_Encoder();
  68.   Setup_THC();
  69.   ReadProg();
  70.  
  71.   // Initialize the timer for periodic interrupt
  72.   Setup_Timer2();
  73. }
  74.  
  75. // ===== Arduino Main Loop =====
  76. // Continuous loop that executes after setup()
  77. void loop() {
  78.   // Check encoder button for menu navigation
  79.   checkButton();
  80.   // Process menu selection based on encoder button
  81.   checkMenu();
  82.  
  83.   // Update LCD display
  84.   doLCD();
  85.  
  86.   // Process THC logic (arc voltage control and torch height adjustment)
  87.   doTHC();
  88.  
  89.   // Read arc voltage from ADC
  90.   ArcV = analogRead(arcVoltagePin);
  91. }
  92.  
  93. /* END CODE */
  94.  
Advertisement
Add Comment
Please, Sign In to add comment