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?
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?
What does not work about it? Wrong reading?
Dave
Always wear safety glasses while programming.
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.
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 " !!!
*****************************************
It's alright Alain, just gaze into your crystal ball and I'm sure you'll find all the answers![]()
![]()
... 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.
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
Bookmarks