If I set 'A' at 100 and set 'B' at 200. How do I make a adc input 'C' with full range (0 -255) work at full range between A & B? Then if I Change 'B' to 150, C still need to operate at full rang , but between A & B.
C is a pot opperating between 0-5V.
I can achieve this through hardware, but would like to downsize on components.
Cheers
JOHN
Mathimatical question
Moderator: Benj
- Dan81
- Valued Contributor
- Posts: 268
- Joined: Sun Jan 15, 2006 4:07 pm
- Location: Albi France
- Been thanked: 60 times
- Contact:
Re: Mathimatical question
Hello John
If I understand your question :
D=B when C=255 and D=A when C=0.
D = (((B-A)*C)/255) + A ; D must be an integer.
Be careful with the brakets or accuracy will be lost
If it is not the right answer : sorry ,i will remove it .
Daniel
If I understand your question :
D=B when C=255 and D=A when C=0.
D = (((B-A)*C)/255) + A ; D must be an integer.
Be careful with the brakets or accuracy will be lost
If it is not the right answer : sorry ,i will remove it .
Daniel
Re: Mathimatical question
Thanks heaps. I nearly had it. Will give it go but I think you're on the money there
Thanks
JOHN
Thanks
JOHN
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Mathimatical question
Dan that is a very useful equation. I have used it quit a bit now. I wished I had your maths skillsDan81 wrote: D=B when C=255 and D=A when C=0.
D = (((B-A)*C)/255) + A ; D must be an integer.
Be careful with the brakets or accuracy will be lost
Daniel
Thank you
Martin