11/29/2007 5:59 AM | |
Joined: 9/27/2006 Last visit: 11/1/2024 Posts: 12292 Rating: (2690) |
Hello Ady; First, I would be very interested to find out why you would want to program your own conversion tool, as it is not a simple thing to do. And a PLC is not the easiest beast to program this on; STL would be the only way to go. By the way, if you can't or won't use TRUNC or RND, In Step 7 there are also FLOOR and CEILING instructions that could do the job... Now, to start with, look at the IEEE floating-point number definition (from Wikipedia): http://en.wikipedia.org/wiki/IEEE_754-1985 Here are some sites with converters and converter logic for PCs (linux and Windows) from HEXA to decimal floating-point : http://babbage.cs.qc.edu/IEEE-754/32bit.html http://www.61131.com/download.htm http://citeseer.ist.psu.edu/goldberg91what.htmlhttp://support.automation.siemens.com/WW/view/en/23803063 Up till now, I have found no code for PLCs to do a truncation of a floating-point value, and I have not much time to work on this. Here are links to C-code for a conversion to integer value: http://www.cs.tut.fi/~jkorpela/round.html http://www.mega-nerd.com/FPcast/ Try applying the logic, when you hit a snag come back to us, we'll see if we can help. Hope this helps, Daniel Chartier |
Last edited by: O_Moderator at: 9/16/2010 3:10 PMlink edited Last edited by: dchartier at: 29.11.2007 06:00 |
|
11/29/2007 1:18 PM | |
Joined: 9/27/2006 Last visit: 11/1/2024 Posts: 12292 Rating: (2690) |
Looks good, Aret. Regards, Daniel Chartier |
Follow us on