Use a timer on VBA form in DeltaV Operate

I have created a userform on a DeltaV Operate graphic. When the operator wants to start or stop a sequence, he clicks on a button on the graphic which opens the form. From the form, he selects various parameters which are sent to the sequence, which is located in a module within a DeltaV controller.

I would like to add a few links to 'live' data on this form, so that the data would update while the form is open, similar to a normal 'datalink' on a graphic. To do this I would typically use the VB 'timer' control. But I have learned that the timer control in not available in VBA. Several other options, such as using the Application.OnTime method, also do not seem to be supported within the DeltaV Operate VBA environment.

Does anyone have suggestions on how to provide a 'timer' like method that can be used within the DeltaV Operate VBA environment?

10 Replies

  • While I realize this isn't a direct answer to your question, is there any reason you couldn't use a DeltaV pop-up graphic for your operator form?  Then you could use the standard DeltaV datalink functionality.  In my mind, the closer you can stay to DeltaV functionality (and conversely the further from VBA and MS functions), the better you will be for future sustainability of the graphics.

    Brian

  • You could always add a timer to a DeltaV graphic and add the code there. 

    Aaron

    On Dec 18, 2012, at 4:17 PM, "Alan K" <bounce-Alan_K@community.emerson.com> wrote:

    I have created a userform on a DeltaV Operate graphic. When the operator wants to start or stop a sequence, he clicks on a button on the graphic which opens the form. From the form, he selects various parameters which are sent to the sequence, which is located in a module within a DeltaV controller.

    I would like to add a few links to 'live' data on this form, so that the data would update while the form is open, similar to a normal 'datalink' on a graphic. To do this I would typically use the VB 'timer' control. But I have learned that the timer control in not available in VBA. Several other options, such as using the Application.OnTime method, also do not seem to be supported within the DeltaV Operate VBA environment.

    Does anyone have suggestions on how to provide a 'timer' like method that can be used within the DeltaV Operate VBA environment?

  • Perhaps I don’t quite understand the issue, here.  A standard DeltaV faceplate has “live” links in it, that are fully supported in native form.  Could you not simply create a faceplate for this sequence module, and put whatever live links you want on it in the same manner as a faceplate does?
     
    Steve Elves | Control Systems Tech. 
    From: Aaron Crews [mailto:bounce-Aaron_Crews@community.emerson.com]
    Sent: Tuesday, December 18, 2012 5:13 PM
    To: DeltaV@community.emerson.com
    Subject: Re: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    You could always add a timer to a DeltaV graphic and add the code there. 

    Aaron

    On Dec 18, 2012, at 4:17 PM, "Alan K" <bounce-Alan_K@community.emerson.com> wrote:

    I have created a userform on a DeltaV Operate graphic. When the operator wants to start or stop a sequence, he clicks on a button on the graphic which opens the form. From the form, he selects various parameters which are sent to the sequence, which is located in a module within a DeltaV controller.

    I would like to add a few links to 'live' data on this form, so that the data would update while the form is open, similar to a normal 'datalink' on a graphic. To do this I would typically use the VB 'timer' control. But I have learned that the timer control in not available in VBA. Several other options, such as using the Application.OnTime method, also do not seem to be supported within the DeltaV Operate VBA environment.

    Does anyone have suggestions on how to provide a 'timer' like method that can be used within the DeltaV Operate VBA environment?

  • I think that was Brian's suggestion and I agree with both of you. But the specific question asked for a timer control. Those are available in DeltaV displays, just not in VBA forms. 

    Aaron

    On Dec 18, 2012, at 8:18 PM, "Steve Elves" <bounce-Steve_Elves@community.emerson.com> wrote:

    Perhaps I don’t quite understand the issue, here.  A standard DeltaV faceplate has “live” links in it, that are fully supported in native form.  Could you not simply create a faceplate for this sequence module, and put whatever live links you want on it in the same manner as a faceplate does?
     
    Steve Elves | Control Systems Tech. 
    From: Aaron Crews [mailto:bounce-Aaron_Crews@community.emerson.com]
    Sent: Tuesday, December 18, 2012 5:13 PM
    To: DeltaV@community.emerson.com
    Subject: Re: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    You could always add a timer to a DeltaV graphic and add the code there. 

    Aaron

    On Dec 18, 2012, at 4:17 PM, "Alan K" <bounce-Alan_K@community.emerson.com> wrote:

    I have created a userform on a DeltaV Operate graphic. When the operator wants to start or stop a sequence, he clicks on a button on the graphic which opens the form. From the form, he selects various parameters which are sent to the sequence, which is located in a module within a DeltaV controller.

    I would like to add a few links to 'live' data on this form, so that the data would update while the form is open, similar to a normal 'datalink' on a graphic. To do this I would typically use the VB 'timer' control. But I have learned that the timer control in not available in VBA. Several other options, such as using the Application.OnTime method, also do not seem to be supported within the DeltaV Operate VBA environment.

    Does anyone have suggestions on how to provide a 'timer' like method that can be used within the DeltaV Operate VBA environment?

  • Hi Aaron:
     
    I guess I didn’t read it the same way.  Why do you need a “timer” control if you simply want to access “live” data?  Is there some specific functionality that the VB timer control gives that is not present on a faceplate?
     
    Steve Elves | Control Systems Tech. 
    From: Aaron Crews [mailto:bounce-Aaron_Crews@community.emerson.com]
    Sent: Tuesday, December 18, 2012 6:24 PM
    To: DeltaV@community.emerson.com
    Subject: Re: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    I think that was Brian's suggestion and I agree with both of you. But the specific question asked for a timer control. Those are available in DeltaV displays, just not in VBA forms. 

    Aaron

    On Dec 18, 2012, at 8:18 PM, "Steve Elves" <bounce-Steve_Elves@community.emerson.com> wrote:
    Perhaps I don’t quite understand the issue, here.  A standard DeltaV faceplate has “live” links in it, that are fully supported in native form.  Could you not simply create a faceplate for this sequence module, and put whatever live links you want on it in the same manner as a faceplate does?
     
    Steve Elves | Control Systems Tech. 
    From: Aaron Crews [mailto:bounce-Aaron_Crews@community.emerson.com]
    Sent: Tuesday, December 18, 2012 5:13 PM
    To: DeltaV@community.emerson.com
    Subject: Re: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    You could always add a timer to a DeltaV graphic and add the code there. 

    Aaron

    On Dec 18, 2012, at 4:17 PM, "Alan K" <bounce-Alan_K@community.emerson.com> wrote:

    I have created a userform on a DeltaV Operate graphic. When the operator wants to start or stop a sequence, he clicks on a button on the graphic which opens the form. From the form, he selects various parameters which are sent to the sequence, which is located in a module within a DeltaV controller.

    I would like to add a few links to 'live' data on this form, so that the data would update while the form is open, similar to a normal 'datalink' on a graphic. To do this I would typically use the VB 'timer' control. But I have learned that the timer control in not available in VBA. Several other options, such as using the Application.OnTime method, also do not seem to be supported within the DeltaV Operate VBA environment.

    Does anyone have suggestions on how to provide a 'timer' like method that can be used within the DeltaV Operate VBA environment?

  • A faceplate would work fine. He is using a form instead for some reason. I think the gist is that he needs an event in the form to trigger the reading of the data. Since he can't add a timer to the form, he's stuck.  And as I think about it, I don't really have a good suggestion on how to get unstuck while still using a form.  

    In the past, I have read the current value upon loading the form, but never live updates.  I suppose you could add a refresh button. You could create an infinite loop, but that seems like a pretty bad idea.  Seems like there would be a timer control in VBA - I'm taking the problem at face value. 

    Aaron

    On Dec 18, 2012, at 8:29 PM, "Steve Elves" <bounce-Steve_Elves@community.emerson.com> wrote:

    Hi Aaron:
     
    I guess I didn’t read it the same way.  Why do you need a “timer” control if you simply want to access “live” data?  Is there some specific functionality that the VB timer control gives that is not present on a faceplate?
     
    Steve Elves | Control Systems Tech. 
    From: Aaron Crews [mailto:bounce-Aaron_Crews@community.emerson.com]
    Sent: Tuesday, December 18, 2012 6:24 PM
    To: DeltaV@community.emerson.com
    Subject: Re: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    I think that was Brian's suggestion and I agree with both of you. But the specific question asked for a timer control. Those are available in DeltaV displays, just not in VBA forms. 

    Aaron

    On Dec 18, 2012, at 8:18 PM, "Steve Elves" <bounce-Steve_Elves@community.emerson.com> wrote:
    Perhaps I don’t quite understand the issue, here.  A standard DeltaV faceplate has “live” links in it, that are fully supported in native form.  Could you not simply create a faceplate for this sequence module, and put whatever live links you want on it in the same manner as a faceplate does?
     
    Steve Elves | Control Systems Tech. 
    From: Aaron Crews [mailto:bounce-Aaron_Crews@community.emerson.com]
    Sent: Tuesday, December 18, 2012 5:13 PM
    To: DeltaV@community.emerson.com
    Subject: Re: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    You could always add a timer to a DeltaV graphic and add the code there. 

    Aaron

    On Dec 18, 2012, at 4:17 PM, "Alan K" <bounce-Alan_K@community.emerson.com> wrote:

    I have created a userform on a DeltaV Operate graphic. When the operator wants to start or stop a sequence, he clicks on a button on the graphic which opens the form. From the form, he selects various parameters which are sent to the sequence, which is located in a module within a DeltaV controller.

    I would like to add a few links to 'live' data on this form, so that the data would update while the form is open, similar to a normal 'datalink' on a graphic. To do this I would typically use the VB 'timer' control. But I have learned that the timer control in not available in VBA. Several other options, such as using the Application.OnTime method, also do not seem to be supported within the DeltaV Operate VBA environment.

    Does anyone have suggestions on how to provide a 'timer' like method that can be used within the DeltaV Operate VBA environment?

  • I had a similar issue with a DeltaV faceplate for a command driven module; I needed to update the available list box entry depending upon which states were available.
     
    Standard DV faceplate for command modules CDA_fp doesn’t refresh, you need to reopen the faceplate for the list items to change.
     
    To get around this I added a timer to the faceplate to keep refreshing the list items, worked well, and I assume would be fine for this kind of application.
     
    From: Aaron Crews [mailto:bounce-Aaron_Crews@community.emerson.com]
    Sent: Wednesday, December 19, 2012 5:54 AM
    To: DeltaV@community.emerson.com
    Subject: Re: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    A faceplate would work fine. He is using a form instead for some reason. I think the gist is that he needs an event in the form to trigger the reading of the data. Since he can't add a timer to the form, he's stuck.  And as I think about it, I don't really have a good suggestion on how to get unstuck while still using a form.  
     
    In the past, I have read the current value upon loading the form, but never live updates.  I suppose you could add a refresh button. You could create an infinite loop, but that seems like a pretty bad idea.  Seems like there would be a timer control in VBA - I'm taking the problem at face value. 

    Aaron

    On Dec 18, 2012, at 8:29 PM, "Steve Elves" <bounce-Steve_Elves@community.emerson.com> wrote:
    Hi Aaron:
     
    I guess I didn’t read it the same way.  Why do you need a “timer” control if you simply want to access “live” data?  Is there some specific functionality that the VB timer control gives that is not present on a faceplate?
     
    Steve Elves | Control Systems Tech. 
    From: Aaron Crews [mailto:bounce-Aaron_Crews@community.emerson.com]
    Sent: Tuesday, December 18, 2012 6:24 PM
    To: DeltaV@community.emerson.com
    Subject: Re: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    I think that was Brian's suggestion and I agree with both of you. But the specific question asked for a timer control. Those are available in DeltaV displays, just not in VBA forms. 

    Aaron

    On Dec 18, 2012, at 8:18 PM, "Steve Elves" <bounce-Steve_Elves@community.emerson.com> wrote:
    Perhaps I don’t quite understand the issue, here.  A standard DeltaV faceplate has “live” links in it, that are fully supported in native form.  Could you not simply create a faceplate for this sequence module, and put whatever live links you want on it in the same manner as a faceplate does?
     
    Steve Elves | Control Systems Tech. 
    From: Aaron Crews [mailto:bounce-Aaron_Crews@community.emerson.com]
    Sent: Tuesday, December 18, 2012 5:13 PM
    To: DeltaV@community.emerson.com
    Subject: Re: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    You could always add a timer to a DeltaV graphic and add the code there. 

    Aaron

    On Dec 18, 2012, at 4:17 PM, "Alan K" <bounce-Alan_K@community.emerson.com> wrote:

    I have created a userform on a DeltaV Operate graphic. When the operator wants to start or stop a sequence, he clicks on a button on the graphic which opens the form. From the form, he selects various parameters which are sent to the sequence, which is located in a module within a DeltaV controller.

    I would like to add a few links to 'live' data on this form, so that the data would update while the form is open, similar to a normal 'datalink' on a graphic. To do this I would typically use the VB 'timer' control. But I have learned that the timer control in not available in VBA. Several other options, such as using the Application.OnTime method, also do not seem to be supported within the DeltaV Operate VBA environment.

    Does anyone have suggestions on how to provide a 'timer' like method that can be used within the DeltaV Operate VBA environment?

  • I think the original requirement should be stated, in order that we understand exactly what is wanted.
     
    In general, my rule is NOT to try to be too clever with scripting or other heavily-customized graphics, wherever possible.  There is the very real chance that a future upgrade or change of graphics engine will nullify all the hard work and cleverness that went into the original solution.  Perhaps a command-driven module is not the best solution, from a graphics standpoint.  Perhaps the operators would be happy with a different presentation, one that fit within the core capabilities that one would expect to be forward-compatible.
     
    Whenever I come across difficult problems in some kind of implementation, I am very wary.  Usually, the problems are manufactured by “tunnel vision” in finding an answer.  If this is a tricky situation that seems to need some kind of complex scripting or other VBA “magic”, it can usually be fixed by re-framing the requirements or expectations.  This almost always works out better in the long run, even if it appears to be a compromise at the beginning.  Sometimes, a configuration engineer just has to know when to say, “No, that just can’t be done the way you want it.  Here’s an equivalent solution that will be just as good.”.
     
    Steve Elves | Control Systems Tech. 
    From: AdrianOffield [mailto:bounce-AdrianOffield@community.emerson.com]
    Sent: Tuesday, December 18, 2012 8:00 PM
    To: DeltaV@community.emerson.com
    Subject: RE: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    I had a similar issue with a DeltaV faceplate for a command driven module; I needed to update the available list box entry depending upon which states were available.
     
    Standard DV faceplate for command modules CDA_fp doesn’t refresh, you need to reopen the faceplate for the list items to change.
     
    To get around this I added a timer to the faceplate to keep refreshing the list items, worked well, and I assume would be fine for this kind of application.
     
    From: Aaron Crews [mailto:bounce-Aaron_Crews@community.emerson.com]
    Sent: Wednesday, December 19, 2012 5:54 AM
    To: DeltaV@community.emerson.com
    Subject: Re: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    A faceplate would work fine. He is using a form instead for some reason. I think the gist is that he needs an event in the form to trigger the reading of the data. Since he can't add a timer to the form, he's stuck.  And as I think about it, I don't really have a good suggestion on how to get unstuck while still using a form.  
     
    In the past, I have read the current value upon loading the form, but never live updates.  I suppose you could add a refresh button. You could create an infinite loop, but that seems like a pretty bad idea.  Seems like there would be a timer control in VBA - I'm taking the problem at face value. 

    Aaron

    On Dec 18, 2012, at 8:29 PM, "Steve Elves" <bounce-Steve_Elves@community.emerson.com> wrote:
    Hi Aaron:
     
    I guess I didn’t read it the same way.  Why do you need a “timer” control if you simply want to access “live” data?  Is there some specific functionality that the VB timer control gives that is not present on a faceplate?
     
    Steve Elves | Control Systems Tech. 
    From: Aaron Crews [mailto:bounce-Aaron_Crews@community.emerson.com]
    Sent: Tuesday, December 18, 2012 6:24 PM
    To: DeltaV@community.emerson.com
    Subject: Re: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    I think that was Brian's suggestion and I agree with both of you. But the specific question asked for a timer control. Those are available in DeltaV displays, just not in VBA forms. 

    Aaron

    On Dec 18, 2012, at 8:18 PM, "Steve Elves" <bounce-Steve_Elves@community.emerson.com> wrote:
    Perhaps I don’t quite understand the issue, here.  A standard DeltaV faceplate has “live” links in it, that are fully supported in native form.  Could you not simply create a faceplate for this sequence module, and put whatever live links you want on it in the same manner as a faceplate does?
     
    Steve Elves | Control Systems Tech. 
    From: Aaron Crews [mailto:bounce-Aaron_Crews@community.emerson.com]
    Sent: Tuesday, December 18, 2012 5:13 PM
    To: DeltaV@community.emerson.com
    Subject: Re: [EE365 DeltaV Track] Use a timer on VBA form in DeltaV Operate
     
    You could always add a timer to a DeltaV graphic and add the code there. 

    Aaron

    On Dec 18, 2012, at 4:17 PM, "Alan K" <bounce-Alan_K@community.emerson.com> wrote:

    I have created a userform on a DeltaV Operate graphic. When the operator wants to start or stop a sequence, he clicks on a button on the graphic which opens the form. From the form, he selects various parameters which are sent to the sequence, which is located in a module within a DeltaV controller.

    I would like to add a few links to 'live' data on this form, so that the data would update while the form is open, similar to a normal 'datalink' on a graphic. To do this I would typically use the VB 'timer' control. But I have learned that the timer control in not available in VBA. Several other options, such as using the Application.OnTime method, also do not seem to be supported within the DeltaV Operate VBA environment.

    Does anyone have suggestions on how to provide a 'timer' like method that can be used within the DeltaV Operate VBA environment?

  • In reply to Steve Elves:

    Thank you all for the discussion.

    In the past I have used VBA forms when I need to present choices and/or data to the operator, especially when the choices do not fit neatly into the standard YES/NO or other limited responses available using the 'Data Entry Expert', or when I need the operator to enter 2 or more pieces of data at the same time.

    This time the complexity of what I was trying to accomplish has reached a tipping point. As several have suggested, a pop-up graphic or a custom faceplate seems to be a better chioce in this case. I will proceed down that path

    Thanks again for the help

    Alan

  • In reply to Alan K:

    For future reference, you can create a timer in Operate VBA by invoking the Timer API.  

    support.microsoft.com/.../180736

    (This example is for VB6, but I've used it in Operate VBA before).

    This is fairly standard VB code.  For the specific use case, I would agree that keeping as close to Operate standard functionality is a wise decision, but there's always some use case where standard won't cut it.