counter
Moderator: Benj
-
siliconchip
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 25 times
counter
hi all i have just downloaded the flowcode 6 demo version as im currently a version 5 user and to get use to the program i have done a simple counter using 7 seg leds as the display, in the past i have never used more than 1 7 seg display so i would be happy if some one could look into my program to see if i could have simplified it, also as the common cathodes are on port a do they multiplex with in the parameters of flowcode or in the real world would i need to sort this i have not tried this on hardware yet also i have set no parameters in the chip config box just tried simulating, any input would be greatly appreciated thanks in advance
- Attachments
-
- Flowcode1.fcfx count.fcfx
- (6.87 KiB) Downloaded 290 times
-
siliconchip
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 25 times
Re: counter
hi hypamat yes its a simple program it was done whilst finding my way around version 6 it is working in simulation but my concerns are with the quad seven segment common cathode terminals and multiplexing, as mentioned earlier plus if there is a shorter way for my program to work it would be nice to know as part of the learning process writing code 
Re: counter
personally i haven't really used any seven segment displays, purely because of the ridiculous number of wires, and they're not cheap! personally i use the 16x2 LCD displays, as they're only £2.50 each, and can easily display any character.... plus it makes your project look more techy
lol I'm afraid i may not be the correct person to help you with this 
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: counter
Hi siliconchip,
I can look at your flowchart tomorrow as not got time tonight.
Attached is an untested version, so no guarantees it will even work on hardware.
I can test on hardware tomorrow, and post results
If not already done so the bst way is to place 7seg LED's within an interrupt routine.
Each 7Seg is turned on one at a time very fast, so persistence of vision will make it look like they are all on.
Reason as you will see below is because all the anodes of each 7seg displays are connected in parallel.
I have explained briefly how multiple common cathode 7seg displays work
The way that you can set up hardware can bee seen on Eblock EB008 data sheet
Although circuit is for a common anode, you should be able to adapt for a common cathode displays.
Martin
I can look at your flowchart tomorrow as not got time tonight.
Attached is an untested version, so no guarantees it will even work on hardware.
I can test on hardware tomorrow, and post results
If not already done so the bst way is to place 7seg LED's within an interrupt routine.
Each 7Seg is turned on one at a time very fast, so persistence of vision will make it look like they are all on.
Reason as you will see below is because all the anodes of each 7seg displays are connected in parallel.
I have explained briefly how multiple common cathode 7seg displays work
The way that you can set up hardware can bee seen on Eblock EB008 data sheet
Although circuit is for a common anode, you should be able to adapt for a common cathode displays.
Martin
- Attachments
-
- Basic counter.fcfx
- (7.69 KiB) Downloaded 269 times
Martin
-
siliconchip
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 25 times
Re: counter
hi martin does this mean then that the way I have my common cathodes it will not work on hard ware??
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: counter
What you can do is connect common cathode to a collector of an NPN transistor. so if two 7segs then you will need two transistors.
the emitter of the transistor will go to GND. A base bias resistor e.g 4k7 resistor connects between the pin that is set up for common for that 7seg display and the base of the transistor that's connected to the cathode of the 7seg.
All the anodes of one segment (e.g.segment a) of 7seg displays are connected together and go to 1 pin of the microcontroller e.g portA0 (make sure you have set the ports up in flowcode to match connections of your hardware) .
The anodes e.g segment b of all 7seg displays are connected together and go to 1 pin of the microcontroller e.g portA1 etc.
If you're still stuck, post the datasheet for 7seg display and I will draw a circuit diagram for you.
Martin
the emitter of the transistor will go to GND. A base bias resistor e.g 4k7 resistor connects between the pin that is set up for common for that 7seg display and the base of the transistor that's connected to the cathode of the 7seg.
All the anodes of one segment (e.g.segment a) of 7seg displays are connected together and go to 1 pin of the microcontroller e.g portA0 (make sure you have set the ports up in flowcode to match connections of your hardware) .
The anodes e.g segment b of all 7seg displays are connected together and go to 1 pin of the microcontroller e.g portA1 etc.
If you're still stuck, post the datasheet for 7seg display and I will draw a circuit diagram for you.
Martin
Martin
-
siliconchip
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 25 times
Re: counter
hi martin ive seen the arrangement using transistors for the cathodes the thing that is throwing me is that in flowcode my program simulates as I intended with the common cathodes connected directly to port a is this because they are permanently low so always providing the negative for the display
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: counter
Hi siliconchip,
Simulation and hardware are two different things.
In the simulation you will need to connect the cathodes to the ports as you have no choice in that.
With hardware you use transistors because all the anodes of a segment are on at the same time because they are in parallel.
E.g suppose you have just 2 x 7segment displays and you send the number 31.
Because segment a of both displays goes to the same pin of microcontroller then if cathode of both displays are grounded, then both segment a's will be on.
However segment a in the 1st display should only be on. this will cause the wrong value to be displayed.
How we get around quad seg display being multiplexed is by very quickly enabling only one 7seg display at a time very quickly (milliseconds) while the other display/'s are disabled.
this happens so quickly it looks like both displays are on due to persistence of vision.
That is why you cant permanently ground the cathodes.
If you want to permanently ground the cathodes then only way is to use single 7seg displays, and connect all the anodes to individual pins.
so for two displays, if not using dp then MCU will require 2 x 7 = 14 pins
With multiplexing & using transistor MCU will required 1x 7 + 1 x 2 = 9 pins
With quad 7seg then:
If not using dp then MCU will require 4 x 7 = 28 pins
With multiplexing & using transistor MCU will required 1x 7 + 1 x 4 = 11 pins
A big difference if just using transistors for each display!
Simulation and hardware are two different things.
In the simulation you will need to connect the cathodes to the ports as you have no choice in that.
With hardware you use transistors because all the anodes of a segment are on at the same time because they are in parallel.
E.g suppose you have just 2 x 7segment displays and you send the number 31.
Because segment a of both displays goes to the same pin of microcontroller then if cathode of both displays are grounded, then both segment a's will be on.
However segment a in the 1st display should only be on. this will cause the wrong value to be displayed.
How we get around quad seg display being multiplexed is by very quickly enabling only one 7seg display at a time very quickly (milliseconds) while the other display/'s are disabled.
this happens so quickly it looks like both displays are on due to persistence of vision.
That is why you cant permanently ground the cathodes.
If you want to permanently ground the cathodes then only way is to use single 7seg displays, and connect all the anodes to individual pins.
so for two displays, if not using dp then MCU will require 2 x 7 = 14 pins
With multiplexing & using transistor MCU will required 1x 7 + 1 x 2 = 9 pins
With quad 7seg then:
If not using dp then MCU will require 4 x 7 = 28 pins
With multiplexing & using transistor MCU will required 1x 7 + 1 x 4 = 11 pins
A big difference if just using transistors for each display!
Martin
-
siliconchip
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 25 times
Re: counter
hi martin that makes perfect sense its just the fact the simulation was running without the transistor but as you said there is a difference between simulation and hardware many thanks
bob
bob
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: counter
No worries.
Thinking about it, (without testing on hardware)
If using common cathode, the the output that connects to the cathode will have to go low to light segment.
Therefore it's not an NPN that is required, it's a PNP.
Thinking about it, (without testing on hardware)
If using common cathode, the the output that connects to the cathode will have to go low to light segment.
Therefore it's not an NPN that is required, it's a PNP.
Martin