i get not korrect result i dont know why? please help:clap:t2:
/* FSR testing sketch.
int zahl =0;
int fsrPin = 0; // the FSR and 10K pulldown are connected to a0
int fsrReading; // the analog reading from the FSR resistor divider
int fsrVoltage; // the analog reading converted to voltage
unsigned long fsrResistance; // The voltage converted to resistance, can be very big so make "long"
unsigned long fsrConductance;
long fsrForce; // Finally, the resistance converted to force
void setup(void) {
Serial.begin(9600); // We'll send debugging information via the Serial monitor
Serial.println("CLEARDATA");
Serial.println("LABEL,Date,Time,Zahl,fsrReading,fsrVoltage,FSR resistance,fsrConductance,fsrForce");
}
void loop(void) {
fsrReading = analogRead(fsrPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading);
zahl++;
// analog voltage reading ranges from about 0 to 1023 which maps to 0V to 5V (= 5000mV)
fsrVoltage = map(fsrReading, 0, 1023, 0, 5000);
Serial.print("Voltage reading in mV = ");
Serial.println(fsrVoltage);
if (fsrVoltage == 0) {
Serial.println("No pressure");
} else {
// The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
// so FSR = ((Vcc - V) * R) / V yay math!
fsrResistance = 5000 - fsrVoltage; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance *= 10000; // 10K resistor
fsrResistance /= fsrVoltage;
Serial.print("FSR resistance in ohms = ");
Serial.println(fsrResistance);
fsrConductance = 1000000; // we measure in micromhos so
fsrConductance /= fsrResistance;
Serial.print("Conductance in microMhos: ");
Serial.println(fsrConductance);
// Use the two FSR guide graphs to approximate the force
if (fsrConductance <= 1000) {
fsrForce = fsrConductance / 80;
Serial.print("Force in Newtons: ");
Serial.println(fsrForce);
} else {
fsrForce = fsrConductance - 1000;
fsrForce /= 30;
Serial.print("Force in Newtons: ");
Serial.println(fsrForce);
}
}
Serial.println("--------------------");
Serial.print("DATA,DATE,TIME," + String(zahl) +","+ String(fsrReading) +","+ String(fsrVoltage) +","+ String(fsrResistance) +","+ String(fsrConductance) +","+ String(fsrForce));
delay(1000);
}
Please help me here by this code i want to read the result in Exce (PLX-DAQ) but something rong here
int zahl =0;
int fsrPin = 0; // the FSR and 10K pulldown are connected to a0
int fsrReading; // the analog reading from the FSR resistor divider
int fsrVoltage; // the analog reading converted to voltage
unsigned long fsrResistance; // The voltage converted to resistance, can be very big so make "long"
unsigned long fsrConductance;
long fsrForce; // Finally, the resistance converted to force
void setup(void) {
Serial.begin(9600); // We'll send debugging information via the Serial monitor
Serial.println("CLEARDATA");
Serial.println("LABEL,Date,Time,Zahl,fsrReading,fsrVoltage,FSR resistance,fsrConductance,fsrForce");
}
void loop(void) {
fsrReading = analogRead(fsrPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading);
zahl++;
// analog voltage reading ranges from about 0 to 1023 which maps to 0V to 5V (= 5000mV)
fsrVoltage = map(fsrReading, 0, 1023, 0, 5000);
Serial.print("Voltage reading in mV = ");
Serial.println(fsrVoltage);
if (fsrVoltage == 0) {
Serial.println("No pressure");
} else {
// The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
// so FSR = ((Vcc - V) * R) / V yay math!
fsrResistance = 5000 - fsrVoltage; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance *= 10000; // 10K resistor
fsrResistance /= fsrVoltage;
Serial.print("FSR resistance in ohms = ");
Serial.println(fsrResistance);
fsrConductance = 1000000; // we measure in micromhos so
fsrConductance /= fsrResistance;
Serial.print("Conductance in microMhos: ");
Serial.println(fsrConductance);
// Use the two FSR guide graphs to approximate the force
if (fsrConductance <= 1000) {
fsrForce = fsrConductance / 80;
Serial.print("Force in Newtons: ");
Serial.println(fsrForce);
} else {
fsrForce = fsrConductance - 1000;
fsrForce /= 30;
Serial.print("Force in Newtons: ");
Serial.println(fsrForce);
}
}
Serial.println("--------------------");
Serial.print("DATA,DATE,TIME," + String(zahl) +","+ String(fsrReading) +","+ String(fsrVoltage) +","+ String(fsrResistance) +","+ String(fsrConductance) +","+ String(fsrForce));
delay(1000);
}
What exactly do you define as wrong? Could you post some output from your program and describe what readings you believe are erroneous?
Also, from the PLX_DAQ website… are you aware the software is no longer supported? Have you tried PLX_DAQ with any other micro-controller successfully? It looks like Parallax developed the software for use only with their controllers. I’m not sure what is proprietary about it so do you know if it will work with Particle devices?
i use now arduino and it works good but I get the measured values (analog reading) twice
i dont know why?(look PIC)
this is my Code
int zahl =0;
int fsrPin = 0; // the FSR and 10K pulldown are connected to a0
int fsrReading; // the analog reading from the FSR resistor divider
int fsrVoltage; // the analog reading converted to voltage
unsigned long fsrResistance; // The voltage converted to resistance, can be very big so make "long"
unsigned long fsrConductance;
long fsrForce; // Finally, the resistance converted to force
void setup(void) {
Serial.begin(9600); // We'll send debugging information via the Serial monitor
Serial.println("CLEARSHEET");
Serial.println("LABEL,Date,Time,Zahl,fsrForce,fsrVoltage,FSR resistance,fsrConductance,fsrReading");
}
void loop(void) {
fsrReading = analogRead(fsrPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading);
zahl++;
// analog voltage reading ranges from about 0 to 1023 which maps to 0V to 5V (= 5000mV)
fsrVoltage = map(fsrReading, 0, 1023, 0, 5000);
Serial.print("Voltage reading in mV = ");
Serial.println(fsrVoltage);
if (fsrVoltage == 0) {
Serial.println("No pressure");
} else {
// The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
// so FSR = ((Vcc - V) * R) / V yay math!
fsrResistance = 5000 - fsrVoltage; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance *= 10000; // 10K resistor
fsrResistance /= fsrVoltage;
Serial.print("FSR resistance in ohms = ");
Serial.println(fsrResistance);
fsrConductance = 1000000; // we measure in micromhos so
fsrConductance /= fsrResistance;
Serial.print("Conductance in microMhos: ");
Serial.println(fsrConductance);
// Use the two FSR guide graphs to approximate the force
if (fsrConductance <= 1000) {
fsrForce = fsrConductance / 80;
Serial.print("Force in Newtons: ");
Serial.println(fsrForce);
} else {
fsrForce = fsrConductance - 1000;
fsrForce /= 30;
Serial.print("Force in Newtons: ");
Serial.println(fsrForce);
}
}
Serial.println("----------------------------------------------------------------");
Serial.print("DATA,DATE,TIME," + String(zahl) +","+ String(fsrForce) +","+ String(fsrVoltage) +","+ String(fsrResistance) +","+ String(fsrConductance) +","+ String(fsrReading));
delay(1000);
}
To answer your question about the double readings: This is the last line of your loop() followed by your first line of the loop():
Both are serial.print() statements. So the first serial.print() in loop is just tacking onto whatever the last serial.print() was sending. You need to include a serial.println() as the last line in loop() to stop that behavior.
Regarding the column order on the spreadsheets, I’m not sure if this is the appropriate forum for your quesitons. I’ll explain… I pic 1, I see the columns in the same order as you are publishing in your loop. Only at the bottom of your loop do you publish a consolidated line with the data string in a different order. It looks like at the start of that consolidated println you have 3 column headers. I don’t know anything about how PLX_DAQ accepts the data and plots it to the appropriate columns. As far as I can tell, your code and Particle device are functioning appropriately. Are you not able to edit the sheet to place the columns where you want them? If not, you probably want to ask these questions in a forum dedicated to Parallax or PLX_DAQ.
Perhaps an Elite (@ScruffR, @Moors7, @bko, @peekay123) could split your comments from this thread into its own thread because your questions are not related to the original post’s problems. Your issue is with an external 3rd-party software.
Not entirely sure, but since you are not setting new values for any of your variables in case of …
if (fsrVoltage == 0) {
Serial.println("No pressure");
} else {
... // new values would be produced here but doesn't happen if fsrVoltage == 0
}
Serial.println("----------------------------------------------------------------");
Serial.print("DATA,DATE,TIME," + String(zahl) +","+ String(fsrForce) +","+ String(fsrVoltage) +","+ String(fsrResistance) +","+ String(fsrConductance) +","+ String(fsrReading));
… but still print out the old values, I’d think you are seeing artefacts of previous readings.
BTW, since Particle devices use 12bit ADCs your mapping of the analog value should probably be using 4095 instead of 1023 (10bit) and having said that 4095 equals 3300mV not 5000.
You don’t have to set those values to 0 but I’m not sure what the default (or no-reading) values should be. If it were me, I’d just set them all to 0 so I know it’s erroneous data.
#include <SD.h>
#include <SPI.h>
File myFile;
long id =1;
int fsrPin = 0; // the FSR and 10K pulldown are connected to a0
int fsrReading; // the analog reading from the FSR resistor divider
int fsrVoltage; // the analog reading converted to voltage
unsigned long fsrResistance; // The voltage converted to resistance, can be very big so make "long"
unsigned long fsrConductance;
long fsrForce; // Finally, the resistance converted to force
void setup(void) {
Serial.begin(9600); // We'll send debugging information via the Serial monitor
// SD Card Initialization
if (SD.begin(10))
{
Serial.println("SD card is ready to use.");
} else
{
Serial.println("SD card initialization failed");
return;
}
//Write myFile Header
File myFile = SD.open("test.txt", FILE_WRITE);
if (myFile)
{
String header = "ID, fsrReading, fsrVoltage, fsrResistance,fsrConductance, fsrForce";
myFile.println(header);
myFile.close();
Serial.println(header);
} else {
Serial.println("error opening test.txt");
}
}
void loop(void) {
fsrReading = analogRead(fsrPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading);
// analog voltage reading ranges from about 0 to 1023 which maps to 0V to 5V (= 5000mV)
fsrVoltage = map(fsrReading, 0, 1023, 0, 5000);
Serial.print("Voltage reading in mV = ");
Serial.println(fsrVoltage);
if (fsrVoltage == 0) {
Serial.println("No pressure");
} else {
// The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
// so FSR = ((Vcc - V) * R) / V yay math!
fsrResistance = 5000 - fsrVoltage; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance *= 10000; // 10K resistor
fsrResistance /= fsrVoltage;
Serial.print("FSR resistance in ohms = ");
Serial.println(fsrResistance);
fsrConductance = 1000000; // we measure in micromhos so
fsrConductance /= fsrResistance;
Serial.print("Conductance in microMhos: ");
Serial.println(fsrConductance);
// Use the two FSR guide graphs to approximate the force
if (fsrConductance <= 1000) {
fsrForce = fsrConductance / 80;
Serial.print("Force in Newtons: ");
Serial.println(fsrForce);
} else {
fsrForce = fsrConductance - 1000;
fsrForce /= 30;
Serial.print("Force in Newtons: ");
Serial.println(fsrForce);
}
}
File myFile = SD.open("test.txt", FILE_WRITE);
if (myFile) {
myFile.println(fsrReading);
myFile.print(",");
myFile.println(fsrVoltage);
myFile.print(",");
myFile.println(fsrResistance);
myFile.print(",");
myFile.println(fsrConductance);
myFile.print(",");
myFile.println(fsrForce);
myFile.close();
} else {
Serial.println("error opening test.txt");
}
Serial.println("--------------------");
id++;
delay(1000);
}
why I getting 0 if I have already written the if function loook pic Please
the Code:
/*
Connect one end of FSR to power, the other end to Analog 0.
Then connect one end of a 10K resistor from Analog 0 to ground
*/
int zahl =0;
int fsrPin = 0; // the FSR and 10K pulldown are connected to a0
int fsrReading; // the analog reading from the FSR resistor divider
int fsrVoltage; // the analog reading converted to voltage
unsigned long fsrResistance; // The voltage converted to resistance, can be very big so make "long"
unsigned long fsrConductance;
long fsrForce; // Finally, the resistance converted to force
float Pressure = 0; // Finally, the N converted to mmHg
void setup(void) {
Serial.begin(9600); // We'll send debugging information via the Serial monitor
Serial.println("CLEARSHEET");
Serial.println("LABEL,Date,Time,Zahl,fsrReading,fsrVoltage,FSR resistance,fsrConductance,fsrForce,Pressure");
}
void loop(void) {
fsrReading = analogRead(fsrPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading);
zahl++;
// analog voltage reading ranges from about 0 to 1023 which maps to 0V to 5V (= 5000mV)
fsrVoltage = map(fsrReading, 0, 1023, 0, 5000);
Serial.print("Voltage reading in mV = ");
Serial.println(fsrVoltage);
if (fsrVoltage == 0) {
Serial.println("No pressure");
//um Offset zu verhindern, wenn fsrVoltage == 0
fsrResistance = 0;
fsrForce = 0;
fsrConductance = 0;
} else {
// The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
// so FSR = ((Vcc - V) * R) / V yay math!
fsrResistance = 5000 - fsrVoltage; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance *= 10000; // 10K resistor
fsrResistance /= fsrVoltage;
Serial.print("FSR resistance in ohms = ");
Serial.println(fsrResistance);
fsrConductance = 1000000; // we measure in micromhos so
fsrConductance /= fsrResistance;
Serial.print("Conductance in microMhos: ");
Serial.println(fsrConductance);
// Use the two FSR guide graphs to approximate the force
if (fsrConductance <= 1000) {
fsrForce = fsrConductance / 80;
Serial.print("Force in Newtons: ");
Serial.println(fsrForce);
} else {
fsrForce = fsrConductance - 1000;
fsrForce /= 30;
Serial.print("Force in Newtons: ");
Serial.println(fsrForce);
}
if (fsrForce >= 1){
Pressure = fsrForce/176;
Serial.print("Pressure in mmHg: ");
Serial.println(Pressure);
}
else {
}
}
Serial.print("DATA,DATE,TIME," + String(zahl) +","+ String(fsrReading) +","+ String(fsrVoltage) +","+ String(fsrResistance) +","+ String(fsrConductance) +","+ String(fsrForce)+","+ String(Pressure));
Serial.println();
Serial.println("----------------------------------------------------------------");
delay(1000);
}
Try writing Pressure = fsrForce/176.0; instead.
Without the final .0 both variables are integer types and hence you’ll get an integer result even if storing the result in a float. And since the result will be less than 1 you’ll only ever get 0.
i got the result with point thanks @ScruffR but can i get the result for Pressure through arduino Like the Pic ?? so i mean the arduino give me only the first two Points but i need all Point (or 4 points) to show me
i did calculate with excel then it give me the correct result but arduino not