01-24-2017 12:37 PM
Thanks. I ran the code and it did work, however I did find that when I put in N- number of Holding registers, The Output of Typecast reduces the output to half. eg, for 8 register, I see 4 from the typecast. Can you explain to me what this is doing? Also I have the D6300 and D6500 Omega Modules. I used register address 40049 in each module to access holding register 1, but I keep getting Modbus exception Error code 2 as shown in the attach. Any help on getting this resolved will be greatly appreciated.I have also attached Data sheet cutouts for the two D-Modules.
01-24-2017 01:17 PM
Of course. It takes 2 registers to give the data for 1 single precision number. So if you ask for 8 registers, you will get 4 numbers.
If you have parameters that only need 1 register (such as if they were integers), then you wouldn't be running them through the typecast conversion to single precision.
Register 40049 accesses Data Channel 1. (not sure why you call that holding register 1) It says 0-FFFF. It looks like instead of that being a signed 16-bit integer (two-s complement, in which case you could typecast to an I16), it is an integer where 0 is x8000. So take the U16 value and subtract 32768 (the decimal value for x8000).
At least that is what the D6300 says. The D6500 says it is says Analog Out Channel 1 and -FS (Full scale?) is 0 and +FS is FFFF. Which is a completely different way of writing it, but it is the same result. (Also, Odd is that the D6300 is read only, and the D6500 is read/write.)
I highly recommend you read up more on modbus, but also articles on how numbers are represented in computer memory.
01-25-2017 08:54 AM
Thanks RavensFan for the Information and Help so far and to your question, yes, the D6500 is a Read and Write Model. Can you please help withy the below questions based on your email.
01-25-2017 08:56 AM - edited 01-25-2017 09:12 AM
I didn't say subtract 32768 from the address.
You subtract 32768 from the value that you get from that address.
Here is the VI modified with first read doing a single precision float and typecast pairs of U16 registers into single precision. Second read taking the U16 value as described in your last manual, offseting the value as the manual describes. Then dividing so that it gives the fraction of the full scale range. You can multiply as necessary to scale it to any engineering units.
01-26-2017 10:06 AM
Hello RavensFan,
Attached is the result when I ran the code. It makes no sense to me. Any help?
01-26-2017 10:27 AM
Do you understand the difference between an integer and a floating point number and how they are represented in memory? It seems like you don't.
In the first read, you are reading 8 registers. These registers happen to point to a group of 16-bit integer parameters related to the analog values. Each register represents a single U16 integer. So why are you using the process I showed you earlier that applies to single precision floating point numbers? (That is where two register are combined to give you a 32-bit, 4 byte) value that needs to be typecast to a single precision float.)
In the second read you are also reading 8 registers, basically the same group. Here you are properly interpreting them as integers like I showed you in the recent messages. It looks like most of them are maxed out at 65535. Probably analog input channels that are not connected to anything and floating high. One is 8202 which would convert to -0.749 x full scale value according to the way they describe the register in the manual where zero is in the middle at hex8000.
The one thing I'm not certain of is whether the start address is correct. In the first read, you start with register 49, in the second register 48. By standard practice, if you were looking for register 40049, you'd drop the beginning 4 and and subtract 1. So entering 48 would be correct. I don't know if you have something connected to analog input #1, or analog input #2 to know if the 8202 value is showing up in the correct spot. If the Omega manual follows normal Modbus practices, I believe you have something connected to analog input 2 that is at about -75% of full scale range.
01-26-2017 12:21 PM
RavenFan,
Yes I have a Thermocouple attached to D6300 Channel 2 (Register address = 40050)and nothing attached to Channel 1 and from Channel 3 to Channel 7. The Value as seen on the earlier attachment was 8202 which I believe is decimal. My question is why do we have to change to hex? If the Module range is 0-FFFF (which is equal to 0-65535 decimal), then the temp can be read as
(8202/65535) X FS. The thermocouple I am using as shown below says Temp Limit is 2150 F. So, going by this, the temp can be calculated as = ((8202/65535) X 2150) = 147.2F. This is quite very high and did not match the measured temp using a Fluke temperature measuring instrument. Not sure if this is right.
01-26-2017 12:22 PM
Datasheet of Tc attached.
01-26-2017 12:45 PM
Yes. 8202 is a decimal number. That means that it is 8202/65536 of the way between the bottom of the channel range 0, or x0000, and the top of the range 65535 or x FFFF. The manual on page 31 says it is "offset by x8000". That means that "zero" is in the middle of that range. You say "My question is why do we have to change to hex?" No where are we changing anything to hex. We are just working with numbers, whether those numbers are described in decimal format or hex format, it doesn't matter. As long as you understand how numbers work.
For that module on page 31. I don't know how you translate a thermocouple input to a range. Thermocouples don't have a "zero". They are generally in the millivolt range, sometimes positive, sometimes negative.
I suggest you contact Omega to find out more about how temperatures read by the thermocouple translate to values in that register, and translate back to deg C, or deg F, or whatever you want to see on your screen. Pages 31-34 talk about other registers related to scaling and t/c type, and a rather complicated procedure to calibrate the inputs. If you need help, then contact Omega.
For some reason, the manual you attached doesn't really talk about ranges. But I did see this link on Omega http://www.omega.com/pptst/D6000_SERIES.html. It says a J-type has a range of -200 deg C to 760 deg C. Let's assume that is correct and it does map to the 0-65535 or 0-xFFFF range. Take 8202 divide by 65536. You have 0.125. Your span is 960 deg C and it starts at -200. So .125*960 - 200 is -80 deg C. Does that value mean anything to you?
Call Omega.
01-30-2017 10:45 AM
Thanks RavensFan. I was able to get things working. I am very appreciative of all your efforts.