Shop OBEX P1 Docs P2 Docs Learn Events
Please explain SimpleIDE rc_time function description in the Library documentation — Parallax Forums

Please explain SimpleIDE rc_time function description in the Library documentation

The SimpleTools Library documentation describes the rc_time function:
long rc_time ( int pin,
int state
)
Set I/O pin to input and measure the time it takes a signal to transition from a start state to the opposite state.

Named rc_time because it is often used to measure a resistor-capacitor circuit's tendency to "decay" to either ground or 5 V (depending on wiring). Default time increments are specified in 1 microsecond units. Unit size can be changed with a call to set_io_dt function. The pulse will be positive if the I/O pin is transmitting a low signal before the call.

Parameters
pin I/O pin number.
state Starting pin state.
Returns
Time from starting pin.

The specific phrase I don't understand is:
"decay" to either ground or 5 V

I think rc_time works by me specifying a pin and whether it is initially high or low. If high (3.3v) when rc_time is called, the voltage will decay and at 3.3v/2 the prop will read the pin as low. rc_time will return the time in usec.

If the pin is initially low (0v) the voltage will increase and at 3.3/2 volts the prop will read it as high, returning the time.

Where and how does the 5v in the quote come into play?

Thanks
Tom

Comments

  • Probably just a typo. I believe the rc_time function originally appeared in the Basic Stamp, where 0 and +5 are the power rails, and that description probably had carried over from the Stamp erroneously
Sign In or Register to comment.