Inrcrement/Decrement Button vba (Factory Talk)

djpalaz

Member
Join Date
Jan 2007
Location
Montreal
Posts
57
Hello,

I'd like to know if anybody has vba code for a button which can increase a number while being held down (sort of like a clock radio button to change the time). If you press for less than 1 second the number increments by one. If you hold it longer than a second it increases at one unit/second. For example if the value was 10 and then you held the button down for 5 seconds the value would be 15.
 
djpalaz said:
Hello,

I'd like to know if anybody has vba code for a button which can increase a number while being held down (sort of like a clock radio button to change the time). If you press for less than 1 second the number increments by one. If you hold it longer than a second it increases at one unit/second. For example if the value was 10 and then you held the button down for 5 seconds the value would be 15.
Probably can be done with a timer where you write code separately for a mousePressed and mouseReleased event. That said, you may want to revisit your UI. That's pretty non-standard with a computer based interface. I know hardware guys are used to that sort of interface when a physical "button" is a switch. PLCs can create a pretty cool such effects.

What are you trying to accomplish? I'm sure there are other, better ways of doing the same thing.
 
Microsoft UpDown Control (included in Microsoft Windows Common Controls-2 library MSCOMCT2.OCX) almost has this functionality. If you hold either "up" or "down" button with a mouse, the associated value begins to scroll up or down. No time delay though.
 
I've been using FactoryTalk (RSView SE, CPR7+ (version 4)) for a solid 3 months now - and apart from my personal opinion that I think it's the worst HMI ever spawned from satan, I can also offer this advice;
The functionality the OP requires is built into many of the controls in RSView Studio. There are several types of buttons that all have configurable repeat rates, latching, multi-state positions, etc. Although I haven't performed the exact same configuration, I'm pretty sure it's easily possible with the provided tools.
 
Excellent advice. Always much better to use the pre-built tools if they can do the job instead of jumping to code.

What's wrong with RSView SE?

grimreaper_29_uk said:
I've been using FactoryTalk (RSView SE, CPR7+ (version 4)) for a solid 3 months now - and apart from my personal opinion that I think it's the worst HMI ever spawned from satan, I can also offer this advice;
The functionality the OP requires is built into many of the controls in RSView Studio. There are several types of buttons that all have configurable repeat rates, latching, multi-state positions, etc. Although I haven't performed the exact same configuration, I'm pretty sure it's easily possible with the provided tools.
 
What's wrong with it?!!?!? What's right with it?!
We're using the older version (v4 / CPR7+) because our systems require 100% uptime/redundancy, and since I haven't played with the latest release, I can't say whether it's good or bad. However, even the European director of RA has admitted that CPR7 is a load of rubbish.
We've had random crashes at random times, tag server processes, vstudio processes and directory server processes simply dying with error message, and a whole host of other issues.

The biggest problem I've had recently is in trying to get to the bottom of all the configuration issues using Server 2003 and XP, and discovering that 3 RA documents state opposing facts on how to configure a 'standard' system!
 
/shrug, whatever.

We use exclusively FT View SE, Release 4 and 5, and haven't had issues that weren't hardware related.

TO the original point, If you are trying to use self-incrementing buttons to communicate to a PLC tag, I'd advise against it. I use an MOP AOI in Logix, which was based on an older MOP subroutine from SLC/PLC days.

Simple reason is with a PLC based routine, you can safely control how many people are trying to modify it at one time. Windows controls, and even VBA is very bad at handling two users on two terminals modifying the same thing.
 
Right - besides concurrency, it's nearly impossible to account for lag and other issues, including guarenteeing the safety of your write. Your better bet for a PC based input is for the operator to input an amount that is autonomous. ie, a single 5 second click, or press the button to tell the PLC to move the device to the next preset location, etc.

rdrast said:
Simple reason is with a PLC based routine, you can safely control how many people are trying to modify it at one time. Windows controls, and even VBA is very bad at handling two users on two terminals modifying the same thing.
 
Looks like I could use the ramp button already created in RS View studio but it also looks like you can access it through vba.
 
Can you write the code for the functionality you want in VBA/VB/any other language which stores the value the operator decides on internally, and then have another button (like an OK or Apply button for instance) which actually writes the value down to the PLC?

(I've got skeleton code to write to RSViewSE tags from VB6 and VB.NET if you need it... )
 
I'm not sure what you mean grimreaper by "value the operator decides on internally, and then have another button (like an OK or Apply button for instance) which actually writes the value down to the PLC?"

It looks like there is a ramp function you can execute as a macro ex you could use the following command:

Ramp tag tagvalue -> Ramp {#1.set.sp} +1

You can place this function in the button properties under press and release action as seen in attached bmp

If you click onnce on the button it will increase by 1 if you hold it longer than 0.25sec it will increase by 1 every 0.25sec.

Now id like to use vba to do the same thing since this action will be only restricted to certain users. If the user with no permissions presses the button a pop_up will display. Here is the code that I have been working on:

Private Sub RampButtontest_Press()
On Error GoTo Handler
If Application.CurrentUserHasCode("B") Then
ExecuteCommand "Ramp " & Me.SP.Value & " " & 1
Else
ExecuteCommand "Display POP_NoSecurity /CC"
End If
Exit Sub
Handler:
Application.LogDiagnosticsMessage "VBA Error : " & Me.Name & " - RampButtontest_Press : " & Err.Description
End Sub
 

Similar Topics

Hi, I have a stand alone inspection unit with no PLC but I can send 24v input signals to the machine PLC to show a good read and a bad read when...
Replies
9
Views
753
In structured text, can you decrement in a for loop? I need to shift an array and I can either use while loop or if decrement in for loop works...
Replies
6
Views
4,866
i'm newbie in PLC, would u like to help me, plese.. i'm using an instruction MOV, for moving Hexadecimal data #0020 which is &32 in decimal,to...
Replies
3
Views
1,809
All Looking for a way to use a momentary relay closure and the digital inputs to increase or decrease the speed of a Powerflex VFD. I looked...
Replies
3
Views
2,780
hi guys, i am new plc programming learner. i stucked in one of the excercise problem of speed control of servo motor using increment/decrement...
Replies
3
Views
3,794
Back
Top Bottom