Shop OBEX P1 Docs P2 Docs Learn Events
DS1302 Sample Program Problem — Parallax Forums

DS1302 Sample Program Problem

GuidoGuido Posts: 195
edited 2006-11-13 01:54 in BASIC Stamp
A few years back I found this DS1302 sample program somewhere????? I am trying to get EMIC to speak the actual month, not a numeric number. Anyway after an hour looking for this program I found out that it can only display the month until September.....How can I get it to say the other months?

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-11-12 14:58
    Guido said...
    ...I found out that it ("this program") can only display the month until September
    Please explain.· Maybe you meant to tie in the EMIC part of it?·
  • GuidoGuido Posts: 195
    edited 2006-11-12 15:20
    If you run this program and set Month to exceed $09 or Basically Month=$10 it will not display the Long version of the Month after September
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-11-12 15:42
    Guido said...
    If you run this program and set Month to exceed $09 or Basically Month=$10 it will not display the Long version of the Month after September
    If you are actually forcing Month = $10, that's Month = 16 (base 10.)· So, that might be your problem.· If you want to use hexadecimal values for October (10), November (11), and December (12), then use·$0A, $0B and $0C, respectively.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-12 15:56
    Guido,
    ·
    ·· Since the EMIC relies on ASCII strings to speak, you need to send the time information to it in that format.· In SEROUT you can use the HEX formatter to get the time into the correct format.

    SEROUT Emic, Baud, [noparse][[/noparse]HEX2 hrs, ":", HEX2 mins, ampmFlag, "P"]
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • GuidoGuido Posts: 195
    edited 2006-11-12 19:03
    Thanks everyone, but I guess the question I am having is the problem with this program that is attached. It seems that the Lookup Month-1, table can not go past Data Number 9. Why?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-12 20:47
    Guido,
    ·
    ·· I’ve never seen/used this particular code before, but it appears that while the date is stored in BCD format the program is using the literal value for the lookup.· $10 is October to the DS1302, but it is the 16th element of the lookup table, which doesn’t work.· The value would have to be converted to Decimal before the lookup.· You can do that with the following line of code.

    month = (month.NIB1 * 10) + month.NIB0           ' BCD To Decimal
    

    The code I use is located at the following link.· Take care.

    http://forums.parallax.com/showthread.php?p=531080

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • GuidoGuido Posts: 195
    edited 2006-11-13 01:54
    Thank You Chris, That did the trick!
Sign In or Register to comment.