Page 1 of 1

Flashing 7-segments

Posted: Fri Sep 24, 2010 12:20 pm
by FCCHow
I have build a circuit which connects to a 3 common anode 7-segment LED display. This is for a project for a friend which I want to test out the 7-segment LED function. The program functions as follows:

1) When powered up, it displays '999'
2) Pressing the switch at Port A6 will make the display countdown. At the same time, LED connected to Port A7 will light up for 150ms.
3) It will countdown until '000' where the display will flash on and off indefinitely.
4) Pressing the switch at A4 will increase the count back to '999' in a very fast fashion, the starting point being at the current countdown value.

Initially, I used the Tutorial file #20 but there was a problem where the first two digits became very dim and i could not create the flashing function when it reaches '000'. In the enable TMR0 function, I have created a "Refresh" macro where it contains the 'Showdigit'S macros for the three 7-segment displays, but when I inserted the 5ms delay inserted between each function, the LED at A7 lit up indefinitely and the program freezes. Leaving that out, I be left with the same problem of having the first 2 digits being very dim while the third digit would be too bright.

So, I re-created the same program but without the 'Enable TMR0' function which more or less fulfilled my requirements. Unfortunately, at the LED at A7 lights up for 150ms, the 3 7-segment digits will go off instead. I have checked the circuit itself but i could not fin anything wrong with it. During the 'simulation' with Flowcode, I noticed the digits were always flickering about which I paid no heed since simulating Tutorial #20 also gave the same problem, which I attributed it to my Pentium 933 PC. By the way, I am using Flowcode 3 unfortunately. But I plan to upgrade to version 4 soon.

So, can you hep me take a look at the problem? I have included the Flowcode file for you here:

Re: Flashing 7-segments

Posted: Sat Oct 02, 2010 7:16 am
by FCCHow
So, can anyone help me?

Re: Flashing 7-segments

Posted: Sat Oct 02, 2010 11:05 am
by medelec35
Hello FCCHow
This is just an idea I had. Timer0 Interrupt is accessed every 4ms. Count2 changes to either 0,1 or 2. A different branch is acessed which causes the LED Segment to light depending on count2 value.
Count3 is used for timing only Each time Count3 is = 0 then count = count +1
Timer0 Interrupt.jpg
Timer0 Interrupt.jpg (192.29 KiB) Viewed 14150 times
I have no way of testing it, since not got any segment LED's to try myself :cry:
LED segments are updated via timer0 interrupt.
Just change the MOD value of count3 to increase or decrease the speed count counts back up, since I did not see an update count time in your description.
So it may not even work, but give it a try and see how you get on.

Sorry if it does not work as intended.

Re: Flashing 7-segments

Posted: Sun Oct 03, 2010 9:22 pm
by medelec35
Sorry. so used to using Flowcode V4, the post above was edited and saved with V4.
Here is the Flowcode V3 version.
Hope it works for you.
Note: With both version, you need to press and then release switch to count down. If left as counting down only when switch is held, then will count too fast. This way is better for batch counting.
When resetting back to 999, then switch can be pressed and release just once.

Re: Flashing 7-segments

Posted: Thu Oct 07, 2010 2:17 pm
by FCCHow
Dear medelec35,

Sorry for the late reply. I will try this out this weekend.


Yeah, I am saving up for FC v4 soon.

Re: Flashing 7-segments

Posted: Tue Oct 26, 2010 2:10 pm
by FCCHow
Dear medelec35,

Wow! It works! Just rebuilt the circuit (as I only had one proto board for two projects) and tested it. Its working fine. Thanks for your help!

Re: Flashing 7-segments

Posted: Tue Oct 26, 2010 5:05 pm
by medelec35
Your welcome.
Thats Great!
Glad it's working, and thanks for letting us know.