Assistance requested with custom LED display code

Hello all,

I’m a new-new Arduino user, so of course my first project is entirely too complex to accomplish on my own. :slight_smile:

I’m attempting to build an thermostat for a Peltier cooler. This system will incorporate digital readout, manual temp control via front panel switches, and multiple modes: Temp set, humidity control, and “max”. That’s it in a nutshell. For exact details, my design guide is at the bottom of this post.

The PWM FET controller is relatively simple and I think I can handle the code for it. The display is giving me issues though. The board I designed uses two shift registers: an eight-channel LED driver chip (row access), and a 74HC595 (column access) to access the eight, 7-segment LED displays that make up the DRO unit. The idea is the first chip will power the segments of all displays, and the second chip will provide a drain to a particular display unit so only that display will illuminate. Rapidly cycling through each display and resetting the segments should allow a pretty good refresh rate.

The issue is, I have a total mental block on how to accomplish this. Here’s what I have so far:

//Displays - creating a var per character, two characters per display
int display1 = 0 // 1 - Temp target
int display1b = 0
int display2 = 0 //2 - Humidity
int display1b = 0
int display3 = 0 //3 - Cold side temp
int display1b = 0
int display4 = 0 //4 - Hot side temp
int display1b = 0

void setup(){
//Serial data OUT to display board
pinMode(D3, OUTPUT) //Serial Latch
pinmode(D4, OUTPUT) //Serial Data Out
pinMode(D5, OUTPUT) //Serial Clock
}

void loop()
{
int ambient = analogRead(A9);
int lowtemp = analogRead(A7);
int hightemp = analogRead(A10);

}

void display()
{
digitalWrite(D3, LOW); //Latch enable pulled low
shiftOut(D4, D5, LSBFIRST, value); //Write out first byte
shigtOut(D4, D5, LSBFIRST, (value >>8)); //Write out second byte
digitalWrite(D3, HIGH); //Latch enable pulled high, displays on
}

And that’s about as far as I can get. I know I need to somehow take the reading from the sensors and turn that into a temp between 0-99 (negative temps I’ll just turn on the decimal point) Celsius (so, 0-1023 to 0 to 99 using the B values from the sensors) then output the two-digit temp to the one-digit displays by breaking the number into (example: temp is 53, first digit is 5, second digit is 3) shifting out the numbers one-by-one until all eight displays are updated, then starting the process again.

If it’s helpful, I’ve attached my schematic for the display board. When all is done and tested, I’ll be releasing the code, schematics, and PCB layouts for all to use.

Description of operation:

Upon powering the unit up with the main power switch, the “Main power ON” light will illuminate showing mains power, and the microcontroller will poll the position of the mode switch. In Dew point control and Max power modes, the output relay will be set ON immediately and the “Relay Output ON” lamp will illuminate, indicating mains power is available to the computer. In Temp target mode, the relay power will not be commanded on until the target temp is reached. This will allow pre-cooling of the CPU before system power-on.

Dew point control mode will read the analog inputs from ambient temp sensor and humidity sensor to determine the ambient humidity level, and thus the condensation temperature. The controller will then attempt to keep the TEC at a temperature 5 degrees Celsius warmer than the dew point. This will be mutable through the USB interface via reprogramming.

Temp target mode will command the TEC ON until the cold-side temp sensor reads within ±2 degrees Celsius of a front-panel-selected temperature, at which point a PWM function will vary the power to the TEC to keep it at this temperature.

Max mode will command the TEC ON indefinitely. Icicles will form. The room will heat. Major temperature drops will be seen. Condensation will be a serious concern.

For safety of devices (and sanity) involved, the controller will be in a normally-off state for all outputs, AKA fail-off. This will ensure the PC powers off immediately if the controller loses power, protecting the TEC and CPU from thermal runaway. Overtemp shutdown will be implemented. The hot side sensor will fail-off the relay AND TEC power at 50 degrees Celsius, while the cold side sensor will fail-off at a lower temperature to be determined through experimentation. It is assumed that the cold side will never be getting “hot”, so 35-40 degrees C may be a starting point. This is very important, since in the case of loss of coolant, the CPU will overheat and crash, but the TEC will continue to pump hundreds of watts of heat out, potentially melting or setting fire to the components in the area. Any out-of-range readings should cause a failure condition, in case a sensor fails, shorts, or is damaged by condensation or heat.

edit: tags.

edit: Uploaded new schematic - LED driver sinks current, not sources it.

here's my design guide

Code goes in code tags, not your post.

Code goes in code tags!

Fix your post, using Modify.

I know I need to somehow take the reading from the sensors and turn that into a temp between 0-99 (negative temps I’ll just turn on the decimal point) Celsius (so, 0-1023 to 0 to 99 using the B values from the sensors)

Look up the map function.

then output the two-digit temp to the one-digit displays by breaking the number into (example: temp is 53, first digit is 5, second digit is 3)

firstDigit = temperature /10; //an int will ignore the fractional part. Ints are Procrustean.
secondDigit = temperature %10;//look up modulo

Where are the base resistors on those transistors?
Where are the current limit resistors on those LEDs?

Why is that diagram so stupidly large? Have you clicked on it?

I know I need to somehow take the reading from the sensors and turn that into a temp between 0-99 (negative temps I’ll just turn on the decimal point)

So you’ll need your temp to be between -99 (or your lowest possible temp) to +99, unless you’re working in oK

Thank you Henry, that’s exactly the lead I needed. I should be able to cobble something together from that. The temp range will be in C, and will range from (if I’m extremely lucky) -30 to at most 60 or 70C. I’m going to have programmed bounds that shut down the system past that point.

As for the circuit diagram: I started this thread right after major surgery, so I made a couple of mistakes. It’s big because that’s the resolution it saved at. On my screen it’s scaled to the proper size, so it might be a browser thing.
Resistors for LEDs are obsolete :slight_smile: the LED driver chip is a constant-current source, which is what the resistor-plus-variable resistor is for: controlling the output current within preset bounds to vary the maximum brightness of the displays. It’s a pretty nice LED driver chip - just wish I would’ve realized it was a sink instead of a source before I designed this!
The resistors for the transistors are missing because… I forgot them. On the other hand, the breadboard version of this circuit doesn’t have them and it’s working fine, albeit without all eight channels built up. Power wasteful but I don’t think will damage anything. That said, now you’ve noted it, I’ll figure out a resistor to put in there.

Thank you for the substantive responses.