1

I am trying to run a thermometer with thermocouple sensor on Arduino Nano.

I have bought 4x 7 segment display and 74HC595 chip. Everything is connected like in the attached diagram below (without DS18B20) schematic, but when I uploaded sketch to Nano - only dots are turn on dots.

Below You Can find my code

#include <OneWire.h>
const int latchPin = 8; // Pin connected to ST_CP of 74HC595
const int clockPin = 9; // Pin connected to SH_CP of 74HC595
const int dataPin = 10; // Pin connected to DS of 74HC595
const int digitPins[4] = {
 3, 4, 5, 6}; // pins to control the 4 common anode pins of display
// seven segment digit bits + blank + minus
const byte digit[12] = {
 B00111111, // 0
 B00000110, // 1
 B01011011, // 2
 B01001111, // 3
 B01100110, // 4
 B01101101, // 5
 B01111101, // 6
 B00000111, // 7
 B01111111, // 8
 B01101111, // 9
 B00000000, // Blank
 B01000000 //-
};
int digitBuffer[4] = {1};
int digitScan = 0;
int soft_scaler = 0;
float tempC, tempF;
int tmp;
boolean sign = false;
void setup()
{
 TCCR2A = 0;
 TCCR2B = (1 << CS21);
 TIMSK2 = (1 << TOIE2);
 TCNT2 = 0;
 for (int i = 0; i < 4; i++)
 pinMode(digitPins[i], OUTPUT);
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(dataPin, OUTPUT);
}
ISR(TIMER2_OVF_vect)
{
 soft_scaler++;
 if (soft_scaler == 15)
 {
 refreshDisplay();
 soft_scaler = 0;
 }
};
void refreshDisplay()
{
 for (byte k = 0; k < 4; k++)
 digitalWrite(digitPins[k], LOW);
 digitalWrite(latchPin, LOW);
 shiftOut(dataPin, clockPin, MSBFIRST, B11111111);
 digitalWrite(latchPin, HIGH);
 delayMicroseconds(50);
 digitalWrite(digitPins[digitScan], HIGH);
 digitalWrite(latchPin, LOW);
 if (digitScan == 1)
 {
 shiftOut(dataPin, clockPin, MSBFIRST,
 ~(digit[digitBuffer[digitScan]] | B10000000));
 }
 else
 {
 shiftOut(dataPin, clockPin, MSBFIRST, ~digit[digitBuffer[digitScan]]);
 }
 digitalWrite(latchPin, HIGH);
 digitScan++;
 if (digitScan > 3)
 digitScan = 0;
}
void loop()
{
 tempC = 90.8;
 tmp = int(tempC * 10);
 if (tempC < 0)
 {
 sign = true;
 tmp = abs(tmp);
 }
 else
 {
 sign = false;
 }
 if (int(tmp) / 1000 == 0)
 {
 digitBuffer[3] = 10;
 if (sign)
 {
 digitBuffer[3] = 11;
 }
 }
 else
 {
 digitBuffer[3] = int(tmp) / 1000;
 }
 if (int(tmp) / 1000 == 0 && (int(tmp) % 1000) / 100 == 0)
 {
 digitBuffer[2] = 10;
 if (sign)
 {
 digitBuffer[2] = 11;
 digitBuffer[3] = 10;
 }
 }
 else
 {
 digitBuffer[2] = (int(tmp) % 1000) / 100;
 }
 digitBuffer[1] = (int(tmp) % 100) / 10;
 digitBuffer[0] = (int(tmp) % 100) % 10;
 delay(500);
}

I didn't connect thermocouple yet, but I use constant "tempC" with value = 90.8, to check if it works. If I change the value to higher - dots on displays are more dimmed.

Vincent
2322 silver badges10 bronze badges
asked Apr 7, 2023 at 6:13
4
  • 3
    please indent your code properly ... right now, it is difficult to read Commented Apr 7, 2023 at 6:37
  • That is a big display. That only the dots turns on is an indication that the voltage could be too low. The dots probably have less series diodes than the segments. Green display diodes also have a relatively high forward voltage. There may be other problems too. Post a link to the data sheet or vendor site for that display. Also this indicates a software problem because the schematic implies a common cathode type display: //pins to control the 4 common anode pins of display Remember also the absolute max 40mA limit for Arduino pins especially relevant for d3 to d6 here Commented Apr 7, 2023 at 7:50
  • Your digit pins can probably not source enough current for the display segments to light. You need a PNP transistor with a proper base resistor on each digit pin to drive the displays using an active low (inverted) signal. This would have been easier if your display was of the Common Cathode type. The fact that the dots are the only thing to light might also indicate there's something wrong with your code. Commented Apr 7, 2023 at 10:36
  • Thank You for response! You may be right, that transistors will be necessary. Below You can find vendor site of this display sklep.avt.pl/wyswietlacz-led-2-30-57mm-zielony-wa.html You can find in the descrpition - this is common anode display. Commented Apr 8, 2023 at 9:32

1 Answer 1

-1

The vendor description is not very good, however it is clear that 5 volts is not enough for these displays implying that you have to redesign the circuit to include a higher voltage power source. It does appear from the description, however, to be a common anode device. The screen shot from the data sheet shows each segment has 4 diodes in series and the DP has 2 diodes in series. That the DP lights with 5 volts indicates that the segments will light with 10 volts (possibly a bit less). Because it is common anode type you could use a TPIC6B595 shift register to replace the 74HC595. You need also 4 high side switches (each 1xPNP + 1xNPN transistor) for the 4 anodes. For this, you could also use a high side driver chip, say a MIC2981. Since the segment diode voltage drop is not shown, but should be in the range 2.1 to 4 volts, you really need to do a test to discover the optimum value of the segment current limiting resistors to give the 10mA talked about in the description, at the voltage you decide to drive the display at. The DP really requires a correspondingly higher value current limiting resistor.

answered Apr 8, 2023 at 12:14
3
  • Thank You for Your support! Does changing 74HC595 to TPIC6B595 is requiring changing code or circuit? And to be sure - on the output of D3-D6 I need to place MIC2981? Commented Apr 8, 2023 at 14:30
  • The wiring to the TPIC6B595 is different to that of the 74HC595. You'd best search for a tutorial Arduino TPIC6B595. Also, the data you send is inverted because sending a "1" switches on a segment by pulling it LOW. On the 74HC595, sending a "1" would have switched the segment off by pulling it HIGH. It would be easiest to invert the table, for example "8" is currently B01111111, //8. You'd change this to B10000000, //8 . The MIC2981 is an 8 channel source driver. You'd connect Arduino pins D3 to D6 to MIC2981 pins 1 to 4. The MIC2981 outputs 18 to 15 would go to the display common anodes. Commented Apr 8, 2023 at 17:43
  • Looking at your code, it is difficult to see how all four dots could be displayed simultaneously as in your picture. Only the dot on the second digit should be displayed. However, the pinout of the display on the schematic differs from that on the vendor document. The anode is connected to pins 3 & 8 on the schematic and 1 & 5 in the vendor document. This implies also that you have wired the display incorrectly. The code change for the TPIC6B595 should be even easier than I said earlier. Simply remove the inverting tildas '~' in the two shiftOut() statements. Commented Apr 9, 2023 at 1:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.