Potentiometer rctime?

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

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: 22,904
    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.
  • "If pin remains in state longer than 65535 timing cycles RCTIME returns 0". Try a smaller C or R or both.
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
  • ercoerco Posts: 19,484
    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.
    "When you make a thing, a thing that is new, it is so complicated making it that it is bound to be ugly. But those that make it after you, they don’t have to worry about making it. And they can make it pretty, and so everybody can like it when others make it after you."

    - Pablo Picasso
  • 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.
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
  • 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,411
    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.
    https://www.parallax.com/sites/default/files/downloads/28123-Whats-a-Micro-v3.0.pdf
Sign In or Register to comment.