Mitsubishi Q Series: Converting a float to an Integer

Mas01

Member
Join Date
Oct 2020
Location
Leicester, England
Posts
1,105
How do I convert a float to an integer?


I've got a floating-point number D606, value 3999.863.
I need to convert it to an integer (4000), then I need to move it into Data register D600 (integer), which is then output on a Digital to Analogue card , Q68DAIN (Mitsubishi Q-series). This integer value of 4000 should output 20mA.


Is there such a command like this & will it work? :


-----[INT D606 D600]---


Anyone help?
 
Last edited:
Mitsubishi will not allow mixed int/floats on maths and as there are many built in functions for conversion so there is no need.
Int to float, float to int, Dint to float, Float to Dint, Bool to word, BCD to int etc.
 
Mitsubishi will not allow mixed int/floats on maths and as there are many built in functions for conversion so there is no need.
Int to float, float to int, Dint to float, Float to Dint, Bool to word, BCD to int etc.

What's the difference between Int.and Dint? Maybe I should have converted to Dint (instead of int) for sending it out on the AO card, although I did get the correct mA I was expecting.
 
An integer is a value from -32767 to + 32767 a Dint is a double word cannot remember how big it is but it's into the millions so no you do not need a Dint as the analogue card only goes up to a max of 32767 (4000 in your case).
Therefore all analogue cards (Mitsubishi) only use integers.
 
An integer is a value from -32767 to + 32767 a Dint is a double word cannot remember how big it is but it's into the millions so no you do not need a Dint as the analogue card only goes up to a max of 32767 (4000 in your case).
Therefore all analogue cards (Mitsubishi) only use integers.

Cheers, clear explanation as ever.
 
A signed double(32 bit) is 2,147,483,647 to -2,147,483,648.
An unsigned Double (32 bit) is 0 to 4,294,967,295
Argh Alan beat me to it.
 
Final story:

  • 16-bit signed INT range is -32,768 to +32,767 i.e. -(2^15) to (2^15)-1
  • 32-bit signed DINT range is -2,147,483,648 to -2,147,483,647 i.e. -(2^31) to (2^31)-1 (argh parky and alan beat me to it ;))
Caveats

  • If the float is outside the range of the INT (or DINT) conversion function by which it is being converted, the result may be undefined, or may even cause a fault.
 
lol, Even I could not remember the max on DInt, never need to think about it, never needed such a large number a few million is usually enough.
 

Similar Topics

Hi, Our PLC measures WATER FLOW RATE as an analog input. The PLC reads it as an integer value (D34) in the range 0-4000 as follows: Range...
Replies
12
Views
2,565
how to communicate FactoryTalk Optix and Mitsubishi Q Series. I want to know the details of that
Replies
0
Views
32
In this sample programming, what does U4 mean? Any assistance would be greatly appreciated.
Replies
8
Views
262
Hi, I have a project with a R04CPU, RD77GF16 and a RJ71PN92 modules. The cell is given to me to change the program since the previous integrator...
Replies
9
Views
282
Back
Top Bottom