AB ML1200, Interger to Floating Point

This is solvable but only with data.

Post the N10:0 and N10:1 values. Post the F8:0 value.

Post the actual instruction or the *.RSS file in ZIP format.

I am certain that this can be done in a MicroLogix 1200. But you're overlooking something important about byte order or about word order, or about instruction arguments.

The values you posted before absolutely do work when the word order is reversed. Post more values. Data ! Dataaaa !
 
I have attached the program, along with a screen shot of the integers. The first N7:20 integer is 17381, which equals 488 volts.

I will post more, once I can get communications back...
 
You're psyching yourself out. The answer is easy and has already been posted twice.

The logic you were still using, with ABS and MOV and ADD instructions, is for converting a large Integer number encoded as Twos-Complement Binary into a Floating-Point number encoded as IEEE-754 Single-Precision Floating Point.

Your source data isn't in Twos-Complement Binary. It's already in IEEE-754 Single-Precision Floating Point format.

Therefore all you need is one CPW instruction:

CPW N7:25 F8:0 1
 
Ken, thanks for looking at it and make the changes. I have attached a word DOC, with some screen shots.
The changed version you sent back, gives a number that is still unuseful. And as far as I can tell, there is no direct releveance that I can tie it to (ie multiply by x.) I have attached a screen shot of that program running, its on page 3.

Again, your help has been extremely appreciated!

NH
 
When you originally posted the program:

N7:25 = 17396 (decimal) = 42f4 (hex)
N7:26 = 6554 (decimal) = 199A (hex)

Which when you perform the CPW instruction makes the F8:0 register equal to 488.2 (floating point).

The screenshot you posted has a different source value:

N7:25 = 17396 (decimal) = 42f4 (hex)
N7:26 = -29491 (decimal) = 8CCD (hex)

Which when you perform the CPW instruction makes the F8:0 register equal to 489.1 (floating point)

I did not have a MicroLogix 1200 or 1100 handy, so I ran the calculation on an emulator then pasted the rung back into your program. I failed to copy over the result into F8:0 in your program.

Hmm.

I'm going to the office to get a MicroLogix 1200 and a Modbus emulator to settle this once and for all.

Here's one suggestion; edit the CPW instruction so that it only executes when the .DN bit of the message instruction is done. It's possible you're executing the CPW instruction before the MSG instruction has, in the background, finished copying both Modbus words into N7:25 and N7:26.
 
I will give the .DN a shot.
The source will change constantly, its hooked up to a digital meter thats reading the 480V line voltage... Almost impossible to get the same two source values!

Thanks
NH
 
Aha ! I was thinking about ControlLogix, where the Length of a COP instruction is the number of destination elements. In SLC/MicroLogix the Length is the number of 16-bit Words, no matter what the data types are.

Change your CPW instruction to Length 2.

CPW N7:25 F8:0 2


I am running this now on a MicroLogix 1500 1764-LRP FRN10 with Modsim32 and it works correctly.
 
I will give this a shot on Monday morning. Unfortunetly, this is one of the very few weekends I wont be in the office!
I am though, pretty confident, that we tried 2 in the CPW command, with no change in result.
Its odd that the data is there, and correct, in the Hex format at least, and in the Integers, but so difficult to get it into 1 correct floatiing point! Could the ML1500 and ML1100 be that different that the commands act differently??!

NH
 
I have not had a chance to try the change yet. Will do it first thing Monday AM.

However, while bored watching a tear-jerker with(for) the wife last night, I was wondering a few things:
-Could the CPW command need a trigger, such as the .DN bit of the modbus capture? Will it execute every scan?
-Could the Modbus register be updating too fast for the CPW command? Is there a way for the modbus read command to happen once a second/once every other second, rather than continuous?

NH
 
Not sure if there is another conversion I need to do rPraveenkum?
The data is in "floating point format to IEEE.754".

I used the 2 for the CPW instruction, no change. The result in F8:0 is a 4.283757e+08 constant, doesnt change at all.

Im wondering if the Modbus data is being updated so fast, that the math function cant keep up?

NH
 
Enough!!! Divide And Conquer

The CPW instruction should work. If not then you are doing something wrong. Disable the modbus and enter known test numbers by hand. Try entring a number in the F8:0 and CPW it back to N10:0 and N10:1. This will give you an idea what to look for.
Enter in numbers like 0.0, 1.0, 2.0 into F8:0 and convert them to ints and display them in hex. This will give you an idea as to what to look for.

Use thig to check the results.
http://babbage.cs.qc.edu/IEEE-754/Decimal.html

So far you have not helped the forum help you by providing numbers. You must learn to divide and conquer. At this time you don't know if the modbus is sending down correctly. You can be doing everyting right on the ML and still end up with bogus numbers because the Modbus format isn't right. First prove to yourself that the numbers can be transfered back and forth between floats and ints with the modbus off.

Next enable the modbus and download a 1.0 to the integer file. Is it the same bit patter as if you copied 1.0 from F8:0? If not then you have a modbus problem.

This thread should not have been this long and it has been all covered before almost 5 years ago by PhilipW and me.
http://www.plctalk.net/qanda/showthread.php?t=1393&highlight=CPW
PhilipW's is more to the point.
http://www.plctalk.net/qanda/showthread.php?t=5374&highlight=CPW

What good is a search if no one uses it? This forum has history. If you don't remember it you will repeat the same threads again and again and again.
 
I appreciate your post Peter, harsh but straight to the point.

I broke the program down, removed everything, and have 1 rung, a CPW command.
When set as Source=F8:0 and Dest=N10:0, Length of 2 I get the following: F8:0=478.65, N10= 5333 43EF, which checked in the babbge calc, comes out correctly. I can change F8:0 and the N10 registers correspond correctly. I do find that the registers are flipped, N10:1 being the first word.

When I change the CPW to Source N10:0 and Dest F8:0, length of 1 I get: I enter the hex value of the number above (478.65), into N10:0/1, I get 9.02xxx in F8:0. If I switch the values in N10:0/1, I get the same number, it never changes.
If I change the legth to 2, I get the correct number.

So, according to the babbge calculator, 43EF 5333 in hex = 478.65 in decimal.
In my program with one line, CPW S=N10:0 and D=F8:0 length 2 : I enter 43EF and 5333 into N10:0 and N10:1 repectively, I get a result of 7.699389e+11. If I switch N10:0 and N10:1 (to effectively be 5333 43EF), I get 478.65.

So going back into my program, I moved the Integers so they line up as in my example. Once I have them lined up, I use the CPW as shown in the paragraph above. S=N10:1 S=F8:0 Length 2, it works properly.

In deed, with what you mentioned, and Ken Roach's help... all put together, it works. I apologize if I wasted anyones time, and Im sorry to have created another topic with this information. Hopefully someone down the road may be able to use it. With this being my first venture not only into floating point/integers, as well as Modbus, I have learned a great deal of information that will benefit me and others down the road.
Again, I appreciate your help, and Im sorry to have been a nuisance!

Neil Hicks
 

Similar Topics

Hey all! Long time reader, first time poster! I have an EA9-T7CL and an MicroLogix 1200 connected via DF1. I'm all good and got everything mostly...
Replies
3
Views
656
Hi every master,Recently i met a fault about 1762-L40BWA 1,When i get the PLC, The Fault light is lighting, I am not remember the fault message,I...
Replies
0
Views
722
Hello everybody and master,I met a problem about ML1200.It is described as below: 1,When i got this PLC,The FAULT light is lighting, My computer...
Replies
4
Views
1,115
I had planned to use PTO instructions to control a servo motor, single axis only. We have a ML1200 BWA model. According to the ML1200 manual...
Replies
7
Views
3,496
I am using Modbus to read 36 registers from a ML1200. 2 of those registers are suppose to be L11 data and 2 of the registers are F8 data. Long...
Replies
3
Views
1,400
Back
Top Bottom