Shop OBEX P1 Docs P2 Docs Learn Events
Potentiometer rctime? — Parallax Forums

Potentiometer rctime?

johnprokojohnproko Posts: 121
edited 2015-11-26 13:58 in Accessories
I want to get a result depending where the potentiometer is.
yet i get a value up to a point and then 0s. it is a 10k. as see in the picture i get a value from the start and counterclockwise almost up to half.
any ideas?[img][/img]
the code is a simple rctime for the BS2
r var word
do
high 7
pause 1
rctime 7, 1, r
debug home, cls, dec5 r
pause 100
loop.

3264 x 1840 - 2M

Comments

  • RCT is achieved by using the microcontroller's pin to charge the cap, and measure the time it takes to discharge. It looks like your trying to use potentiometer circuit ment for ADC, voltage measurement.
  • Mike GreenMike Green Posts: 23,101
    edited 2015-11-26 15:12
    Please read the chapter on the RCTIME statement in the Basic Stamp Syntax and Reference Manual (downloadable here). It discusses in some detail how to use the RCTIME statement. There's also a good discussion at the EmeSystems website (use Basic Stamp link).

    You're not going to be able to get useful readings over the whole range of the pot. You can do better by having several capacitors and switching the additional capacitors in and out of the RC circuit under control of the Stamp. You can also restrict the motion of the pot to a smaller range.
  • "If pin remains in state longer than 65535 timing cycles RCTIME returns 0". Try a smaller C or R or both.
  • ercoerco Posts: 20,256
    edited 2015-11-28 14:27
    Is it a lower resistance limit below which rctime doesn't work? If so, add a fixed resistor of that value in series with your pot.

    Edit: Tomcrawford nailed it, ignore my ramblings.
  • Doesnt take anythign of that.
    Use the middle pin for the pin connction and one of the others for the ground.
    Connect a simple capacitor between them and that is all.
    depending on which outer pin you connect the ground will work for the starting point.
    the values are in all the spectrum of the potentiometer and will go (for mine at least) from 1 to 60.
  • You are absolutely correct. Connecting the pot between +5 and ground (see the red wire in the photo) makes a whole different circuit. When the pot gets past half way, RCTIME will definitely time out and return zero.
  • No i get i reading in all the spectrum of the movement of the pot.
    It goes from 1 to 60 this allows the user to make ratios for usage with other items such as leds. Motors need a smaller total resistor. If you use too much then it will work for only a small movement of the pot.
  • GenetixGenetix Posts: 1,754
    edited 2015-12-13 22:54
    johnproko wrote: »
    No i get i reading in all the spectrum of the movement of the pot.
    It goes from 1 to 60 this allows the user to make ratios for usage with other items such as leds. Motors need a smaller total resistor. If you use too much then it will work for only a small movement of the pot.

    Have you looked at Activity #4 in Chapter 5 of What's a Micrcontroller? (page 156); It shows how to Scale the potentiometer value for a Servo.
    Activity #3 (page 150) also shows how the capacitor value affects the range of RCTIME values that are returned.
    https://www.parallax.com/sites/default/files/downloads/28123-Whats-a-Micro-v3.0.pdf
Sign In or Register to comment.