PDA

View Full Version : How to use the LabView communicate with BS via RS232 ?



Lin
01-01-2006, 04:30 PM
Hello,I have downloaded the "BASIC Stamp example using National Instruments Student Edition of LabView 7.0" from the Download field in the www.parallax.com (http://www.parallax.com), and now I run the progarm named "StampSerial.vi" in the
LabView 7.1, but it happen a wrong. I find the "context help" show that I must download the serial I/O Basic Stamp code before I run the program. So, what is·"serial I/O Basic Stamp code"? And after I download it, what can I do ?·
Do you have a experience about communicate the BS with LV? Can you introduce me some other functions or experiments·about this? If you have some good example program, please send it to me.Thank you very much!
My Email: linqinyu1@163.com (mailto:linqinyu1@163.com)

PJ Allen
01-01-2006, 11:43 PM
What is supposed to happen, Lin?


Lin said...
So, what is·"serial I/O Basic Stamp code"? And after I download it, what can I do ?·

Is there supposed to be serial communication between the STAMP and LabView?· The STAMP needs to be programmed for serial communication (Hello STAMP, This is LabView·--·Hello LabView, this is STAMP); read about SERIN and·SEROUT.

What would be a simple LabView transmission to the STAMP and what would be the desired response from the STAMP?

Bruce Bates
01-02-2006, 02:00 AM
Lin -

There are four documents in that Labview download, as listed below:

1. BSII&Labview.PDF -· Documents the process of connecting Labview to the Stamp BS-2

2. LabviewIO.BS2 -·Basic Stamp II Program to interface to and communicate with Labview software

3. StampSerial.LIB - A Labview library for serial communcation

4. StampVI.LIB - A Labview library representing VI, a virtual instrument

Here are the steps required to implement the system as described in the BSII&Labview PDF document, with minor additions that I have made for clarity:

1 Connect the BSII board to the PC Development system and run the Stamp Editor. If you don't have a copy of the Stamp Editor, it can be downloaded for free from the Parallax web site, Stamp Software download section.

2 Load the BASIC Stamp II® software "LabVIEWIO.BS2" into the BASIC Stamp® on the carrier board, using the Stamp Editor.

3 Quit the Stamp Editor

4 Use a serial (RS232) cable to connect the BSII board to the target LabVIEW® workstation. Rememeber to power-up your Stamp. If you are a PC user, this step repeats step 1.

5 Open the LabVIEW® library "StampVI.LIB" and Run the VI "StampSerial.LIB". In some LabVIEW systems, it will run automatically when opening the library. For other systems, you may need to select and run it from the contents of the library.

6 Select a command and click on the·RUN arrow. The·RUN arrow is the single full arrow on the upper left corner of the VI's window.

7 The VI will send a command to the BSII, receive a response and display the
received response.

- - - - - -

At what point (which step)·above are you having a problem?

Regards,

Bruce Bates

Lin
01-03-2006, 12:20 AM
Thanks,PJ Allen,Bruce Bates.
I have some questions ask Bruce Bates:
I have downloaded the "BASIC Stamp example using National Instruments Student Edition of LabView 7.0" from the Download field in the www.parallax.com.And in this example,there have three documents:"LabVIEWIO.bs2", "LabVIEWSerial.bs2" and "StampSerial.llb",the "StampSerial.llb"contain two vi :"StampSerial.vi" and "Stamp_Serial_Comm.vi".
Now, I have some questions:
1. I can't understand the function of these two documents :"LabVIEWIO.bs2", "LabVIEWSerial.bs2" .
2.I do it follow the process like Bruce Bates say:first load the LabVIEWIO.bs2 to the BS in carrier (is it just run the program use BS Editer?),then close the Editer and run the program named "StampSerial.vi", I set the baud in every value to try, but it all happen a wrong (the red LED light on).
What's the wrong ? How can I run the program normally ?

Bruce Bates
01-03-2006, 01:26 AM
Lin -

You inquired in your reply (quoted individually below):

Now, I have some questions:

Question -

quote
1. I can't understand the function of these two documents :"LabVIEWIO.bs2", "LabVIEWSerial.bs2" .

end quote

Answer

Those aren't documents, per se. Those are two PBASIC SOURCE PROGRAMS to be run on the PBASIC Stamp microcontoller, as supplied by the author, and to be used as noted in the PDF instructions.

Question

quote
2.I do it follow the process like Bruce Bates say:first load the LabVIEWIO.bs2 to the BS in carrier (is it just run the program use BS Editer?),then close the Editer and run the program named "StampSerial.vi", I set the baud in every value to try, but it all happen a wrong (the red LED light on).

end quote

Answer

This is a step-by-step process, as I noted before. You may be overwhelming yourself by not seeing it·that way. Make a checklist if that's easier for you, noting where you feel there may be problems as you go along. There's nothing magic about this, it's merely procedural, with each step being important to the overall goal.

Quick Undetailed Summary

First you use the Parallax PBASIC Editor/Compiler/IDE (a Windows·executable program)·to load the PBASIC source code program from your disk drive, compile it, and then issue the RUN·COMMAND to cause it to execute. It apparently will run unattended at first. At this juncture you no longer need the·PBASIC Editor/Compiler/IDE, so you can shut it down.

Next you must begin execution of the LabView program on your computer. Once that begins execution you apparently open the two libraries which the author has supplied. I have no experience with LabView but I suspect that if I followed the step-by-step instructions, even I could do it.

Process Overview

At this juncture you have the following:

1. An external PBASIC Stamp Microcontroller running a supplied program.·The Stamp microcontroller·is attached to the computer via a serial port (note this physical connection), through a serial cable.·If it's not connected via a straight through serial cable (carrier board to PC), this may be one source of problems.

2. A copy of LabView is running on the PC, a couple of LabView libraries (supplied) have already been opened, and LabView "owns" and thus may use the serial port to which the Parallax PBASIC Stamp microcontroller is attached (note this same physical connection). If you have started LabView and NOT loaded and executed the supplied libraries, this is another possible source of problems.

3. If all has gone well, up to this point, at this juncture the two programs (one on the PC - LabView, the other on the external PBASIC Stamp) can "handshake" or communicate, due to the use of the common serial port.

4. If the programs are indeed communicating, as planned, then the "user experimentation" can take place.

Question

quote
What's the wrong ? How can I run the program normally ?

end quote

Answer

I have no idea what's wrong. If you give us some SYMPTOMS, error messages, or indicate where you're having a problem, we may well be able to help. Other than that, I respectfully don't know what to say.

I don't know what you mean by "How can I run the program normally?", sorry.

Regards,

Bruce Bates

AS
07-16-2010, 09:42 AM
Hi!
I already do all the steps.
At begining i think that was everything fine but i start doing some experimentation.

- In the file "LabVIEWIO.bs2" i change the instruction "SEROUT 16,baudmode,["-- ", DEC3 val, CR]", only in the string "-- " to see the changes in LabVIEWSerial.bs2 and nothing happen.
I think that maybe it was echo that labview was reading.

- I decided try the other file "LabVIEWSerial.bs2", only to test a more simple example. Labview read the line with the string from the "debug", i see it in both files of labview.

After some modifications i think: _ that: the Labview files are working fine;
_ i put a "debug" after the "SERIN 16,baudmode,[STR indata\5\CR] 'get command", and i think that for some reason it block, the result is
that in Labview it just read the first debug and no more after "SERIN"

Please i really need help

i thank for anyone that cloud me help
AS

WIT Engineer
03-10-2011, 04:36 PM
Hey Guys,

I know it has been awhile since the last post on this forum but I am currently working with a BS2 for a project and we are in need of some desperate help to get our project moving. Our overall goal is to be able to use LabVIEW to read and write to each pin. Once we get basic communication then the rest of the programming should be straight forward for us.

The issues that we are having is the interface with the BS2 and LV. We have communication with the basic stamp editor and were able to download the LabVIEWIO.BS2 into the stamp with no problems. We are using our laptops which doesn't have a serial port so we are using a USB to 232 converter. I downloaded the proper drivers and we can see the stamp in our Device Manager as COM5. Once I downloaded the LabVIEWIO.BS2 into the stamp, I quit the editor and tried to run the LV program that was posted on parallax.com. Each time we run it, we get an error. We set the baudrate to 9600 and the Resource name to COM5. Since we are using the converter, we are not sure what has to be configured in order to get the correct communication. Also, we are running Windows 7 with LabVIEW 2010.

If anyone could help or if you have example code that would get us working, it would be much appreciated.

Again thank you guys and let me know if you need further information.