YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Using PIPutVal for single data point Options · View
Chris Buresh
#1 Posted : Wednesday, July 27, 2011 3:25:31 PM
Rank: Newbie
Groups: Member

Joined: 7/27/2011
Posts: 4
Location: Minnesota
I don't really know what I'm doing, so need some help in using PIPutval function. I've tried to modify the code we've been using from OSI that loads a set of data to respective tags. My goal is to do this for a single point only, but the highlighted line needs debugging. I don't even understand what the "PIPutVal" refers to in this line - like I said I don't know what I'm doing.

Sub PIPutVal1()

Dim sTagname As String 'Tagname
Dim stime As String 'Timestamp
Dim valueCell As Range 'Cell reference containing value to be written
Dim resultCell As Range 'Cell reference to hold result

Dim macroResult As Variant

Set resultCell = Cells(24, 9)
Set valueCell = Cells(24, 8)
sTagname = Cells(4, 3).Text
stime = Cells(24, 7).Text

'Call the PIPutVal() macro function
'Note that we pass just a , for the PIServer argument; i.e., we
'are using the default PIServer
macroResult = Application.Run("PIPutVal", sTagname, valueCell, stime, , resultCell)
End Sub

Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
squatty
#2 Posted : Wednesday, July 27, 2011 3:58:49 PM
Rank: Advanced Member

Groups: Member

Joined: 4/7/2011
Posts: 137
Location: KZN, South Africa
Hi Chris

Welcome to RJK.

The code work on my side as long as I have the following.

Cell C4 must have a valid PI tag
Cell G24 must have a timestamp
Cell H24 must have a value to write

In Excel Cell(24,9) actually means row 24 & column 9 or "I"

I think your problem might be that you don't have all the valid entries required in order to write a value to a tag. You can try and debug your result by adding the debug.print into your VBA code. Make sure you have your Immediate window open. In VBA click "View->Immediate Window", add the debug.print section as in bold below and see what your results are.

Sub PIPutVal1()

Dim sTagname As String 'Tagname
Dim stime As String 'Timestamp
Dim valueCell As Range 'Cell reference containing value to be written
Dim resultCell As Range 'Cell reference to hold result

Dim macroResult As Variant

Set resultCell = Cells(24, 9)
Set valueCell = Cells(24, 8)
sTagname = Cells(4, 3).Text
stime = Cells(24, 7).Text

'Call the PIPutVal() macro function
'Note that we pass just a , for the PIServer argument; i.e., we
'are using the default PIServer

Debug.Print sTagname
Debug.Print valueCell
Debug.Print stime
Debug.Print resultCell

macroResult = Application.Run("PIPutVal", sTagname, valueCell, stime, , resultCell)
End Sub
Chris Buresh
#3 Posted : Wednesday, July 27, 2011 4:12:28 PM
Rank: Newbie
Groups: Member

Joined: 7/27/2011
Posts: 4
Location: Minnesota
The debug return this...

81AI0004
0.69
24-Jul-11 23:38:00

Is there a specific date/time format needed? The timestamp referred to here is generated from finding the next entry after a given time (G22).

=PIArcVal($C$4,$G$22, 1,"Father","next only")

squatty
#4 Posted : Thursday, July 28, 2011 9:15:48 AM
Rank: Advanced Member

Groups: Member

Joined: 4/7/2011
Posts: 137
Location: KZN, South Africa
Is the data security attribute configured correctly to allow the user/s to write to this tag.

Depending your you PI-UDS version and PI-TagCnf version you should have something like this.
piadmin: A(r,w) | piadmins: A(r) | PIWorld: A(r,w)

Chris Buresh
#5 Posted : Thursday, July 28, 2011 1:19:34 PM
Rank: Newbie
Groups: Member

Joined: 7/27/2011
Posts: 4
Location: Minnesota
Both the dataaccess and ptaccess have o:rw, g:rw, w:rw. This tag gets written to every day as well as hundreds of others with the same configuration, so I don't think there is a hurdle there.
Chris Buresh
#6 Posted : Thursday, July 28, 2011 3:01:58 PM
Rank: Newbie
Groups: Member

Joined: 7/27/2011
Posts: 4
Location: Minnesota
For some reason it works now after Excel froze on me and needed restarting. I should have following the golden rules.

1) Is it plugged in and turned on?
2) Restart it.
3) Kick it.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.