Sign in to follow this  
Followers 0
vtripathi

data registers Data register over flow

5 posts in this topic

Hi,

data registers are getting full, because of extremely high speed pulsing

is there any way , if the data value in register goes above the capacity of 32 bit register, it automatically attaches itself to next set of data registers

so lets say if data was written in D10,D11

Upon reaching the limit, it goes to D10, D11, D12, D13

please share if there is an alternate way to do this

Share this post


Link to post
Share on other sites

I don't fully understand what you want to do but look at Z registers.

Psudo codeo follows...

Initialise Z0 to 0

Using 5 double registers

IF Z0 = 20 THEN Z0= 0;

Something that adds to D10Z0;

IF D10Z0 > (limit)THEN Z0 = Z0+2;

Total = D10+D12+D14+D16+D18; but you are back to the initial problem of representation of a value greater than a double word/Dint.

Enter that in your code of choice and you should be able to work something out.

Alternatives,

 

1.used cascading counters.

C1 counts to say 1000,

C1 done then reset C1, increment C2.

C2 counts to say 1000 but represents 1,000 to 999,000

Repeat for as many counters as necessary.

Total = C1 count + C2 count x1000+...etc

2. Counter example but use registers instead of counters. A mix of the original solution and 1.

3.Use real/float datatype.

 

4. Pay me and I'll do it for you :)

1 person likes this

Share this post


Link to post
Share on other sites

Hi

please find the code attached

i have 2 pole motor, which runs approximately at 3000 rpm, and encoder is 2000ppr

Frequency is approx 100 khz, Counting is not a problem, its just holding the values

32 bit register can hold 2 billion bits, and at 100khz , my data register will be filled in 2000 sec, i need it to operate for much longer time than that

so my quest is if it reaches lets say 1 billion bits, it automatically attaches it to adjacent register

Explaining it in simple ways would be, i have created dataflow as a water flow analogy

i will try with index registers, since its used for positioning, i will still be required to add the values, and then start decrementing them in reverse order

i am still trying to get my head around Last in first out command and shifting registers, may be that can work 

thanks 

Best Regards,

Vib

Encodercontrol.pdf

Encodercontrol1.pdf

Share this post


Link to post
Share on other sites

Sounds like you need "register extension" to make  a 64-bit register.  If you are doing the adding in code, you would use your PLC's arithmetic carry bit to indicate when to add one to the 2nd register.  But if the register is external, (like an external digital encoder), you will need to monitor changes in the top two bits of the register to decide when to overflow/underflow into the 2nd register.  The pythonish pseudocode would be like this, where E is the external encoder, and V0 and V1 are the two 32bit registers composing the 64-bit result:

# Catch forward rollover
if V0.30 and V0.31 and not E.30 and not E.31:
    V1 += 1
# Catch reverse rollover
if E.30 and E.31 and not V0.30 and not V0.31:
    V1 -= 1
# Copy low 32 bits
V0 = E

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0