I'm trying to control the temperature of a LED laser (which have a thermistor as temperature sensor and a Peltier Cell, both integrated with the laser) and what I'm implementing is a PID controller with Arduino Uno. The project is going as follows:
1.- I set the Setpoint and get the value of the thermistor with the next cirtuit (the obtained raw data are processed in arduino and transformed to the corresponding temperature):
2.- I'm using the PID arduino library, so with the value of the temperature, the setpoint and the chosen Kp, Ki and Kd I'd get the corresponding output. And with this output value is where I have the problem, which I'll explain later.
3.- The idea is to send this output given by the PID to a PWM pin and then, depending if we need to increase or decrease the temperature, generate a positive or negative current in order to feed the Peltier Cell. The PWM signal will go from 0 to 4V (0-2V when we want to cool down and 2-4V when we want to heat up). To generate the corresponding currents I've implemented the next circuit:
It sets 2V as threashole, which is compared with the arduino DC signal, generating then a positive or negative value. Then I amplify this small current at the output of the comparator (U1A) with the Darlington transistors (one for positive and the other for negative values) and that will be the current that goes through the peltier cell.
As you see, I need to set up the output of the PID in arduino in a way that gives me 2V in case that there is no error, 0-2V when the error is negative and 2-4V when the error is positive. I don't know how to do this with the PID arduino library, so if someone has any idea please help me!!
I know it can be a long question just for this, but I wanted to explain a bit some of the system so it is easier to see the situation and also it can be of help for other people. Anyway if something is still not clear, please ask me.