Couple of Questions Regarding SCP Instruction and Sensor Calibration

mike64b

Member
Join Date
Oct 2011
Location
richland
Posts
77
Hey guys, I've got a pH/conductivity transmitter and a 1762-IF4 A/D for my micrologix 1200. I'm using an SCP command with implied decimal places to turn the value into a scale for 0 to 1400 for pH (corresponding to 0.00 to 14.00 pH) and the conductivity is scaled for 0 to 100 for mS/cm (corresponding to 0.0 to 10.0 mS/cm ).

Now, to calibrate these two, it comes down to basically displaying the current sensor value on the screen and changing the offset or trimmer pots to set the sensor to the buffer solution currently being measured.

So I've got a couple questions, firstly can I have the SCP command run every loop through? I know that I've set the card to update without filtering for 130mS update so it probably won't be having a new value every loop but Im just concerned if weather the SCP command will take up significant processing time? I'm guessing not..

Now as for actually taking measurements, I'd imagine I'm going to want to take some averaged measurements over time.. So this brings up the question of whether there is a way to see if the measurement has updated....Here is an example, lets say I have measurement values of 5,3,6,2. Now the actual average of these should be (5+3+6+2)/4 = 4. However, if I just simply added it up every cycle I could end up with (5+5+3+3+6+6+2)/7=4.28 which would not be correct... So I'm wondering if there is a way to only update the average with new measurements?

Thanks!
 
You could use a compare to see if the value has changed and move the new value to a new register use this register for your display
 
I thought of that but for averaging how will I know if the measurement remains the same? I dont think it will count towards the average as faras I can tell?
 
Like bce123 said, compare SCP output to a storage register, if the values are NEQ, take action, then move new value to storage value. That way you only take samples for averaging when the value changes.

Let's say that N7:0 is the value returned from SCP each scan. N7:1 is the stored value. We'll use N7:10-19 for the samples to be averaged. We'll store the sum in F8:0 in case it's too large for a 16-bit register. N7:2 will be the average of 10 samples.

Code:
SOR NEQ N7:0 N7:1 BST MOV N7:0 N7:1 NXB SUB F8:0 N7:10 F8:0
NXB COP N7:11 N7:10 9 NXB MOV N7:0 N7:19 NXB ADD F8:0 N7:0 F8:0
NXB MUL F8:0 .1 N7:2 BND EOR
This method will give you a rolling average of the last 10 samples that will only be updated when a new value comes in, rather than every scan. This will only return an accurate average once all 10 sample registers (or you can adjust for however many samples you need) are full. If that is an issue, then you can add an ADD block to increment an integer every time a sample is added until the queue is full, then divide the sum by the sample count, rather than MUL by .1, i.e.:

Code:
LES N7:3 10 ADD N7:3 1 N7:3 DIV F8:0 N7:3 N7:2
 

Similar Topics

I am converting an old Siemans program to AD and I have a couple of questions. Looking at the old printout I guess NETZWERK # is equal to a...
Replies
5
Views
1,932
Hello. I have a couple of very basic questions about RSL5000. I went through training many years ago but haven't used it much since. First, the...
Replies
2
Views
2,042
I have been using GE versapro extensively for years now, but my company has decided to use some new Direct 06 plcs for some trial applications. I...
Replies
1
Views
1,193
1 when converting from a micro 1000 to a micro 1400 can I replace a OSR instruction with a ONS instruction the OSR for a 1400 is set up different...
Replies
7
Views
1,800
Hey all- I'm a total n00b when it comes to PLC programming so I apologize in advance for the stupidity of these questions. I'm using RSLogix...
Replies
3
Views
1,801
Back
Top Bottom