Am I beyond help, countdown display

VIAD2

New Member
Hello, as part of a project I require a countdown timer with led display.
It seems that the only or best way to achieve this is to use a programmable chip.
Looking at other posts on here I don't think I have the time or brains to carry out the programming

What I require is 'relatively simple' I guess but to me the programming looks daunting.

This is what I require A countdown timer 120 seconds to 0 seconds
The countdown to be displayed on three 7 segment led displays
After the countdown has reached 0 I would like to be able to reset it to 120 by a single simple operation .
( I can buy ready made count down/up counters quite cheaply , it's the reseting to 120 seconds that's the problem)

I will supply the 1 second pulses to operate the countdown.

If I bought a Picaxe kit do you think I could program it easily ,by numbers so to speak or would it entail weeks of practice ?

Can I find a circuit anywhere of the project I described ?

Can anyone program say half a dozen of the chips for me at a reasonable cost and supply a circuit to show connections etc for driving the 3 x 7 segment leds ( I'm in the UK )

I can solder, design simple circuits but my amateur training dates back to the eighties.

Any help much appreciated.
 

eclectic

Moderator
Welcome to the Forum.

The project looks straightforward for a Picaxe.
Two initial questions please.

1. What size do you want the digits?

2. Where will the display be used?
(I'm thinking about brightness levels)

You'll get lots of help within a short time here. :)

e
 
Last edited:

VIAD2

New Member
That was indeed quick eclectic, the displays are just your average 20mm x 10mm type. It is housed indoors brightness shouldn't be a problem
It is part of an automated sports starting sequence ( a siren, a flashing light , then three spot lights switching off at three minute intervals.
I have programmed a Zelio programmable relay to carry out the sequence, but wanted the countdown display so that the time keepers are aware and can start their stop watches at the end of the three minutes.
Trying to get this 120 to 0 countdown 'easily resettable' to 120 is where I came unstuck.
The picaxe could no doubt be programmed to carry out the whole sequence, but as I already have the Zelio all i want now is the count down display
The Zelio will provide the 1 second pulses
Cheers
 

VIAD2

New Member
Thanks russbow , I'm sure it helps many but it's double dutch to me ,,, nibble ? it's another language .
I don't wish to appear lazy and I will put in as much effort as I'm able . I suppose what I would like is a complete circuit digram showing component types and values along with advice about programming the chip, is it possible for me to do it easily ?
I dunno ?
 

VIAD2

New Member
Thanks marks, that's the kind of thing i'm after, but can that be set to count down from 120 to 0 and be reset back to 120 at the push of a button
 

RexLan

Senior Member
This does exactly what you want and can be bought for under $8. Fully adjustable and can be reset to start over.

868.jpg
 

g6ejd

Senior Member
If you use the CMOS 4516/20 counters they can be pre-set in what's called BCD, so three counters linked together can be preset with 1 2 0 and they can count up or down, so obviously the latter. When they have finsihed counting down, they will pre-load 120 again and so-on.

For a PICAXE version, for the moment connected to the standard LCD display, the BASIC programme would look like this:

Symbol count_down = b0
Start:
Do loop until pin0 = 0
For count_down = 120 to 0
pause 1000
serout 6, N2400, (#count_down)
If pin0 = 0 then GOTO Start
Next count_down
Goto start

This assume a push-switch (press to make) is connected to input 0, so that you can start and reset the counter. Pin0 would also need a resistor to the supply rail to keep it pulled high.

The next step would then be to connect the PICAXE to a 7-segment display.
 

VIAD2

New Member
Thanks Rexlan, yes I know the device or at least the same thing under a different brand. The problem is that the timer has to be left to complete its count down to reset, it can not be reset during the countdown, also the unit I am building is using mains power not battery power. This timer could be run from a transformer but every time the power was switched off the timer would loose it's setting.
 

eclectic

Moderator
Goodness, they look expensive!

I'm sure the whole Picaxe kit (including cable)
could be done cheaper.

What kit do you already own?

e
 

VIAD2

New Member
g6ejd suggested using cmos 4516/20 chips, here is a circuit diagram using CD4510 to count down from 9 to 0 , could this be modified to count from 120 to 0 ( I wouldn't require the 555 )cnt_down resize.gif
 

VIAD2

New Member
Several now eclectic, I was so pleased with the first one, I didn't have to pay the full list price. They can be bought with or without display, I have both types but even if the display could be utilised it is really too small for the job in hand . The model I happen to be using is an SR2 D201FU
 

jtcurneal

Senior Member
The circuit in #14 could be modified to count from 120 to 0, I have done 4 digit preset-able count down timers using similar chips years ago.
It would be much more complicated than using a Picaxe to do the counting down.

If you need larger LED displays, The CD4511 driver, LED displays used in that circuit work great, but use a lot of current.

Joel
 

jtcurneal

Senior Member
I believe that the CD4026s mentioned in #16 are up counter/display drivers and could not be used for counting down.

Joel
 

VIAD2

New Member
Gentlemen, thanks for the advice but I am still at a loss, I guess the days of Practical Electronics and similar magazines are finished, one could browse back issues and find a circuit for just about anything.
As to programming a chip for my purpose, could I do it over a day or to given the correct program ?
Alternatively I do not mind using 4156/20 chips , just to get the job done
If what I require is relatively simple, then perhaps someone out there could post a circuit diagram, as I said I don't know too much about modern electronics but I can follow a circuit diagram,,, I can't follow your programming codes
ANYONE please post a circuit diagram for what I require , now I'm exhausted and must take drink, to cheer myself up
 

mrburnette

Senior Member
@VIAD2,

g6ejd has already provided the proto-code for the countdown. The issue you are facing is interfacing to the 3 7-segment displays... something you specified in post #1. Were you using the AXE133Y OLED display, we would be 99% finished.

What makes this project interesting is the three LEDs... and this is where you/we need to concentrate. Once this is a given, everything else falls into place... for example, does the external LEDs increment/decrement/reset on its own logic? I remember many kits available once that had this capability in the logic. OR, do you wish to have a minimal electronic design where the PICAXE manages segment/digit illumination and selection?

It is frustrating, I empathize. There are just so many ways that this can be accomplished. If you were using the pre-manufactured serial displays, the code could be written in minutes. With a commercial LED up/down counter, only reset and preset changes would need to be incorporated... for example, issue a reset to 0 and rapidly pulse the count "up" 120 times. When the button is pushed on the PICAXE pin, the pulse per second would be directed to the count-down pin.

Something in this line of product may work http://parts.digikey.ca/1/1/876897-ic-counter-adj-led-4digit-28-dip-icm7217ipi.html

Edit: here is how it is done with another popular uC
http://www.electronicsblog.net/arduino-4-digits-7-segments-led-countdown-timer-with-buzzer/
Please note the mess of wires to handle the segments and strobes.

- Ray
 

inglewoodpete

Senior Member
I believe that the CD4026s mentioned in #16 are up counter/display drivers and could not be used for counting down.

Joel
They only count upwards but the PICAXE could reset and reload 3 of these, cascaded, in a few milliseconds. And it could do that once every second with a decending count value. Use a PICAXE 08M2 as the controller.
 

westaust55

Moderator
Maybe a little primative but if you wish to drive three 7-segment displays with external components, one way is some readily available and easy to use cascaded 74HC595 shift registers.
Have alook at the project I posted here in the past (Oct 2009): http://www.picaxeforum.co.uk/showthread.php?13687-3-digit-display-using-74HC595

The counting is all done in the PICAXE and just clock out 3 bytes of data to represent the three digits from 120 down to 000 (Bang!) :)
 

VIAD2

New Member
Thanks everyone for your time, I do appreciate it however I am beginning to think I am beyond help, things have progressed so much since I last dabbled. You experts casually reel of numerous explanatory terms, no doubt perfectly understandable amongst yourselfs but leave me at a loss ... erm what's an uC

If I am becoming tiresome please let me know,

mrburnette you suggest using an AXE133Y OLED display would simplify matters, that's fine I'm open to any suggestions, it seemed to me at the time that simple led technology would keep things simple , but maybe not after all
The thing is would this approach still require programming, which I think would be a stumbling block for me ?

OK here is what I require
A display counting down from 120 to 0
The countdown will be operated by 1 second pulses supplied by an existing device
The timer must be able to be reset by a single switch back to 120 at any time during the countdown
The timer must remember the 120 setting when power is removed

What is the simplest way to do the above
If it requires some programming can I easily do that, I haven't much of an idea what the programming entails, what do I do with all that code you all post
Alan
 

nick12ab

Senior Member
PS here is a Velleman kit it has all I need for only £20 unfortunately I don't know if it can be set with a fixed countdown number, and if it could will it retain it with power off , just a thought
http://www.velleman.co.uk/manuals/k8035.pdf
This timer uses a PIC16C57 which is a OTP EPROM device (with only 2K EPROM and 72 bytes of RAM). This PIC has no internal rewriteable EEPROM so it would lose any preset value when power is removed.

The feature list on page states that there is a "programmable pre-set value with equal output" which probably means that you can set the value that the timer starts at and that it will output a pulse when the timer reaches 0. The PICAXE could be connected to the header on the kit to set the time at startup.
 

VIAD2

New Member
Thanks nick12ab, if a PICAXE was connected to header would the unit then behave as I require, and would it retain it's memory when power is removed ?
Is it a viable method or better just to build the whole thing from new using a PICAXE ?
Alan
 

Dippy

Moderator
My first question to you is; do you want to learn the principles, understand it, design and make , or you just want to get on with it i.e. a served-up solution ?

If you want to understand it then a good clue is in the Velleman Data Sheet where it shows how the LEDs are connected....

Put to one side all the components thrust at you.

First, try and plan the design principle.
Basically, you are designing a counter.
You want to :
1. Pre-load a value (e.g. 120).
2. Display it.
3. Decrement the value each second.
4. Sense a 'reset counter' switch.
5. Do something when it reaches Zero.
6. Go back to (2).

Therefore, you have 4 basic sections of code.
Set a value is as simple as b0=120
Sensing a switch can be an 'IF' or an Interrupt.
Decrementing a value is dec b0 (note; test the value before the decrement so it never goes 'below' Zero).
i.e. if b0=0 then do something else decrement.
Your most difficult part is to display the values.
This is a matter of setting the LED segments to represent b0.
Then superimpose it onto a 3digit-7segment display.
The usual method is to set a port-wide value, which changes.
A port is simply an output where a I/O pin represents a 'bit'.
Look at the PICAXE pinouts.
So, a PORTB output is B.0 to B.7.
Setting PortB = whatever sets the pins to the binary value.

You will to modify that for each numeric value and for each LEDcluster as you strobe.
See those little transistors on the Velleman kit schematic?
They control which LED cluster will be on and the Port.B value determines which segments are on or off.
Think of it like a matrix or a Rows & Columns spreadsheet.
It's how many keypads work too -except reading the port and not writing.


If all that is too much., then build your Velleman kit, reset, give it 120 pulses to get it to display '120' and do a countdown each second, compare the value to zero etc.

PS. My reading is that you pre-set the value at which is does something, not a pre-loaded start value.
You will have to pulse it up to 120 then decrement and then when it reaches a pre-set value (e.g. 0) it does something i.e, sets 'Equal Out' pin 5.
 

nick12ab

Senior Member
Thanks nick12ab, if a PICAXE was connected to header would the unit then behave as I require, and would it retain it's memory when power is removed ?
Is it a viable method or better just to build the whole thing from new using a PICAXE ?
Alan
You'd need to program the PICAXE to set the timer each time. However, I do think that for a unit that would only be used for a single purpose, £20 is quite expensive since an entire PICAXE implementation could be done for less than that even with the MAX7219 multiplexing the displays for you. As your specification says that you only need the counter to count down from 120, multiplexing can be done directly by a PICAXE in the same way as the Velleman kit.


OK here is what I require
A display counting down from 120 to 0
The countdown will be operated by 1 second pulses supplied by an existing device
The timer must be able to be reset by a single switch back to 120 at any time during the countdown
The timer must remember the 120 setting when power is removed
This is a section of (unoptimized) code I've cut from an old project thaty should do what you want using a 40X2 but it will need some small adaptation for your project as this was designed for 4 displays.
Code:
#picaxe 40X2
#no_end
#terminal off
symbol sl1 = b0
symbol speed = b8
symbol mode = b9
symbol time1 = b10
symbol time2 = b11
symbol time3 = b12
symbol time4 = b13
symbol vardisplay = b14
symbol buttonvar = b18
symbol tempvar = b19
symbol buttonvar2 = b20
symbol runvar = b21
symbol nodp = b22
symbol displayselect = b23
symbol i2cin = b24
symbol cvarA = b25
symbol blanking = b26
symbol loopcounter = b31
symbol adcvar = w16
symbol slow = 0
eeprom 10,(0,1,2,0)
table 0,($3F,$06,$5B,$4F,$66,$6D,$7C,$07,$7F,$67,$00,$40,$38,$78,$31,$39,$5E,$73,$6F,$79,$77,$37)
    setfreq em64
    settimer t1s_8
    disconnect
    disablebod
    speed = 4
    let dirsb = %11111111
    let dirsd = %00001111
    let pinsd = %00001111
    let adcsetup2 = %0100
    let adcsetup  = %0010
    let buttonvar = 1
    let nodp = 1
    let timer = 0
    adcconfig %1000



mode3:let nodp = 0
    let pinsB = 0
    let pinsD = 255
    let timer = 0
    read 10,time1
    read 11,time2
    read 12,time3
    read 13,time4
    let nodp = 1
    write 9,3
mode3display:
    if time1 = 10 then
        let time2 = time2 + 1
        let time1 = 0
    end if
    if time1 = 255 then
        let time2 = time2 - 1
        let time1 = 9
    end if
    if time2 = 6 then
        let time3 = time3 + 1
        let time2 = 0
    end if
    if time2 = 255 then
        let time3 = time3 - 1
        let time2 = 5
    end if
    if time3 = 10 then
        let time4 = time4 + 1
        let time3 = 0
    end if
    if time3 = 255 then
        let time4 = time4 - 1
        let time3 = 9
    endif
    if time4 = 10 then
        let time4 = 0
    end if
    if time4 = 255 then
        let time4 = 9
    end if
    if time4 = 0 then : let blanking = 1 : end if
    if sl1 = 0 then : let varDisplay = time4 : else : let varDisplay = 10 : end if
    gosub prc_setoutputs
    low D.0
    pause speed
    if sl1 = 0 then : let varDisplay = time3 : else : let varDisplay = 10 : end if
    let nodp = 0
    blanking = 0
    high D.0
    gosub prc_setoutputs
    low D.1
    pause speed
    if sl1 = 0 then : let varDisplay = time2 : else : let varDisplay = 10 : end if
    let nodp = 1
    high D.1
    gosub prc_setoutputs
    low D.2
    pause speed
    if sl1 = 0 then : let varDisplay = time1 : else : let varDisplay = 10 : end if
    high D.2
    gosub prc_setoutputs
    low D.3
    pause speed
    high D.3
    if runvar = 1 then
        if timer = 10 then
            let timer = 0
            let time1 = time1 - 1
        end if
        if time1 = 0 and time2 = 0 and time3 = 0 and time4 = 0 then
            let runvar = 0
            let pinsb = %00111111
            for tempvar = 0 to 25
                let pinsD = %00001111
                pause 400
                let pinsD = %00000001
                pause 400
                toggle A.0
                sl1 = 0
            next tempvar
        end if
    end if
    if pinD.7 = 0 and pinD.6 = 0 and pinD.4 = 0 and pinD.5 = 0 then
        let buttonvar = 0
        let buttonvar2 = 0
        if runvar = 0 then
            let timer = 0
        end if
        goto mode3display
    end if
    if pinD.5 = 1 then
        if buttonvar = 0 and runvar = 0 then
            reset
        end if
    end if
    if pinD.7 = 1 then
        if runvar = 0 then
            if buttonvar = 0 or timer > 3 then
                let buttonvar = 1
                if timer > 15 then
                    let time2 = time2 + 1
                    goto thingy0006
                end if
                let time1 = time1 + 1
            end if
        elseif buttonvar = 0 then
            if sl1 = 1 then : sl1 = 0 : else : sl1 = 1 : end if
            buttonvar = 1
        end if
    end if
thingy0006:
    if pinD.6 = 1 then
        if runvar = 0 then
            if buttonvar = 0 or timer > 3 then
                let buttonvar = 1
                if timer > 15 then
                    let time2 = time2 - 1
                    goto thingy0005
                end if
                let time1 = time1 - 1
            end if
        else
            if buttonvar = 0 then
                let buttonvar = 1
                if speed <> slow then
                    speed = slow
                else
                    read 8,speed
                end if
            end if
        end if
    end if
thingy0005:
    if pinD.4 = 1 then
        if buttonvar = 0 then
            sl1 = 0
            let buttonvar = 1
            if runvar = 1 then
                runvar = 0
            else
                runvar = 1
                write 10,time1
                write 11,time2
                write 12,time3
                write 13,time4
            end if
        end if
    end if
    goto mode3display
    
prc_setoutputs:
    if blanking = 1 then
        pinsB = 0
        goto x
    end if
    readtable varDisplay,pinsB
x:    if nodp = 0 then
        pinsb = outpinsb + 128
    end if
    return
It used common anode displays with anodes driven with PNP transistors on pinsD.0-D.3 and cathodes driven by NPN transistors on portB. It had switches on pins D.4-D.7. Assemble it and see how you get on.
 

VIAD2

New Member
Thanks Dippy, yes I was hoping for a served up reply so I could get on with it, but the more I read the more I think I'm going to have to bite the bullet and get to grips with this PICAXE stuff . Would I be wise to buy a kit , the EXPERIMENTERS perhaps ?

Incidentally I see several posters have joining dates of 1970, what was PICAXE back then ?
 

VIAD2

New Member
Thanks again nick12ab , as just posted it looks like I'm going to have to buy a kit and get to grips with all this code stuffso if you don't hear from me for a while you will know what I'm up to , but beware I'm likely to return with a vengeance :)
 

Dippy

Moderator
Thanks Dippy, yes I was hoping for a served up reply so I could get on with it, but the more I read the more I think I'm going to have to bite the bullet and get to grips with this PICAXE stuff . Would I be wise to buy a kit , the EXPERIMENTERS perhaps ?

Incidentally I see several posters have joining dates of 1970, what was PICAXE back then ?

I wish you'd said that in the first place - it would saved me 20 minutes typing ;)


Yes, the PICAXE used valves in those days... :)


If I were you I'd search around for counters... there must be loads of them.
There are some (albeit LCD) ones that can count so fast that preloading it with a value of 120 can be done in a twinkle.
I suspect a wide range of prices though.

As with most uC (microControllers) the results only come out when you put the effort in. And that needs knowledge and time. If either is lacking then you'll have to part with the cash to buy a ready-made thingy - unless kind, generous or keen-to-impress souls on the Forum do it for you.
 

VIAD2

New Member
Dippy your previous post was interesting, the 20 minutes certainly not wasted. Sorry to be so dumb but when you say to search around for counters, what exactly do you mean, the display unit similar to AXE 133Y or a complete countdown unit, if the latter then i'm b... if I can find any that will do what I require

Did this forum operate via a magazine or such in the 70s ?
 

VIAD2

New Member
I wish you'd said that in the first place - it would saved me 20 minutes typing ;)


Yes, the PICAXE used valves in those days... :)


If I were you I'd search around for counters... there must be loads of them.
There are some (albeit LCD) ones that can count so fast that preloading it with a value of 120 can be done in a twinkle.
I suspect a wide range of prices though.

As with most uC (microControllers) the results only come out when you put the effort in. And that needs knowledge and time. If either is lacking then you'll have to part with the cash to buy a ready-made thingy - unless kind, generous or keen-to-impress souls on the Forum do it for you.
Yes I wouldn't mind paying a reasonable amount ( to someone who would do it out of interest/fun ) to maybe design fully what I want and perhaps program a few chips so I could build it at home. That would get me going with the project in hand and I could investigate the whole business at leisure.
 

nick12ab

Senior Member
Yes I wouldn't mind paying a reasonable amount ( to someone who would do it out of interest/fun ) to maybe design fully what I want and perhaps program a few chips so I could build it at home.
You wouldn't learn anything by doing it that way. You need to attempt to write your own code and create your own schematic for it too. A PICAXE is capable of controlling an output device, doing the timing and possibly something else too. Multiplexing can be done with my code example above using 7-segment LED displays and you can also get small large-character LCDs (such as this) which does not require multiplexing, just copy-and-pasting of existing routines (see stuff by me, Hippy and Marks).
 

mrburnette

Senior Member
mrburnette you suggest using an AXE133Y OLED display would simplify matters, that's fine I'm open to any suggestions, it seemed to me at the time that simple led technology would keep things simple , but maybe not after all
The thing is would this approach still require programming, which I think would be a stumbling block for me ?

OK here is what I require
A display counting down from 120 to 0
The countdown will be operated by 1 second pulses supplied by an existing device
The timer must be able to be reset by a single switch back to 120 at any time during the countdown
The timer must remember the 120 setting when power is removed
Alan
Alan:

Do NOT get frustrated. When you ask a question on a forum, there are many, many folks offering helpful information.
So, DOWNLOAD and install Program Editor from here: PE4Win/
INSTALL
OPEN
Select the PICAXE08M2 chip (the smallest and cheapest)
Paste the following code in the editor window:
Code:
; Original by g6ejd
; modified by Ray

Symbol Seconds = b0
Symbol SW = pinC.3

Start:
	If SW = 0 then Start
	
	For Seconds = 120 to 0 step -1
		' pause 1000  ' <---- UNREMARK & adjust for 1ms accuracy
		sertxd (#Seconds)
	Next
	
	Goto start
There is a little yellow arrow that will run the code in a software simulator. Click the yellow arrow.
You will see a skeleton of the 08M2 PICAXE chip. Physical pin #4, on the left side counting down from the top, can be clicked with the mouse to start the counting in the display. Click pin #3 (the 4th pin) and it will turn yellow to represent HIGH. The terminal display shows the countdown. Click pin#3 again to turn it dark... the clicks represents a pushbutton of type momentary contact.

This is the skeleton code for a serial display. You would change the lines:
' pause 1000 ' <---- UNREMARK & adjust for 1ms accuracy
and
sertxd (#Seconds)
to adjust the code timing and the serial output. The most common serial command is SEROUT which is fully described in the PDF manual2 on page 208.

The above codes works. You will need to make a few modifications (for the external time pulse and anytime reset) and others here will assist. But if you wish to work with uC (microcontrolllers) you MUST let your fear of programming come to an end. Programming is fun and will reward you with many rich projects and lots of personal pride. But, like swimming, you are going to get wet.

- Ray

OLED serial display is available here: http://www.picaxe.com/Hardware/Add-on-Modules/Serial-OLED-Module/

NOTE: You could also use a less expensive serial LCD. If you want to go with physically brighter and larger LED displays, then code must be written to support the external display... unless the external display is serial rs232. Good luck.
 
Last edited:

VIAD2

New Member
Many thanks mrburnette , your post has given me the will to continue, I can see a glimmer of light at the end of the tunnel. I shall try that later on.

and thanks to everyone who has posted with help . It's an excellent forum
 

VIAD2

New Member
Trying your advice out now, the Mac software doesn't appear to work, I use a Mac , but ok as I have a PC Windows and all is ok on that
 
Top