Shop OBEX P1 Docs P2 Docs Learn Events
Looking for some math...is this even possible? — Parallax Forums

Looking for some math...is this even possible?

Bobb FwedBobb Fwed Posts: 1,119
edited 2011-10-26 16:30 in General Discussion
I am creating a four resistor digital rheostat. With a combination of the four resistors, I can create up to 15 different resistance values (or 16, if you include no connectivity -- infinite resistance).

So the math I am looking for, is to create a somewhat linear line of values between the 15 different resistances. It doesn't have to be perfect, but somewhat close. I would like to specify a minimum resistance value (always above 0), a maximum value (always the value of the highest single resistor), and the 13 values in between, I'd like somewhat evenly spaced between. Is this even possible?

An example: if the four resistors are: 4500,3400,2300,1200; we get these resistances: 560,640,671,741,789,887,947,1051,1200,1372,1522,1937,2300,3400,4500. Not very linear, but somewhat logarithmic, which might work anyway.

Any help would be awesome.

Comments

  • Dave HeinDave Hein Posts: 6,347
    edited 2011-10-24 13:56
    If the resistors are connected in series you would just use values of R, 2R, 4R and 8R. The various combinations would give you values from R to 15R, and you could get zero with a direct connection.

    If the resistors are in parallel you would be summing up the conductances instead. The resistance would be the inverse, and you wouldn't be able to get a linear progression of resistances.
  • Mike GMike G Posts: 2,702
    edited 2011-10-24 14:02
    Not sure if I follow but f(x)= [high value] - [low value] / 13. Then [low value], [low value+f(x)], [low value + 2f(x)], ...

    The next thing would be to iterate over the array and find the closest match to 3400 and 2300, save the close match index and replaced.

    Or is this series and parallel calcs?

    Edit: after looking at the 560 value it looks like you want parallel calculations? It that case you just drop the 4 values in an array the execute the various calculation combinations. Store each value in an array. Then execute a bubble sort of you need the values in order.
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2011-10-24 14:17
    Series resistor connections would only give you 4 resistances for 4 resistors (unless you had transistors to allow you to "hop" resistors in the series).

    The design I have is simpler (I think). There are only 4 transistors, and they are wired in series to resistors. The resistor/transistor pairs are wired in parallel to the other pairs.

    wiring.jpg


    I'm going to write a program to brute force a solution, it won't be elegant or fast, but I think it can get me a reasonable result.
    1006 x 535 - 35K
  • ctwardellctwardell Posts: 1,716
    edited 2011-10-24 14:39
    Bobb Fwed wrote: »
    Series resistor connections would only give you 4 resistances for 4 resistors (unless you had transistors to allow you to "hop" resistors in the series).

    Like David said four resistors in series that could be shorted individually would give you 16 values, one being very low. Think through 1, 2, 4, and 8 ohms in series with each resistor being able to be shorted.

    All shorted but the 1 ohm, you have 1 ohm.

    All shorted but the 2 ohm, you have 2 ohms.

    All shorted but 1 and 2, you have 3 ohms.

    All shorted but 4 ohms, you have 4 ohms, and so on.

    C.W.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-24 14:41
    If you drove the gates with photovoltaic optoisolators, you wire the MOSFETs in series with each other and use the R, 2R, 4R ..., scheme.

    Another thought: there might be a variation of the R-2R ladder network that would work here, too.

    -Phil
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2011-10-24 15:13
    Ah, I wasn't thinking about it correctly....like this then? (I know it's a bit messy with the combined MOSFET ICs)

    wiring.jpg
    906 x 603 - 36K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-24 15:25
    Yes, but if you do it that way, you have to have the outputs of your photovoltaic optoisolators connected between the gate and source of each MOSFET.

    -Phil
  • BitsBits Posts: 414
    edited 2011-10-25 17:06
    Why not just use one FET to accomplish your entire array of resistors?

    A FET can be a variable resistor, true it’s non-linear, but may be worth a look over. I have used multiple FETs to increase resolution and bring additional linear qualities to the design.
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2011-10-26 09:23
    The non-linearity of it, hurts it as a prospect in my current application. Also, I'm guessing that you use a constant PWM to maintain a desired resistance? Or you could get fancy and use some type of sample-and-hold circuitry. But I think either way, it would likely exhaust too many IOs (I've got to have 12 --maybe more-- of these). I was planning on driving the MOSFET gates through a shift register, then through a FET driver (the driver is their either way), but running PWM through a shift register seems a bit iffy.
    I've done the MOSFET-as-a-resistor method before, as well, but I only needed one, and it didn't need to maintain a constant resistance.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-26 09:38
    Bobb, is there any reason you can't just use a programmable potentiometer?

    -Phil
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2011-10-26 10:21
    The voltage (9+ V) and current (500+ mA) requirements. Guess I should have mentioned it earlier, but yes, this thread and this one: http://forums.parallax.com/showthread.php?135326-Looking-for-an-IC-(that-hopefully-exists)-but-I-don-t-know-what-it-s-called .
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-26 10:30
    What are you driving? Is it necessarily a variable resistance that you're after, or a controllable current?

    -Phil
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2011-10-26 10:36
    Variable resistance. I am replacing a manual potentiometer (wired as a rheostat).
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-26 10:45
    This is like pulling teeth. :) Does the rheostat control a ground-referenced load, or ... ?

    -Phil
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2011-10-26 11:14
    lol. Sorry, I'm not trying to be difficult, or thick :-P .. also this being in two different threads is showing to be a bad idea. Originally I figured it as two different questions, but I guess they are too closely related to have done that.

    I kind of mentioned this in the other thread, but in less detail: one side of the rheostat is a pulsing source (of sorts) at up to 9.5V (with respect to ground). The other side is referencing ground, but not directly, so it could be as high as 1.5V (with respect to ground) but will likely be closer to 0.5V.
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-10-26 11:37
    It seems like it would be possible to use a transitor controlled by an op-amp as a variable resistor. There must be a circuit on the internet that does something like this. The amount of resistance that the transistor would emulate would just be a function of the control voltage. Maybe someone on the forum is familiar with a circuit like this.
  • ctwardellctwardell Posts: 1,716
    edited 2011-10-26 11:52
    Do you really need rheostat behavior? Can't you just use PWM?

    I don't think you have mentioned what the actual load will be, maybe you can't say, but it would be easier to suggest solutions if we had more info.

    C.W.
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2011-10-26 12:25
    Because I'm replacing a rheostat pot, I can't use PWM. The current over the circuit is a function of the input voltage, and the voltage change is fairly fast (a few kHz). And moreover, I am attempting to match (specifications-wise) an existing component, and altering something like the function of the rheostat, could affect a much larger part of the device.

    I want it to be able to handle up to 500mA, but more likely it will be about half that.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-10-26 15:53
    There's some motor controller with a 5K pot that people keep inquiring about whether they can replace with a 10K "digipot" because there isn't a 5K "digipot".
    Is this (or this) related to such a thing?
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2011-10-26 16:30
    No motors involved. This is a small part of a custom industrial controller or PLC or something, I doubt it really has a name.
Sign In or Register to comment.