- /*
- {
- if (pwminit == 0) { // If inactive, start the pwm module
- pwm_init();
- }
- if (pwmstart == 0) {
- pwm_start();
- pwm_set_period(FREQ); // Frequency is 50Hz defined in pwm header file
- }
- if(value >= 0 && value <= 1000) {
- double duty = value/1000 * 100; // Convert pressure to duty percentage
- pwm_set_duty((int)duty); // Set duty percentage for actuator (0-100%)
- }
- }
- */
+ static long freq = 16666666; // This is 60Hz
+ PWM_Set(EHRPWM0A, true, freq, value * freq); // Set the duty cycle