Shop OBEX P1 Docs P2 Docs Learn Events
Help with sensor problem — Parallax Forums

Help with sensor problem

Lone_huskyLone_husky Posts: 13
edited 2009-02-01 16:23 in BASIC Stamp
Hi there,

I'm using the BS sx to measure the light coming from a TSL230 light to frequency converter.· I need to detect the transition from high signal to low signal but sometimes the reverse is true.· I thought about using a differential and have been successful in calculating it but cannot use it as both positive and negative.·

How do I use a negative integer with a conditional statement to signify the transition from one state to another.

I have also tried using the levels themselves but there is too much variablity.

Any advice

-V

Comments

  • metron9metron9 Posts: 1,100
    edited 2009-01-30 06:48
    Can't you just use the pulsin command to read a pulse length as the frequency is a square wave it won't matter if you measure the high or the low pulse.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • PaulbotPaulbot Posts: 3
    edited 2009-02-01 16:23
    Maybe you can check the high bit and convert to absolute value·if negative for further testing.

    as in

    XSIGN = 1

    IF XVAL&32768 THEN··········· ' is it negative

    ···· XSIGN = 0

    ···· XVAL = (XVAL^65535)+1· ' two's complement

    ENDIF

    You would use 128 and 255 for byte values, of course.
Sign In or Register to comment.