1
\$\begingroup\$

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.

Thanks!!

\$\endgroup\$
  • \$\begingroup\$ The Arduino framework has a function called "map". Have you read up on that? \$\endgroup\$ – MrGerber Feb 12 '18 at 15:10
  • \$\begingroup\$ I suspect this would actually be easier to do without Arduino... then you'd just re-scale the format read from the ADC into PWM duty cycles, which is fairly trivial compared to hacking into some icky Arduino library. \$\endgroup\$ – Lundin Feb 12 '18 at 15:20
  • \$\begingroup\$ @MrGerber Thanks for the answer. Yes I know about that function, but I don't see how it could help me in this situation \$\endgroup\$ – Martin Feb 12 '18 at 15:57
  • \$\begingroup\$ Oh, I think I get it. You don't know how the PID works, and want help with setting it up properly? \$\endgroup\$ – MrGerber Feb 21 '18 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.