PDA

View Full Version : Valid data checking help please… Hysteresis Question ?



andybarrett1
- 22nd July 2014, 22:11
Hi.. Looking for a bit of help … Again :-)

I have a temperature monitoring design all working fine but I am attempting to filter a low temp alarm (A little like a hysteresis window). In my case "temp" has to be <=2 degrees for 5 seconds before I jump to the alarm label.

At moment as soon as it sees 2degrees alarm condition.

My Code:-

START:

IF temp <2 THEN
FOR COUNTBYTE = 0 TO 9
PAUSE 500
IF temp >2 THEN START
NEXT COUNTBYTE
GOTO ALARM
END IF

I am assuming that if I sample and act 10 x 500ms this will do as I think….

As usual comments / help advice welcome

Thank you for reading

Andy

aratti
- 22nd July 2014, 23:01
Temp must be the differential from setpoint - reading. So this could be a solution:


Allarm_Validation:
For a0 = 1 to 500
Pause 1
Next a0
If temp <= 2 then
time_count = time_count + 1
If time_count >= 10 then gosub allarm_label
Count = 0
Flag_alrm = 1
Else
time_count = 0
Flag_alrm = 0
ENDIF

Cheers

Al.

EarlyBird2
- 22nd July 2014, 23:28
Hi.. Looking for a bit of help … Again :-)

I have a temperature monitoring design all working fine but I am attempting to filter a low temp alarm (A little like a hysteresis window). In my case "temp" has to be <=2 degrees for 5 seconds before I jump to the alarm label.

At moment as soon as it sees 2degrees alarm condition.

My Code:-


START:

IF temp <2 THEN
FOR COUNTBYTE = 0 TO 9
PAUSE 500
IF temp >2 THEN START
NEXT COUNTBYTE
GOTO ALARM
END IF
I am assuming that if I sample and act 10 x 500ms this will do as I think….

As usual comments / help advice welcome

Thank you for reading

Andy

"IF temp >2 THEN START" will never happen as temp will not change within the loop. You need to take a new temp reading before the IF temp>2 test. Another way is to set an alarm flag and increment it so when alarm flag >8 goto alarm.


InAlarm var Byte

START:
.
.
read temp routine
.
.
IF temp <2 THEN
InAlarm=InAlarm+1
PAUSE 500
If InAlarm>8 then ALARM
ELSE
InAlarm=0
Goto START
END IF

Demon
- 23rd July 2014, 14:05
Close, can't monitor during PAUSE 500.


InAlarm var WORD
LOOP VAR WORD

START:
.
.
' Tweak 5000 value to take into account
' time to take temp reading.
.
.
InAlarm=0
FOR LOOP= 1 TO 5000 ' Loop 5 seconds
...READ TEMP
IF temp <2 THEN
InAlarm=InAlarm+1
PAUSE 1 ' Pause 1 millisecond
ELSE
InAlarm=0
LOOP=5555 'Reset loop
ENDIF
NEXT LOOP
IF InAlarm=5000 THEN ALARM ' Check if InAlarm incremented during entire 5 seconds
GOTO START

Personally, I'd use a timer in Darrel's instant interrupts to control 5 second lapse.

Robert

andybarrett1
- 24th July 2014, 13:02
HI..

Thank you for all suggestions of code examples....

Am away from the issues till next week.... Hot Sticky Queen Anne Blast furnace in Scunthorpe UK

Will try them and update when I get back..... Or any suggestions for a simulator.

As yet have seen them but easier to build and prove. But simulation looks interesting

Thank you
Andy

andybarrett1
- 3rd August 2014, 11:02
Thank you Robert and Steve

A mixture of both your suggestions got me more or less on the right track…. I "Think" it is working now.

Thank you others as well …. Software is not my strong point
If I can't measure what it doing with a Fluke I find it difficult

So Thank you

AvionicsMaster1
- 5th August 2014, 13:41
I know how you feel about using a Fluke. Trying to explain it to some of my bosses the difference between analog and digital troubleshooting is even tougher.

More importantly though, you get to work on a blast furnace? Do you use any of your programming abilities? Are PICs involved in any way?

Best wishes.

andybarrett1
- 7th August 2014, 08:58
I get to work on a Blast furnace yes....

There are 4 furnaces at Scunthorpe UK.... We are presently getting one back up and running (Queen Anne).

Unfortunately pics are not used ....not where I am anyway. Probably due to my lack of programming abilities. :-) I

I look after the weighing.... mostly Analogue.. SG's

So Mv and V little bit of mA.... Serial / Profi and Modbus...

BR



Andy

EarlyBird2
- 7th August 2014, 09:12
Any chance of playing with that big "1200 tonne" crane?

Anyone that looks after the four Queens is a friend to all in Sunny Scunny.

Keep asking the questions and programing help will hopefully be provided.

andybarrett1
- 7th August 2014, 16:55
Any chance of playing with that big "1200 tonne" crane?



I wouldn't mind having a go with that myself....

I have been close during lift ops..... :-)