Jump to content

I32 roll over to extented to I64 if possible


Recommended Posts

Posted

Greetings:

I have a Smart motor by animatics that has an internal encoder that rolls over on i32 integers. the encoder is

2000 counts / rev and when you are running at 3600 RPM that will roll over in about 5 hours. (i will be running almost continousely)

I am taking continous readings thru the RS232 port at 38400 baud of the counts.

I need to convert the counts to a continous up positive going reading, unless the motor reverses, than a down going reading.

Can i convert the readings into a Extended precision variable ??

Thanks Forrest

Posted
Can i convert the readings into a Extended precision variable?

I don't think convert is quite the right word - but you can add / subtract your i32 input to / from an i64 that you're handling in LabVIEW (I don't know your architecture, but maybe hold the position in a shift register?) Can you post some example code so we can make more informed suggestions?

Posted
Greetings:

I have a Smart motor by animatics that has an internal encoder that rolls over on i32 integers. the encoder is

2000 counts / rev and when you are running at 3600 RPM that will roll over in about 5 hours. (i will be running almost continousely)

I am taking continous readings thru the RS232 port at 38400 baud of the counts.

I need to convert the counts to a continous up positive going reading, unless the motor reverses, than a down going reading.

Can i convert the readings into a Extended precision variable ??

Thanks Forrest

Perhaps you can get by with an up / down indication rather than an absolute "count" of the motor position. An example code snippet or a better explanation of your end goal might be in order here.

Posted

Greetings:

I just have the numbers coming in from the RS232. The software in the motor just uses Integer 32 , so the number in the motor rolls over. Example: 2,147,483,648 + 1 = -2,147,483,647 ; ( next count )= -2,127,483,646 ; (next count)=-2,127,483,645 ... etc.

Now i want a variable (extended mode)

2,147,483,648 + 1 = 2,147,483,649 ; ( next count )= 2,127,483,650 ; (next count)=2,127,483,651 ... etc.

(ie. to increase al the time with out a sign roll over)

Thanks Forrest

Posted

One of the properties of signed integers is that a substraction operation will still be the opposite of an addition operation. So, if you take each number and substract the previous number from it you will get the right amount even if the number rolled over. You can use this to increment your counter.

Since you don't have 64 bit integers in LV, you will either have to use your own logic or one of the floating point representations.

Posted

The following sort of logic should do the trick (replacing the "reading" controls by input from your motor, and assuming that you make sure to make a reading more often than it can possibly roll over):

post-3022-1152655014.png?width=400

Of course in LV7 you don't have 64-bit integers for free, but you can either do them yourself with two 32-bit integers or use doubles; their mantissa has 53 bits of precision so you won't lose count for a good long time.

Posted
Of course in LV7 you don't have 64-bit integers for free, but you can either do them yourself with two 32-bit integers or use doubles; their mantissa has 53 bits of precision so you won't lose count for a good long time.

They are both valid options, but personally I'd go for the 2 x 32bit integers - it's a more elegant solution.

Posted
I know that, but...

Ahhh - good point. Consider me appropriately chastized :headbang:

Looks like Guillaume Lessard's yen's suggestions are going to be your best way out.

Posted
Looks like Guillaume Lessard's suggestions are going to be your best way out.
Since we're chastising, aren't those suggestions identical to mine? :angry::o:D
Posted
Since we're chastising, aren't those suggestions identical to mine?

I think identical is probably a bit of a stretch, but I have edited my previous post accorfingly :)

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.