-sensorTemperature Probe
-Overviwe
• Wide temperature range: -20 Celsius to 133 Celsius
• Resolution within two significant figures (XXX.XX)
• Accuracy: ± 1°C
• Continuous readings every 520 ms
• Output temperature in Celsius, Kelvin or Fahrenheit
• Built in data logger storing up to 100 individual temperature readings.
• Programmable high temp and low temp alarms
• One step calibration (optional)
• Simple asynchronous serial connectivity (voltage swing 0-VCC)
• 8 different selectable baud rates from 300 baud to 115.2k baud
• Wide operating voltage range: 3.3V to 5.5V
• Shock resistant: 16,126,837 Pascals
(2,339 pounds per square inch)
• Submersible
• Water Tight
• Dust Tight
• Ice/sleet tolerant
• Non reactive to salt water
• Sensor will sink when submerged
• Dimensions 12mm X 35mm (1/2" X 1.4")
• Resolution within two significant figures (XXX.XX)
• Accuracy: ± 1°C
• Continuous readings every 520 ms
• Output temperature in Celsius, Kelvin or Fahrenheit
• Built in data logger storing up to 100 individual temperature readings.
• Programmable high temp and low temp alarms
• One step calibration (optional)
• Simple asynchronous serial connectivity (voltage swing 0-VCC)
• 8 different selectable baud rates from 300 baud to 115.2k baud
• Wide operating voltage range: 3.3V to 5.5V
• Shock resistant: 16,126,837 Pascals
(2,339 pounds per square inch)
• Submersible
• Water Tight
• Dust Tight
• Ice/sleet tolerant
• Non reactive to salt water
• Sensor will sink when submerged
• Dimensions 12mm X 35mm (1/2" X 1.4")
แหล่งที่มา http://www.atlas-scientific.com/product_pages/probes/env-tmp-d.html
-ข้อมูลโดยละเอียดยังไม่ได้ศึกษาและหาข้อมูลเพิ่มเติม เช่น ราคา ข้อจำกัดที่ชัดเจนกว่านี้
-ต่อมาการcaltbrate PH และ EC
-ยังคงติดปัญหาคือเปลียนค่า string เป็น charไม่ได้ ถ้าส่งหำพรฟสไปแล้วจะเกิดการ errorของข้อมูล
-แต่PWM สามรถทำงานได้อย่างปกติ
แต่มีโค้ดที่ใช้ทดสอบดั้งต่อไปนนี้ แต่เป็นโค้ดที่ใช้แก้ปัญหาการ calibrate PH เพียงตัวเดียว
String inputstring = ""; //a string to hold incoming data from the PC
int inputstringLength = 0;
boolean input_stringcomplete = false; //have we received all the data from the PC
String sensorstringPH = ""; //a string to hold the data from the Atlas Scientific product
boolean sensor_stringcompletePH = false; //have we received all the data from the Atlas Scientific product
String sensorstringEC = ""; //a string to hold the data from the Atlas Scientific product
boolean sensor_stringcompleteEC = false; //have we received all the data from the Atlas Scientific product
String latter = "";
float time1 = 0.0;
float time2 = 0.0;
float s = 0.0;
float counter = 0.0;
float j = 0.0;
float k = 0.0;
float rpm = 0.0;
float rpm_set = 0.0;
float err = 0;
float sum_err = 0;
float old_err = 0;
float Kp = 1; //ค่าคงที่ kp
float Ki = 0.5; //ค่าคงที่ki
float Kd = 1; //ค่าคงที่kd
float u = 0;
float pwm_set = 0;
unsigned long Cur_time = 0;
unsigned long Prev_time = 0;
int latter1 = 1; //set pwm out 0-50
int pwm = 9; // PWM connected to digital pin 9
int inputstring1 = 0;
void setup()
{ //set up the hardware
Serial.begin(38400); //set baud rate for the hardware serial port_0 to 38400
Serial2.begin(38400); //set baud rate for software serial port_2 to 38400
Serial3.begin(38400); //set baud rate for software serial port_3 to 38400
inputstring.reserve(5); //set aside some bytes for receiving data from the PC
sensorstringPH.reserve(30); //set aside some bytes for receiving data from Atlas Scientific product
sensorstringEC.reserve(30); //set aside some bytes for receiving data from Atlas Scientific product
attachInterrupt(0, Millis, RISING);
//LOW to trigger the interrupt whenever the pin is low,
//CHANGE to trigger the interrupt whenever the pin changes value
//RISING to trigger when the pin goes from low to high,
//FALLING for when the pin goes from high to low.
pinMode(pwm, OUTPUT); //PWM
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
}
void serialEvent()
{ //if the hardware serial port_0 receives a char
char inchar = (char)Serial.read(); //get the char we just received
inputstring += inchar; //add it to the inputString
if (inchar == '\r')
{
input_stringcomplete = true; //if the incoming character is a <CR>, set the flag
}
}
void serialEvent2()
{ //if the hardware serial port_2 receives a char
char incharEC = (char)Serial2.read(); //get the char we just received
sensorstringEC += incharEC; //add it to the inputString
if (incharEC == '\r')
{
sensor_stringcompleteEC = true; //if the incoming character is a <CR>, set the flag
}
}
void serialEvent3()
{ //if the hardware serial port_3 receives a char
char incharPH = (char)Serial3.read(); //get the char we just received
sensorstringPH += incharPH; //add it to the inputString
if (incharPH == '\r')
{
sensor_stringcompletePH = true; //if the incoming character is a <CR>, set the flag
}
}
void Millis()
{
counter++;
}
void loop()
{
if (Serial.available() > 0)
{
while (Serial.available() > 0)
{
inputstring += char(Serial.read());
inputstringLength += 1;
delay(10);
}
}
for (int i = 1; i <= inputstringLength; i++)
{
if ((inputstring[i] == 'U') && (inputstring[i - 1] == 'Y'))
{
Serial.println(inputstring);
if (inputstring[0] == 'P')
{
String temp = "";
temp.reserve(30);
for (int i = 1; i < (inputstringLength - 2); i++)
{
temp += inputstring[i];
}
Serial.println(temp);
}
if (input_stringcomplete)
{ //if a string from the PC has been received in its entirety
Serial3.print(inputstring); //send that string to the Atlas Scientific product
inputstring = "";
input_stringcomplete = false; //reset the flag used to tell if we have received a completed string from the PC
}
}
inputstringLength = 0;
inputstring = "";
}
}
if (sensor_stringcompletePH)
{ //if a string from the Atlas Scientific product has been received in its entierty
Serial.print( "PH:");
Serial.print(sensorstringPH); //send that string to to the PC's serial monitor
sensorstringPH = ""; //clear the string:
Serial.println("\t");
sensor_stringcompletePH = false; //reset the flag used to tell if we have received a completed string from the Atlas Scientific product
}
}
-อีกไม่ช้าคงแก้ปัญหาได้และสำเร็จตามต้องการ




ไม่มีความคิดเห็น:
แสดงความคิดเห็น