12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    @SLEEP can not be used like that. The OSC is stopped when sleeping so it would not know what to do with it.

    But... Bruce to the rescue again.
    http://www.picbasic.co.uk/forum/showthread.php?t=7013
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit

    But... Bruce to the rescue again.
    I must add him to my Christmas card list too.....!

    So @SLEEP (no period) for the visits count with IOC and a WDT timing loop for the "is it dark or just very cloudy" 30 min sleep.

    Code:
    OPTION_REG = %00001111
    So with OPTION reg bit.4 set to 1 prescaler assigned for WDT on and a 128 prescaler I'm thinking that:

    30mins x 60sec / 2.304secs = 781 counts for Bruce's timing / SLEEP loop below.

    Code:
    COUNTER=0 ' clear before entry
    WHILE COUNTER < 781
    @ SLEEP
    COUNTER=COUNTER+1
    WEND
    So not really sleeping, more power napping.........

    How does the above sound / look.

    Dave
    Last edited by LEDave; - 14th December 2010 at 00:33.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    So not really sleeping, more power napping.........
    That is what I was doing while driving home today....
    How does the above sound / look.
    Looks like it should work.
    And you say that you have been doing this less than a year.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    That is what I was doing while driving home today....
    Careful, we don't want any incidents now do we...!

    And you say that you have been doing this less than a year.
    A year February from memory, I think the progress made has been down to the tutors as much as the pupil.

    Dave

  5. #5
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Ok,

    Time to stick my neck out and say I think (I think) I've finished the TX / RX programs. I haven't connected them to the sensor / LDR to test for operation but I'd be very interested as to whether you can see any gaping errors in the code, here goes, TX first:

    Code:
    '****************************************************************
    '*  Name    : rfPIC_TX.BAS                                      *
    '*  Author  : B. Reynolds 90% LEDave 10%...Ok 5%                *
    '*  Notice  : Copyright (c) 2007 Reynolds Electronics           *
    '*          : All Rights Reserved                               *
    '*  Date    : 10/09/2007                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : 2-BIT Encoder for remote control with the         *
    '*          : rfPIC12F675 on Microchip rfPIC demo board         *
    '****************************************************************
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
        
        DEFINE OSC 4
        DEFINE NO_CLRWDT 1
        DEFINE OSCCAL_1K 1
        
        SYMBOL D_OUT = GPIO.2 ' RF serial data output
        SYMBOL E_OUT = GPIO.5 ' RF transmitter enable output
        
        
        VISITS   VAR word   ' Holds total daily bird visits
        DAT_OUT  VAR BYTE   ' Holds 8-bit data byte
        DAT_OUT2 VAR BYTE   ' Holds 8-bit test byte 
        LOOPS    VAR BYTE   ' Loop var
        CHK_SUM  VAR BYTE   ' Holds calculated checksum of outbound data
        COUNTER  VAR BYTE   ' Holds WDT count values
        BAUD     VAR WORD   ' Holds baud rate
        
        ' Constants
        PreAmble CON $A5    ' 10100101 preamble
        Synch    CON "~"    ' 01111110 synch byte
        N4800    CON 188    ' 4800 bps 
        N2400    CON 16780  ' 2400 bps
        GUARD    CON 5      ' 5mS guard time pause
        
        
        ' hardware init 
        GPIO = 0            ' Everything off on boot
        ' GPIO.2=data out, GPIO.5=RF enable, GPIO.3,4 = Bird_visit_count / It's dark..maybe
        TRISIO = %00011011  '
        ANSEL = 0           ' Disable A/D
        INTCON = %00001000  ' Enable port change wakeup from sleep
        WPU = %00010000     ' pull-up on for GPIO.4 (external pull-up already on GPIO.3)
        IOC = %00011000     ' Wakeup on change enabled for GPIO.3,4
        VRCON = 0           ' Disable internal Vref
        CMCON = 7           ' Disable comparators
        OPTION_REG = %00001111 'Watch_Dog_Timer ON with a 128 prescaler
        
        
        D_OUT = 0           ' Idles low for inverted serial output
        E_OUT = 0           ' Enable for RF transmitter=0 (transmiter off)
        BAUD = N2400        ' Set baud rate here
        
    Main:    
        ' Read port to clear missmatch, if with no buttons pressed, then
        ' clear int-on-change flag & snooze until wake up on change. This
        ' conserves battery power on the demo board with 3V coin cell.
        
      IF GPIO.3= 1 AND GPIO.4= 1 THEN ' Nothing has happened so SLEEP
           E_OUT=0       ' Disable transmitter
           INTCON.0 = 0  ' No Bird detected or it's still light so clear int on change flag
           @ SLEEP       ' and start snoozin..zzzzzzzzzzz indefinatly
           @ NOP         ' Do nothing for 1st instruction on wake-up
      ELSE  
       IF  GPIO.3=0 THEN GOSUB COUNTS 'Bird detected at box - GOTO LABEL COUNTS   
       IF  GPIO.4=0 THEN GOSUB DARK   'It's got dark? or just cloudy - GOTO LABEL DARK
      ENDIF     
      GOTO MAIN          'Back to sleep / continue counting
        
        
     COUNTS:
          VISITS = VISITS +1 'Bird at box so increment counter
          INTCON.0 = 0       ' Clear int on change flag
      RETURN                 ' Then back to sleep....
        
     DARK:
          INTCON.0 = 0     ' Clear int on change flag
          E_OUT=0          ' Disable transmitter
                           ' It could be night time...It might only be a cloud though...   
                           ' so back to sleep / wake / sleep for half an hour..zwzwzw
          COUNTER=0        ' clear before entry
    WHILE COUNTER < 781    'Loop for 30 mins
         @ SLEEP
         COUNTER=COUNTER+1
         IF  GPIO.3= 0  THEN COUNTS 'Bird at box so continue counting
    WEND     
                  
        if  GPIO.4= 0  then ENCODE  ' It really ia dark so carry on and transmit VISITS
        
        IF  GPIO.4= 1  THEN RETURN  ' It's not dark after all so carry_on_sleeping_counting 
        
    Encode:  
        E_OUT=1     ' Turn transmitter on 
        pauseus 25  ' Let transmitter settle
        DAT_OUT = %10101001
        INTCON.0 = 0  ' Clear int on change flag
          
        ' Build checksum of 2 data bytes
        CHK_SUM = (DAT_OUT * 2)
        
    Transmit:
        LET VISITS = VISITS / 2  'Just VISITS to not from the box
        SEROUT2 D_OUT,BAUD,[PreAmble,Synch,DAT_OUT,DAT_OUT,CHK_SUM,VISITS.highbyte,VISITS.lowbyte]
        PAUSE GUARD ' 5mS guard time gives decoder time to respond,calculate,change,etc.
        
        GOTO Main
            
        END
    Dave

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I do not see anything obviously wrong. Should work.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Cheers mackrackit,

    I guess the next thing is to wire it up and see what happens....

    One thing that has become very apparent to me with programming is that due to the permutations / complexity of a program, an error can easily slip in and be very difficult to identify, almost like a sleeping time bomb. I hope the TX program is glitch free, we shall see.

    Dave

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