You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old July 15th, 2017, 10:38 AM   #1
Node1
Member
United States

Node1 is offline
 
Join Date: Jul 2017
Location: USA
Posts: 4
Avg of a array

I am trying to find the average of a array[31]. I am using the AVE instruction. My destination value is 1.$. Is that because there are 0 or null values? How do you seperate out the 0 or null values before using the AVE instruction?

Controller 1769-L33ERM
Revision 24.11
  Reply With Quote
Old July 15th, 2017, 11:17 AM   #2
keshik
Lifetime Supporting Member
Canada

keshik is online now
 
Join Date: Jun 2011
Location: Portland, OR
Posts: 325
What data type is the array?
  Reply With Quote
Old July 15th, 2017, 11:24 AM   #3
Node1
Member
United States

Node1 is offline
 
Join Date: Jul 2017
Location: USA
Posts: 4
real
  Reply With Quote
Old July 15th, 2017, 11:32 AM   #4
labeledas
Member
Canada

labeledas is offline
 
labeledas's Avatar
 
Join Date: Apr 2010
Location: Peace River Alberta
Posts: 524
1.$ or 1.QNAN means you have and undefined number, which would be from a Null. 0's would not cause this unless in the divisor.

How is the array created you could always prefill it with zeros
  Reply With Quote
Old July 15th, 2017, 11:39 AM   #5
Node1
Member
United States

Node1 is offline
 
Join Date: Jul 2017
Location: USA
Posts: 4
How would you single out the 0's or null values
  Reply With Quote
Old July 15th, 2017, 11:40 AM   #6
Node1
Member
United States

Node1 is offline
 
Join Date: Jul 2017
Location: USA
Posts: 4
or prefill it with 0's
  Reply With Quote
Old July 15th, 2017, 11:49 AM   #7
labeledas
Member
Canada

labeledas is offline
 
labeledas's Avatar
 
Join Date: Apr 2010
Location: Peace River Alberta
Posts: 524
you could use an FLL to prefill it with zeros how is the whole process iniated? how often do you need to prefill it? or is it a one time thing?

for a one time thing I will just manually do it

some suggestion for prefill in this thread

http://forums.mrplc.com/index.php?/t...-rslogix-5000/

Last edited by labeledas; July 15th, 2017 at 11:52 AM.
  Reply With Quote
Old July 15th, 2017, 04:11 PM   #8
ganutenator
Member
United States

ganutenator is offline
 
ganutenator's Avatar
 
Join Date: May 2002
Location: akron, ohio
Posts: 990
roll your own.
an average is just the total divided by the number of samples.
the toughest part is knowing when to reset the average w/ new samples.
  Reply With Quote
Old July 16th, 2017, 08:43 AM   #9
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
daba's Avatar
 
Join Date: Jul 2004
Location: uk
Posts: 3,914
No need for a pre-fill. When arrays are created, they will be filled with zero value. "Null" values isn't a concept that the O/S supports or recognises. Something must have corrupted one or more values since it was created.

The only way to corrupt a REAL array is to FLL, COP or CPS something that isn't a properly-encoded REAL into it. This is because those instructions take no notice of data-type, and are just fast "byte-for-byte" copiers.

EDIT : Actually 1.$ is "infinity", usually preceded by + or -, and the only way I can figure how you might get that as a result is if you have the LENgth specified as longer than the array, and the instruction is picking up stuff from memory outside of the array tag
__________________
___________________________
ControlLogix & SLC Training
a-b train ltd.
abtrain@tiscali.co.uk
www.abtrain.co.uk
tel: 07506 73 9999
nil illegitimi carborundem



Last edited by daba; July 16th, 2017 at 09:10 AM.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Help Sorting a Dynamic Array (elements) in Logix 5K skyfox LIVE PLC Questions And Answers 9 June 11th, 2017 11:18 PM
Variable array size call to add-on instruction - A solution Mr Modbus LIVE PLC Questions And Answers 4 July 17th, 2015 07:59 AM
Array of struct dahnuguy LIVE PLC Questions And Answers 9 November 21st, 2012 10:27 PM
RSLogix Array Pains BillRobinson LIVE PLC Questions And Answers 4 June 3rd, 2010 11:56 PM
Building an S7 Array Move Questions DesertDog LIVE PLC Questions And Answers 19 June 17th, 2004 09:51 AM


All times are GMT -5. The time now is 01:52 PM.


.