Controllo PID con L298N

Good morning,

My name is Luca and I write from the province of Forlì Cesena. I am new to the forum.
I am a mechanical engineer and I don't know anything or almost C programming. I write because I need to program my Arduino Mega for a mechanical application that I have already built but that I have to manage in a fairly linear way.
Honestly, I don't feel like it and I don't have much free time to learn to program in a refined way, and therefore I wondered if someone wanted to help me (with compensation of course) in writing the lines of the text for what I have to do.
It is an Input potentiometer (0-5 kOhm) operated by me which acts as analog input A0. In feedback I have another Output potentiometer (always 0-5 kOhm) as analog input A1. This last potentiometer is operated by a hydraulic cylinder. The cylinder is controlled by a 24 V proportional solenoid valve which varies the oil flow rate according to the supply current of the internal solenoid (from 0 to 2 A). It is a valve with double solenoid (left and right) to allow the oil to reverse the flow and then operate the cylinder back and forth (double acting cylinder).
To have the necessary power to supply the proportional valve, I installed the L298N driver.
L298N is powered by 24V and is connected as follows:

  • ENA digital pin through which to send a PWM type signal to the module (output 10)

  • IN1 digital pin to determine the logical states to send to the module (output 30)

  • IN2 digital pin to determine the logical states to send to the module (output 32)

  • digital ENB pin through which to send a PWM type signal to the module (output 11)

  • IN3 digital pin to determine the logical states to send to the module (output 34)

  • IN4 digital pin to determine the logical states to send to the module (output 36)

I would like to perform a PID (Proportional Integral and Derivative) control, or at least something similar, so that the error (A0-A1) always tends to 0; when I move the potentiometer A0 the mechanism with the hydraulic cylinder should move in linear mode so that A1 "copies" the values ​​of A0.
At the moment I only managed to send a PWM signal to the L298N driver with the following formula:
power = map (abs (error), 0, 1024, 0, 255);

However, it's not really linear.

Now I would not want to bore too much, if someone is interested, you can contact me at luca.spadina@libero.it and then agree on what is necessary.

Thank you and Regards,

Luca

luca0281:
Honestly, I don't feel like it and I don't have much free time to learn to program in a refined way, and therefore I wondered if someone wanted to help me (with compensation of course) in writing the lines of the text for what I have to do.

As you want someone to write a program for you I am suggesting to the Moderator to move your request to the Gigs and Collaborations section of the Forum.

...R

Hi Luca I’ve reached out for some more information.