Programming for controlling polymer dispersed liquid crystal film transparency/opacity depending on temperature

Hi guys,
I am new to programming and my background is in Mechanical Engineering. Recently I have been working on a project to implement the use of PDLC film for thermal management. I am using an ESP32 microcontroller with LM35 sensors. I am trying to use the code for the PID controller in my sketch so that I can regulate the transparency/ opacity of the PDLC film depending on the temperature inside and outside of the vehicle cabin. Can anyone help me out? Thanks.

1 Like

Could you share the code you have so that we can see which parts you need help with? Is it the code to compute the PID values?

This is the code which I was able to come up with till now.

#include <PID_v1.h>
#include “LM35.h”
#define PIN_INPUT 13
#define PIN_OUTPUT 2
#define LM35_1_PIN_VOUT 13
#define LM35_2_PIN_VOUT 14

LM35 lm35_1(LM35_1_PIN_VOUT);
LM35 lm35_2(LM35_2_PIN_VOUT);

float temp1, temp2;
int tempPin1 = 13;
int tempPin2 = 14;
double Setpoint, Input, Output;
double Kp=2, Ki=5, Kd=1;
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);

void setup()
Input = analogRead(PIN_INPUT);
Setpoint = 100;
pinMode(2, OUTPUT);

void loop()
Input = analogRead(PIN_INPUT);

temp1 = analogRead(tempPin1);
temp1 = (1.515temp11000)/(102410);
temp2 = analogRead(tempPin2);
temp2 = (1.515

Serial.print("Inside_Temperature = “);
Serial.print(“Deg C”);
Serial.print(”\tOutside_Temperature = ");
Serial.print(“Deg C”);
if (temp1>=30)
digitalWrite(2, HIGH);
Serial.print(“Pdlc is on \n”);
digitalWrite(2 , LOW);
Serial.print(“Pdlc is off \n”);
I want to implement the PID in such a way that it will take input from one sensor and such that it will propogate the input according to a setpoint. The main aim is to control the “Polymer dispersed liquid crystal” film’s transparency/opacity depending on the temperature.

1 Like