Hello all I am currently working on a project using a march pump, water heating element, and rtd sensor. Two relays are used for the pump and heater. And the rtd read in circuit has been designed well and gives me an accurate temp reading. My code runs the pump off a millis timer and my heater is contolled using the PID library. The rtd read in is on analog 0. I have downloaded the LArVA Labview software from angstromdesigns.com. Below is the link to this design reading in an rtd. This works fine and well. However, when I use my code the software doesn’t work and when I use the software the code won’t run. Obviously both of these applications are trying to run on the same COM, but once my code is uploaded to the board, the board should be self sustaining. So I don’t know why the LArVA shouldn’t work with it? Anyone have experience with this or have any general ideas on how to get this to work. It would be great if i could get a nice graph showing my PID loop working. Thanks for any responses
link: http://angstromdesigns.com//index.php?option=com_content&view=article&id=83&Itemid=74
code:
#include <PID_v1.h>
//******************************* Pump Setup *************************************
const int pump = 12; //save pump pin
int pumpState = LOW; //initialize pump as off
unsigned long previousMillis = 0;
unsigned long interval = 10000; //interval pump will cycle on and off
//****************************** PID & Heater Setup *************************************
const int heat = 8; //save heat pin
int Input; //digital read from rtd
double TempSet, Output, TempIn; //Define Variables for PID
PID myPID(&TempIn, &Output, &TempSet, 5, 2, .25, DIRECT); //Specify the links and initial tuning parameters
unsigned long WindowSize = 5000;
unsigned long windowStartTime;
void setup()
{
pinMode(pump,OUTPUT); //initialize pump as output
pinMode(heat,OUTPUT); //initialize heater as output
analogReference(INTERNAL); //set ref voltage 0 - 1.1 V
windowStartTime = millis();
TempSet = 110; //insert desired temp
myPID.SetOutputLimits(0, WindowSize); //tell the PID to range between 0 and the full window size
myPID.SetMode(AUTOMATIC); //turn the PID on automatically
}
void loop()
{
Input = analogRead(A0); //reads in digital value
TempIn=(.1959*Input)+28.39; //converts digital read to temp based on my linear calibration
myPID.Compute(); //Turns relay on/off based on temp read in
unsigned long now = millis();
if(now - windowStartTime>WindowSize)
{ //timer for SSR based on PID OUTPUT value
windowStartTime += WindowSize;
}
if(Output > now - windowStartTime)
digitalWrite(heat,HIGH);
else
digitalWrite(heat,LOW);
unsigned long now1 = millis();
if(now1 - previousMillis > interval) //timer for pump
{
previousMillis = now;
if (pumpState == LOW)
pumpState = HIGH;
else
pumpState = LOW;
digitalWrite(pump, pumpState);
}
}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.