My project is to use an Arduino to control two solenoid valves with PWM and receive an input signal from a sensor as feedback.
The valves direct the flow of water which cause a hydraulic actuator to move which is detected by an LVDT sensor.
What I want my program to do is to allow me to set a desired displacement as a goal which causes the Arduino to dynamically change the duty cycle of the pwm signal based off of the feedback input the Arduino receives. I am going to implement a PID to control it.
The circuit consist of the Arduino sending PWM signals to two logic level NPN mosfets to control the solenoids that are powered by 2 external 12V sources.
What I specifically need help with is how to write the part of the program that will let me produce 2 PWM signals that will allow me to change the frequency of the pwm waves so that the solenoids have enough time to switch and then also the ability to set the duty cycle.
I am a total novice programmer and its my first time working with electronics. I'm just hoping someone can point me in the right direction.