Shop OBEX P1 Docs P2 Docs Learn Events
Activity #2 - What's A Microcontroller? — Parallax Forums

Activity #2 - What's A Microcontroller?

TheTech69TheTech69 Posts: 51
edited 2014-11-25 17:31 in BASIC Stamp
Is the RCTIME command to be ONLY used with potentiometers,humidity, and temperature sensors? I am trying to figure out how to use RCTIME with discrete passive components to get the same values as I got with the PBASIC coding in Activity #2. I tried inputting some of the coding from RCTIME into the coding from Activity #2 and measurements do take place; just not the same as with the original coding. The goal is to get the original coding in Activity #2 and the coding using RCTIME to have the same time constant decay values.

I am using BS2 on Board of Education Rev.c.

Thank you,
Jason

Comments

  • GenetixGenetix Posts: 1,749
    edited 2014-11-22 11:40
    RCTIME is commonly used to measure variable resistances such as potentiometers, thermistors, and photoresistors. The value will actually be in a range that will vary with temperature and from Stamp to Stamp. You can use the scaling techniques at the end of Chapter 5 of WAM to change the received values to whatever range you need,

    What exactly are you trying to do?
  • Mike GreenMike Green Posts: 23,101
    edited 2014-11-22 14:43
    The Basic Stamp Reference Manual chapter on the RCTIME statement goes into some detail on how it works. Essentially it charges or discharges a capacitor, then lets the capacitor discharge or charge (respectively) through a resistor and measures the amount of time it takes for the voltage on the capacitor to reach a threshold, usually 1/2 Vcc (about 2.5V). This threshold varies somewhat with temperature and from Stamp to Stamp as Genetix noted.

    The resistor is usually the unknown and supplied by the sensor. The capacitor can be the unknown with the resistor known. RCTIME can also be used to measure small voltages using known resistors. See the discussion at http://www.emesystems.com/stamp.html.
  • TheTech69TheTech69 Posts: 51
    edited 2014-11-22 16:23
    @Genetix- Activity #2 teaches how to determine RC time constant of a capacitor and a resistor using the variable timeCounter. I understand the variable can be almost any thing. The goal is to use the RCTIME command with the same circuitry called for in Activity #2 and get the same values as obtained from using the timeCounter variable and coding in Activity #2.

    I am trying to get the same values from the same circuitry using the two different coding methods. I use a stop watch with the original Activity #2 and the value I get on the stopwatch is not even close to what the Stamp measures. The difference between what I measure with a stop watch and what the Stamp measures is bugging me. I am curious as to why it is so far off. I thought RCTIME would be more accurate and closer to what I get with the stopwatch, but I am having difficulty getting the circuitry and coding to work together.

    Thank you both (Mr. Green, also) for assisting with this.
  • GenetixGenetix Posts: 1,749
    edited 2014-11-23 19:37
    A microcontroller has a response time that is 1000s of times faster than a human. Also the resolution, or smallest unit, between each method is vastly different. While RCTIME has a resolution of 2 us the best a stopwatch can do is only 1/100 of a second.
  • TheTech69TheTech69 Posts: 51
    edited 2014-11-25 08:32
    So how can I get the same values using RCTIME command that I did when using the coding in Activity #2? I can't get the RCTIME command to work with the circuitry called for in Activity #2.

    In addition, when I replace the .1 micro-farad capacitor with the 3300 micro-farad capacitor in Activity #3, there is no reading from the program.

    There are a few different ways to create a program and use different commands that will get the SAME RESULT; which is what I am trying to do here. I know RCTIME may be more efficient and quicker that using timeCounter = timeCounter +1, but I was still expecting to get the same time constant values. However, I didn't get the same values.

    The GOAL is to get the same values using the two different coded programs BUT using the same or slightly modified circuitry.

    Thank you.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-11-25 08:38
    TheTech69 wrote: »
    In addition, when I replace the .1 micro-farad capacitor with the 3300 micro-farad capacitor in Activity #3, there is no reading from the program. Thank you.

    That sounds about right. That huge capacitor will take a very long time to discharge compared with the 0.1 µF capacitor. A value like that is not practical for such an application and using RCTIME.
  • GenetixGenetix Posts: 1,749
    edited 2014-11-25 09:39
    On page 365 of the Basic Stamp Manual is a formula that gives the approximate number that RCTIME will return. Now understand that the biggest number the BS2 can handle is 65535.
    If we take the circuit on Page 145 of WAM 3.0 and plug in the capacitor value we get:
    RCTIME = 635 x R (in K) x C (in uF) = 635 x R (in K) x C (3300 uF) = 2,095,500 x R (in K)
    2,095,500 (0.47K) = 984,885 which is greater than 65535
    2,095,500 (1K) = 2,095,500 which is greater than 65535
    2,095,500 (2K) = 4,191,000 which is greater than 65535
    2,095,500 (10K) = 20,955,000 which is greater than 65535

    The capacitor is too large for RCTIME to use because the discharge time is longer than RCTIME can count.
    Using the same circuit on Page 151 of WAM 3.0:
    RCTIME = 635 x R (in K) x C (in uF) = 635 x (10K) x (0.1 uF) = 635, which is a lot smaller than 65535.

    Also note what it says at the bottom of page 363 of the Basic Stamp Manual:
    "If Pin remains in State longer than 65535 timing cycles RCTIME returns 0."

    http://www.parallax.com/sites/default/files/downloads/27218-Web-BASICStampManual-v2.2.pdf
  • TheTech69TheTech69 Posts: 51
    edited 2014-11-25 17:31
    OUTSTANDING! This is exactly the explanation I was looking for! Now I understand why it does work.

    Thank you very much!
Sign In or Register to comment.