Basic Sensor Integration Question

afm

Member
Join Date
Aug 2023
Location
Tennessee
Posts
88
Hi all,

I have a noob question regarding data handling from sensors. I understand configurations and I/O mapping sensor input/output variables and can view behavior that way, however when it comes to using those variables in ladder I am lost. Its more straightforward in ST, but for LD I have been using a similar method used by a past engineer that I attached to this post, which has worked for me thus far, but I want to understand why it works and learn more simple, efficient ways to do this. I am using Automation Studio which I know is somewhat abnormal for some aspects of programming, but I feel like there is a better to do this? But please correct me if I am wrong. Thanks in advance.

1708925783159.png
 
I want to understand why it works
From the image in Post #1, it looks like those instructions are transferring 13 bits, HarnessByte1.2 through HarnessByte2.5 plus a 0-valued bit, to the low 13 bits of (16-bit?) integer HarnessInt. This assumes that HarnessByte1 and HarnessByte2 are two 8-bit bytes comprising a single 16-bit integer.

Iit is likely that the I/O transducer, which writes the HarnessByte1 and HarnessByte2 bytes, is a 12-bit Analog-to-Digital Converter (ADC or A/D), with range of 0-2047, and a resolution of one part in 2048 of the sensor range. It is also possible that the I/O transducer is a 14-bit ADC and this code discards the least-significant two bits, perhaps because any values in those two bit are essentially noise; it is more likely that they are status bits. Either way, if we assume HarnessByte1 and HarnessByte2 are indeed bytes i.e. 8-bit integers, then the I/O is delivering 16 bits, but only 12 of those bits compose the usable analog value mesurement. Perhaps the other bits are status bits e.g. to indicate over- or under-range, instrument error, configuration, etc. While somewhat inconvenient, using the least-significant bits, or other non-data bits, in a 16-bit word as status bits is not unheard of. For example, in some Allen-Bradley PLCs, there is a BTD (BiT Distribute) instruction that can extract and shift subsets of the bits in integers from one tag to another.
learn more simple, efficient ways to do this.
I don't know if it's more efficient, but something like the following should achieve the same result:
MOVE HarnessByte2 HarnessInt
AND HarnessInt 63 HarnessInt
MUL HarnessInt 64 HarnessInt
MOV HarnessByte1 TemporaryInt
AND TemporaryInt 252 TemporaryInt
DIV TemporaryInt 4 TemporaryInt
ADD HarnessInt TemporaryInt HarnessInt
or this
COP HarnessByte1 HarnessInt 1 ### Copies one word of (i.e. 16) bits from harness bytes to integer
AND HarnessInt 8188 HarnessInt
DiV HarnessInt 4 HarnessInt
 
It is also possible that the I/O transducer is a 14-bit ADC and this code discards the least-significant two bits, perhaps because any values in those two bit are essentially noise; it is more likely that they are status bits.
Got it, looking at the components some more I can confirm this. Thank you for the explanation.

So for another application, I have some force sensors (FSR sensor) on an 13 bit analog input card (+/-10V). I can see the output from each sensor when I view its I/O mapping (they are assigned as INT type variables), but when I used those configured variables directly in ladder, they all read as "n.a". So between configuring my sensor variables and using the variables in ladder what is the step I am missing/how would I shift the bits in this scenario? Is it standard procedure to move bits over for all analog inputs?
 

Similar Topics

Hello I am new here and new to PLC's, I wrote this program for a class that I am taking and my local tech school. The description is switch 7 will...
Replies
0
Views
415
Hello I am new here and new to PLC's, I wrote this program for a class that I am taking and my local tech school. The description is switch 7 will...
Replies
10
Views
1,976
I’m a bit stuck on HMI (KTP-1200) programming… See the picture attached. The PASS or FAIL box should only appear when the toggle switch is...
Replies
7
Views
1,073
Hey Programmers, Heres todays puzzle I was trying to solve... I have a Modbus TCP network with two Modicon M221 controllers live on my work bench...
Replies
0
Views
467
General Question: My trial version of TIA Portal v16 expires in 5 days and I'll be buying the full licence (Basic). I spoke to a chap at Siemens...
Replies
5
Views
1,304
Back
Top Bottom