uptown47
Lifetime Supporting Member
Hi all,
(Firstly, I did post a similar topic yesterday but I felt that this is sufficiently removed from my original question to warrant a new topic)
I've been trying to write a block to basically take in a set of 'words' check to see which bits are on and then load an appropriate value into an output word.
I'm going to use the output word to display a message on a HMI.
The tricky bit (for me) is that, if there is more than 1 bit on in the input words, I want to load in the different values to the output word with a 2 second pause between each.
For instance... input word is MW206 and bits M207.0, M207.2 and M207.7 are on (Estop pressed and Guard door open). I want to make my output word equal to '1' for a couple of seconds and then equal to '3' then to '8', then back to '1' etc etc....
I've also been using this as a learning aid to STL as I'm trying to improve my code writing in STL.
I've created an FB that allows me to denote whether the alarm conditions are in a datablock or markerwords. The FB then counts through the 'bits' and if one of them is 'on' it passes the relevant value to the output word.
Unfortunately my timer isn't working. The reason is that the timer seems to be always 'on' i.e. it isn't seeing the rising edge on its enable input. I'm not sure why?
I've tried putting a one-shot on the enable of the timer and I've tried ensuring that "MESS_ON" (the bit that brings on the timer) is Reset in the code but to no avail..
I wondered if someone could cast an experienced eye over my code and answer the following questions (all or some)...
1) Why is my timer enable staying 'high' all the time? ie. why is T71 not working??
2) Why is it that I can indirectly address a TEMP type from the Variable Declaration Table but not a STAT type. i.e. The software wouldn't let me write:
... but it would let me write...
???
3) If you are able to get your head around what my code is doing could you let me know if I'm making any glaring errors or writing the code in an overly complicated way? Basically, could you suggest ways to improve the code or techniques that would make it easier to do the same thing in the future (help/advice/constructive criticism etc). I started by trying to use "Area Pointers" but then got bogged down with that method.
I've attached the FB in a 'library' file that you can 'retrieve' I tried to attach the code to this post but it wouldn't let me post it for some reason. I'll try and post it again in the reply box below.
Many thanks for any help you can give me.
Cheers
;-)
(Firstly, I did post a similar topic yesterday but I felt that this is sufficiently removed from my original question to warrant a new topic)
I've been trying to write a block to basically take in a set of 'words' check to see which bits are on and then load an appropriate value into an output word.
I'm going to use the output word to display a message on a HMI.
The tricky bit (for me) is that, if there is more than 1 bit on in the input words, I want to load in the different values to the output word with a 2 second pause between each.
For instance... input word is MW206 and bits M207.0, M207.2 and M207.7 are on (Estop pressed and Guard door open). I want to make my output word equal to '1' for a couple of seconds and then equal to '3' then to '8', then back to '1' etc etc....
I've also been using this as a learning aid to STL as I'm trying to improve my code writing in STL.
I've created an FB that allows me to denote whether the alarm conditions are in a datablock or markerwords. The FB then counts through the 'bits' and if one of them is 'on' it passes the relevant value to the output word.
Unfortunately my timer isn't working. The reason is that the timer seems to be always 'on' i.e. it isn't seeing the rising edge on its enable input. I'm not sure why?
I've tried putting a one-shot on the enable of the timer and I've tried ensuring that "MESS_ON" (the bit that brings on the timer) is Reset in the code but to no avail..
I wondered if someone could cast an experienced eye over my code and answer the following questions (all or some)...
1) Why is my timer enable staying 'high' all the time? ie. why is T71 not working??
2) Why is it that I can indirectly address a TEMP type from the Variable Declaration Table but not a STAT type. i.e. The software wouldn't let me write:
Code:
A M[MESSAGE_POINTER] // THIS IS A 'STAT' TYPE
Code:
A M[TEMP_MESS_POINTER] // THIS IS A 'TEMP' TYPE
3) If you are able to get your head around what my code is doing could you let me know if I'm making any glaring errors or writing the code in an overly complicated way? Basically, could you suggest ways to improve the code or techniques that would make it easier to do the same thing in the future (help/advice/constructive criticism etc). I started by trying to use "Area Pointers" but then got bogged down with that method.
I've attached the FB in a 'library' file that you can 'retrieve' I tried to attach the code to this post but it wouldn't let me post it for some reason. I'll try and post it again in the reply box below.
Many thanks for any help you can give me.
Cheers
;-)