Shop OBEX P1 Docs P2 Docs Learn Events
Find a maximum value from sets of RCTIME data — Parallax Forums

Find a maximum value from sets of RCTIME data

FairuzFairuz Posts: 12
edited 2007-09-28 04:11 in BASIC Stamp
Hie..
I am interested to get a maximum value from a sets of 20 values of RCTIME data I·read from port and would like to display it·using debug command. I have tried to integrate my RCTIME data with the equation presented in Emesystem... but not able to make it work.

Please assist me.

Thanks

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-09-27 15:09
    Hello,

    I am not clear on how the data is being stored or used, but on the fly you can update the maximum value by using the line:

    IF value > maxValue THEN maxValue = value

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-09-27 16:50
    I agree with Chris. It would help if you provide more detail about what you are doing and what method from emesystems.com you tried without success.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • FairuzFairuz Posts: 12
    edited 2007-09-28 00:23
    Hie.

    I'm designing a water turbidity meter. The meter is able to identify the capacity of clay in water with the range of 10mg/L. I am using a proposed design by emesystems under topic, "measuring the small voltage" and integrate it with light sensor "TSLB257" and the system work very well. However, when I debug my output on screen or through Stamp Plot Lite, the output data seems to be fluctuating all the time, so it is hard for me to tell what value of RCTIME is representing the turbidity level of water. So, I decided to take only the maximum value out of all my outputs to represent my actual reading. It is the same like in the Stamp Plot Lite, there is one part that is indicating maximum and minimum value throughout the entire graph shown. What I plan to do is to debug the maximum value from the first 50 output values.

    Besides, experimentaly and statistically, I am not pretty sure my idea to use maximum RCTIME value from the entire data is accurate enough to represent the level of turbidity.

    I have tried to use the method proposed under the chapter statistics, finding maximum value, but I do not know how to modify the program to fulfill my requirement.

    Thanks so much for your assistance
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-09-28 04:11
    The easiest way to find the maximum is to track it as you take the readings...
    DO
      resultMax = 0   ' initial maximum = zero
      FOR idx=1 to 50
        RCTIME 0,1,result
        resultMax = result MIN resultMax
      NEXT
        DEBUG ? resultMax
    LOOP
    



    It can also help to do a smoothing low pass filter...
    ' works only for RCTIME result<16384
    DO
      FOR idx=1 to 50
        RCTIME 0,1,result
        IF idx=1 THEN resultLP = result * 4
        resultLP = resultLP */ 192 + result
      NEXT
        resultLP = resultLP/4   
        DEBUG ? resultLP
    LOOP
    



    or a straight out average...
    '  average of 50, assumes the first reading is representative
    resultDelta = 0  ' accumulator
    DO
      FOR idx=1 to 50
        RCTIME 0,1,result
        IF idx=1 THEN resultAvg = result  ' reference to first reading
        resultDelta = result - resultAvg + resultDelta  ' accumulate difference from initial value
      NEXT
        resultAvg = resultAvg + (resultDelta/50)  ' final adjustment
        DEBUG ? resultAvg
    LOOP
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.