Bit Level db.DBW or db.DBDW access

arkansascontrols

Lifetime Supporting Member
Join Date
Jan 2008
Location
Arkansas
Posts
112
Other than transfering the value to a Memory word variable is there a way I can directly access the individual bits of an int or dint defined in a db?


ie.

A DB1.DBW1.xx (I know this doesn't work but is there a correct syntax for accessing the individual bits or is it restricted to word / dword access only? I know I can define a DWORD and then access either or both words within the DWORD register, but I can't seem to get it down to the BIT level)

Any help appreciated.

Eric
 
Last edited:
CharlesM said:
Try this

DB1.DBX1.1
I knew there had to be a syntax issue, thanks Charles. By the way I assume the X stipulates Byte Level Access??? So x0.0 through x3.7 would represent the 32 bits of my first DINT?

Eric
 
Timers

I have written my own Timer Function for a particular application within my program and I'd like to get a little advise on it. Essentially what I need is a Timer that will time Segments of my recipe that may be up to several days in lenth, plus an overall recipe timer that is always over 5 days long. The user enters times into the Set Point Programmer as Hours and Minutes for each segment which are INTs. I could totalize the minutes and convert to S5Time but then there is the Timer Preset Limitation that falls short of what I need. So here is what I have conceived as the simplest workaround;



Any thoughts or suggestions? Is there a better or easier way to accomplish what I'm trying to do? I don't need a precision timer I just need a long life timer.

Eric
 
Last edited:
Have a look at the IEC Timers, you'll find them in the Standard Library. I don't have Step7 available at present, so I can't give exact details, but I believe the IEC Timer runs to about twenty days - the exact details you'll find in the help files.
 
arkansas.... What mechanism are you going to use to start the timer ? The "normal" method is to use the rising edge of a boolean variable, but you are not passing one into your FB.
I will post an example of the IEC timer mentioned by RMA later today.
 
LD,

It is a recipe segment timer. My recipe's run from about 90 to around 120 hours and are comprised of between 8 and 14 "segments", that range from 1 hour to (at present the longest segment is 36 hours) Each segment has different discrete and process functions but functions that require timers I of course use standard timers.

Thanks, I'd appreciate an example of the IEC timer.

Eric
 
to address your other question. The function is an FB and I call it from within a rung of Ladder with an instance DB to store the TT, EN, PRE and ACC values, then just place it into a rung of logic as I would any other timer, which is why I'm not passing an Enable to the function.
 
If the logic prior to the block is false then your function block will not be called !

S5 timers are built in functions and are scanned differently to calls to functions and function blocks.
 
Once a recipe is started the Running Bit will never be false until the timer times out. But please show me an example of the IEC timer, I'm all in favor of using an integral function over a custom function.
 
Here's the source code for a function block implementing three simultaneous timers. The block should be called all of the time. Note that SFB4 has to exist in your blocks folder for this to compile. Note also that the symbol name for SFB4 is "TON" so it will clash with the timer block you have already written - rename the symbol for your custom timer block.

Code:
FUNCTION_BLOCK FB 1
TITLE =
VERSION : 0.1

VAR_INPUT
  iSegment1Hours : INT ; 
  iSegment1Minutes : INT ; 
  iSegment2Hours : INT ; 
  iSegment2Minutes : INT ; 
  iSegment3Hours : INT ; 
  iSegment3Minutes : INT ; 
  bSegment1Start : BOOL ; 
  bSegment2Start : BOOL ; 
  bSegment3Start : BOOL ; 
END_VAR
VAR_OUTPUT
  bTimer1Timing : BOOL ; 
  bTimer2Timing : BOOL ; 
  bTimer3Timing : BOOL ; 
END_VAR
VAR
  fbTimer1 : SFB4; 
  fbTimer2 : SFB4; 
  fbTimer3 : SFB4; 
  bTimer1StartEdge : BOOL ; 
  bTimer1FinishEdge : BOOL ; 
END_VAR
VAR_TEMP
  Times : ARRAY  [1 .. 3 ] OF TIME ; 
  ElapsedTimes : ARRAY  [1 .. 3 ] OF TIME ; 
  ElapsedHours : ARRAY  [1 .. 3 ] OF INT ; 
  ElapsedMinutes : ARRAY  [1 .. 3 ] OF INT ; 
END_VAR
BEGIN
NETWORK
TITLE =calc time in ms for sfb4
	  L	 #iSegment1Hours; 
	  L	 L#3600000; 
	  *D	; 
	  T	 #Times[1]; 
	  L	 #iSegment1Minutes; 
	  L	 L#60000; 
	  *D	; 
	  L	 #Times[1]; 
	  +D	; 
	  T	 #Times[1]; 
	  L	 #iSegment2Hours; 
	  L	 L#3600000; 
	  *D	; 
	  T	 #Times[2]; 
	  L	 #iSegment2Minutes; 
	  L	 L#60000; 
	  *D	; 
	  L	 #Times[2]; 
	  +D	; 
	  T	 #Times[2]; 
	  L	 #iSegment3Hours; 
	  L	 L#3600000; 
	  *D	; 
	  T	 #Times[3]; 
	  L	 #iSegment3Minutes; 
	  L	 L#60000; 
	  *D	; 
	  L	 #Times[3]; 
	  +D	; 
	  T	 #Times[3]; 
NETWORK
TITLE =iec timer
	  A	 #bSegment1Start; 
	  =	 L	 36.0; 
	  BLD   103; 
	  CALL #fbTimer1 (
		   IN					   := L	 36.0,
		   PT					   := #Times[1],
		   ET					   := #ElapsedTimes[1]);
	  NOP   0; 
NETWORK
TITLE =iec timer
	  A	 #bSegment2Start; 
	  =	 L	 36.0; 
	  BLD   103; 
	  CALL #fbTimer2 (
		   IN					   := L	 36.0,
		   PT					   := #Times[2],
		   ET					   := #ElapsedTimes[2]);
	  NOP   0; 
NETWORK
TITLE =iec timer
	  A	 #bSegment3Start; 
	  =	 L	 36.0; 
	  BLD   103; 
	  CALL #fbTimer3 (
		   IN					   := L	 36.0,
		   PT					   := #Times[3],
		   ET					   := #ElapsedTimes[3]);
	  NOP   0; 
NETWORK
TITLE =timer timing
	  A	 #bSegment1Start; 
	  AN	#fbTimer1.Q; 
	  =	 #bTimer1Timing; 
NETWORK
TITLE =timer timing
	  A	 #bSegment2Start; 
	  AN	#fbTimer2.Q; 
	  =	 #bTimer2Timing; 
NETWORK
TITLE =timer timing
	  A	 #bSegment3Start; 
	  AN	#fbTimer3.Q; 
	  =	 #bTimer3Timing; 
NETWORK
TITLE =give elapsed time in hours/mins
	  L	 #ElapsedTimes[1]; 
	  L	 L#3600000; 
	  /D	; 
	  T	 #ElapsedHours[1]; 
	  L	 L#3600000; 
	  *D	; 
	  L	 #ElapsedTimes[1]; 
	  TAK   ; 
	  -D	; 
	  L	 L#60000; 
	  /D	; 
	  T	 #ElapsedMinutes[2]; 
	  L	 #ElapsedTimes[2]; 
	  L	 L#3600000; 
	  /D	; 
	  T	 #ElapsedHours[2]; 
	  L	 L#3600000; 
	  *D	; 
	  L	 #ElapsedTimes[2]; 
	  TAK   ; 
	  -D	; 
	  L	 L#60000; 
	  /D	; 
	  T	 #ElapsedMinutes[2]; 
	  L	 #ElapsedTimes[3]; 
	  L	 L#3600000; 
	  /D	; 
	  T	 #ElapsedHours[3]; 
	  L	 L#3600000; 
	  *D	; 
	  L	 #ElapsedTimes[3]; 
	  TAK   ; 
	  -D	; 
	  L	 L#60000; 
	  /D	; 
	  T	 #ElapsedMinutes[3]; 
END_FUNCTION_BLOCK
 
Last edited:
LD,

THanks for the example. Have you ever employed the use of this timer function yourself? I assume from looking at the code that I could access the Elapsed time from Ladder Logic by specifying fbtimerx.et. Do SFB's not require instance DB's as well?

THanks again for all your help.

Eric
 
I use SFB4 all the time but I created this block and tested it in the simulator this evening. One of the features of function blocks is that they have a static data area. This area is stored in the instance DB and hence you can remember the state of variables between calls (unlike the temp area which is lost after each call). You can also declare other function blocks in the stat area. These are called multiple instance function blocks and they all end up using the same instance data block. Just open up the instance DB after you have created one using the above function block - all will become clear (hopefully)

Yes you can access the elapsed timed via fbTimerx.ET (this is in millisecs)
 
Last edited:
On a completely different topic, in Siemens is it permissable to have duplicated output coils in logic? I know in AB that causes problems if one rung is true and one rung is false but both have an Output Energize (coil) with the same address. I found a subroutine in this program that has 20 different rungs with different conditions but all energize the same output. It's bad programming form to be sure, but will it even work in Siemens?

Thanks guys
 
arkansascontrols said:
... in Siemens is it permissable to have duplicated output coils in logic?....but will it even work in Siemens?

Yup...obviously only last solved is valid..
 

Similar Topics

Hello, Haven't been on in a while. I need to generate a bit level pdf of the I/O for RSLogix 500. I can generate a report but it just shows the...
Replies
1
Views
155
I am currently using Micrologix 1100 connected to my pc using RSLinx Lite. I need to file data from Keyence IL series lasers using DL-EP1 module...
Replies
2
Views
1,263
I'm working on a number of HMI projects just now using Factorytalk View ME V9 and I've come to map in my I-O onto the status pages of the screen...
Replies
5
Views
3,202
Hello, I am working within the RSLOGIX 500 software and am trying to index at the bit level. I have attached a screen shot. When using MOV...
Replies
4
Views
1,966
Hello everyone... I need to enable a float value(Analog output) through a bit input. Kindly help me to do the same
Replies
1
Views
1,462
Back
Top Bottom