Matching time conditions


Closed Thread
Results 1 to 40 of 49

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    You've set TRIS for PORTD.7 for Output?

    You've checked that anything else that share that pin is switched off (eg any Analogue or other devices).

    You've connected your LED the correct way around (with a current limiting Resistor) and it works?

    Personally I like to use HIGH and LOW... eg...

    HIGH PortD.7

    eg

    If AlarmH1=AlarmHour then
    HIGH PortD.7
    else
    LOW PortD.7
    endif

  2. #2
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    You've set TRIS for PORTD.7 for Output?

    You've checked that anything else that share that pin is switched off (eg any Analogue or other devices).

    You've connected your LED the correct way around (with a current limiting Resistor) and it works?

    Personally I like to use HIGH and LOW... eg...

    HIGH PortD.7

    eg

    If AlarmH1=AlarmHour then
    HIGH PortD.7
    else
    LOW PortD.7
    endif
    Scrub my last post - I used your HIGH LOW example and it worked

    Thank you.....

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    LOL - the LED just went out as the clock turned to 22:00 hrs

    The best bit is I've learned more about datasheets through this thread, and some of the pitfalls of my poor coding

    Thank you for your patience Mel - I do appreciate it

  4. #4
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    Scrub my last post - I used your HIGH LOW example and it worked
    If HIGH / LOW works, but PORTD.7 = 1 DOESN'T work, that sounds like a sure sign that you don't have your pin correctly set as an output.

    Using HIGH or LOW automatically sets the pin as an output first before it sets it high or low

    Check your TRIS settings again. PORTD.7 = 1 SHOULD work if the port is set up right....


    steve

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks Steve... I had the TRISO for port D set so no Idea !

    One last thing (for tonight)

    I added a section for minutes too and could get the LED to come on at say 22:34 and go out at 22:35.

    Code:
    AlarmH1=(RTCHour>>4)
    AlarmH1=(AlarmH1&$03)*10
    AlarmH1=AlarmH1+(RTCHour&$0F)
    
    AlarmM1=(RTCMin>>4)
    AlarmM1=(AlarmM1&$03)*10
    AlarmM1=AlarmM1+(RTCMin&$0F)
        
    AlarmHour1 = 22
    Alarmmin1 = 34
    	
    	LCDOut ":",#(RTCMin>>4)&$0F,#RTCMin&$0F,":"
    	LCDOut #(RTCSec>>4)&$0F,#RTCSec&$0F," "
    	LCDOut $FE, $D4,"value = ",  # alarmh1, #alarmhour1
    
    If AlarmH1 = AlarmHour1 and AlarmM1 = alarmmin1 then
    HIGH PortD.7
    else
    LOW PortD.7
    endif
    So I added a a few more variables to try and set a time range but whilst it compiles it no longer lights the LED.


    Code:
    AlarmH1=(RTCHour>>4)
    AlarmH1=(AlarmH1&$03)*10
    AlarmH1=AlarmH1+(RTCHour&$0F)
    
    AlarmM1=(RTCMin>>4)
    AlarmM1=(AlarmM1&$03)*10
    AlarmM1=AlarmM1+(RTCMin&$0F)
        
    AlarmHour1 = 22
    Alarmmin1 = 53
    alarmhour2 = 22
    Alarmmin2 = 55
    	
    	LCDOut ":",#(RTCMin>>4)&$0F,#RTCMin&$0F,":"
    	LCDOut #(RTCSec>>4)&$0F,#RTCSec&$0F," "
    	LCDOut $FE, $D4,"value = ",  # alarmh1, #alarmhour1
    
    If AlarmH1 >= AlarmHour1 and AlarmH1 <= alarmhour2 and AlarmM1=>alarmmin1 and alarmM1<= alarmmin2 then
    HIGH PortD.7
    else
    LOW PortD.7
    endif
    Any ideas ?

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Malcolm,

    I'm wondering if you missed the link I showed in post 11.

    I really think that's what you're looking for.
    <br>
    DT

  7. #7
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    Must of overlooked that... I'll have a read at work in the morning, and the see if I can implement the suggestions... It's getting late, my two little gray cells have gone to sleep...

  8. #8
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Malcolm, you can't have '&$03' for MINUTES (the way you have for HOURS)... but can you figure why and what value it should be if not $03? Correct that small omission and your code will run (there's incentive for you).

Members who have read this thread : 0

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