RCTIME question


Closed Thread
Results 1 to 8 of 8

Thread: RCTIME question

  1. #1
    Join Date
    Nov 2010
    Posts
    12

    Default RCTIME question

    so this works in pbp
    LOW portb.6
    LOW portb.5
    PAUSE 10
    RCTIME portb.5,0,dtime

    but this doesn't
    LOW portb.5
    LOW portb.6
    PAUSE 10
    RCTIME portb.5,0,dtime

    any thoughts?

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


    Did you find this post helpful? Yes | No

    Default

    What does not work about it? Wrong reading?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Nov 2010
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    The cap never charges and results count of 1. With the first snippet it works and I get the count of 350 with the rc connected per the book. I can just use the first method but wondered if anyone else had the happen and what made the code do that.

    When I was first saw this I was trying to see if I could use a single cap and different pins to connect multiple resistors and measure them that way. I was getting a count of 1 no matter the resistor. Then I reorder the code and it seemed to work. I got different values then a direct connection to VDD though. I am guessing the pins output must not go quite to vdd or something else in the pic does something to the rc circuit. (I was using opposite logic HIGHportb.6) not low but either way it didnt' seem to make any diffence. still got count of 1

    I still want to try and do this, maybe use outputs setting reed relays to connect the resistors between the rctime pin and vdd, or just do some math to adjust the results for the offsets if they stay consistant.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default

    Hi, Scootie

    First thought ...

    WHICH Pic are you using

    Second thought ...

    Your FULL program ( " copied and pasted " - not re-written - ) would be useful here

    Third Thought ...

    a nice FULL SCHEME would be interesting to verify everything

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    It's alright Alain, just gaze into your crystal ball and I'm sure you'll find all the answers

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Scootie

    First thought ...

    WHICH Pic are you using

    Second thought ...

    Your FULL program ( " copied and pasted " - not re-written - ) would be useful here

    Third Thought ...

    a nice FULL SCHEME would be interesting to verify everything

    Alain
    ... and what crystal you are using???

    From the manual


    RCTIME may be used to read a potentiometer (or some other resistive
    device). Resistance can be measured by discharging and timing the
    charge (or vice versa) of a capacitor through the resistor (typically 5K to
    50K).

    The resolution of RCTIME is dependent upon the oscillator frequency. If
    a 4MHz oscillator is used, the time in state is returned in 10us
    increments. If a 20MHz oscillator is used, the time in state will have a
    2us resolution. Defining an OSC value has no effect on RCTIME. The
    resolution always changes with the actual oscillator speed.

  7. #7
    Join Date
    Nov 2010
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Hopefully these code tags show up properly and this is the place to paste the code, I am new at this
    Code:
    ' Name        : dtime.pbp
    ' Compiler    : PICBASIC PRO Compiler 2.60
    ' Assembler   : PM or MPASM
    ' Target PIC  : 40-pin 16F887
    ' Hardware    : Lab-X1
    ' Oscillator  : 20MHz external crystal
    
    'set device type
    'fl pic16f887
    
    ' Define LCD registers and bits
    DEFINE  LCD_DREG  PORTD
    Define  LCD_DBIT  4
    Define  LCD_RSREG PORTE
    Define  LCD_RSBIT 0
    Define  LCD_EREG  PORTE
    Define  LCD_EBIT  1
    
    ANSEL = %00000001      ' Set AN0-AN7 to digital with the exeption of AN0
    ANSELH = %00000000     ' Set AN8 and higher channels to digital operation
    '**********************************************************
    
    dtime VAR WORD
    res1 VAR WORD
    res2 VAR WORD
    res3 VAR WORD
    
    'Set up cap = 2uf pin b.5 to VDD
    'nom resistance b.5-b.6 350ohm
    'nom resistance b.5-b.4 5ohm
    
    'TRISA = %11111111             ' Set PORTA to all input
      Low PORTE.2                   ' LCD R/W line low (W)
      PAUSE 500                     ' Wait .5 second
    
    mainloop:
    'measure strain gage resistance
    
    TRISB.6 = 0
    TRISB.4 = 1
    HIGH portb.6
    LOW portb.5
    PAUSE 10
    RCTIME portb.5,0,dtime
    res1 = ((dtime*175)/10)
    
    'measure wiring resistance loop
    TRISB.6 = 1
    TRISB.4 = 0
    HIGH portb.4
    LOW portb.5
    PAUSE 10
    RCTIME portb.5,0,dtime
    res2 = ((dtime*175)/10)
    res3 = res1-res2
    
     LCDOUT $fe, 1                 ' Clear LCD
      LCDOUT "Raw ", DEC res1 ' Display value R1
     LCDOUT $fe, $88
      LCDOUT "Wirie ", DEC res2 ' Display value R2
     LCDOUT $fe, $c0
      LCDOUT "Gage ", DEC res3 ' Display value R3  PAUSE 1000                     ' Wait 1 second
    
      GOTO mainloop
      End

  8. #8
    Join Date
    Nov 2010
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    I figured out that when I put in another pause my origional problem went away and it didn't matter what order the outputs were set in. Still don't know why though

    Also changed the port bits because the others caused a porblem with the programmer left plugged into the x1 board

    I need a larger (but stable) capacitor than the 2uf I am using now. The count is so low that I don't get the tolerance I need, each step is about 17.5 ohms and I would like to have about 1.0 ohm resolution if possible. My parts drawers don't have any good choices though.

    Code:
    TRISB.0 = 0
    TRISB.2 = 1
    HIGH portb.0
    PAUSE 10
    LOW portb.1
    PAUSE 10
    RCTIME portb.1,0,dtime

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