Shop OBEX P1 Docs P2 Docs Learn Events
Real time clock on 4X 20X LCD And Strings — Parallax Forums

Real time clock on 4X 20X LCD And Strings

chris joneschris jones Posts: 391
edited 2009-11-05 02:12 in Propeller 1
Hello

NOTE· : i am new to the propekller world but i will try 100% to read if i need to read and follow instructions

i have done some reading in the manual and found my section for· a run time clock but there is no exmpales on how i can access that clock and keep it running on 1 COG. i want to waste a COG just haveing it keep time is there a internal clock without using a cog.

i have a LCD screen that i got from parallax 4X 20X serial communication i know i need to use an object but not sure what section to look under for the object exchange.

the time format i want to display is
Days Hours minuts Seconds
00:00:00:00


BUT i can do the logic on that how do i get that info from the propeller chip.


Last can i do things with strings with teh propeller instead of serial or since the devices i am using are serial i have to send serial?

Comments

  • photomankcphotomankc Posts: 943
    edited 2009-10-28 15:43
    There is no internal real-time clock. You either have to use a cog to provide it or you have to do it in the foreground and make sure that your code will absolutely always complete before the next tick needs to be added. Otherwise you get an RTC chip and connect it up so you can read the time from that when required. Debug_LCD in the object exchange will take a string and deal with the serial comms to get it out to the LCD in serial format. There is also just an LCD driver for the parallax displays but it doesn't have as many formating options as Debug_LCD.
  • chris joneschris jones Posts: 391
    edited 2009-10-28 15:45
    oh so there is no clokc that will run as long as the chip is running ?
  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-28 16:00
    There is a 32 bit counter that increments as long as the chip is running (CNT), but it rolls over about every 50 seconds (2^32 clock ticks) at 80MHz. This system clock can be used to create an accurate real-time clock, but it requires the use of a cog to do so. Typically you have an assembly program that runs in the cog and simply waits for a second to go by (using the system clock), then it increments a second counter in the shared (hub) RAM and carries the usual way for minutes, hours, days, weeks, months, and years.
  • photomankcphotomankc Posts: 943
    edited 2009-10-28 16:14
    As Mike said, If all I want is some running counter I use an object I created to tick off 100ths of a second and provide a running count of seconds. That gives me the ability to at least note the passage of time. There is also an RTC clock object in the exchange if you want the clock/calendar type function. In most cases I'd prefer the external chip. It can be setup to handle at least brief power loss without resetting and it's not tying up a processor to sit there and count seconds.
  • JonnyMacJonnyMac Posts: 9,205
    edited 2009-10-28 17:44
    I created a simple software rtc object for my projects that don't need to save the time when the Propeller is powered down; you can find it here:

    obex.parallax.com/objects/532/

    The demo uses a serial terminal but the code is easily adapted to an LCD.
  • chris joneschris jones Posts: 391
    edited 2009-10-30 01:09
    in your code where is the pin set for the LCD
  • chris joneschris jones Posts: 391
    edited 2009-10-30 15:35
    looking at the code i have included your file in my code but i get an error and trying to see if you can help

    ERROR
    required subroutine

    here is my line of code
    lcd.time12(value.8)

    here is your line of code
    term.str(rtc.time12)


    Any ideals, i know you used the terminal but i setup my 4x 20x lcd
  • JonnyMacJonnyMac Posts: 9,205
    edited 2009-11-02 18:29
    I don't know what LCD driver you're using; mine has a .str method so I can do this:

    lcd.str(rtc.time12)
    



    See attached demo.
  • chris joneschris jones Posts: 391
    edited 2009-11-04 01:01
    hello

    i have my lcd working but i was wanting to know if someone can help i am trying to call a func from an object but why am i geting subrotine requred

    code listed..........................
    lcd.zip 26.6K
  • BradCBradC Posts: 2,601
    edited 2009-11-04 01:13
    chris jones said...
    hello


    i have my lcd working but i was wanting to know if someone can help i am trying to call a func from an object but why am i geting subrotine requred



    code listed..........................

    Main(79,7) Error : Unable to locate method/constant in Object
      lcd.time12(value , 8)
    ______^
    
    Compiled 963 Lines of Code in 0.105 Seconds
    brad@bklaptop2:~/temp/WSN$ grep time12 *
    jm_softrtc.spin[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ub time12 | h
    
    



    You are trying to reference the method "time12" in the "lcd" object, but it's actually in jm_softrtc which is "TIM" in your code.

    <edit> On top of that, time12 does not take parameters... What is it you are trying to do?

    Something like lcd.str(tim.time12) would probably achieve what I assume you want (put the time on the display) ?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If you always do what you always did, you always get what you always got.

    Post Edited (BradC) : 11/4/2009 1:18:41 AM GMT
  • chris joneschris jones Posts: 391
    edited 2009-11-04 14:17
    i am trying to set a running timmer for the time the chip is running.

    JonnyMac·posted his code and it looks like he is calling time12.i caqll lcd so i can display it on my debug lcd, also it looks like time 12 takes a peram of (d).
    ·
  • BradCBradC Posts: 2,601
    edited 2009-11-04 14:37
    chris jones said...
    i am trying to set a running timmer for the time the chip is running.


    JonnyMac posted his code and it looks like he is calling time12.i caqll lcd so i can display it on my debug lcd, also it looks like time 12 takes a peram of (d).

    Have a closer look at time12 in jm_softrtc. It does not take a parameter.
    It returns the address of a zero terminated string with a representation of the current rtc time in it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If you always do what you always did, you always get what you always got.
  • chris joneschris jones Posts: 391
    edited 2009-11-04 14:47
    hmmm i see....

    ok i will look maybe i need to look at --> pub initx
  • JonnyMacJonnyMac Posts: 9,205
    edited 2009-11-04 22:32
    If your LCD works then all you need to do is use a string output routine with .time12() -- as Brad points out, that method returns a pointer to a string which contains the current time in 12-hour format. I posted a how-to above. You just need to have a string output method in your LCD code (assuming that you're not using mine).
  • chris joneschris jones Posts: 391
    edited 2009-11-05 02:12
    ok i have your clock working how do i set it to run untill the propeller chip is disconnected?
Sign In or Register to comment.