Sign in to follow this  
Followers 0
FET_Destroyer

cx-supervisor data with timestamp format

4 posts in this topic

Hello Guys, I'm with some doubts regarding cx-supervisor. I need to read/write data from one CJ2M plc, I was thinking on cx-server opc, but my company already bought a cx-supervisor licence so I will have to use it. My question is, I'm reading 3 words from PLC, A351,352 and 353 with date information, I want to save it to a SQLserver db with timestamp format, but my knowledge in cx-supervisor is very small. I may have to program it in VB right? Can somebody help me with it? Regards

Share this post


Link to post
Share on other sites
if it is cx-supervisor plus than you can connect directly to sql server database (using odbc - checkout the user's manual section Databases) and use cx-s script commands to read/write data to database. i recomend to use sql server's function to insert a timestamp into record in the moment of writing to database e.g. make a field date_time of datetime type and in Default value or binding property put (getdate()) function. regards

Share this post


Link to post
Share on other sites
you can extract info from A351, 352 etc words in scada and create a textual point containing a date and time information. you can create it in datetime format SQL Server uses (something like 2013-12-09 11:45:23 but I am not sure if this depends on regional settings - i think not since this is I suppose some standard. also, I think in SQL Server's datetime format there are miliseconds). this way you can treat later in SQL statements field Date_Time as datetime type. you can do that in plc also - create a string with date and time. for plc or scada conversion try this: (* this is ST code you can put this in FB. similar is for SCADA *) MySecond := MOD(WORD_BCD_TO_UINT (mmss), 100); (* mmss is A351 *) MyMinute := WORD_BCD_TO_UINT (mmss) / 100; MyHour := MOD(WORD_BCD_TO_UINT (DDHH), 100); (* DDHH is A352 *) MyDay := WORD_BCD_TO_UINT (DDHH) / 100; MyMonth := MOD( WORD_BCD_TO_UINT (YYMM), 100); (* YYMM is A353 *) MyYear := WORD_BCD_TO_UINT (YYMM) / 100 + 2000; Date_Time := UINT_TO_STRING(MyYear) + '-' + UINT_TO_STRING(MyMonth) + '-' + UINT_TO_STRING(MyDay) + ' ' + UINT_TO_STRING(MyHour) + ':' + UINT_TO_STRING(MyMinute) + ':' + UINT_TO_STRING(MySecond); (* end of code *) Where Date_Time is in/out since editor doesn't allow string type as only output: Date_Time STRING EXTERNAL 0 20 Watch out for data format, A351 ... A353 are UINT_BCD therefore the conversions. since you use A351...A353 for creating your timestamps for alarms I suppose they too are of UINT_BCD. regards Edited by tashinz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0