Seven Segment Display - Basic Help

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

Seven Segment Display - Basic Help

Post by Jay Dee »

Hi guys,
Re:Having trouble displaying multiple digit values using either of the Seven Segment Display components in V4.

Using the component macros for the seven segment displays I can correctly get a number displayed on any individual section but I am having trouble getting a multi digit value displayed over several sections.

After sending a digit to the display, the common annode pin for that section remains high, as such when I try to send another digit to the next section both are updated by the new digit.

If I disable the common anode pin for the first section the value is erased (as would be expected).

I've checked my connections and looked for flowcode examples that use multiple digit values with the seven segment displays but I have not made much progress, I'd really appreciate any 'idoits guide' answers :oops:
Cheers, John.

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: Seven Segment Display - Basic Help

Post by medelec35 »

Hello Jay. The way I am assuming Flowcode drives the LED Displays are:
Common anode only goes high for a shot time (about 5ms long enough for LEDs to light e.g Anode 3, then goes low but looks like still on due to persistence of vision, then anode goes high for the next display e.g. anode 2 etc.) While the anode is high, the cathodes go low for the individual segments that have to be on, and cathodes remain high for segments that have to be off.
If you are measuring anodes with meter, then anodes of all LEDs will be on then off so fast, the meter will display an average voltage, so anodes will appear to be on when they are not. Have you tried to add a delay e.g 2 seconds for testing purposes so each anode will have time to go off whilst being measured?
Have a look at :
http://www.matrixmultimedia.com/mmforum ... =23&t=7737
You can remove the switches and adapt it to run with your hardware.
Note: it is untested but if you step thought it, you can see how each anode takes it in turn to go high. Only three LED components are used, but the fourth is easily added.
If you would like to post your flowchart, It can be looked at for you.
Another thing, if you have the room on your chip, then you could use ICD and single step to check each anode takes it in turn to go high, then low.
Martin

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

Re: Seven Segment Display - Basic Help

Post by Jay Dee »

Thanks Medelec,
I should mention that I'm still working on my project only in software and running the program using the flowcode simulate function.

I downloaded the modified FC V4 example you posted ( SOB_Bolter v2_Modified.fcf ) and ran that using the simulate function. When I did this, the correct digits are displayed but the simulation flickers between each segment. The simulation is running at 'fast as possible' speed. I wonder if this flicker just a function of the simulation?
Im running FC4 V4.3.7.63

A I just threw together a very simple project
7Seg_Test.fcf
(8 KiB) Downloaded 371 times
to increment units and tens values with the press of a button; and then pass these values to two seven segment display components.
I must be going about this the wrong way, since when the program first runs through the common anode pins AN0 and AN1 get set Hi, subsequently any further values output on port B are shown by both seven segment displays.
There must be an obvious way to selectivly send a digit to each display. Is the solution (as you mentioned before) to rely on persistance of vision. send a digit to one display, turn that anode off and then write to the next display.
The displays would be only momentarily flicking the values up but persistance of vision should cover that problem....
J.

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: Seven Segment Display - Basic Help

Post by medelec35 »

Jay Dee wrote: The simulation is running at 'fast as possible' speed. I wonder if this flicker just a function of the simulation?
Im running FC4 V4.3.7.63
The simulation is running at a much lower speed than the real hardware. So you will see flickering on the simulation.
On real hardware, the displays are changed from one to the next every 5ms = 200Hz
Perhaps someone could correct me if im wrong: With four 7seg LEDs if my theory is correct, each 7seg LED is on/off for 5ms at 50 times a second (200/4 = 50)

Edit: Just had a look at your Flowchart. Your time delay is too high. 200ms = 5Hz. for flicker free you need 50Hz +
Try 5ms delay.
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: Seven Segment Display - Basic Help

Post by medelec35 »

I have taken a closer look at your Flowcode.
Try this attached one.

Since the cathodes are connected together, when you use a show digit macro, you should have a small delay, then have either a clear digit macro or portA0=0 or PortA1=0 depending on which 7seg LEDs you want to turn off. Otherwise you will have both displays on, and wrong digits will be displayed.

I have also noticed Flowcode does not simulate both 7seg LEDs correctly. Led 7seg0 enables both 7seg0 and 7seg1, when should only enable 7seg0….Odd
Attachments
7Seg_Test Modified.fcf
(8 KiB) Downloaded 394 times
Martin

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

Re: Seven Segment Display - Basic Help

Post by Jay Dee »

Hi,
Yes that's defiantly an improvement. By playing with your version, I agree that....

The 'Clear Digit' macro sets all of Port B's pins, thus clearing the digit on led7seg(1) - As expected.
But this macro does not toggle the common anode pin A1.
As such led7seg(1) remains active and receives anything sent out on the shared Port B.
By using a output component pin A1 may be toggled and this de-activates led7seg(1)
Leaving the program to work with Led7seg(0), which is dealt with in the same way.
7Seg_Test Modified V2.fcf
(8.5 KiB) Downloaded 380 times
This all seem to work but seems a bit clunky and whilst readable the flicker under simulation is a pain.
For me, its a solution that works and thanks for your help in playing about but I suppose my remaining question is;
Is this the intended and most efficient way in FC to write multiple digit values to the led7seg display components?
Cheers, J.

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: Seven Segment Display - Basic Help

Post by medelec35 »

Jay Dee wrote:Is this the intended and most efficient way in FC to write multiple digit values to the led7seg display components?
Cheers, J.
My answer would be no. I believe the best way would be use the method from my post here:
http://www.matrixmultimedia.com/mmforum ... =23&t=7737
It is better to use the interrupt with LED7seg4 component macro within the timer interrupt for couple of reasons.
1) If you extend your flowchart to use keypad routines, wait for switch presses, delays etc. Then without using timer interrupt the refresh rate will be dramatically affected, and the persistence of vision effect will be lost. LED dispalys will end up flashing like emergency services lights!
However if LED7seg4 are placed in the timer interrupt, then no matter what delays etc you have, the refresh rate will always stay the same i.e. at timer interrupt frequency.
2) if you use LED7seg4 then when show digit is selected all the other digits are automatically cleared, so you don't need to clear the bit that's connected to the digit that's displayed, or don't need use ClearDigit function, as there is not one!
But if you use LED7seg4 instead of single LED7seg, on your Flowchart you will need to connect all unused anodes to either a spare port, or the same port as one of the used LED7seg4 connections... See below
Unused connections.jpg
Unused connections.jpg (81.56 KiB) Viewed 6704 times
Ignore the same pin warning message.
Because the simulation of timer interrupt component can be slow, whilst developing your flowchart ,replace a timer interrupt component macro with a call macro, instead of relying on flowcode to simulate timer interrupt. When you have finished and want to test on real hardware, replace call timer macro with the timer interrupt component macro.
Important: When using a timer interrupt, do no place any delays, or component macros that have delays longer then interrupt time. If you do then corruption will occur.
Jay Dee wrote:But this macro does not toggle the common anode pin A1.
Whilst that is true for simulation, It should toggle A1 on real hardware. So its just a simulation issue which I have reported.
Martin

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

Re: Seven Segment Display - Basic Help

Post by Jay Dee »

Medelec,
Thanks for your help, I think I've got pretty good control over my 7Seg displays now. I had a closer look over your examples and yeah, the use of the interrupts looks a much better solution. I've now incorporated these ideas into my mini project...so all looking good.
Cheers, J.

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: Seven Segment Display - Basic Help

Post by medelec35 »

You’re welcome. So long as your project is working the way it’s intended that’s great!

Thanks for letting us know
Martin

Post Reply