Shop OBEX P1 Docs P2 Docs Learn Events
DS1302 Julian — Parallax Forums

DS1302 Julian

dbjdbj Posts: 75
edited 2007-01-22 23:42 in General Discussion
Trying to figure out how to return days julian from DS1302, Says Error 10
how do you look for this type of error. Thanks

Comments

  • BeanBean Posts: 8,129
    edited 2007-01-19 02:06
    JD = Month - 1 * 30 + Month / 9 + Month / 2 - Month max 3 / 3 * Year // 4 max 1 + 1 + Day

    SX/B does not allow more than 1 math operator per line.
    You'll have to use some temporary variables to hold the results as you build the expression.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
  • JonnyMacJonnyMac Posts: 9,071
    edited 2007-01-19 16:32
    Also keep in mind that the * and / operators generate a fair bit of code -- you may want to package those as functions (I do called MULT and DIV respectively).
  • Mr_NukeMr_Nuke Posts: 47
    edited 2007-01-19 17:01
    SX/B does not allow more than 1 math operator per line.
    Just one of the many reasons I find SX/B useless, and preffer the assembler.

    Alex.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fear not that your project does not work, for it will,

    Fear not if you see·a long dark path ahead, but follow it,
    Fear not if what worked now refuses to,
    For the only thing that's perfect is imperfection.
  • BeanBean Posts: 8,129
    edited 2007-01-19 17:28
    Mr_Nuke said...
    SX/B does not allow more than 1 math operator per line.
    Just one of the many reasons I find SX/B useless, and preffer the assembler.

    Alex.

    And how many operators per line does assembler allow ?

    Bean.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-01-19 19:32
    Bean said...
    JD = Month - 1 * 30 + Month / 9 + Month / 2 - Month max 3 / 3 * Year // 4 max 1 + 1 + Day

    Bean,

    I have a few questions about the formula you presented. Where did you obtain it? What is the order of operation? Is it strictly left to right?

    The standard order of operations implies that 1 should be multiplied by 30 before being subtracted from the month. Since 1 * 30 is always 30, this is a wasted calculation and surely not what you meant! If the order of operation is strictly left to right, then the Max 1 statement near the end will return a 1 or a 0 which will be added to 1 plus the day. I am fairly certain that is not right either, hence my questions. Can you (or someone else) help me better understand how to implement this formula?

    Also, I believe the result will require more than a simple word variable, probably three bytes at least. Is this easy to work around?


    - Sparks
  • BeanBean Posts: 8,129
    edited 2007-01-19 21:03
    Sparks,
    That is a forumla in the file that dbj posted. I have no idea where it came from.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-01-19 21:40
    Sorry, Bean. cool.gif



    dbj,

    I do not understand your formula! confused.gif

    - Sparks
  • David BDavid B Posts: 592
    edited 2007-01-20 00:39
    If you want a continuous count instead of a calendar date then maybe a DS1371 32-bit counter timekeeping chip would be a better fit for your project.

    Instead of having the DS1302 generate the full calendar date, then having your code turn the date parts into a count by applying a fairly elaborate set of calculations, the DS1371 could deliver you a continuous count in seconds, and you'd have a much simpler calculation to convert it to a Julian number of just a single division by the number of seconds per day, then adjust the result with an origin offset.

    David
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2007-01-20 09:35
    The formula looks familiar, but it is missing parentheses.
    www.emesys.com/BS2math4.htm#JulianDate

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-01-20 14:33
    It slices, it dices, it makes Julian dates... Amazing.
  • Mr_NukeMr_Nuke Posts: 47
    edited 2007-01-21 20:44
    Bean (Hitt Consulting) said...
    Mr_Nuke said...
    SX/B does not allow more than 1 math operator per line.
    Just one of the many reasons I find SX/B useless, and preffer the assembler.

    Alex.

    And how many operators per line does assembler allow ?

    Bean.

    ·
    You do not understand. It is one of the·MANY reasons. Adding the 1 operator/line to all the other reasons, it is easier to see how·SX/B becomes useless. SX/B might be useful for fast projects, but when it comes to increasing complexity, I find the assembler better suited.
    Also, I have seen many threads with different questions related to bugs·in SX/B. Although harder to understand, the assmembler is straightforward and·problem free.

    We can choose to·start a useless argument·about this, but it is obvious that you are a fanboy of SX/B supporting SX/B because you wrote it, while I am using my programming experience to select the best coding method.

    Alex.

    To answer your question, zero. The assembler does not allow any operator.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fear not that your project does not work, for it will,

    Fear not if you see·a long dark path ahead, but follow it,
    Fear not if what worked now refuses to,
    For the only thing that's perfect is imperfection.

    Post Edited (Mr_Nuke) : 1/22/2007 9:30:08 PM GMT
  • JonnyMacJonnyMac Posts: 9,071
    edited 2007-01-22 23:42
    I won't argue that I'm biased (having been a part the team that created SX/B), but I find it very useful because I can get results quickly -- my clients don't care what tool(s) I use, they just want the product to work to their specifications. And SX/B has the flexibility to add assembly blocks wherever required/desired. I'd hate for a real newcomer to see this thread and come away with the idea that SX/B is less than useful, when indeed it is very useful. That will never persuade an assembly purist, but it's not intended to (an assembly purist wouldn't use a C compiler for the same reasons he/she wouldn't use SX/B).

    I think SX/B is a great way for some to use the power of the SX without the steep learning curve of pure assembly. In short, it's just another [noparse][[/noparse]useful] tool to have in one's shed....
Sign In or Register to comment.