Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Graphing in VB 6.0

I want to write a code in VB 6.0 which will measure the width of a pulse to calculate the rpm of a rotating shaft.
A gear is mounted on the shaft and a photencoder reads the rotation of the shaft and gives a square wave as the output pulse.
Also I need to plot the change in rpm vs time when there is a load on the shaft.
I did get a code for measuring the pulse width from this website. I attach the same here.

' TachCounter.Vbp
'
' Description:
' This measures time and period of the output from the tachometer circuit.
' It then displays the value of the selected events or time in the CWNumEdit
' control. All of these events are found with the CWCounter control. You
' can use the CWCounter control to perform counting and other measurement
' operations on a data acquisition device like pulse width measuremnet also.
'
' Pin Connection Information:
' The necessary pin connections will vary depending on what operation is
' selected by the user. When the user's selection is made, the Signal Input
' indicator will display the necessary connections. These connections are also
' listed below:
'
' Time - No connection needed
' Period - Connect signal to counter gate
' '

Option Explicit
Dim IsRunning As Boolean

Private Sub CWCounter1_AcquiredData(Measurement As Variant, ByVal Overflow As Boolean)
CWNumEdit1 = Measurement
IsRunning = False
End Sub

'Allows the user to select which counter application they would like to perform.
'Based upon this selection, the corresponding 'Signal Input' caption will be displayed.

Private Sub CWSlide1_PointerValueChanged(ByVal Pointer As Long, Value As Variant)
Select Case Value
Case 1
Label2.Caption = "No connection needed."
CWNumEdit1.FormatString = ".0##"" s"""
Case 2
Label2.Caption = "Connect signal to counter gate."
CWNumEdit1.FormatString = ".0# k""s"""
End Select
End Sub

'Reads the current value of the counter; whether it be a number of events, time,
'period, or pulse width. This value is displayed in the 'Measurement' indicator.

Private Sub Read_Click()
Dim data As Variant, Overflow As Boolean
CWCounter1.ReadMeasurement data, Overflow
CWNumEdit1 = data
End Sub

'Starts the counter operation corresponding to the selection previously made by the
'user.

Private Sub Start_Click()
On Error GoTo ErrHandler
CWCounter1.Reset
With CWCounter1
'Time measurement
.MeasurementType = cwctrTime
.Time = cwctrFrequencyTB
.TimebaseSignal = 100000
'Period measurement
.MeasurementType = cwctrPulsePeriodRisingEdge
.Period = cwctrNIDAQChoosesTB
End Select
End With
CWCounter1.Configure
CWCounter1.Start
IsRunning = True
Exit Sub

rpm = 5 / Period ' I need to use this formula for calculating the rpm

ErrHandler:
MsgBox "DAQ Error: " + Err.Description
End Sub



I would be grateful if some one is able to say what I should be doing as I dont have any prior experience in coding in VB 6.0.
I cant figure out head or tail of codes online. I'm not able to distinguish between VB 6.0 code and VB.net.
I also need to know how I can talk to ports from the DAQ card (NI-DAQ 7).

Many thanks in advance.
0 Kudos
Message 1 of 4
(6,795 Views)
Hi,

It looks like you've stumbled into one of the component works VB6 examples. We have Traditional DAQ VB6 examples in two flavors

1) component works programs that use the component works ActiveX controls on the front panel. You can right click on these ActiveX objects and change their settings.

2) traditional DAQ function call programs. These programs make regular function calls to the traditional DAQ driver.

In this case you're using the component works example program. You can tell by all of the CW calls.



What card do you have? Do you want to use VB6 or VB.NET? Would you like to use DAQmx in VB6? Traditional DAQ is our older legacy driver that will be phased out. DAQmx is our new driver that is supported by all of our new hardware. It would be best for you to use DAQmx.

DAQmx support is still in beta but it works very well in my experience. Check out this KB:

http://digital.ni.com/public.nsf/websearch/B22FE2B0F9C8935286256E920073DA07?OpenDocument

You need DAQ 7.4 and a DAQmx compatable board. DAQmx is much easier to program with than traditional DAQ.

-Sal
0 Kudos
Message 2 of 4
(6,768 Views)
Dear Mr. Salvador Santolucito,

Thank you for your reply. I want to code my stuff in VB 6.0. I have installed the lastest drivers(7.4) for the DAQmx card (NI 6220). I just wanted to know how I can talk to a particular port on the DAQ board (say a counter gate) so that I need not enter any stuff in to a form during the measurement process. I will not be using the Measurement Studio. Will the CW functions still work for me?

I will have to integrate this code into a main program which is for controlling a machine which is run by the shaft whose speed I'm trying to find. I have already figured out how I can plot the graph real-time using VB 6.0 using a code I found on the NI example code site.

Thank you once again.

Regards,
Krishna.
0 Kudos
Message 3 of 4
(6,763 Views)
Hi,

Since you are using an M-series card that ONLY works with DAQmx, you will NOT be able to use the CW controls or the other VB Traditional DAQ shipping examples.

Instead you MUST go to the link I sent you and follow the instructions for using DAQmx in VB 6. This is not fully supported yet and the VB6 DAQmx type library is still in beta. If you are unfamiliar with VB6 it may be best for you to use a simplier language like LabVIEW. Using LabVIEW with DAQmx is very easy and we have many useful shipping examples.

-Sal
0 Kudos
Message 4 of 4
(6,741 Views)