Round the clock


Closed Thread
Results 1 to 28 of 28

Thread: Round the clock

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    64

    Default Round the clock

    Hi,

    I'm programming a PIC in Oshonsoft basic and having problems with > or < when it comes to, in my case a 360 degree compass bearing. I understand that this is not an Oshonsoft forum, but I am more interested in the logic.

    If I explain it with a CLOCK face and a hour HAND. Hopefully it can be understood, by this explanation, but bear with my simple!!! explanation, and I have been known to make mistakes. There are 4x states, in the program.

    If the HAND is pointing at 3 (HAND = 3) and I want it to go to 4 on the FACE (FACE = 4); [If HAND < FACE then move cwise] and visa versa.
    If the HAND is pointing at 12 and I want it to go to 1; [If HAND < FACE then move cwise] doesn't apply.

    It's this crossover point that I'm having trouble with. (HAND is counting and comparing as it moves)

    1/2 way round the clock is 6, so [If HAND - FACE > 6 then move cwise] applies.

    There is an added complication: I want HAND to be HAND + or - 1, so 3 includes 2 and 4.

    If this is understandable, does anyone know how to solve it please?

    Camerart.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Round the clock

    Can you count on 24h basis? If your counter is counting that way, then you can display the modulus 12 value.

    Ioannis

  3. #3
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Round the clock

    Hi I,

    No because the HAND goes round and round.

    C.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Round the clock

    The hand can do the round, but your variable can hold whatever value. Also with Mod 12 you still have the 12h basis value.

    Ioannis

  5. #5
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Round the clock

    Quote Originally Posted by Ioannis View Post
    The hand can do the round, but your variable can hold whatever value. Also with Mod 12 you still have the 12h basis value.

    Ioannis
    Hi I,

    I don't understand your answer, can you explain what MOD 12 is please?

    C.

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Round the clock

    Modulus division. You divide by 12 and keep the as a result the integer remainder of the division.

    So 23.00 h mod 12 gives remaider 11, exactly what 23 at 12h basis is.

    Ioannis

Similar Threads

  1. DT_INT Vs ASM - Round 1
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th January 2013, 21:33
  2. How to round number using integer only
    By Yvesmazzon in forum Code Examples
    Replies: 2
    Last Post: - 6th March 2011, 13:37
  3. external clock / internal clock
    By grounded in forum General
    Replies: 4
    Last Post: - 31st May 2008, 17:44
  4. Clock
    By Fredrick in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st February 2008, 02:23
  5. Round Dial, Electronic Combination Lock
    By Pic_User in forum Off Topic
    Replies: 5
    Last Post: - 6th July 2006, 13:34

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts