
adccommunitymod (AutomationDirect) asked a question.
How To: Reading analog inputs??
Created Date: November 11,2002
Created By: cdobis
**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****
This is probably really easy and I am making it harder than it should be, but I can't seem to read my analog input values from an F2-04AD-2. I am using some 7B modules to give me 0-10 volt inputs. I have a DL205 with a 260 CPU. This Analog input module is in the first (0) slot, next to the CPU. Can you help me with the programming basics in DSoft and scaling this signal? I can't seem to find a simple example of this. TIA Craig
Created Date: November 11,2002
Created by: cdobis
This is probably really easy and I am making it harder than it should be, but I can't seem to read my analog input values from an F2-04AD-2. I am using some 7B modules to give me 0-10 volt inputs. I have a DL205 with a 260 CPU. This Analog input module is in the first (0) slot, next to the CPU. Can you help me with the programming basics in DSoft and scaling this signal? I can't seem to find a simple example of this.
TIA
Craig
Created Date: November 11,2002
Created by: marksji
On the first PLC scan you need a rung of logic that sets how many channels you want to read, what data format you want to use, and where the analog data should be stored in VMEM. You can use the special contact SP0 as the control logic for the rung. For example:
SP0---------LD K0400
OUT V7660
LDA O2000
OUT V7670
This would set BCD data to be stored in VMEM locations v2000 through v2003. If you want binary data change the K0400 to K8400. V7660 & V7670 are special VMEM locations for slot 0, if you move the card to slot x then use V766x & V767x.
This is all in the manual for the card which can be downloaded from ADs site.
Created Date: November 11,2002
Created by: showsys
I have successfully been able to get the numbers in binary and bcd using the ladder example, but my biggest difficulty is in understanding if I need to look at 2 vmem locations per channel.
I am using a DL250-1 and a F2-04THM with an EZ-Touch mono display.
I cannot seem to get a stable reading from the J-type thermocouples that we 're using. We 've played with the possibilities of chamging jumper settings, but or thermocouple vendor insists the specs meet the settings we 've seen as factory default.
The range seems off, which leads me to wonder if we need to display and calculate using both vmem locations (v2000, and v2001 in the example)
We may also have issues with improperly spec'd thermocouple wire. It appears to be unshielded over a distance of 10-15 meters.
Any suggestions would be appreciated.
TJ
Created Date: November 11,2002
Created by: cdobis
I appreciate the help, but the data in the book for the module leaves a newby like myself, still scratching his head. I have themocouples and a shunt going into 7B modules to convert my signals to 0-10v for my analog input module. There is where I run into trouble. My 7B module's range is -100 C to +300 C, 0 - 10 volts output respectively, for the thermocouple. Now, do I leave it in binary form, convert it to a real number, and where do I do the math? I need a math example, I think, just to get me going on this.
Thanks!
Created Date: November 11,2002
Created by: Tom Jenkins
For any unit conversion on any PLC you can use four function math with the following, which assumes integer math:
DataOffset = Data in input register at 4 mA (or zero analog signal of whatever range - for example 0 VDC on a 0-10 VDC transmitter)
DataSPan = Data at 10 VDC - Data @ 0 VDC
FACTOR = arbitrary factor (multiple of 10) needed to get proper resolution and accuracy
EU = Engineering Units x FACTOR
EUOffset = Engineering Units @ 0VDC x FACTOR
EUSpan = (Engineering Units @ 10VDC - Engineering Units @ 0VDC) x FACTOR
DATA = Actual data reading in input register
EU = ((EUSpan x (DATA - DataOffset))/DataSpan) + EUOffset
ProcessValue = EU / FACTOR
Example,-100 to 300 °C from 0-10 VDC with resolution of 0.1°F:
FACTOR = 10
Data @ 0 VDC = 0
Data @ 10 VDC = 4095
DataOffset = 0
DataSpan = 4095 - 0 = 4095
EUOffset = -100 x 10 = -1000
EUSpan = (300 - (-100)) x 10 = 4000
DATA = 2048
EU = ((4000 x (2048 - 0)) / 4095) + -1000 = 1000
Process Value = 1000 / 10 = 100.0 °F
One problem you will have is that the integer math for the DirectLogic PLCs isn't friendly to negative math. Because your temperature transmitter starts at -100 you can't avoid this problem. There are two solutions. One is to use floating point math - not always the best answer for a novice. The better solution is probably to have two sets of math rungs. If the raw data is below 25% (1024) use one set. If it is above 1024 use the other. Then you can avoid negative numbers. You will have to set a bit to indicate if the temperature is above or below zero.
There are lots of math examples in the manuals. Try programming first with known values, then convert to the logic needed for the temperature.
Created Date: November 11,2002
Created by: Tech Guy
Here is a program that will do what Tom's post implies. This example assumes that all data is in signed binary format. This can be imported by Directsoft version 4.0 only. To import, start at the PLC 250(-1) line and select to #END. Save this as a text file with no formatting. In Directsoft v4 Go to File -> Import. Pick the text file that you saved and give it a project name.
PLC 250(-1)
// Rung 1
// Address 0
#BEGIN COMMENT
"This program will do a zero and full scale calibration and scaling of a V-memory location "
"according to the straight line equation: "
" "
"SV=((Iv-Cfs)*(Dfs-Dz))/(Cfs-Cz)-b+Dz "
" "
"b=(Dz-(Dfs-Dz))/(Cfs-Cz) "
" "
"SV=Scaled Value "
"Iv = Input value (Number to be calibrated & scaled) "
"Dz = Device Zero "
"Dfs = Device Full Scale "
"Cz = Plc Counts at Device Zero "
"Cfs = Plc Counts at Device Full Scale "
" "
"The following example assumes that the zero and full scale values will be entered via a "
"data view into V-memory addresses v2000-v2006. IE. 5-25psi device that reads 300 "
"counts at 5psi and 4015 counts at 25 psi; "
"V2000=5, V2002=25, V2004=300, V2006=4015. "
" "
"** Solve for b ** "
#END
STR SP1
LD V2002
SUBB V2000
OUT V2020
// Rung 2
// Address 4
STR SP1
LD V2006
SUBB V2004
OUT V2022
// Rung 3
// Address 8
STR SP1
LD V2000
SUBB V2020
INV
ADDB K1
ANDD Kffff
DIVB V2022
OUT V2010
// Rung 4
// Address 17
#BEGIN COMMENT
" "
"** Now Solve for SV ** "
" "
" "
" "
#END
STR SP1
LD V2100
SUBB V2004
MULB V2020
DIVB V2022
ADDB V2010
ADDB V2000
OUT V2200
// Rung 5
// Address 25
END
// Rung 6
// Address 26
NOP
#BEGIN ELEMENT_DOC
"V2000 ", " ", " ", "Device Zero "
"V2002 ", " ", " ", "Device Fullscale "
"V2004 ", " ", " ", "PLC Counts - Zero "
"V2006 ", " ", " ", "PLC Counts - Fullscale "
"V2010 ", " ", " ", "b = (V2000-(V2002-V2000) / (V2004-V2006) "
"V2020 ", " ", " ", "Device Range "
"V2022 ", " ", " ", "Count Range "
"V2100 ", " ", " ", "Value to be Scaled and Calibrated "
"V2200 ", " ", " ", "Scaled Value "
#END
Created Date: November 12,2002
Created by: marksji
showsys,
Thermocouples are inherently unstable in most situations and need filtering. I say they are unstable in most situations because the input signal your dealing with is in the milivolt range. At those voltages it doesn't take much to generate interfearance from other AC lines that are nearby. As far as the spec of the TC wire, as long as its type-J wire it shouldn't be the problem. Check for any AC lines near your TC wire and make sure you don't have any junctions (or as few as possible) in your TC wire. When we run TC wire its always in its own metallic conduit to provide sheilding from any interfearance. In the case of the 205 I 've had to make sure the TC wire is always routed away from the power supply on the base, apparently ADC bases don't have much shielding.
Created Date: November 13,2002
Created by: Tech Guy
Sorry to those that tried to import the program I posted. It has been edited and now works. http://forum1.automationdirect.com/board/smile.gif
Created Date: November 13,2002
Created by: Tech Guy
Showsys,
1) The THM module is a 16-bit resolution module, which consumes two words per channel, BUT the module converts the T/C signal into actual deg. C or deg. F with one implied decimal point. So according to the type of T/C you are using, you most likely will only be using values that are in the lower word. The upper word is mostly for diagnostics like a broken transmitter (burnout detection) and the negative sign bit.
2) For unstable readings you will most likely want to start by looking at the power supply being used for the THM card itself. With the T/C signal being a mV range it can be susceptible to noise, even a noisy power supply. Take the 0V that is connected to the F2-04THM and jump it over to the PLC's incoming power Ground. (even if you are pulling it from the base aux. 24 VDC) You want to make sure that you have a good solid earth connection and the PLC and module power supplies have a common reference.
Created Date: November 22,2002
Created by: JHobbs
Thanks Tech Guy...you just saved me some brainwork. Was getting ready to write a routine to do this for my program. Thanks again.