Code for directly connected 7 segment display.

crazynight

Senior Member
feeling happy managed to program up a 7 segment display (CA), I know resistors should be there but thought I would live dangerously as will be moving the project over to CC's with 4026B's in the near future. Is there are driver available for Common Anode displays?

[video=youtube_share;Im6HSjfZ_F8]http://youtu.be/Im6HSjfZ_F8[/video]

Is there any way to tidy up this code, it works but seems long winded.

Code:
symbol seg_dp = c.0
symbol sega = c.4
symbol segb = b.2
symbol segc = b.1
symbol segd = c.1
symbol sege = b.5
symbol segf = b.4
symbol segg = b.3


;          a
;        f   b
;          g
;        e   c
;   dp     d    

Main:

gosub all_off

do
gosub num_0
pause 1000
gosub num_1
pause 1000
gosub num_2
pause 1000
gosub num_3
pause 1000
gosub num_4
pause 1000
gosub num_5
pause 1000
gosub num_6
pause 1000
gosub num_7
pause 1000
gosub num_8
pause 1000
gosub num_9
pause 1000
loop 

all_off:
high sega
high segb
high segc
high segd
high sege
high segf
high segg
return

all_on:
low sega
low segb
low segc
low segd
low sege
low segf
low segg
return

num_1:
high sega
low segb
low segc
high segd
high sege
high segf
high segg

return 
num_2:
low sega
low segb
high segc
low segd
low sege
high segf
low segg

return 
num_3:
low sega
low segb
low segc
low segd
high sege
high segf
low segg
return 

num_4:
high sega
low segb
low segc
high segd
high sege
low segf
low segg
return
 
num_5:
low sega
high segb
low segc
low segd
high sege
low segf
low segg
return 

num_6:
low sega
high segb
low segc
low segd
low sege
low segf
low segg
return 

num_7:
low sega
low segb
low segc
high segd
high sege
low segf
high segg
return 

num_8:
low sega
low segb
low segc
low segd
low sege
low segf
low segg
return 

num_9:
low sega
low segb
low segc
low segd
high sege
low segf
low segg
return 

num_0:
low sega
low segb
low segc
low segd
low sege
low segf
high segg
return
 
Last edited:

ZOR

Senior Member
This decoder/driver will drive common anode displays SN74LS47N

Follow this link and look for the Truth Table. It shows the combinations for getting relevant display digits.

http://www.doctronics.co.uk/4511.htm#truth_table

When you study what 4 inputs are for each digit the code should fall into place

Also look at Picaxe manual 3, output into 7 segment display.
 

westaust55

Moderator
Study up on the LOOKUP command.
http://www.picaxe.com/BASIC-Commands/Variables/lookup/
You can have one byte for each number/character to be displayed and using pins = command can set all outputs in one step.
If the outputs are not all on one port (B or C) then you will need to use a remapping routine.
Hippy has posted such remapping routine in the past if you care to try a forum search.

If you have no series resistors you may overload the PICAXE outputs causing failure of PICAXE internal circuits.
Please always include some resistor to suit voltage and drive method (continuous/PWM/etc)
 

crazynight

Senior Member
Yes. As said in the other thread. SAA1064 can do all 4 7 segs at once. lookup tables etc. are all in the threads mentioned.
Marz.
I was looking for other means of driving a display as ultimately I need 4" displays, which all seem to be +12v. the SAA1064 is i2c which is great but will be using i2c for the RTC. I have not had much success with multiple I2C devices as some of commands have to happen at the same time which is why I am favouring the 4026B

The SAA1064 and 4026B seem to be able to drive 12v displays so might even build my own from something like this
http://www.ebay.co.uk/itm/Green-1M-60-LED-Strip-Light-3528-SMD-Tape-Waterproof-Flexible-Strip-Lighting-12V-/161149634334?pt=UK_Home_Garden_Night_Lights_Fairy_Lights&hash=item258544471e
 

westaust55

Moderator
You should not have problems with multiple i2c devices in general provided you assign each a unique address.
I have occasions with RTC, RAM, multiple EEPROM, multiple IO expander chips, SAA1064 or compass modules, and more connected at the same time
 

marzan

Senior Member
As you know I wanted to build the same thing as you. Correct me if I'm wrong, but the only critical part is the clock stopping when the IR is interruptedUsing an RTC chip I had it collect the time when the the Ir is interrupted and it seemed to me that it didn't really matter if the display is a tad behind when running as long as it showed the correct times when it matters,so it was ok using more than one chip on the I2c bus. I treated the Picaxe chip as the ringmaster so to speak and let other chips do the hard work. I wanted to pursue my idea , but unfortunately other club stuff has taken priority at the moment.
Marz.
 

crazynight

Senior Member
As you know I wanted to build the same thing as you. Correct me if I'm wrong, but the only critical part is the clock stopping when the IR is interruptedUsing an RTC chip I had it collect the time when the the Ir is interrupted and it seemed to me that it didn't really matter if the display is a tad behind when running as long as it showed the correct times when it matters,so it was ok using more than one chip on the I2c bus. I treated the Picaxe chip as the ringmaster so to speak and let other chips do the hard work. I wanted to pursue my idea , but unfortunately other club stuff has taken priority at the moment.
Marz.
Yes you are correct I am still working on the same project as you Marzan, I abandoned i2c as my first build using the RTC and displays on i2c was not very reliable (think it was my soldering was the problem) so went down the route of reusing the old timers. v2 was a success (awaiting official testing and verification in just over a week) however the timers were small plus I am unable to source any more/replacements; sourcing large timers which go down to 100's of a second is going to cost hundreds of £ so I am now working on building standalone large timers capable of recording down to 100's of a second. Once they are built I should be able to interface them with v2. by my calculations the cost will be about £25 per timer and they will be about the size of an a4 sheet of paper.

I am learning very quickly with electronics there are always several ways to get to the same results ;)
 
Last edited:

crazynight

Senior Member
this is my design the picaxe will be running at 5v and not 12v with just a common 0v. each segment will be a strip of 3528 LEDs either 3 or 6.

 
Top