Welcome to the Parallax Discussion Forums, sign-up to participate.

# Potentiometer rctime?

Posts: 121
edited 2015-11-26 - 13:58:36
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.

• Posts: 2,176
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.
• Posts: 23,000
edited 2015-11-26 - 15:12:27
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.
• Posts: 1,079
"If pin remains in state longer than 65535 timing cycles RCTIME returns 0". Try a smaller C or R or both.
• Posts: 19,697
edited 2015-11-28 - 14:27:49
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.
• Posts: 121
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.
• Posts: 1,079
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.
• Posts: 121
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.
• Posts: 1,471
edited 2015-12-13 - 22:54:15
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.