Shop OBEX P1 Docs P2 Docs Learn Events
Measuring Resistance — Parallax Forums

Measuring Resistance

JBWolfJBWolf Posts: 405
edited 2013-01-06 14:28 in Propeller 1
I am working with the 2-axis joystick (part #27800) and having a little trouble getting reliable readings.
The SPIN object from the product page uses RCTIME.SPIN to measure the decay of a capacitor connected to the joystick.
I have tried it with several capacitors (1nf, .1uf & 10uf) and the recommended 220ohm resistors but get odd results with all.

First, I connected an ohmmeter to the 'UD' pins and moved the joystick up and down... I get a good transition from 30ohms full up and around 3kohm full right.
I also did the same with the 'LR' pins and got the same type of results... this was just a standalone test with the joystick isolated on a breadboard.

Using the spin object from the product page, the one that uses rctime, I do not get a good transition for either LR or UD.
The way I believe it is supposed to act is lowest value is full left and highest is full right.... instead I get a very high value in one direction leading down, and the other direction I get a lower value leading up.
So for example at rest, LR will read about 1600 (displayed in PST). Pushing the joystick right makes LR increase from 1600 linearly until it maxes at about 3000... but if I go left (from at rest (1600)) it will immediately jump to 6000 and then decrease until it reaches minimum at about 200. I cannot use these results for positioning as now there are 2 different positions that have the same value.

I need to figure out a way to get useable results.
Since I get good values with an ohmmeter I was hoping I could use one or two pins on the prop to measure resistance.
Is there a simple way to measure resistance? If not, what do you guys suggest?
Thanks,
J

Comments

  • MJBMJB Posts: 1,235
    edited 2013-01-05 00:57
    http://forums.parallax.com/showthread.php/141459-RCTIME-resistor-value?highlight=RCTIME

    http://forums.parallax.com/showthread.php/144037-RC-Time-Circuit?highlight=RCTIME

    I don`t know the RCTIME Object - have you calculated the expected time constant T = 0.7 * R * C to check if this makes sense with the objects timing parameters?

    30 Ohms to 3k Ohms is a factor of 100 !!
    Maybe you need a series resistor - 1k to 3k to get it into a smaller range which you can handle with one single C value.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2013-01-05 03:02
    Perhaps consider putting the two axis into a dual 555 osc and select te cap and other resistor valu to give you a frequency proportional to position of the joystick. Once you decide the freq range use one counter for each axis to determine the pulse time of a cycle. Let the desired resolution determine the counter frequency, and use say waitpeq in_pin,in_pin to enable count-up when pulse is high, then read count and perform calcs to figure position from number of pulses during high time.

    Another way, feed pots to ADC and figure position from ADC value from 0 to say vref w/ vref also being supplied to the pits of the joy stick. 12 bit would give you 4096 count range, w/ Vref/4096 the smallest resolvable value.

    A very costly way would be feed the pot output to a comparator, feed a DAC to the comparator and have the prop step up the DAC outputs while watching for the comparator output to flip indicating digital valeue of the input. Digital ramp method.

    I also have not played with rc time, but if it is sigma-delta based, there are problems with that method related to layout and other issues especially on a bread board. Memory weak onthis, but google is my navigator.

    Lots of ways, play and have fun.

    Frank
  • Mike GMike G Posts: 2,702
    edited 2013-01-05 07:37
    JDWolf, please read PE Kit Tools: Measure Resistance and Capacitance. This tutorial will answer your questions.
  • JBWolfJBWolf Posts: 405
    edited 2013-01-05 09:57
    30 ohms to 3k ohms is the natural resistance of the potentiometer inside the joystick. Thats literally connecting one axis directly to a multimeter, setting to ohms and then adjusting the joystick axis from minimum to maximum distance.

    The PEkit is where I started, RCTIME does not work like it should with the joystick added in as the potentiometer.
    I just tried again using .1uf caps and 100ohm resistors instead of 220. Same type of results, at rest it reads 16k.... going left it jumps to 90k then reduces to a minimum of 500... going the other way (right) goes up from 16k (rest) to about 35k maximum..... so once again I have 2 positions with the same value.

    using 1k instead of 100 or 220ohm simply scales the results. So Im getting a left range of 9k to 500, and a right range of 1.6k to 3.5k
  • frank freedmanfrank freedman Posts: 1,983
    edited 2013-01-05 11:55
    Try the mcp3201 (or 3202 single channel differential mode if noisy environment) use the same supply for Vref to the chip Vref and the high side of the pot. Center to input of ADC; do this in spin if it's easier. Run the output into the prop via series resistor if using 5V for Vcc. Put the digitized values out through the prop term/fd serial object or whatever. You should see a smooth progression from 0 - about 4096 or the hex equivalent. If the values have jumps or non-linearities the pot may have an issue, see what another would do. 'course it would not be to likely to have both pots on on a joystick to exhibit the same failure mode. It may be interesting to see how this may work with an old 4*4" touch screen panel.

    Just an alternate idea to try,

    Frank


    Just tested one of my controllers, range was about 290 to 9.2k with ~5k center position.
  • ctwardellctwardell Posts: 1,716
    edited 2013-01-05 13:43
    Have you tried this tutorial:

    http://learn.parallax.com/KickStart/27800

    C.W.
  • JBWolfJBWolf Posts: 405
    edited 2013-01-05 14:47
    Frank: I havent looked up that part yet but I'm assuming its a mosfet... I would definitely like to use a mosfet but unfortunately will not have any cash in my paypal account for a few weeks.
    ctw: yes that is the exact tutorial I followed on my first attempt.
  • ctwardellctwardell Posts: 1,716
    edited 2013-01-05 14:56
    JBWolf,

    The 30 ohm to 3K measurement does not sound correct, that Joystick is supposed to have 10k pots.

    Are you sure you had nothing else connected and measured resistance from GND to U/D for up/down and from GND to R/L for left/right?

    C.W.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2013-01-05 16:21
    The mcp3201/2 is a 12 bit Analog to Digital Converter. The 01 is a single input withexternal Vref input, the 02 part has two inputs that can be used independently or as a single differential input with internal Vref.

    Looking at C.W.s post, it maybe worth checking your device connections against the part schematic. I have noticed that you will not get the full range of the pot as the mechanics will limit the pot to a fairly narrow range. Forgot about testing this a while back. To get the full range of output from the adc, you may need to scale/amplify the input to the ADC.

    Frank
  • jmgjmg Posts: 15,173
    edited 2013-01-05 18:18
    JBWolf wrote: »
    So for example at rest, LR will read about 1600 (displayed in PST). Pushing the joystick right makes LR increase from 1600 linearly until it maxes at about 3000... but if I go left (from at rest (1600)) it will immediately jump to 6000 and then decrease until it reaches minimum at about 200. I cannot use these results for positioning as now there are 2 different positions that have the same value.

    Do you have a scope to sanity check this ?

    You could also try a 74HCT4538 Dual Monostable, which has proper charge and discharge management, and use that as a 'gold standard' while you experiment with doing the same thing, via prop pins.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2013-01-06 00:09
    Is the resistance from the Prop pin to the capacitor, which is connected to the ground end of the chain? I was wondering if there is some interaction between your hand and the Prop pin. If that is the case then setting the JS to a position and then letting go of it should show consistant(ish) readings.

    How much are the readings varying ? Some quantization errors are bound to happen.

    Alan
  • MJBMJB Posts: 1,235
    edited 2013-01-06 03:41
    can you give a complete schematic of how you set it up?
    together with the results of your OHM-meter
  • ctwardellctwardell Posts: 1,716
    edited 2013-01-06 14:28
    I grabbed one of these joysticks at the local Radio Shack.
    It took a while to find it as they are in regular Radio Shack packaging with the other Radio Shack switches.

    I haven't tried using it with my quickstart yet but I did check the resistance values:

    UP (9.05k ohms) - MIDDLE (4.67k ohms) - DOWN (9 ohms)

    LEFT (6.5 ohms) - MIDDLE (4.86k ohms) - RIGHT (9.77k ohms)

    C.W.
Sign In or Register to comment.