Host Engineering Forum
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
March 27, 2017, 01:38:32 am


Login with username, password and session length


Pages: [1] 2 3 ... 10
 1 
 on: March 26, 2017, 07:14:56 pm 
Started by Mike Nash - Last post by Mike Nash
In particular, TimeStamp(thousandths)

I see this is available in scripting and I would like to know if it is possible to get the time to more than the seconds elsewhere.

So how does TimeStamp get the sub-second values and can I get them also?

BACKSTORY

This gets back to wanting to use indexed arrays but not seeing a good way to use an indexed timer (the timers don't accumulate time while not "active") to check if a certain period of time has elapsed since the last "event" for each indexed value. SO if it has been 30 seconds since D[V0] was true I need to do SOMETHING, but T[V0] only accumulates while V0 is that value but I am incrementing V0 multiple times per second. This led to my saving $NOW+30 in D[V0+50] and comparing D[V0+50] against $NOW to determine if 30 seconds has elapsed. But seconds is the resolution (which is fine at the moment.)


 2 
 on: March 25, 2017, 03:17:25 pm 
Started by BobO - Last post by BobO
Well, I was just thinking about a few possibilities. For instance, I have a machine. It calculates the amount of time (in minutes) the machine runs per shift, the total production during that shift, and the average production (total production/minutes ran). I was going to make the log write those values to a file. So, if I'm writing those logs to a file anyway, I figured I could use the last 5/10 values or so to produce weekly averages, without having to write the daily values to memory locations and then calculate it.

It would be far more work to access and parse from the file, than to track it in memory. I would do something similar to the attached image. Small code...but packed...so I'll describe it:
1. The DT2EPOCH converts the current time stamp to seconds since 1970 and stores in D0.
2. The first MATH box converts seconds in D0 to a daily index of 0 to 15 (16 days, including weekends) and stores in V0.
3. The second MATH box would be run every day at the same time to store today's run time (D1) into CachedData[0 to 15]. This is a ring buffer, that just goes CachedData0 to CachedData15, and then wraps. But sure to do this every day, writing 0 on days the machine doesn't run.
4. The third MATH box calculates the average time of all non-zero CachedData values using CountIfNE and SumIfNE. CountIfNE determines the number of elements in CachedData that aren't zero. SumIfNE calcs the sum of those non-zero elements.

In the data view, V0 contains the day index, R0 contains the current average, and CachedData0-15 shows the data.

Pretty easy really and far less code than reading and parsing a log file.

 3 
 on: March 25, 2017, 11:25:33 am 
Started by BobO - Last post by Evilbeard
I guess the biggest thing I don't get is, how do I read the data points from the log file. I guess I don't grasp the pointer and how it functions.

The output of FILELOG really isn't optimized for a PLC program, it's optimized for a spreadsheet or other PC based app. If you are wanting to log things internally, and then access that log to read values back in and act on them, it might be easier to go a different direction. Maybe you could give us a little more detail of what you are wanting to do, and we can give you some guidance.

Well, I was just thinking about a few possibilities. For instance, I have a machine. It calculates the amount of time (in minutes) the machine runs per shift, the total production during that shift, and the average production (total production/minutes ran). I was going to make the log write those values to a file. So, if I'm writing those logs to a file anyway, I figured I could use the last 5/10 values or so to produce weekly averages, without having to write the daily values to memory locations and then calculate it.

 4 
 on: March 24, 2017, 02:01:08 pm 
Started by BobO - Last post by BobO
I guess the biggest thing I don't get is, how do I read the data points from the log file. I guess I don't grasp the pointer and how it functions.

The output of FILELOG really isn't optimized for a PLC program, it's optimized for a spreadsheet or other PC based app. If you are wanting to log things internally, and then access that log to read values back in and act on them, it might be easier to go a different direction. Maybe you could give us a little more detail of what you are wanting to do, and we can give you some guidance.

 5 
 on: March 24, 2017, 01:47:47 pm 
Started by BobO - Last post by Evilbeard
@Evilbeard, it might benefit you to look at the File System Training Slides for BRX.

http://www.hosteng.com/FAQFiles/BRXTraining/BRXTechTrainingSlides.html

I mean, I understand the theories, I just was curious to the limits/capabilities of these additions.

I guess the biggest thing I don't get is, how do I read the data points from the log file. I guess I don't grasp the pointer and how it functions.

 6 
 on: March 24, 2017, 09:49:58 am 
Started by BobO - Last post by BobO
So, Could the FILEOPEN command be used to open a file on the network drive?  If it is possible, could you provide a quick example of what this would look like?

That would be incredibly cool though! The DM1x runs bare metal (no OS) so the facilities to do such things don't exist.

 7 
 on: March 24, 2017, 08:25:59 am 
Started by BobO - Last post by racrowd
So, Could the FILEOPEN command be used to open a file on the network drive?  If it is possible, could you provide a quick example of what this would look like?
No.  FILEOPEN can only reference files within the PLC itself, either on the PLC's RAM Drive (@RamFS) or the SD Card (@SDCardFS).

If you want to LOG data to a PC, you can do that using the DmLogger Window's application that is installed with Designer, and use STREAMOUT instruction with @DmLogger "device".

If you need to READ data or do more complex file I/O, you would have to implement a protocol to reference data on a PC/Server, which can be done using the Do-mores Ethernet TCP and/or UDP instructions, and some kind of software running on the PC/Server.  Many users have done this.  I would recommend you create a new topic with some details of what you are looking for.  Many users can help you down that path.
I was just trying to grasp the capability.  I've used the file command with the dmlogger to log to csv file.  It works well and is really simple.

 8 
 on: March 24, 2017, 08:14:21 am 
Started by BobO - Last post by franji1
So, Could the FILEOPEN command be used to open a file on the network drive?  If it is possible, could you provide a quick example of what this would look like?
No.  FILEOPEN can only reference files within the PLC itself, either on the PLC's RAM Drive (@RamFS) or the SD Card (@SDCardFS).

If you want to LOG data to a PC, you can do that using the DmLogger Window's application that is installed with Designer, and use STREAMOUT instruction with @DmLogger "device".

If you need to READ data or do more complex file I/O, you would have to implement a protocol to reference data on a PC/Server, which can be done using the Do-mores Ethernet TCP and/or UDP instructions, and some kind of software running on the PC/Server.  Many users have done this.  I would recommend you create a new topic with some details of what you are looking for.  Many users can help you down that path.

 9 
 on: March 24, 2017, 08:04:34 am 
Started by BobO - Last post by racrowd
So, Could the FILEOPEN command be used to open a file on the network drive?  If it is possible, could you provide a quick example of what this would look like?

 10 
 on: March 23, 2017, 10:34:05 am 
Started by ElroyJetson - Last post by ElroyJetson
Is your DTDIFF result negative?  Modulo does not work as expected on negative values.  Just swap your DTDIFF order to make it a "positive" difference.  Or programmatically see if you need to negate the negative result before doing any divides or modulo?!?

Yes it was, but I had done exactly as you said and reversed the DTDIFF....

Muchos Gracias!!!!

Pages: [1] 2 3 ... 10
Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM