CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Please, help me with making hysteresis!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
40inD



Joined: 30 Jul 2007
Posts: 112
Location: Moscow, Russia

View user's profile Send private message

Please, help me with making hysteresis!
PostPosted: Wed Aug 01, 2007 6:01 am     Reply with quote

I need to implement hysteresis in termoregulator device. I have desired temp (Td), current temp (Tc) and Delta Td (hysteresis).
libor



Joined: 14 Dec 2004
Posts: 288
Location: Hungary

View user's profile Send private message

PostPosted: Wed Aug 01, 2007 9:46 am     Reply with quote

Do you read current temp as an analog input using the A/D ? I suppose you want the hysteresis done in software, and you are controlling a digital port.
You can define the two levels for the switching and use the according level depending on the current state (ON or OFF) of the state machine.
Code:
#define OFF 0
#define ON 1
int state;
...
lowerlimit=Td-delta;
upperlimit=Td+delta;
...
if (state == ON) {
  if (Tc>upperlimit)  {
  state = OFF;
  //... turn off heating
  }
}
if (state == OFF) {
  if (Tc<lowerlimit)  {
   state = ON;
  // ...turn on heating
  }
}


if you are controling an analogue output like a PWM output I would rather suggest to use a PID algorythm instead calculating the error and acting upon it.
40inD



Joined: 30 Jul 2007
Posts: 112
Location: Moscow, Russia

View user's profile Send private message

PostPosted: Wed Aug 01, 2007 12:22 pm     Reply with quote

Idea Thanks! It works. Very Happy
(I use DS18B20, but it's no matter)
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group