12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    Sorry guys, I will have to just keep following. I'm stumpted.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    Can you post your entire program as it stands now?

    (There's no way my feeble mind can remember all changes through a 23 page thread.)
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

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


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    Two versions to look at really Demon. I've posted two, it might help you see 'something' because although very similar, what they both do is subtley different things.

    The first one does this on button presses:

    1/ If a button is pressed and released RFEN briefly flashes after the 5sec delay (no data is Tx'd).

    2/ If a button is continually pressed, nothing happens at all (RFEN doesn't light / no data is Tx'd.


    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF & _BODEN_OFF & _PWRTE_ON
     
        ' With rfRXD0420 module installed in PICkit 1 board;
        ' SW1 toggles LED D6 on PICkit 1 board
        ' SW2 toggles LED D7 on PICkit 1 board
        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
     
        DAT_OUT VAR BYTE    ' Holds 8-bit data byte
        LOOPS   VAR BYTE    ' Loop var
        CHK_SUM VAR BYTE    ' Holds calculated checksum of outbound data
        BAUD    VAR WORD    ' Holds baud rate
        I       VAR BYTE
     
        ' 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=SW1/SW2 switch inputs (rfPIC board)
        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 = 0      ' Pull-ups on
     
        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 ' pins will be 0 only when buttons are pressed
         E_OUT=0         ' Disable transmitter
         INTCON.0 = 0    ' No buttons down, so clear int on change flag
         @ SLEEP         ' and start snoozin..zzzzzzzzzzz
         @ NOP           ' Do nothing for 1st instruction on wake-up
        ENDIF
       ' E_OUT=1          ' Enable transmitter (+ lights RFEN LED on demo board)
       ' PAUSEUS 25       ' Allow RF stage to stabilize
     
    ' Button pressed (or being held down), so keep going   
    ' Here is where you want to put the 5 second loop
    Delay:
    FOR I = 1 TO 5
        PAUSe 1000
    NEXT I 
    'Then check the buttons again
     IF (GPIO.3=1) AND (GPIO.4=1) THEN
    'Look for ENDIF near the end.  
    'If button are still pressed then it goes to ENCODE
    'If not, go back to MAIN and the INTERRUPT ON CHANGE will be reset
    Encode: 
    E_OUT=1          ' Enable transmitter (+ lights RFEN LED on demo board)
    PAUSEUS 25       ' Allow RF stage to stabilize 
        ' Only DAT_OUT bits 1 and 2 are used. We add a few 1's in bit
        ' positions 0,3,5,7 to balance out the data packet being sent.
        DAT_OUT = %10101001
        ' Get data on button inputs & invert 0's to 1's
        DAT_OUT.0[1]=~GPIO.3
        DAT_OUT.0[2]=~GPIO.4
        INTCON.0 = 0  ' Clear int on change flag
     
        ' Build checksum of 2 data bytes
        CHK_SUM = (DAT_OUT * 2)
     
    Transmit:
        SEROUT2 D_OUT,BAUD,[PreAmble,Synch,DAT_OUT,DAT_OUT,CHK_SUM]
        PAUSE GUARD ' 5mS guard time gives decoder time to respond,calculate,change,etc.
        ENDIF
        GOTO Main
     
        END
    This one does this:

    1/ Tx's the data after the button is continually held down for 5secs.

    2/ The RFEN led briefly flashes (after 5secs) if either button is pressed and released.

    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF & _BODEN_OFF & _PWRTE_ON
     
        ' With rfRXD0420 module installed in PICkit 1 board;
        ' SW1 toggles LED D6 on PICkit 1 board
        ' SW2 toggles LED D7 on PICkit 1 board
        DEFINE OSC 4
        DEFINE NO_CLRWDT 1
        DEFINE OSCCAL_1K 1
     
       ' ON INTERRUPT goto  Delay
     
        SYMBOL D_OUT = GPIO.2 ' RF serial data output
        SYMBOL E_OUT = GPIO.5 ' RF transmitter enable output
     
        DAT_OUT VAR BYTE    ' Holds 8-bit data byte
        LOOPS   VAR BYTE    ' Loop var
        CHK_SUM VAR BYTE    ' Holds calculated checksum of outbound data
        BAUD    VAR WORD    ' Holds baud rate
            I   VAR BYTE
     
             ' 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=SW1/SW2 switch inputs (rfPIC board)
        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 = 0      ' Pull-ups on
     
        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 ' pins will be 0 only when buttons are pressed
         E_OUT=0         ' Disable transmitter
         INTCON.0 = 0    ' No buttons down, so clear int on change flag
         @ SLEEP         ' and start snoozin..zzzzzzzzzzz
         @ NOP           ' Do nothing for 1st instruction on wake-up
        FOR I = 1 TO 5
         PAUSe 1000
         NEXT I 
        ENDIF
     
    'Then check the buttons again
     
     IF (GPIO.3=1) AND (GPIO.4=1) THEN Encode 'Button pressed & released But carry on)
     if (GPIO.3=0) OR  (GPIO.4=0) THEN        'Carry on to ENDIF & Tx DATA
     
    'Look for ENDIF near the end.  
    'If button are still pressed then it goes to ENCODE
    'If not, go back to MAIN and the INTERRUPT ON CHANGE will be reset
    Encode:
     E_OUT=1          ' Enable transmitter (+ lights RFEN LED on demo board)
        PAUSEUS 25       ' Allow RF stage to stabilize   
        ' Only DAT_OUT bits 1 and 2 are used. We add a few 1's in bit
        ' positions 0,3,5,7 to balance out the data packet being sent.
        DAT_OUT = %10101001
        ' Get data on button inputs & invert 0's to 1's
        DAT_OUT.0[1]=~GPIO.3
        DAT_OUT.0[2]=~GPIO.4
        INTCON.0 = 0  ' Clear int on change flag
     
        ' Build checksum of 2 data bytes
        CHK_SUM = (DAT_OUT * 2)
     
    Transmit:
        SEROUT2 D_OUT,BAUD,[PreAmble,Synch,DAT_OUT,DAT_OUT,CHK_SUM]   
        PAUSE GUARD ' 5mS guard time gives decoder time to respond,calculate,change,etc.
     
        ENDIF
        GOTO Main
     
        END
    Dave
    Last edited by LEDave; - 15th May 2011 at 10:46.

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    I started by looking at your first code:

    Code:
    'Then check the buttons again
     IF (GPIO.3=1) AND (GPIO.4=1) THEN
    'Look for ENDIF near the end.  
    'If button are still pressed then it goes to ENCODE
    'If not, go back to MAIN and the INTERRUPT ON CHANGE will be reset
    Encode: 
    E_OUT=1          ' Enable transmitter (+ lights RFEN LED on demo board)
    PAUSEUS 25       ' Allow RF stage to stabilize 
        ' Only DAT_OUT bits 1 and 2 are used. We add a few 1's in bit
        ' positions 0,3,5,7 to balance out the data packet being sent.
        DAT_OUT = %10101001
        ' Get data on button inputs & invert 0's to 1's
        DAT_OUT.0[1]=~GPIO.3
        DAT_OUT.0[2]=~GPIO.4
        INTCON.0 = 0  ' Clear int on change flag
     
        ' Build checksum of 2 data bytes
        CHK_SUM = (DAT_OUT * 2)
     
    Transmit:
        SEROUT2 D_OUT,BAUD,[PreAmble,Synch,DAT_OUT,DAT_OUT,CHK_SUM]
        PAUSE GUARD ' 5mS guard time gives decoder time to respond,calculate,change,etc.
        ENDIF
        GOTO Main
    If GPIO.3 and GPIO.4 are both 1, then neither are being pressed when pull-up resistors are used.


    Code:
    'If button are still pressed then it goes to ENCODE
    'If not, go back to MAIN and the INTERRUPT ON CHANGE will be reset
    I read these comments backwards to what the code does.


    Personally, the technique of using 1 for OFF and 0 for ON is extremely confusing; it makes trying to follow your code extremely difficult. I always use pull-down resistors and 0=OFF / 1=ON 'cause that's how binary works as well as power switches.

    EDIT: Unless it's a requirement for Sleep mode to have current ON, and the interruption signals Wake.

    Otherwise, if power consumption is an issue, I'd keep the line OFF, saving power, and only applying a bit of current to Wake.
    Last edited by Demon; - 15th May 2011 at 22:08.

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


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    Hi mackrackit / All

    In Bruce's oringinal code, the rfpic (if no buttons are pressed) goes to SLEEP until a button is pressed then Encodes & Tx's straight away.

    It seemed to me the data Tx is dependant on a button press occuring and staying pressed until the data is Tx'd. If a button is pressed then released the RFEN led flashes but no data is ever sent, hence our delay loop problem, the button is pressed then released by the time the loop has run the button press is history. The the only time data has ever Tx'd is when the button is actually pressed when the code gets to 'Transmit'.

    I added LOW GPIO.4 to simulate a button press (staying pressed) result: The rfpic Tx'd no problem after the delay loop had run.

    We now have a IOC that wakes up from sleep, then runs a delay loop, then Tx's the data. We've cracked it you cry.....hoorah! Well almost, problem is the rfpic locks into Tx mode (GPIO.4 is always low - Button is never released if you like).

    Figure a way of GPIO.4 back to 'normal' and we're there, any thoughts. Bear in mind though that GPIO.4 must be 'low' to make the rfpic Tx.

    Any ideas....?

    Code:
    Transmit:
    LOW GPIO.4
        SEROUT2 D_OUT,BAUD,[PreAmble,Synch,DAT_OUT,DAT_OUT,CHK_SUM]
        PAUSE GUARD ' 5mS guard time gives decoder time to respond,calculate,change,etc.
    Dave

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


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    Hi Demon

    I hear what you're saying. By the time this project is finished a lot of changes will have been made to the set-up.

    This is my first excursion into RF, with Tx - Rx programs that Bruce kindly posted up. Right now it's a learning curve for me.

    Dave

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


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    I think I've sent everyone on a wild Goose chase (sorry).

    Mackrackit's Tx code was working fine all along.

    I now think It's the Rx program that holds the key. The reason I think this is becasue Bruce's Rx program (as I understand it) looks to reset if no data recieved within 65ms of button press ( that's why the data only ever Tx'd with a button actually pressed). Any timing loop throws out the 65ms data arrival, hence no flahing led.

    I commented out a section of the Rx program and although not working perfectly, the Rx led now flashes after the time delay and data is sent.

    What do we think? Am I on to something here?

    Again apologies for the curved ball.

    Dave

  8. #8
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    Well thats good to know, Thanks Dave!! So does that me the Tx side is done? Do we get to see the Rx side to chew on for a bit?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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