View unanswered posts | View active topics It is currently Fri Oct 31, 2014 3:11 am






Reply to topic  [ 3 posts ] 
Problem with Pressure Sensor 
Author Message
Rookie

Joined: Mon Aug 20, 2007 4:01 am
Posts: 28
Post Problem with Pressure Sensor
Hello,

I'm building a Pneumatic compressor, and have attached a mindsensors PPS35-NX pressure sensor. I want to have it reach 20 PSI, then stop. If the pressure goes below 20 PSI start pumping again until 20PSI is reached.

In the following code, why do I get a minus output from the psi, rather than the expected positive output. I got the formula, PSI = 0.043 * (RawReading) - 38 from the mindsensors documentation.

Code:
int psi;
int val;

task PSI()
{
   SensorMode[S1] = modeRaw;
  while(true) {
    val = SensorRaw[S1];
    psi = 0.043 * (val) - 38;
  }
}

task main()
{
   StartTask(PSI);
   while(true) {
      if (psi < 20) {
         motor[Pump] = 100;
        nxtDisplayBigStringAt (0,60,"Bx: %d", psi);
        nxtDisplayBigStringAt (0,40,"By: %d", val);
      nMotorEncoderTarget[Pump] = 360;
    }
    else {
      motor[Pump] = 0;
      nxtDisplayBigStringAt (0,60,"A: %d", psi);
    }
  }


Thanks
Karl


Mon Jan 26, 2009 2:08 pm
Profile
Rookie

Joined: Thu Nov 20, 2008 7:38 pm
Posts: 10
Post Re: Problem with Pressure Sensor
Obviously the documentation contains an error.

If you do a linear regression on the given graph,
the formula looks like:

p = -(0.043*digits - 48)

And yes, it's "48", not "38".

Somehow the second graph doesn't make sense too.
Whats does 100% mean? Does it represent 1023 digits?
If so, there is at least one more error in the given data...

AS


Mon Jan 26, 2009 4:42 pm
Profile
Rookie

Joined: Mon Aug 20, 2007 4:01 am
Posts: 28
Post Re: Problem with Pressure Sensor
Hello,
Yes, that works in that it gives a positive number, however, I have a LEGO analogue pressure meter attached to the compressor too.

Using: psi = -(0.043 * val - 48);
While the meter shows 15psi, the NXT display shows 20psi.

But with: psi = -(0.043 * val - 38);
The meter shows 22psi, with the NXT showing 20psi. I expect LEGO meter isn't as accurate as the sensor.

I think with the percentage I set:

SensorMode[S1] = modePercentage;

the use: psi = 0.27 * val + 8;
but I couldn't get aything useful out of that.

Thanks
Karl


Mon Jan 26, 2009 5:39 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.