// // PWM Out: generate PWM waveform to control factory // #include "pwmout.h" #include "flash.h" static uint32_t last_ssr_on = 0; static uint32_t last_vcp_tx = 0; static uint32_t last_led = 0; void pwmout_init(void) { } void pwmout_process(float duty) { // // Kill SSR once the desired on-time has elapsed // if(set.val.control_mode == MODE_PID && (HAL_GetTick() - last_ssr_on > ssr_output || ssr_output <= 0)) // { // HAL_GPIO_WritePin(SSR_PIN, 0); // HAL_GPIO_WritePin(LED_POWER, 0); // } // // // // Every 200ms, set the SSR on unless output is 0 // if(set.val.control_mode == MODE_PID && HAL_GetTick() - last_ssr_on > SSR_PERIOD) // { // // Heat or cool, if we need to // if(ssr_output > 0) // { // HAL_GPIO_WritePin(SSR_PIN, 1); // HAL_GPIO_WritePin(LED_POWER, 1); // last_ssr_on = HAL_GetTick(); // } // else { // // Make sure everything is off // HAL_GPIO_WritePin(SSR_PIN, 0); // HAL_GPIO_WritePin(LED_POWER, 0); // } // // } }