Announcement

REXYGEN forum has been moved. This one is closed.
Head over to the new REXYGEN Community Forum at https://forum.rexygen.com.

Looking forward to meeting you there!
 

#1 2016-06-29 08:44:42

dmac101
Member
Registered: 2016-05-01
Posts: 9

DbDrv different sample times

Just wondering if it is possible to have different sample times for individual inputs or is this locked to only 1 configured in the *.rio file?

Offline

#2 2016-06-29 10:24:36

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: DbDrv different sample times

Hey dmac101,

thank you for your question.

In DbDrv configuration files it is possible to set different sample time for each "Group". See DbDrv driver user guide (p. 7/8) for more details.

Tip: if you want to force the read/write operation between two samples create an additional flag and append "__Trigger" string to the signal reference. Rising edge on this flag will force the read/write operation (see user guide above for more details - p. 10/11.)

I hope the above is useful to you.

Regards, Tomas

Offline

#3 2016-07-02 21:27:42

dmac101
Member
Registered: 2016-05-01
Posts: 9

Re: DbDrv different sample times

Thanks tomáš čechura,
I now have a level of understanding however I am struggling a little with the modes as well as how to implement the aux signals correctly for trigger, etc.

Offline

#4 2016-07-03 15:54:11

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: DbDrv different sample times

Hey dmac101,

there are also 3 simple examples on data exchange between databases and Rex Control System - these can be useful for you.

Let me know if you need anything else.

Regards, Tomas

Offline

#5 2016-07-04 06:28:35

dmac101
Member
Registered: 2016-05-01
Posts: 9

Re: DbDrv different sample times

Hey tomáš čechura,
The simple examples are pretty straight forward and make sense. The archive export on the other hand is where I am coming unstuck.
I am failing to understand the correlation between the *.rio file and the ACD/ALB blocks in the task file and how this translates to the values that are stored in the DB table

Thanks
dmac101

Offline

#6 2016-07-05 22:38:07

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: DbDrv different sample times

Hey dmac101,

typical database usecase can be as follows:
"I would like to watch my process value (i.e. temperature) and generate alarms with timestamps to my database every time the temperature gets below 0°C."
Archiving subsystem can handle alarms and archives and Database driver configured by *.rio file configures access to the database and which values are imported/exported from/to database.

Of course, it is possible to use just database driver separately without using Archiving subsystem as it is shown in one of the examples mentioned above.

If you are still in troubles, please, post your usecase and I will try to think of some suitable solution for you.

Cheers, Tomas

Offline

#7 2016-07-05 23:04:50

dmac101
Member
Registered: 2016-05-01
Posts: 9

Re: DbDrv different sample times

apologies for my lack of understanding here, but what is "usecase"?

Offline

#8 2016-07-05 23:33:25

dmac101
Member
Registered: 2016-05-01
Posts: 9

Re: DbDrv different sample times

if I create a Goto label and point it to the database I can store the values based on the defined sample time in the *.rio file. With the current measure being temperature there can be long periods of no change in value so it seems an awful waste of DB storage when using a fixed sample period. I then started to look at the "MySQL_archive_export" example and incorporate this into my project. The ADC block in this example seemed to just what I was looking for. Below is my *.rio file and settings from ADC block, with my SQL database the same as the one I used in my working example.
From what I understand the critical thing with this is to ensure that the "Items" used in the *.rio match the ID used in the block.
or have I missed something?

*.rio
ODBC {
  Connection "DRIVER=MySQL;SERVER=MySQL server;PORT=3306;DATABASE=scada;UID=myUID;PWD=MyPWD;"
  Archive{
    Mode 0
    SQL "test"
    ArchiveID 0
        Items 10
  }
}


ACD_TRon
     
      acls                    8: Double
      arc                     1
      id                      10
      tmin                   0.1
      tmax                   5
      TR                      on
      Desc                   Simulated temperature signal, TR=on

Offline

#9 2016-07-06 07:59:44

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: DbDrv different sample times

Hey!

By expression "use case" I meant some short description of your application.

Your code posted above seems to be good except "Mode 0" in your *.rio file:

DbDrv documentation wrote:

Mode – Defines the structure of reading/writing from/to the database. The options are:
For the Archive section:
0 Nothing gets exported (used for disabling the item temporarily).
1 Only the alarms and events are exported (filtered by additional parameters).
The table in the database must contain the following columns: Time, AlarmID, Code, Level, Value.
2 Only the trends are exported, i.e. the data stored by the TRND block. The data is filtered by additional parameters. The table in the  database must contain the following columns: Time, GroupID, Value1, Value2, ...
3 Only the trends are exported, but on the contrary to the above the SQL parameter has the meaning of a full SQL query, to which the values are injected. The following placeholders can be used: ?T = time; ?I =itemID; ?1 =1st item; ?2 =2nd item; ... A plain question mark has the meaning of next item in the following order: time, itemID, 1st value, 2nd value,
...; )

The numbering of Archives is quite confusing, note the different numbering of archives in the project main file, which is the numbering you use e.g. in ACD:arc parameter. In the .rio file the archives are numbered from 0. The id parameters of individual blocks are referred to as Items in the .rio file. See the screenshots which I hope make the numbering clear. It will be unified in future version.

archives_numbering.pngarchives_items.png

Hope it helps.

Cheers, Tomas

Offline

#10 2016-07-11 21:02:11

dmac101
Member
Registered: 2016-05-01
Posts: 9

Re: DbDrv different sample times

Thanks Thomas,
that makes more sense.
I have changed to mode 1, still not working correctly. I get the following error in rex view

    DBDRV: Arc:ReadXxxItem() return=-106)

Is the Archive name in the EXE block used for anything other than a reference for the programmer? or is this used in the rio file as well?

Offline

#11 2016-07-12 12:38:36

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: DbDrv different sample times

This error means "invalid parameter". For full list of Error code meanings go to Function block documentation - Appendix B.

The name is used only as a reference. The .rio file uses archives IDs as described in my previous post.

It seems that you are trying to read something either with wrong name or at a wrong place. Can you share your project files so I can have a look at it?

Cheers, Tomas

Offline

#12 2016-07-16 01:54:56

dmac101
Member
Registered: 2016-05-01
Posts: 9

Re: DbDrv different sample times

Thanks Tomas,
I have decided to go back to basic and have tried again with the MySQL simple and MYSQL archive examples.
I now have passed the simple test, and mostly passed with the archive example. From what I now understand (please correct me if I am wrong), there seems to be a couple of typos in the rio file for this example. the alarms archive refers to items 50,60 however the ID's for the Boolean alarm blocks are 50 & 51.
Also with the insert into temperature archive, the items referenced in the rio file are 1,10 where the archive compression blocks are ID's 1 & 2.

have I understood this correctly or have I missed something?

The readme for the archive example (great to see the sql table structure in the readme, it has really helped) has a column defined for "Value". I am not sure where this comes from. is this the description field in the compression block?

I am not getting any data written to the value field in my "alarm_archive" table.

Regards, Darren

Offline

#13 2016-07-17 22:05:52

josar
Member
From: Czech Rep.
Registered: 2015-11-03
Posts: 17

Re: DbDrv different sample times

The Items line in the .rio file defines intervals. It is not a list. "Items 50,60" thus means all IDs from 50 to 60 and 51 and 52 fall into this interval. The same holds for the temperature archive. See page 10 of https://www.rexcontrols.com/media/DOC/E … rv_ENG.pdf

Offline

Board footer

Powered by FluxBB