Go Down

Topic: I pay for coding for PWM of X-valves (Read 187 times) previous topic - next topic


Hi. I am very very new to coding in general (just in this case I need to learn to solve this specific problem quickly)  to run a part of my setup for my thesis. It became an emergency now and I really appreciate the help.

I use Parker Miniature X-valves to split a gas flow with PWM. currently the arduino (micro 5v, 16mhz) running with one setting (a duty cycle (DC) and period), that can be changed by analog screws.

However now I need to change the coding the way that for instance after 10 hours of DC= 0.200, it AUTOMATICALLY changes the DC to 0.500, then after 35 hours of DC=0.500, change it to DC= 0.800 and so on.

How would it be possible to code the arduino for this automatic DC changes after certain elapsed time?

I pay for a code that functions.

Thank you for any comments and help.


Sep 11, 2019, 12:29 pm Last Edit: Sep 11, 2019, 12:31 pm by Bainesbunch

I can help you with this.

Will the time follow the same pattern every time and will it start from the beginning every time the system is started.

Will there a be a reset to start function needed.

I have PM'd you my email address.

EmbeddedAT .. From Concept to Prototype to Production
Electronics and firmware design and project mentoring
I do answer personal requests for help when accompanied with a PayPal receipt ;)


Very basic, but it's a start if OP wants to give fleshing it out a shot.

Code: [Select]

#define VALVE 2

    int hours;
    int dutyCycle;

struct SCHEDULE _times[] =
    // Format is {hour, duty cycle}
    {0, 20},
    {10, 50},
    {35, 80}

void setup()
  // put your setup code here, to run once:
  pinMode(VALVE, OUTPUT);

void loop()
  static int hours = 0;
  static int seconds = 0;
  static int i = 0;
  if (seconds % 3600)
    if (hours == _times[i].hours)
        // delay should take care of this not being executed more than once per instance
        digitalWrite(VALVE, _times[i].dutyCycle);
        if (i == sizeof(_times)/sizeof(_times[0]))
            // Hold at end of list
Electronics and firmware/software design and assistance. No project too small

Go Up