Mathimatical question

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

Mathimatical question

Post by jbs4wd »

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

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: Mathimatical question

Post by Dan81 »

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

jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

Re: Mathimatical question

Post by jbs4wd »

Thanks heaps. I nearly had it. Will give it go but I think you're on the money there

Thanks
JOHN

jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

Re: Mathimatical question

Post by jbs4wd »

Daniel

Thanks again. It was spot on.

Cheers
JOHN

medelec35
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

Post by medelec35 »

Dan81 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
Dan that is a very useful equation. I have used it quit a bit now. I wished I had your maths skills :-)
Thank you
Martin

Post Reply