cant get the text book answer


ideasman

Recommended Posts

hi

Im trying the alarm sample in the book and whatever I do I cant get the sequence to begin. The alarm is triggered off an led component.

here is the script.

global AlarmReset = 0

delay(1)

if(Alarm.testal.Fired)

AlarmReset = 1

endif

Alarm.AckAllAlarms()

testal being the alarm created.

What have I missed I have followed the book to a tea

cheers

ideasman

Link to comment
Share on other sites

First, how do you know the sequence isn't running? This sequence doesn't have a loop, so it will run and stop in the blink of an eye.

Can you post your complete .ctl doc? The problem probably is a typo somewhere and I want to verify you have everything right.

Link to comment
Share on other sites

Heres the ctl file

this is in the manual

11.6 Questions, Answers and Examples

11.6.1 Basic Alarming

global AlarmReset = 0

// This code allow us to reset the variables only once.

if(Alarm.GreaterThen.Fired)

AlarmReset = 1

endif

// Call the function to acknowledge all alarms

Alarm.AckAllAlarms()

cheers

ideasman

Learn.ctl

Link to comment
Share on other sites

The manual instructions only work as a whole. The main thing you are missing is a Test channel. Alarms are only evaluated when a new data comes in on a channel, or you call Alarm.CheckAlarms(). You have a D to A channel, and unless you are constantly setting that output (which you aren't), the alarm never gets evaluated. In the example, we have a Test A to D channel with Timing 2, so the alarms get evaluated every 2 seconds.

Next problem: you have a typo in the Reset event of the alarm. It should be =0, not =1. The objective being that the flag to reset the alarms is reset to 0 when the alarm is reset. This, by the way, only works if you are resetting a single alarm. An alternative way to do it in script is:

alarmReset = 1

alarm.checkAlarms()

alarmReset = 0

I didn't really look at the rest of your logic. I'm unclear what you are trying to do. I recommend you start simple (i.e. the example in the manual verbatim) and get it working, then add to it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.