RCTIME question


Closed Thread
Results 1 to 8 of 8

Thread: RCTIME question

Hybrid View

  1. #1
    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

  2. #2
    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 : 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