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 May 9th, 2016, 01:52 PM   #16
xC0MMAND0x
Member
United States

xC0MMAND0x is offline
 
xC0MMAND0x's Avatar
 
Join Date: Jul 2013
Location: Minnesota
Posts: 265
You can also just the built in DATALOG files and function within ViewSE - and set that to log to an ODBC source. You can have it run on a condition, timer, or whatever you want. This method would bypass all of the VBA (although very nice of the user to post all of that for you, and that is definitely an option).

Really though, instead of doing VBA logging or DATALOGs you might want to look at getting them a small Historian and putting things an a real Historian. It also comes with 1 named user for VantagePoint, so you would have reporting capabilities as well.
  Reply With Quote
Old May 9th, 2016, 01:56 PM   #17
CaseyH
Member
United States

CaseyH is offline
 
Join Date: May 2016
Location: South Carolina
Posts: 3
Quote:
Originally Posted by jkerekes View Post
I think you might have a problem using ME for this. ME doesn't support VBA in any way. Is this ME running on a PV+ or a PC running ME Station? There is a way I believe to get the FT Diagnostics to a DB, but I'm not positive. But this won't give you much flexibility on what is recorded.
I'll have to ask my client to answer that question. Before I do that, though, do you mean that ME doesn't support the method used in the example detailed above, or that ME might not support me doing what I want to do here at all?
  Reply With Quote
Old May 9th, 2016, 01:57 PM   #18
xC0MMAND0x
Member
United States

xC0MMAND0x is offline
 
xC0MMAND0x's Avatar
 
Join Date: Jul 2013
Location: Minnesota
Posts: 265
You can't do any VBA with ME, so if you are trying to log items to a database, either get a historian and do it the "right" way, or use something like an OLDI module to send values from a PLC to a SQL DB - you could run sprocs or whatever you need and get those tags back into PLC registers and then have tags on your HMI point to the proper values.

ME is very limiting.
  Reply With Quote
Old May 9th, 2016, 02:03 PM   #19
CaseyH
Member
United States

CaseyH is offline
 
Join Date: May 2016
Location: South Carolina
Posts: 3
Quote:
Originally Posted by xC0MMAND0x View Post
You can't do any VBA with ME, so if you are trying to log items to a database, either get a historian and do it the "right" way, or use something like an OLDI module to send values from a PLC to a SQL DB - you could run sprocs or whatever you need and get those tags back into PLC registers and then have tags on your HMI point to the proper values.

ME is very limiting.
Thanks, xC0MMAND0x. Can you elaborate on "historian?"
  Reply With Quote
Old May 9th, 2016, 04:14 PM   #20
xC0MMAND0x
Member
United States

xC0MMAND0x is offline
 
xC0MMAND0x's Avatar
 
Join Date: Jul 2013
Location: Minnesota
Posts: 265
Historian is essentially a way to log values of tags over long periods of time. Rockwell has Historian ME (machine edition) which is a physical device that plugs into a ControlLogix chassis.

They also have Historian SE (Software Edition) which is software based. You would need a server set up to install the Historian, and another to run Vantagepoint (reporting). You can install both on the same server, but it's not recommended unless you have specific considerations (there is a Rockwell KB article on this).

Basically you set up your Historian, license it for X # of tags, choose the tags you want historized, and then their values are constantly logged (and highly compressed) in a proper time series database.

You can you VantagePoint to report based off of the Historian data, or use the built in trend client in FactoryTalk View SE to visualize historical data (and not just live values).

http://www.rockwellautomation.com/ro...historian.page

Feel free to PM me if you want more info or if you are looking for contract type work - we set up and work with Historians all the time and a large number of sites and have a team mainly dedicated to writing custom reports.
  Reply With Quote
Old May 10th, 2016, 07:17 AM   #21
Rod Akers
Member
United States

Rod Akers is offline
 
Join Date: Apr 2011
Location: Clifton Park, NY
Posts: 1
Thank you

rdrast

Thank you for your posts here. I have been beating my brains out with this problem for a month now. Your explanation was superb. Thank you.
  Reply With Quote
Old May 12th, 2016, 05:48 AM   #22
realTIP
Member
Russian Federation

realTIP is offline
 
Join Date: May 2016
Location: Vlg
Posts: 1
Hi rdrast!
we have some stored procedures and its correctly logs.
But we tried return some info from sql server, and its doesnt work.
Code:
USE [Praxair_trends]
GO
/****** Object:  StoredProcedure [dbo].[Add_Indexed_Sample]    Script Date: 05/12/2016 13:37:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[Add_Indexed_Sample] 
	-- Add the parameters for the stored procedure here
	@timestamp datetime,
	@data1 varchar(20),
	@data2 varchar(20),
	@data3 varchar(20),
	@data4 varchar(20),
	@Index_C int out 
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT IGNORE INTO Tests values(@timestamp, @data1, @data2, @data3, @data4)
	Set @Index_C = (SELECT  @@ROWCOUNT from Tests);
	RETURN  
END
and i dont know how i should accept it in VBA.
can you help as...
  Reply With Quote
Old September 29th, 2016, 07:17 AM   #23
chaitra.hebbar
Member
India

chaitra.hebbar is offline
 
Join Date: Sep 2016
Location: banglore
Posts: 1
HI, If you have any sample code to do data logging for FT view SE tags in to SQL data base tables and to read data's from the same table to display? ( for FT view SE ) Please send the same to my email id: chaitra.hebbar@hobvision.com

Thanks & regards,
Chaitra hebbar
  Reply With Quote
Old October 14th, 2016, 08:52 AM   #24
notausp
Member
Brazil

notausp is offline
 
Join Date: May 2016
Location: Americana
Posts: 14
Quote:
Originally Posted by rdrast View Post
Note that this sub here assumes that you have a stored procedure on the database that takes 4 values, inserts them into some table, and returns the row-index of the inserted row
'************************************************* ******************
' Add_Sample_Cmd
' Called when display is first loaded, and creates the interface
' to the database stored procedure to add Reel Report Records, then
' attaches it to the global database connection.
'************************************************* ******************

Public Sub Add_Sample_Cmd()

Dim pPar As ADODB.Parameter

If pPar Is Nothing Then
Set pPar = New ADODB.Parameter
End If

On Error GoTo ErrHandler

If EnableReportAndLogging = False Then
Exit Sub
End If

If oCmdAddSample Is Nothing Then
Set oCmdAddSample = New ADODB.Command
End If

oCmdAddSample.CommandText = "sp_Add_Sample"
oCmdAddSample.CommandType = adCmdStoredProc
oCmdAddSample.Name = "Add_Sample"


Set pPar = oCmdAddSample.CreateParameter("RV", adInteger, adParamReturnValue)
oCmdAddSample.Parameters.Append pPar

Set pPar = oCmdAddSample.CreateParameter("DBDataTag1", adInteger, adParamInput)
oCmdAddSample.Parameters.Append pPar

Set pPar = oCmdAddSample.CreateParameter("DBDataTag2", adVarChar, adParamInput, 20)
oCmdAddSample.Parameters.Append pPar

Set pPar = oCmdAddSample.CreateParameter("DBDataTag3", adVarChar, adParamInput, 20)
oCmdAddSample.Parameters.Append pPar

Set pPar = oCmdAddSample.CreateParameter("DBDataTag4", adVarChar, adParamInput, 20)
oCmdAddSample.Parameters.Append pPar

Set pPar = oCmdAddSample.CreateParameter("Identity", adVarChar, adParamOutput, 20)
oCmdAddSample.Parameters.Append pPar

Set oCmdAddSample.ActiveConnection = oConn

Exit Sub
ErrHandler:
LogDiagnosticsMessage Err.Number & " " & Err.Description & " Sub: Add_Sample_Cmd() ", ftDiagSeverityInfo


End Sub[/ladder]
How do I create this "sp_Add_Sample" stored procedure?
I'm almost there...any help would be pretty much appreciated.
  Reply With Quote
Old October 14th, 2016, 01:32 PM   #25
notausp
Member
Brazil

notausp is offline
 
Join Date: May 2016
Location: Americana
Posts: 14
Nevermind, it worked! Thank you so much rdrast!
  Reply With Quote
Old December 4th, 2017, 10:17 AM   #26
crawler009
Member
Switzerland

crawler009 is offline
 
crawler009's Avatar
 
Join Date: Feb 2012
Location: Planet Earth
Posts: 184
Hello Guys, i want to share my test code about writing and reading values from/to SQL Database from FTV. It very simple, but works.

Code:
Option Explicit
Const sConnString As String = "Provider=SQLOLEDB;Data Source=\SQLEXPRESS;" & "Initial Catalog=TimeLog;" & "Integrated Security=SSPI;"
'Server name = SQLEXPRESS; Database name = TimeLog; Table name = testVBAtable; table has 3 columns: [DateTime], [Value1], [Value2]

Sub WriteToSqlServer()
On Error GoTo errHandler

    Dim conn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim dateandtime
    Dim Value1 As Double
    Dim Value2 As Double
    Dim command As String

    ' Create the Connection and Recordset objects.
    Set conn = New ADODB.Connection
    Set rs = New ADODB.Recordset

    ' Open the connection and execute.
    conn.Open sConnString
    
    dateandtime = Now()
    Value1 = 58456.546
    Value2 = 1415.1516
    
    command = "INSERT IGNORE INTO [testVBAtable] VALUES ('" & dateandtime & "', " & Value1 & ", " & Value2 & "); "
    
    Set rs = conn.Execute(command)
                       
    ' Clean up
    If CBool(conn.State And adStateOpen) Then conn.Close
    Set conn = Nothing
    Set rs = Nothing

Exit Sub
errHandler:
    LogDiagnosticsMessage ("WriteToSqlServer error " & Conversion.Hex(Err.Number) & " " & Err.Description)
End Sub


Sub ReadFromSqlServer()
On Error GoTo errHandler

    Dim conn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim dateandtime
    Dim Value1 As Double
    Dim Value2 As Double
    Dim command As String

    ' Create the Connection and Recordset objects.
    Set conn = New ADODB.Connection
    Set rs = New ADODB.Recordset

    ' Open the connection and execute.
    conn.Open sConnString
    
    ' Read the data from the last entry to the database
    command = "SELECT TOP (1) [DateTime], [Value1], [Value2]  FROM [testVBAtable] order by [DateTime] desc"
    
    Set rs = conn.Execute(command)
    
    dateandtime = rs("DateTime")
    Value1 = rs("Value1")
    Value2 = rs("Value2")
    
    rs.Close
                   
    ' Clean up
    If CBool(conn.State And adStateOpen) Then conn.Close
    Set conn = Nothing
    Set rs = Nothing

Exit Sub
errHandler:
    LogDiagnosticsMessage ("ReadFromSqlServer error " & Conversion.Hex(Err.Number) & " " & Err.Description)
End Sub

Last edited by crawler009; December 4th, 2017 at 10:52 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


All times are GMT -5. The time now is 12:05 PM.


.