Countdown timer.

EricD

Member
Hi all,

I've been a forum member for a few weeks, done a lot of reading but this is only my second post. I'm also very new to pic programming. Picaxe was suggested in an electronics forum so I bought a 14M starter kit and have been experimenting the last few weeks.

What I want to do is to build a countdown timer with a screen and 4 input buttons for "Up", "DOWN", START" and "RESET". I (sort of ) got the timer working on a 12 Character 7 Segment display but, it's too big and not very good for letters.

Thanks to info & code in this forum and elsewhere on the Inet, I managed to get a Nokia 3330 screen working on the 14M. I would like to take it a step further and build the countdown timer using the Nokia screen. I know that the 14M is no good for this project and I need to buy another one but which one I don't know yet.

Actually, there are two projects I want to build, one is the timer and the other one is an RPM counter. Initially I wanted to interface the RPM counter to an old Laptop but am thinking that it might be better to use a Nokia screen for that too.

So my question is, is it a good idea (or even possible) to use the Nokia screen for these projects or should I just stick with the 7 Segment display?

Does anyone have an countdown/up example program they wouldn't mind sharing please?



Thanks in advance.

EricD
 

eclectic

Moderator
Hi all,

Snipped
Actually, there are two projects I want to build, one is the timer and the other one is an RPM counter. Initially I wanted to interface the RPM counter to an old Laptop but am thinking that it might be better to use a Nokia screen for that too.

So my question is, is it a good idea (or even possible) to use the Nokia screen for these projects or should I just stick with the 7 Segment display?

snip
EricD
Just my opinions.

1. As far as I remember, the update time
for the Nokia screen may be too slow.
And you've probably found out that
they're a pain to solder!

2. Equipment for both of your projects?
18M2 or 20X2 and an LCD display (say AXE033).

Set them up right and they work first time.
And importantly, there's loads of background
information and support.

If you're happy to spend time
with the Nokia, then fine, but,
having been there,
I won't go again. :)


e
 

hippy

Ex-Staff (retired)
If you've mastered the Nokia LCD then it seems reasonable to stick with that if you're happy with how it works and what it does.

I'd agree with electtic - 18M2, 20X2 and I'd add 28X2 as a potential. They all have large capacity program memories and high speed operation which will be a benefit. Perhaps especially in communicating with the LCD. I've got a couple of Nokia LCD but haven't had the time to work out how to wire them up let alone write any code for using them so don't I know what that fully entails.
 

EricD

Member
Thanks for the replies guys.

After reading the info here and on the INet, I stripped down the Nokia and took out the screen completely. I soldiered the wires directly on to the tabs on the glass itself, not on the press pins (or what ever they are called). It wasn't easy but a lot easier than soldering on the pins. I used one of them desk reading lamps with magnifying glass so that I could see better and 8 strands of an 80 way HDD ribbon cable. Soldering don't look pretty but it works.



I had a look at the AXE033 but at almost £20 a go with P&P a little expensive for me. I got the 7 Segment LCD off EBAY, it's from the USA & only costed me about 5$ with P&P. The thing I don't like about it is that the screen is just under 4 inches long and the PCB about 5 inches. Too big for my projects really but if in the end I have no choice then I will have to stick with it and order another one.

I'll go with the 20X2, loads more memory to play with but has the +/0V and Serial in/out pins same as the 14M and the new 14M2 when it becomes available. I'm thinking about making one proto type PCB where I can program any of the three instead of making a PCB for each one.

Thanks

EricD
 
Last edited:

hippy

Ex-Staff (retired)
The thing you'll get with the 28X2 which you won't with the 20X2 or 14M is the ability to use an external resonator. That may come in handy for RPM measuring and accurate timing but the others with on-chip osciallator seem to usually fare well enough.

Though the AXE033 is more expensive than other options it is easy to use and control. That 7-seg LCD sounds quite nice; it's funny how some things don't suit some projects and yet would be ideal for others.

On prototype PCB's; that's a good idea. All the 8-pin, 14-pin and 20-pin PIACAXE will be electrically compatible ( have power plus download pins in the same place ) so it is usually possible to pop any into the socket. Some have taken to cutting bits of chip off to get larger chips to fit in smaller sockets !

http://www.picaxeforum.co.uk/showthread.php?t=17191
 

westaust55

Moderator
Like eclectic, I too have done some work with gLCD modules taken from mobile/cell phones. In my case I used the Siemens A55 which had a greater resolution but they are harder to come by and not much easier to solder wires to the connector. Otherwise fairly similar to the Nokia 3310 and derivatives.
A thread on the A55, if you have not already read is here:http://www.picaxeforum.co.uk/showthread.php?t=10014

As eclectic indicates, getting the data across to these gLCD modules can be slow. The Nokia type with a 84x48 resolution equates to 4032 pixels whereas the A55 with a 102 x 64 resolution has 6528 pixels.

Driving the A55 display with a PICAXE 40X1 at 8 MHz took about 2 seconds to totally refresh the screen. Obviously with the new M2 and X2 parts that can be done a lot faster. At 64 Mhz PICAXe clock speed the refresh rate for the A55 display would be around 0.3 seconds and for the Nokia 3310 display around 0.2 seconds.

I did some work on code for double height and/or double width fonts, drawings lines, circles, etc. (See link above)

Using these gLCD's ex mobile phones can teach you a lot about graphics and gLCDs and you can have a lot of fun. I have seen some quite good projects/dispaly in the past incorporating them.
There are also other options for gLCD displays where a lot of the basic work to provide firmware to give fonts and graphics is done for you and with 64k colours. 4D Systems is one such company selling OLED modules. Those with serial interfaces are the easiest to connect to a PICAXE. See: http://www.4dsystems.com.au/
There are alos a number of thread on this forum now for the 4D systems OLED displays. A 96 x 96 resolution 64k colour OLED is around AUD$40.

By comparison the AXE033 from MicroZED in Australia is AUD$49. However the AXE033 takes a lot less program code to drive for basic text results.
In the UK you may find the pricing favours the AXE033 as well
 

EricD

Member
The thing you'll get with the 28X2 which you won't with the 20X2 or 14M is the ability to use an external resonator. That may come in handy for RPM measuring and accurate timing but the others with on-chip osciallator seem to usually fare well enough.
I want to make the RPM counter for a woodlathe so it really doesn't need to be that accurate. I will be using a Magnetic Slotted Hall Effect Switch and a reluctor. Just waiting for summer so that I can get back in the garage.


Originally, I wanted to interface it to a Laptop using Visual C++, another (winter) hobby I started not very long ago. I have not been able to find out how to do that yet and as I was searching for info I found the Nokia 3110 & the Siemans A55 threads in this forum and got interested. One thing led to another and I'm the type of person who can't let go once I've got interested. LOL...I have to find out the how and the why.

The countdown timer is for a PCB UV light box that I picked up for £2 at a boot sale a couple of years ago. It's old but works, well...at least until one of the tubes blew up a few months ago. Haven't bothered to buy a new one yet.

For both projects there just might be enough room to fit the 7 Segment LCD's but will mean cutting larger holes in cases or buying/making bigger boxes to fit them in. That might not be much of a problem but using the Nokia screen I'll learn a lot more about programming the axe chips and maybe one day I'll find out how to replace one character with another one at the same X,Y position. Not enough memory on the 14M to try though, I'll have to wait until I get my 20X2.

WOW, I never thought that you could cut an IC in half and it would still function.

EricD

PS: This is the link for the 7 Segments LCD's if anyone is interested. http://tinyurl.com/6z9p9dw
 
Last edited:

EricD

Member
Like eclectic, I too have done some work with gLCD modules taken from mobile/cell phones. In my case I used the Siemens A55 which had a greater resolution but they are harder to come by and not much easier to solder wires to the connector. Otherwise fairly similar to the Nokia 3310 and derivatives.
A thread on the A55, if you have not already read is here:http://www.picaxeforum.co.uk/showthread.php?t=10014

As eclectic indicates, getting the data across to these gLCD modules can be slow. The Nokia type with a 84x48 resolution equates to 4032 pixels whereas the A55 with a 102 x 64 resolution has 6528 pixels.

Driving the A55 display with a PICAXE 40X1 at 8 MHz took about 2 seconds to totally refresh the screen. Obviously with the new M2 and X2 parts that can be done a lot faster. At 64 Mhz PICAXe clock speed the refresh rate for the A55 display would be around 0.3 seconds and for the Nokia 3310 display around 0.2 seconds.

I did some work on code for double height and/or double width fonts, drawings lines, circles, etc. (See link above)

Using these gLCD's ex mobile phones can teach you a lot about graphics and gLCDs and you can have a lot of fun. I have seen some quite good projects/dispaly in the past incorporating them.
There are also other options for gLCD displays where a lot of the basic work to provide firmware to give fonts and graphics is done for you and with 64k colours. 4D Systems is one such company selling OLED modules. Those with serial interfaces are the easiest to connect to a PICAXE. See: http://www.4dsystems.com.au/
There are alos a number of thread on this forum now for the 4D systems OLED displays. A 96 x 96 resolution 64k colour OLED is around AUD$40.

By comparison the AXE033 from MicroZED in Australia is AUD$49. However the AXE033 takes a lot less program code to drive for basic text results.
In the UK you may find the pricing favours the AXE033 as well
I did read your thread and being a beginner not knowing much I downloaded and tried to run it on the 14M, of course it didn't work. I tried deleting a lot of stuff but still won't fit. I found another code somewhere, can't remember exactly where now but I managed to cut that one down to 253 bytes, only enough space for 4 characters next to each other. Can't figure out how to delete one and replace it with another. i.e changing a 9 to an 8 at the same X,Y position.

The OLED's might be a project for next winter when it'll be too cold to do anything in my garage/workshop. Thanks for the info.

EricD
 

westaust55

Moderator
With a standard serial type display you would have every chance of achieving your display requirements with an “M” series PICAXE part.
But to control a gLCD from a mobile phone you require code to initialise the display and need to have the data for the font so your prosects to use an “M” part are basically nil other than a simple test program.

If you have an 18X which has 2048 bytes of program space then you will be able to drive one of those gLCD display. If no 18X is to hand, then consider the 18M2 which can have far greater clock speeds and has 2048 bytes of program space.
 

EricD

Member
I've ordered an 18M2 and a 20X2 from techsupplies, if they are as good as last time, I'll have them by tomorrow.

EricD
 

EricD

Member
After 5 days of hair pulling I finally got the countdown timer working on a 20X2 running at full 64MHz speed.:D

Everything is too slow running at 4MHz but at 64MHz the update time is pretty good.

At start the code displays a "PRESS START" message and awaits for key press on C.6. At the moment the time is "fixed" at 10 minutes, next step is to connect switches to set the desired time and start/stop the process.

When finished, "00:00" & "E N D" is displayed, additionally, as an acoustic warning it plays the Wombles tune. LOL

Can't remember where I downloaded the Nokia Screen driver program but many thanks to whoever it was.

EricD

Code:
symbol SCLK = 0    'Display pin 2 to PICAXE out 0
symbol SDA = 1    'Display pin 3 to PICAXE out 1
symbol DC = 2    'Display pin 4 to PICAXE out 2
symbol CS = 3    'Display pin 5 to PICAXE out 3
symbol RES = 4    'Display pin 8 to PICAXE out 4
symbol Loop1 = b0
symbol Value= b1
symbol Loop2 = b2
symbol Command = b3
symbol Counter = b4
symbol X = b5
symbol Y = b6
symbol Mask = b7
symbol Loop3 = b8

Main:
    setfreq m64
    gosub ClearFast
    gosub Init


REM BEGIN: ***** TO DO *****
'The lines between "REM BEGIN" and "REM END" will be replaced by Input Key code to set the desired countdown time. 

SetUpScreen: 
    gosub ClearFast
    b9 = 6   'Ones, last digit.
    b10 = 10 
    X = 45 
    Y = 3    
      gosub GotoXY
      command = 0
      gosub One
      
      b11 = 6 'Tens, third digit.
      b12 = 10
      X = 40 
      Y = 3
      gosub GotoXY
      command = 0    
      gosub Ten
      
Colon:
      X = 35 
      Y = 3
      gosub GotoXY
      command = 0    
    for Loop1 = 56 to 60
    Read Loop1, Value
        gosub WriteToLCD        
    next Loop1
      
      b13 = 6 'Hundreds, second digit.
      b14 = 10 
      X = 30 
      Y = 3
      gosub GotoXY
      command = 0    
      gosub Hundred
            
      b15 = 11  'Thousands, 1st gidit.
      b16 = 15
      X = 25 
      Y = 3
      gosub GotoXY
      command = 0    
      gosub Thousand
      
StartScreen:

    X = 14 
    Y=1    
    gosub GotoXY 
    Command = 0
    for Loop1 = 121 to 175 ' Send "PRESS START" to screen.
        read Loop1, Value 
        gosub WriteToLCD  
    next Loop1

if pinC.6 = 1 then 
goto BeginCountDown 'Wait for Key Press
end if 

goto StartScreen

Rem End:**********

BeginCountdown:

    X = 1
    Y = 1
    gosub GotoXY 
    Command = 0
      for b20 = 1 to 15
    for Loop1 = 66 to  70 ' Send "" (Space) to screen to clear previous message.
        read Loop1, Value '
        gosub WriteToLCD  '
    next Loop1
    next b20

    X = 18 
    Y=1    
    gosub GotoXY 
    Command = 0
    for Loop1 = 176 to 220 'Send "TIME LEFT" to screen.
        read Loop1, Value 
        gosub WriteToLCD  
    next Loop1
    
    pause 7750
    
    if b9 = 6 then 
    b9 = 1
      goto Tens
      end if 

Ones:
      
      X = 45
      Y = 3
      gosub GotoXY
      
    for b9 = 51 to 6 step -5
    Command = 0    
    b10 = b9 + 4    
    gosub One
    
    X = 45
    Y = 3
      gosub GotoXY
   
    pause 7750 'Pause 1 second at 64MHz, change if running at slower speed.
      next b9
      
Tens:
      X = 40
      Y = 3
      gosub GotoXY
      command = 0
            
      if b11 = 6 and b9 = 1 then
      goto Hundreds
      end if
      
      b11 = b11 -5
      b12 = b12 - 4         
      gosub Ten
    goto Ones
          
 Hundreds:
      X = 30 
      y = 3
      gosub GotoXY
      command = 0
            
      if b13 = 6 and b9 = 1 then
      goto Thousands
      end if
      
      if b13 > 6 then      
      b13 = b13 -5
      b14 = b13 + 4      
      gosub Hundred
      
    b11 = 31
      b12 = b11 + 4
      X = 40
      Y = 3
      gosub GotoXY
      command = 0      
      gosub Ten
    goto Ones 
    end if   
    goto Ones
    
    
Thousands:
    X = 25
    y=3
    gosub GotoXY
      command = 0
      
      if b15 = 6 and b13 = 6 and b11 = 6 and b9 = 1 then
      goto Endprog
      end if
      
      if b15 = 6 and b13 > 6 then
      b13 = 51
    b14 = 55
      goto Hundreds
      end if
            
      if b15 > 6 and b13 = 6 and b11 = 6 and b9 = 1 then               
      b15 = b15 - 5
      b16 = b15 + 4  
      gosub Thousand
     
    X = 30
      gosub GotoXY
      command = 0
      b13 = 51
      b14 = 55
      gosub Hundred
    
    b11 = 31
      b12 = b11 + 4
      X = 40
      gosub GotoXY
      command = 0     
      gosub Ten 
      goto Ones
      end if
          
Stop
End
          
Endprog: 'Send "E N D" to screen and play tune.

    X = 1
    Y = 1
    gosub GotoXY 
    Command = 0
      for b20 = 1 to 15
    for Loop1 = 66 to  70 ' Send "" (Space) to screen to clear previous message.
        read Loop1, Value '
        gosub WriteToLCD  '
    next Loop1
    next b20


    X = 25 
    Y=1    
    gosub GotoXY 
    Command = 0
    for Loop1 = 61 to 90   '
        read Loop1, Value '
        gosub WriteToLCD  '
    next Loop1

    'Wombles
    tune 7,             4,($27,$69,$00,$6C,$00,$69,$27,$6C,$27,$69,$00,$C4,$2C,$44,$05,$44,$02,$04,$42,$00,$02,$69,$00,$2B,$EC,$27,$69,    $00,$6C,$00,$69,$27,$6C,$27,$69,$00,$C4,$2C,$44,$05,$44,$02,$04,$42,$00,$02,$69,$2B,$C0)

Stop
End    


    
Init:
    EEPROM 0,(33,197,6,19,32,12)
    
    EEPROM 6,  (0x3E, 0x51, 0x49, 0x45, 0x3E) '0
    EEPROM 11, (0x00, 0x42, 0x7F, 0x40, 0x00) '1
    EEPROM 16, (0x42, 0x61, 0x51, 0x49, 0x46) '2 
    EEPROM 21, (0x21, 0x41, 0x45, 0x4B, 0x31) '3
    EEPROM 26, (0x18, 0x14, 0x12, 0x7F, 0x10) '4
    EEPROM 31, (0x27, 0x45, 0x45, 0x45, 0x39) '5
    EEPROM 36, (0x3C, 0x4A, 0x49, 0x49, 0x30) '6
    EEPROM 41, (0x01, 0x71, 0x09, 0x05, 0x03) '7
    EEPROM 46, (0x36, 0x49, 0x49, 0x49, 0x36) '8
    EEPROM 51, (0x06, 0x49, 0x49, 0x29, 0x1E) '9
    EEPROM 56, (0x00, 0x36, 0x36, 0x00, 0x00) ' :
    EEPROM 61, (0x7F, 0x49, 0x49, 0x49, 0x41) 'E
    EEPROM 66, (0x00, 0x00, 0x00, 0x00, 0x00) 'Space
    EEPROM 71, (0x7F, 0x04, 0x08, 0x10, 0x7F) 'N
    EEPROM 76, (0x00, 0x00, 0x00, 0x00, 0x00) 'Space
    EEPROM 81, (0x7F, 0x41, 0x41, 0x22, 0x1C) 'D 
    EEPROM 86, (0x00, 0x00, 0x00, 0x00, 0x00) 'Space
    
    EEPROM 121, (0x7F, 0x09, 0x09, 0x09, 0x06) 'P
    EEPROM 126, (0x7F, 0x09, 0x19, 0x29, 0x46) 'R
    EEPROM 131, (0x7F, 0x49, 0x49, 0x49, 0x41) 'E
    EEPROM 136, (0x46, 0x49, 0x49, 0x49, 0x31) 'S
    EEPROM 141, (0x46, 0x49, 0x49, 0x49, 0x31) 'S
    EEPROM 146, (0x00, 0x00, 0x00, 0x00, 0x00) 'Space
    EEPROM 151, (0x46, 0x49, 0x49, 0x49, 0x31) 'S
    EEPROM 156, (0x01, 0x01, 0x7F, 0x01, 0x01) 'T
    EEPROM 161, (0x7E, 0x11, 0x11, 0x11, 0x7E) 'A
    EEPROM 166, (0x7F, 0x09, 0x19, 0x29, 0x46) 'R
    EEPROM 171, (0x01, 0x01, 0x7F, 0x01, 0x01) 'T
    
    EEPROM 176, (0x01, 0x01, 0x7F, 0x01, 0x01) 'T
    EEPROM 181, (0x00, 0x41, 0x7F, 0x41, 0x00) 'I
    EEPROM 186, (0x7F, 0x02, 0x0C, 0x02, 0x7F) 'M
    EEPROM 191, (0x7F, 0x49, 0x49, 0x49, 0x41) 'E
    EEPROM 196, (0x00, 0x00, 0x00, 0x00, 0x00) 'Space
    EEPROM 201, (0x7F, 0x40, 0x40, 0x40, 0x40) 'L
    EEPROM 206, (0x7F, 0x49, 0x49, 0x49, 0x41) 'E
    EEPROM 211, (0x7F, 0x09, 0x09, 0x09, 0x01) 'F
    EEPROM 216, (0x01, 0x01, 0x7F, 0x01, 0x01) 'T
    
    
    low SCLK 
    low SDA
    low DC
    low CS
    low RES
    pause 20
    low RES
    pause 500
    high RES
    high CS
    Command = 1
    for Loop1 = 0 to 5 ' Was 0 to 5         ‘ start a loop
        read Loop1, Value     ' read value from EEPROM
        gosub WriteToLCD     ' transmit to serial LCD module
    next Loop1

    gosub GotoXY

return

WriteToLCD:
    high DC    'Data mode
    if Command = 0 then DataMode
    low DC    'Command mode
    DataMode:
    low CS
    for Loop2 = 1 to 8
        low SCLK
        Mask = Value & 128
        low SDA
        if Mask = 0 then Skiphigh
        high SDA
        Skiphigh:
        high SCLK
        Value = Value * 2
    next Loop2
    high CS
return

ClearFast:
    low SDA
    high DC
    low CS
    for Loop1=1 to 48
        for Loop3= 1 to 84
            low SCLK
            high SCLK
        next loop3
    next Loop1
return

GotoXY:
    Command = 1
    Value = X + 128
    gosub WriteToLCD
    Value = Y + 64
    gosub WriteToLCD
return

Thousand:
    for Loop1 = b15 to b16
    Read Loop1, Value
        gosub WriteToLCD        
    next Loop1
    return
    
Hundred:
    for Loop1 = b13 to b14
    Read Loop1, Value
        gosub WriteToLCD        
    next Loop1
    return
    
Ten:
    for Loop1 = b11 to b12
    Read Loop1, Value
        gosub WriteToLCD        
    next Loop1
      return

One:
    for Loop1 = b9 to b10
    Read Loop1, Value
        gosub WriteToLCD        
    next Loop1
    return
 
Last edited:
Top