64 bit counter

kreacher

Member
Join Date
Jun 2015
Location
Iasi
Posts
21
Hi,

I have a question. Does anyone have any ideea on how to create a counter that can go above 32767? I have seen in Siemens PLC that the high limit of counters is 32767 but i need a much much bigger number.

How can i do this?

Thank you,

Kreach
 
Most all PLC's will have an ADD function to a DINT that you can count to at least once per scan. Some like the GE-IP PLC/PAC can Add multiple times per scan. If you need to count very fast get a High Speed Counter for your processor.
 
Last edited:
I think you need a 32 bit timer, not 64. a 16 bit word maxes out at 32767, with a 32 bit double word you can go up to 2,147,483,647 (signed).

Unfortunately I have no experience with the PLC platform you are using.

Hope this helps,
Dave
 
Create a new memory location in a Datablock (or a M address) and define it as 'DINT'

Then feed this address into a 'Add_DI' block from the 'Integer function' section.

The other input will need to be a 1 and the output will be the address you created.

AddDint.PNG
 
Source code for a 32 bit counter using the same interface as SFB0 from the standard library:

Code:
FUNCTION_BLOCK FB 1
TITLE =
VERSION : 0.1


VAR_INPUT
  CU : BOOL ;    
  R : BOOL ;    
  PV : DINT ;    
END_VAR
VAR_OUTPUT
  QQ : BOOL ;    
  CV : DINT ;    
END_VAR
VAR
  bEdgeStore : BOOL ;    
  diCount : DINT ;    
END_VAR
BEGIN
NETWORK
TITLE =

      A     #CU; 
      FP    #bEdgeStore; 
      JCN   res; 

      L     #diCount; 
      L     L#1; 
      +D    ; 
      JP    pos; 
      JU    res; 
pos:  T     #diCount; 
res:  A     #R; 
      JCN   nors; 
      L     L#0; 
      T     #diCount; 
nors: L     #diCount; 
      T     #CV; 
      L     #PV; 
      >=D   ; 
      =     #QQ; 



END_FUNCTION_BLOCK
 
Why is everyone mentioning Timers? I need a Counter...
And unfortunately it must be bigger, at least 62 bits... this is what was asked of me.

And i have tried already what Joltron said. But it doesn't do what i need it to do. If i leave the EN Input free it only does 1 Addition. If i try to put my clock there it does more ADD operations but not in the rhythm of the clock. When the Clock is 0 it doesn't do anything but when the Clock is 1 it does multiple operations. Any clue why?
Thank you very much guys.
 
Last edited:
I need a Counter...
And unfortunately it must be bigger, at least 62 bits... this is what was asked of me.

Does anyone have any idea on how to create a counter that can go above 32767? I have seen in Siemens PLC that the high limit of counters is 32767 but i need a much much bigger number.
These are two different things. Is the requirement to use a certain number of bits or, is it to count up to a certain value? Does the value need to fit into one unit (word/dword) or can it be spread over multiple units?
 
The ideea of this exercise is to make a Counter that can count up to a maximum of at least 2^62.
And it does not say but i think it must fit into 1 unit, probably a 64 bits DREAL? I'm very inexperienced with number processing and SCL/STL. So far mostly i've only worked with LAD or FBD.
 
There's no DREAL.
A LREAL instead?
(Long Real).
What are you using as the clock pulse?
A Positive Transition bit should do the trick.
Use a P-Trigger instruction as your pulse (Clock) and tie the Trigger.Q to the Enable of the the ADD instruction.
 
Use a P-Trigger instruction as the Clock.
The internal clock is your problem I think as it is on for the duration (more than one scan).
 
I understand, thank you, i have a question though.

At the output of the ADD i have a MW which is a integer. How can i make it so that i can use a LREAL to be able to count up to 2^62 or even more? I know LREAL should be 64 bits?
 

Similar Topics

Hi Gents I need some help, Keyence UK is not supporting Keyence PLCs in the UK anymore, I have programmed an operation in Ladder with a 24 bit...
Replies
0
Views
1,898
My name is Steve and I'm self learning plc's. I am using RSlogixpro and have successfully programmed Door, Silo and traffic lights. Now tackling...
Replies
12
Views
8,160
Hi... I'm still learning how to code for PLC's Using Allen Bradley SLC 500 and RSLogix, I made a flashing bit using timers. Now, I assumed if I...
Replies
5
Views
2,016
Right now I`m working on S7-200 PLC and facing few doubts. -How to handle a overflow when performing mathematical function.I am performing...
Replies
0
Views
3,039
Good afternoon! i'm using a mitsubishi FX2N, and i need to compare the value of a 32bit counter with a D, ex.: compare a CN252 with D10. how can...
Replies
1
Views
3,236
Back
Top Bottom