Flashing 7-segments

Forum for problems or queries regarding other Flowcode Components. Eg LEDs, Switches, LCD, Gfx LCD etc

Moderators: Benj, Mods

Post Reply
User avatar
FCCHow
Posts: 27
Joined: Fri Jul 28, 2006 10:40 am
Contact:

Flashing 7-segments

Post 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:
Attachments
SOB_Bolter v2.fcf
This is the recreated file minus the enable TMR0 function
(12 KiB) Downloaded 639 times
What can I take apart, today?

User avatar
FCCHow
Posts: 27
Joined: Fri Jul 28, 2006 10:40 am
Contact:

Re: Flashing 7-segments

Post by FCCHow »

So, can anyone help me?
What can I take apart, today?

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Flashing 7-segments

Post 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 13615 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.
Attachments
SOB_Bolter v2_Modified.fcf
(17 KiB) Downloaded 700 times
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Flashing 7-segments

Post 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.
Attachments
SOB_Bolter v2 Modified for Flowcode V3.fcf
(12.55 KiB) Downloaded 695 times
Martin

User avatar
FCCHow
Posts: 27
Joined: Fri Jul 28, 2006 10:40 am
Contact:

Re: Flashing 7-segments

Post 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.
What can I take apart, today?

User avatar
FCCHow
Posts: 27
Joined: Fri Jul 28, 2006 10:40 am
Contact:

Re: Flashing 7-segments

Post 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!
What can I take apart, today?

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Flashing 7-segments

Post by medelec35 »

Your welcome.
Thats Great!
Glad it's working, and thanks for letting us know.
Martin

Post Reply