Welcome to WebmasterWorld Guest from 54.162.226.212

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Textbox comparison on a webserver running on a Ethernet

     
7:57 pm on Oct 8, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Hi there People,

I've got a math probelm, and I can't fathom it out; Id be greatful if I could bounce it here to see if there is anyone who can shed light on this issue.

I have two textbox's that get populated via ethernet to development PCB, and read voltages that are scaled to 250.00V (32767 (16BIT)), and the other textbox is the requested value ie 125.00V (16383 scaled).

As this is a website driven PCB - from webserver, I would like to know how I can present the maths so that I can detect when the read value is +/- 1% of request.

To be honest it's just the maths side of this I can't fathom.

I'd appreciate any ideas,

Thanks,
MRb
11:21 pm on Oct 8, 2012 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



do you need the formula to calculate the percentage?
it's the difference between read and requested divided by requested.
multiply that by 100 to get percentage.
use an absolute value function too capture +/-.
compare the result to 1.0
6:28 pm on Oct 9, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Hi there Phranque,

Thanks for the idea, sounds promising; I'm not brilliant at maths, so it's nice to get another perspective/set of thoughts on this.

I'll be having a play with this before the end of the week, so I'll post back and let you know how I've got on.

*Pseudo code*

CapturedReading = (((ReadValue - SetPoint) / Setpoint) * 1.0)

Putting the margin of error there I think is wrong.. but I've got code here that looks similar to this that I use the work out the scaling including the margin of error

CapturedResult = (CapturedReading * 100)

Somthing like that would be comparing the the result to the 1% margin of error wouldn't it?

Feeling a bit daft now really, somthing this simple, and it's cost me more time than calculating 16bit CRC's!

Thanks for the advice!

Cheers,
MRb
8:27 pm on Oct 9, 2012 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



expected value: X

1%: 1*X/100

bottom: X - X/100 = 99X/100
top: X + X/100 = 101X/100

Read value: Y
if 99X/100 <= Y and Y<= 101X/100 then it's within 1% of X

To speed things up: forget about dividing by 100 (division is slow compared to multiplication):

if ( ( 99*X <= 100*Y) and (100*Y <= 101*X) ) then Y is within 1% of X
7:37 pm on Oct 12, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



@Swa66,

Cool, thanks for this. I appreicate your input :)

Cheers,
MRb

PS: I'll test this on Monday & report back
 

Featured Threads

Hot Threads This Week

Hot Threads This Month