Q: using MCLR for Input on 12F683


Closed Thread
Results 1 to 40 of 47

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Red face One more thing

    Didn't know how to edit last post so:

    Use GPIO.# instead of PORTB.# per pg. 35 of data sheet.
    Louie

  2. #2
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    That should be PAUSEUS not PAUSES.
    PAUSEUS will pause microseconds, not milliseconds.
    If you let PBP devide 3 by 2 then you will always get 1 as an answer.
    So if you want to pause 1.5 milliseconds use PAUSEUS 1500 instead.

    happy new year

  3. #3
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Thanks LinkMtech and eggman (sounds like a TV show in the making!). I'll try your comments today.

    Happy new year to both of you.

    John.

  4. #4
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Thanks gents, both option worked like a charm.

    Cheers!

  5. #5
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    OK, anthor problem...

    I'm trying to run an RC servo from a PIC12F683. I'm using pin 0 as output and pin 1 as input (from receiver)

    As long as there is a signal from pin 1, the PULSOUT will output the PULSIN value. When no signal is present (PULSIN=0) then PULSOUT should go to a failsafe value.

    Situation: When the signal is present, the PULSOUT sends the PULSIN value, but when PULSIN = 0, the PULSOUT does send the proper value, but in 1/2 second intervals (it pulses the value about every 0.5 sec). I can't figure out why!!!

    here's the code:


    oSCCON = %01100000 ' Ocs set to 4 MHz
    TRISIO = %00000000 ' Set all ports to outputs, in this example
    CMCON0 = 7 ' Analog comparators off
    ANSEL = 0 ' Analog select set to digital, pg 69 data
    ADCON0 = 0 ' A/D turned OFF, pg 68 of data


    cont var word
    failsafe var word
    posoutput var word
    posinput var word
    usefailsafe var byte
    pausetime var word



    low gpio.0
    low gpio.1
    low gpio.2
    low gpio.3

    failsafe=80
    pausetime=10

    START:

    ;pulsout portb.4, failsafe
    ;pause 50
    ;goto start


    GETSIGNAL:

    pulsin gpio.1,1,posoutput

    if posoutput=0 then goto runfailsafe
    goto runnormal

    runfailsafe:
    pulsout gpio.0, failsafe
    pause pausetime
    goto getsignal

    runnormal:
    pulsout gpio.0, posoutput
    pause pausetime

    goto getsignal

  6. #6
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    I have one more...

    I want to write the PULSIN value to the memory on the 12F683 (and have it stored even when the power is off) and recall it in the event there is no PULSIN signal.

    What are the proper commands to do this?

    (I assume write and read)

    I.e.

    WRITE 5, failsafe

    READ 5, failsafe

    ...but first I have to get the servo thing working!!

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


    Did you find this post helpful? Yes | No

    Default

    This may help with your data storage.
    The below code is for a counter, sort of like an odometer. It saves the value to EEPROM at each hit of a switch. When the device is turned on the EEPROM is read and the values placed back into a variable for continued use. Also has the ability to reset the stored values back to zero at start up.

    Pick through it and see if it helps.
    Code:
    '*  Notes   :16F877A                                
    '*   SAVE TO EEPROM                                         
    '****************************************************************
     '_config _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF &_BODEN_OFF
    
    DEFINE OSC 20
    
    DEFINE LCD_DREG     PORTB
    define LCD_DBIT     4
    DEFINE LCD_RSREG    PORTB
    DEFINE LCD_RSBIT    1
    DEFINE LCD_EREG     PORTB
    DEFINE LCD_EBIT     0
    DEFINE LCD_BITS     4
    DEFINE LCD_LINES    2
    DEFINE LCD_COMMANDUS    2000
    DEFINE LCD_DATAUS   50
    
    TRISA = %00000000
    ADCON1=14
    
    Asm
        ERRORLEVEL -306
    Endasm
    include "modedefs.bas"
    
    
    'TOTAL VARS
    O	VAR	BYTE	'ONES
    T	VAR	BYTE	'TENS
    H	VAR	BYTE	'HUNDREDS
    TH	VAR	BYTE	'THOUSANDS
    TTH	VAR	BYTE	'TEN THOUSANDS
    HTH	VAR	BYTE	'HUNDRED THOUSANDS
    M	VAR	BYTE	'MILLIONS
    
    OD	VAR	BYTE	'ONES
    TD	VAR	BYTE	'TENS
    HD	VAR	BYTE	'HUNDREDS
    THD	VAR	BYTE	'THOUSANDS
    TTHD	VAR	BYTE	'TEN THOUSANDS
    HTHD	VAR	BYTE	'HUNDRED THOUSANDS
    MD	VAR	BYTE	'MILLIONS
    
    'TOTAL LOGS
    O_LOG	VAR	BYTE	'ONES
    T_LOG	VAR	BYTE	'TENS
    H_LOG	VAR	BYTE	'HUNDREDS
    TH_LOG	VAR	BYTE	'THOUSANDS
    TTH_LOG	VAR	BYTE	'TEN THOUSANDS
    HTH_LOG	VAR	BYTE	'HUNDRED THOUSANDS
    M_LOG	VAR	BYTE	'MILLIONS
    
    'READ LOGS
    READ O_LOG, OD
    READ T_LOG, TD
    READ H_LOG, HD
    READ TH_LOG, THD
    READ TTH_LOG, TTHD
    READ HTH_LOG, HTHD
    READ M_LOG, MD
    
    
    NUM	VAR	BYTE
    NUM = 0
    pause 1000
    
    CHECK:
    IF PORTE.2 = 1 THEN GOSUB CL_LOG 'FOR RESET AT START UP
    IF PORTE.2 = 0 THEN START
    GOTO CHECK
    
    START:
    HIGH PORTD.2      'LED
    PAUSE 5
    IF PORTD.3 = 1 THEN GOSUB C_P_T  'SWITCH FOR PARTS
    LOW PORTD.2
    PAUSE 5
    GOTO START
    
    C_P_T:
    LCDOUT $FE,1,"C TEST"
    LCDOUT $FE,$C0,DEC MD,DEC HTHD,DEC TTHD,DEC THD,DEC HD,DEC TD,DEC OD
    O = O + 1
    IF O = 10 THEN
    O = 1
    T = T + 1
    	IF T = 10 THEN
    	T = 0
    	H = H + 1
    		IF H = 10 THEN
    		H = 0
    		TH = TH + 1
    			IF TH = 10 THEN
    			TH = 0
    			TTH = TTH + 1
    				IF TTH = 10 THEN
    				TTH = 0
    				HTH = HTH +1
    					IF HTH = 10 THEN
    					HTH = 0
    					M = M +1
    					ENDIF
    				ENDIF
    			ENDIF
    		ENDIF
    	ENDIF
    ENDIF
    
    WRITE O_LOG, O
    WRITE T_LOG, T
    WRITE H_LOG, H
    WRITE TH_LOG, TH
    WRITE TTH_LOG, TTH
    WRITE HTH_LOG, HTH
    WRITE M_LOG, M
    
    READ O_LOG, OD
    READ T_LOG, TD
    READ H_LOG, HD
    READ TH_LOG, THD
    READ TTH_LOG, TTHD
    READ HTH_LOG, HTHD
    READ M_LOG, MD
    
    RETURN
    
    CL_LOG:
    
    HIGH PORTD.2
    PAUSE 100
    LOW PORTD.2
    PAUSE 100
    
    O = $0
    T = $0
    H = $0
    TH = $0
    TTH = $0
    HTH = $0
    M = $0
    
    WRITE O_LOG, O
    READ O_LOG, OD
    WRITE T_LOG, T
    READ T_LOG, TD
    WRITE H_LOG, H
    READ H_LOG, HD
    WRITE TH_LOG, TH
    READ TH_LOG, THD
    WRITE TTH_LOG, TTH
    READ TTH_LOG, TTHD
    WRITE HTH_LOG, HTH
    READ HTH_LOG, HTHD
    WRITE M_LOG, M
    READ M_LOG, MD
    RETURN
    
    END
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. How to MCLR by code for 16F877
    By fbestepe in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 26th November 2014, 01:51
  2. 12F683 - Pin1 not working
    By ruijc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th February 2014, 18:38
  3. 16f677a to 12f683
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th July 2007, 07:16
  4. What does this MCLR instruction mean?
    By bartman in forum General
    Replies: 16
    Last Post: - 30th November 2004, 01:32
  5. I/O pin and MCLR
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 1
    Last Post: - 15th July 2004, 11:52

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