News:

  • May 15, 2025, 04:13:14 PM

Login with username, password and session length

Author Topic: brx question  (Read 6490 times)

maciek

  • Sr. Member
  • ****
  • Posts: 95
brx question
« on: April 06, 2017, 08:03:10 PM »
i have a pressure sensor and use c1 as pressure drop contact, every time it goes on i want to save the time and date and number of times this happened, what is an easy way to accomplish this. i did this before with click counter and copy in DS instructions but it was a lot of work. any ideas for easier way   

ASabb

  • Newbie
  • *
  • Posts: 1
Re: brx question
« Reply #1 on: April 07, 2017, 02:14:03 AM »
i have read this great D-Bal Max review and use c1 as pressure drop contact, every time it goes on i want to save the time and date and number of times this happened, what is an easy way to accomplish this. i did this before with click counter and copy in DS instructions but it was a lot of work. any ideas for easier way     

Hi Maciek, did you get it worked out yet?
« Last Edit: March 24, 2022, 08:01:33 AM by ASabb »

MikeS

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 254
    • Host Engineering, Inc.
Re: brx question
« Reply #2 on: April 07, 2017, 09:39:23 AM »
the simplest way is:

Leading Edge One Shot (C1) ------ MEMCOPY ( $Now, UDT0 )

Each time C1 transitions from OFF to ON the MEMCOPY instruction will copy the current Date & Time ($Now) to the user Date/Time structure UDT0.

Whether or not this is what you need depends on what you intend to do with the Date & Time data.
Good design costs a lot. Bad design costs even more.

Dean

  • Sr. Member
  • ****
  • Posts: 73
Re: brx question
« Reply #3 on: April 07, 2017, 10:59:32 AM »
Sounds like a job for the FILELOG instruction. Built in timestamp and everything.
How about Rising edge C1 triggers CT0, and then triggers logging of the CT0.Acc value.
10 Lather
20 Rinse
30 GOTO 10

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3745
    • Host Engineering
Re: brx question
« Reply #4 on: April 10, 2017, 09:17:58 AM »
Another possibility is the User Log that has been there since 1.0.  Use the STREAMOUT instruction with the @UserLog device.  Use STRPRINT to generate the log string.  It also has a built-in date/time stamp (see attached screenshot)

To access the User and System Logs within Designer, use PLC->System Information... Event Logs tab.  If needed, you can export the logs from that dialog.

Evilbeard

  • Hero Member
  • *****
  • Posts: 160
Re: brx question
« Reply #5 on: April 10, 2017, 11:26:12 AM »
Could this also be an option? Whenever the sensor comes on, it copies the EPOCH in the D location. It then converts the epoch to D/T and writes that into the Memory Block that you configure as PressureLog0-255.

So if you viewed PressureLog0-255, it would give you the last 256 timestamps of the pressure valve coming on, and then start over when it reached the limit.


franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3745
    • Host Engineering
Re: brx question
« Reply #6 on: April 10, 2017, 11:49:42 AM »
copies the EPOCH in the D location

Even easier, use a MOVE with DST22 ($LocalTime) as the source into D[V0].  DST22 is the 1970 Epoch value without needing to use MATH/Now().

In Data View, you can enter DST22 or D[V0], and select "1970 Epoch" in the Format drop-down on the Data View toolbar to get the date/time text.

I know it's hard to remember all the DST System elements and what they mean.  If you use the Element Picker, type just a few "critical" characters of what you think is in the nickname in the Show only Nicknames containing the text field.  So I entered "time" in the attached example, and it reduced the nickname list in the Element Picker to just those that contain the text "time" anywhere in the nickname.


maciek

  • Sr. Member
  • ****
  • Posts: 95
Re: brx question
« Reply #7 on: April 14, 2017, 02:18:06 PM »
wow you guys know your

maciek

  • Sr. Member
  • ****
  • Posts: 95
Re: brx question
« Reply #8 on: April 14, 2017, 03:45:38 PM »
can you tell me what this  D[V0] do or what is means

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3595
  • Darth Ladder
Re: brx question
« Reply #9 on: April 14, 2017, 04:49:09 PM »
Indirect addressing.  If V0 == 10, then D[V0] points to D10.  Very powerful tool for efficient programming, and sometimes they only way to do a given task.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Evilbeard

  • Hero Member
  • *****
  • Posts: 160
Re: brx question
« Reply #10 on: April 16, 2017, 08:32:33 AM »
can you tell me what this  D[V0] do or what is means

It's indirect addressing using an array. This uses the accumulated number in the counter and writes to that D memory location. Basically, I've copied the counter's .acc number to a V memory location (because arrays have to use v memory locations). Then we write to that D memory location. The first time your trigger comes on, it writes to D0 (the counter is still at 0). The next time, the counter will be at 1, so it'll write to D1. It'll keep going until it gets to D255, and then it'll start back over at D0. So if you just view D0-D255, it will show you the times where your input came on.
« Last Edit: April 16, 2017, 10:34:33 AM by Evilbeard »

Evilbeard

  • Hero Member
  • *****
  • Posts: 160
Re: brx question
« Reply #11 on: April 16, 2017, 09:22:36 AM »
This could be an even simpler solution if it's what you're looking for:

Using the FILELOG function. On the edge of the sensor, it writes an entry into the log file. (you can store the log on the limited ram of the CPU or utilize a 32GB microSD card that you can add to the CPU). It'll write the time of the fault, as well as the number accumulated in the D location (the number of faults).









« Last Edit: April 16, 2017, 10:36:17 AM by Evilbeard »