Shop OBEX P1 Docs P2 Docs Learn Events
Using Min 0 (zero) Function — Parallax Forums

Using Min 0 (zero) Function

Hello,

Its been a while since I have asked a question here. I still have many Basic Stamp projects and they are working well.

I just added a device to one of my projects that is a current sensor. In my application, the sensor reads zero current as 128. To get it to display something usable, I would just subtract 128 to get zero.

I have 16 Analog to Digital converters reading 0-5 VDC. They come in as NemoString(XX). The 100/100 is a place holder for calibrating the 0 - 256 to give me a usable number.

My line of code is:

NemoString(09) = NemoString(09) * 100/100 ' BAmps - Calibrate Here

I would like to add the following:

NemoString(09) = (NemoString(09) - 128) * 100/50 MIN 0 ' BAmps - Calibrate Here

There is a warning about using MIN 0 in the Syntax manual. Will I have a problem here?

I just would like my current reading to start at zero. I can tweek 100/50 to make any further calibration adjustments. I just don't want a little drift to roll over (under roll) my zero.

Thanks!

Greg

Comments

  • The problem with MIN 0 is that the Stamp does not recognize negative numbers inherently. When an operation rolls under, you end up with a large positive number instead. Try the following:

    NemoString(09) = ((NemoString(09) MIN 128) - 128) * 100/50 ' BAmps - Calibrate Here

    -Phil
  • Makes perfect sense...

    Thank You

    Greg
Sign In or Register to comment.