Topic: Need Help With a Logarithmic Function (Page 1 of 1) |
|
---|---|
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 08-30-2009 01:47
I have an interesting problem I was hoping some of the math/scripting gurus here could help me out with. code: speedDelayMax = 1200; // Maximum delay in milliseconds float calcSpeedDelay(int potLevel) { speedLevel = speedPotLevel / 1023.0; // Convert the pot reading to a percentage speedDelay = speedLevel * speedDelayMax; // Determine milliseconds of delay return speedDelay; }
|
Obsessive-Compulsive (I) Inmate From: |
posted 08-30-2009 05:36
you might need to check resistors. they're awesome at it. |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 08-30-2009 06:27
Actually, I just came back to stop anyone from putting a lot of effort into this, because I just discovered a technique I believe is called shunting that might make a linear pot do what I want with the addition of the right resistor. It's the kind of alternative I've been looking for, but I didn't know what it was called. |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 08-30-2009 07:27
OK, never mind. The hardware solution does not give me the result I want. It may work OK for an audio application, but not for this. All it does is clip one end of the output, which makes the other end seem more sensitive. But from my point of view, all it does is give me a reading of, for example, 92-0. This means I have to increase speedDelayMax to make up for the lost time and I just end up with the same end effect. |
Maniac (V) Mad Scientist From: |
posted 08-30-2009 08:26
Lin = Linear |
Maniac (V) Inmate From: San Antonio |
posted 09-02-2009 22:35
Maybe I'm missing something here (it has been awhile since I've taken a class or dealt with anything more complicated than converting degrees to rads), but the purple line looks pretty close to y = log(x). Stretch it, skew it, and translate it some and you should be able to get something close to it I would think. |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 09-09-2009 09:08
OK, I think maybe the "degrees of rotation" in the graph I posted confused us both. |
Paranoid (IV) Inmate From: Madison, Indiana |
posted 09-09-2009 18:11
Wes, code: . x^n y = -------------- (x-max) ^ n
|
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 09-11-2009 05:24
OK, I've been working on this for the past hour and I'm still clueless and frustrated, probably because I'm not exactly sure what max is supposed to be. |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 09-11-2009 06:16
Haha! Never mind! |
Paranoid (IV) Inmate From: Paris, France |
posted 09-16-2009 17:43
Now that's some twisted logic |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 09-17-2009 06:39 |