Topic: Need Help With a Logarithmic Function |
|
---|---|
Author | Thread |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
![]() ![]() ![]() ![]() 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: |
![]() ![]() ![]() ![]() you might need to check resistors. they're awesome at it. |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
![]() ![]() ![]() ![]() 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 |
![]() ![]() ![]() ![]() 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: |
![]() ![]() ![]() ![]() Lin = Linear |
Maniac (V) Inmate From: San Antonio |
![]() ![]() ![]() ![]() 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 |
![]() ![]() ![]() ![]() OK, I think maybe the "degrees of rotation" in the graph I posted confused us both. |
Paranoid (IV) Inmate From: Madison, Indiana |
![]() ![]() ![]() ![]() Wes, code: . x^n y = -------------- (x-max) ^ n
|
Paranoid (IV) Mad Scientist From: Inside THE BOX |
![]() ![]() ![]() ![]() 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 |
![]() ![]() ![]() ![]() Haha! Never mind! |
Paranoid (IV) Inmate From: Paris, France |
![]() ![]() ![]() ![]() Now that's some twisted logic |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
![]() ![]() ![]() ![]() |