itoa() worked, tried it one of 7 places where it can be used.
Would ftoa() work similar?
http://www.cplusplus.com/forum/beginner/2927/
I don't see how you limit it to one or two decimal places tho.
Look at this mess I had to come up with for multiple blink-without-delay passes to clear the two fault registers, somewhat convoluted, but it seems to work from little testing I've done. Adding two more channels tomorrow and then readings with a real probe or two.
byte fault_test = lsb_rtd&0x01;
if (fault_test == 0x01){
// Serial.print ("Channel 0");
// Serial.print (" Error was detected. The RTD resistance measured is not ");
// Serial.println ("within the range specified in the Threshold Registers.");
// Serial.println(" ");
TemperatureF0char[0] = 'T'; // Maybe send out as TPxx to show the Fault_Error byte.
TemperatureF0char[1] = 'M';
TemperatureF0char[2] = 'P';
TemperatureF0char[3] = '0';
errorTimer0Running = 1; // flag to show timeout for register clearing is running
clearErrorReg0A = 1; // flag to show error register needs clearing
clearErrorReg0B = 1; // flag to shoe error register needs clearing
}
} // end no fault detected
/*
// For human purposes, description of fault codes
temp = 0; //temporary variable created: Purpose is to find out which error bit is set in the fault register
temp = Fault_Error & 0x80; //Logic Anding fault register contents with 0b10000000 to detect for D7 error bit
if(temp>0) {
// Serial.println("Bit D7 is Set. Is the RTD device disconnected from RTD+ or RTD-? ");
// Serial.println("Please verify your connection and High Fault Threshold Value");
// Serial.println("");
}
temp = Fault_Error & 0x40;
if(temp>0) {
// Serial.println("Bit D6 is Set. It's Possible your RTD+ and RTD- is shorted.");
// Serial.println("Please verify your connection and your Low Fault Threshold Value.");
// Serial.println("");
}
temp = Fault_Error & 0x20;
if(temp>0){
// Serial.println("Bit D5 is Set. Vref- is greater than 0.85 * Vbias");
// Serial.println("");
}
temp = Fault_Error & 0x10;
if(temp>0){
// Serial.println("Bit D4 is Set. Please refer to data sheet for more information");
// Serial.println("");
}
temp = Fault_Error &0x08;
if(temp>0){
// Serial.println("Bit D3 is Set. Please refer to data sheet for more information");
// Serial.println("");
}
temp = Fault_Error &0x04;
if(temp>0){
// Serial.println("Bit D2 is Set. Please refer to data sheet for more information");
// Serial.println("");
}
*/
// fault detected, clear out fault registers
if (errorTimer0Running == 1){
if (clearErrorReg0A == 1){
clearErrorReg0A = 0; // flag so only clear register 1 time
// send write address to clear faults
digitalWrite (cs0, LOW);
digitalWrite (cs0, LOW);
SPI.transfer(0x80); // send out register #
delayMicroseconds(10); // see if slight delay between write & read helps
SPI.transfer(0b10000010); // send out data - Fault register isn't cleared automatically. Users are expected to clear it after every fault.
digitalWrite(cs0, HIGH);
startErrorClear0A = millis(); // start timer for clearing error register A
errorReg0ARunning = 1; // flag to show timer running
}
// 700mS delay for register to self clear
if ((errorReg0ARunning == 1) && ((currentMillis - startErrorClear0A) >= oneSecond)){
errorReg0ARunning = 0; // timeout complete
//delay (700); // need 700
}
// Register A cleared, start register B
if ((errorReg0ARunning == 0) && (clearErrorReg0B == 1)){
clearErrorReg0B = 0; // flag so only clear register 1 time
// send write address to clear faults
digitalWrite (cs0, LOW);
digitalWrite (cs0, LOW);
SPI.transfer(0x80); // send out register #
delayMicroseconds(10); // see if slight delay between write & read helps
SPI.transfer(0b10100000); // send out data - Setting the device in autoconfiguration again. 0b10100000 or 0b11000000?
digitalWrite(cs0, HIGH);
startErrorClear0B = millis(); // start timer for clearing error register B
errorReg0BRunning = 1;
}
if (errorReg0BRunning == 1 && ((currentMillis - startErrorClear0B) >= oneSecond)) {
errorReg0BRunning = 0; // timeout complete
//delay (700); // need 700
errorTimer0Running = 0; // both error registers cleared
}
}
Clear register, timeout, clear 2nd register timeout, set flags to allow next reading.
Next step is to have 3 sets of these running at once. Convoluted!