Flashing 7-segments

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

Moderators: Benj, Mods

FCCHow
Posts: 22
Joined: Fri Jul 28, 2006 10:40 am
Contact:

Flashing 7-segments

Postby FCCHow » Fri Sep 24, 2010 12:20 pm

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 380 times

FCCHow
Posts: 22
Joined: Fri Jul 28, 2006 10:40 am
Contact:

Re: Flashing 7-segments

Postby FCCHow » Sat Oct 02, 2010 7:16 am

So, can anyone help me?

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8236
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2358 times
Been thanked: 3347 times
Contact:

Re: Flashing 7-segments

Postby medelec35 » Sat Oct 02, 2010 11:05 am

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.3 KiB) Viewed 6192 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 435 times
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8236
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2358 times
Been thanked: 3347 times
Contact:

Re: Flashing 7-segments

Postby medelec35 » Sun Oct 03, 2010 9:22 pm

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 417 times
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

FCCHow
Posts: 22
Joined: Fri Jul 28, 2006 10:40 am
Contact:

Re: Flashing 7-segments

Postby FCCHow » Thu Oct 07, 2010 2:17 pm

Dear medelec35,

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


Yeah, I am saving up for FC v4 soon.

FCCHow
Posts: 22
Joined: Fri Jul 28, 2006 10:40 am
Contact:

Re: Flashing 7-segments

Postby FCCHow » Tue Oct 26, 2010 2:10 pm

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!

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8236
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2358 times
Been thanked: 3347 times
Contact:

Re: Flashing 7-segments

Postby medelec35 » Tue Oct 26, 2010 5:05 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.