Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I control instrument using its RS232 port in VB or VC++?

1)How can I control instrument using its RS232 port in VB or VC++?
2)What's the module or .h file need I add-in to VB or VC++?
3)Can you provide me some easy examples for that?

Thanks!
0 Kudos
Message 1 of 12
(8,554 Views)
If you are a Measurement Studio or ComponentWorks user (which is what this forum is for) we provide an ActiveX control for Serial communication that can be used in VB and VC++. You can also use our VISA C++ classes or ActiveX control for serial communication in Measurement Studio. If you are not a Measurement Studio or CW user, then you will have to use Microsoft's compiler provided method to talk to the serial port. You can find help for these methods on http://msdn.microsoft.com/.

As for examples, there are Measurement Studio serial examples for VB can be found in your \MeasurementStudio\VB\Samples\Instr directory.

Best Regards,

Chris Matthews
Measurement Studio Support Manager
0 Kudos
Message 2 of 12
(8,554 Views)
hi , i know how to receive data through the serial port using cwserial but i don't know how to send data i need to learn how to do this for my project because i have to send data firts and then the controller will give me data with the information that i need to read or maybe write. i would appreciatte all the help you could give me
Tomás Estrada
0 Kudos
Message 3 of 12
(8,239 Views)
Howdy,

You can find some ANSI C examples of serial communication that install with NI-Serial. They install to C:\Documents and Settings\All Users\Documents\National Instruments\NI-VISA\Examples\C on a Windows XP system. I think that checking out the example(s) would be a great place to start.
Warm regards,

pBerg
0 Kudos
Message 4 of 12
(8,230 Views)
i want to know to send data to a serial port with visual basic 6 using the activeX cwserial, im downloading what you posted to see it now , but if someone know how to send data to serial port using activeX (CW) using Visual Basic 6 i will apprecciate your help
regards Tomás Estrada
PD: sorry for my english


Message Edited by jknight_ve on 03-15-2008 11:55 AM
0 Kudos
Message 5 of 12
(8,218 Views)

Hi jknight_ve,

Measurement Studio for Visual Studio 6 includes a VB6, cwserial example.
You may find the example at: <C>:\Documents and Settings\All Users\Documents\National Instruments\MStudioVS6\VB\Samples\Instr\Basic Serial

Nestor
0 Kudos
Message 6 of 12
(8,200 Views)
Thanks Nestor for that example that was what i was looking for, now i have another question how can i make a txt from visual basic and save there data from the program in VB6?

Tomás Estrada


Message Edited by jknight_ve on 03-29-2008 03:25 PM
0 Kudos
Message 7 of 12
(8,134 Views)
No problem Tomás.
You may try using the FSO objects, such as:
 
Private Sub Command1_Click()
 
Dim fso, txtfile
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtfile = fso.CreateTextFile("c:\test.txt", True)
' Write a line
txtfile.Write ("This is a test. ")
' Write a line with a newline character.
txtfile.WriteLine ("Testing 1, 2, 3.")
txtfile.Close
 
End Sub

 
This is pretty much a generic VB6 question. Simply search online for this topic and you will find tons of info/examples.
For example, MSDN goes into detail using the FSO objects: http://msdn2.microsoft.com/en-us/library/aa263346(VS.60).aspx
Nestor
0 Kudos
Message 8 of 12
(8,110 Views)
thanks nestor that was really helpful now i have another question see, im trying to comunicate with a groups of UDC 3000 (Universal digital controller) using visual basic, now when i send  the data the controller send me for example this data "010004,120,HH" how can i parse that data? knowing that the first 6 digits could change depeding of the response of the controller, this is important for my program because that value of "120" is the value that i asking to read(let's say Set point or the temperature) so i need to separate that message and show in a "isevensegment"

Tomás Estrada
0 Kudos
Message 9 of 12
(8,017 Views)
and another question i was looking this example http://zone.ni.com/devzone/cda/tut/p/id/3759 and copy exactly the fist example of parse the data and the code in the part:

    Option Explicit
      Dim Response As Variant
      Dim data As String
    Private Sub btnParseString_Click()
      data = "@@@002ACK;"
      Response = Comm.Tasks("ACK").Parse(data)
      Text1.Text = Response(0)
      Text2.Text = Response(1)
    End Sub

    in the red part it say's " error type dismatch " why is that? , i did the parse exactly like in the figure...
    Tomás estrada

0 Kudos
Message 10 of 12
(8,014 Views)