How to light decimal dot (common anode LEDS+ 74HC595)--Solved

I am using the schematics and code from Gammon Software Solutions forum
"4-digit display made from minimal parts" at Gammon Forum : Electronics : Microprocessors : 4-digit display made from minimal parts
to drive my 4-segment common anode LED display. Since the original was developed for the
common cathode displays, I had to make changes in the following two parts:

Original:

// which bit to turn on to make a particular pin of the LED go high
const unsigned int DIG1  = 0x0200;  // Q1 of second IC
const unsigned int DIG2  = 0x1000;  // Q4 of second IC
const unsigned int DIG3  = 0x2000;  // Q5 of second IC
const unsigned int DIG4  = 0x0002;  // Q1 of first IC

Changed to:

const unsigned int DIG1  = ~0x0200;  // Q1 of second IC
const unsigned int DIG2  = ~0x1000;  // Q4 of second IC
const unsigned int DIG3  = ~0x2000;  // Q5 of second IC
const unsigned int DIG4  = ~0x0002;  // Q1 of first IC

and Original:

// which segments to light for each digit                    
const unsigned int digitPatterns [15] = {
 SEGA | SEGB | SEGC | SEGD | SEGE | SEGF,  // 0
 SEGB | SEGC,  // 1
 SEGA | SEGB | SEGD | SEGE | SEGG,  // 2
 SEGA | SEGB | SEGC | SEGD | SEGG,  // 3
 SEGB | SEGC | SEGF | SEGG,  // 4
 SEGA | SEGC | SEGD | SEGF | SEGG,  // 5
 SEGA | SEGC | SEGD | SEGE | SEGF | SEGG,  // 6
 SEGA | SEGB | SEGC,  // 7
 SEGA | SEGB | SEGC | SEGD | SEGE | SEGF | SEGG,  // 8
 SEGA | SEGB | SEGC | SEGD | SEGF | SEGG,  // 9
 0,  // space
 SEGG,  // hyphen
 SEGA | SEGB | SEGC| SEGE | SEGF | SEGG,  // A
 SEGA | SEGE | SEGF | SEGG,  // F
 SEGD | SEGE | SEGF,  // L
};

Changed to:

const unsigned int digitPatterns [15] = {
 SEGG | SEGDP,// 0
 SEGA | SEGD | SEGE | SEGF | SEGG | SEGDP, // 1
 SEGC | SEGF | SEGDP, // 2
 SEGE | SEGF | SEGDP ,  // 3
 SEGA | SEGD | SEGE | SEGDP,  // 4
 SEGB | SEGE | SEGDP,  // 5
 SEGB | SEGDP,  // 6
 SEGD | SEGE | SEGF | SEGG | SEGDP, // 7
 SEGDP,  // 8
 SEGE | SEGDP,  // 9
 SEGA | SEGB | SEGC | SEGD | SEGE | SEGF | SEGG | SEGDP,  // space
 SEGA | SEGB | SEGC | SEGD | SEGE | SEGF | SEGDP,   // hyphen
 SEGD | SEGDP,   // A
 SEGB | SEGC | SEGDP,   // F
 SEGA | SEGB | SEGC | SEGDP,   // L 
};

As suggested, I've also connected each segment to a 74HC595 through a 390 ohm resistor.

After these modifications, everything works as it should, except the decimal dot in front
of the tenths of seconds does not light. After many unsuccessful experiments, I have to
ask for help in making the decimal dot to work. Any pointers would be appreciated.

Can you get the dot to light up by just hooking it up (w/o the microcontroller) as you would a normal LED? i.e., Vcc ->resistor -> dot LED -> gnd

Thank you for the suggestion. That was one of the ideas that I've investigated. After a while I've realized that it wouldn't work--with common cathodes or anodes you don't have access to a single segment, but to each particular segment in every digit. What that means is that if you turn on the decimal dot segment on digit #2, you'll have decimal dot lighted on all other three digits when you turn them on. I think that I understood that the only way to do this (to turn the decimal dot on digit 2) is to combine the code for the digit you want to send to digit #2 and the code that light the decimal dot on digit #2. Combining should bi done by ORing the two pieces of code. Say, you want to show 1. on digit #, you would do something like:

ledOutput[2] = 1
ledOutput[2] = ledOutput[2] OR "code to turn on decimal dot"

However, for some reason, I am not able to make this to work.

Thanks again.

If you’re going to keep the 7-segment patterns in arrays then you need two versions of each - those with DP and those without.

Again, that's one of the solutions that I've tried to apply. Something like:

const unsigned int digitPatterns [15] = {
 SEGG | SEGDP,// 0
etc.
};

(for digits #1, 3, and 4), and

const unsigned int digitPatterns2 [15] = {
 SEGG,// 0
etc.
};

(for digit #2--to get DP together with the digit).

And then to have something like (in pseudo-code)

if digit #2 use digitPatterns2
else use digitPatterns

However, I don't know how to do the if...else modification in the code.

Thanks for the suggestion.

Parse the value's digits as chars
http://www.cplusplus.com/reference/cstring/strlen/
Find the decimal point and associate as right-hand or left-hand decimal (depending on which type you have) and use as "special case" or "digit with decimal", whatever we're doing here.

After a few hours of experiments I finally solved my decimal dot problem. The solution was very simple--in addition to the two changes introduced to the original code from Nick Gammon's forum (listed in my first post), I had to change just one more line.

The original code:

// add decimal place if required
  if (ledOutput [digit] & 0x10)
    output |= SEGDP;

my change:

// add decimal place if required
  if (ledOutput [digit] & 0x10)
    output &= 0xFFEF;

As a result, I have a decimal point in front of the tenths of seconds. So, if you want to use Nick Gammon's code (originally developed for the common cathode LEDs) with the common anode displays, you have to introduce these three changes.

Thanks to all who tried to help.