Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

basic serial write and read cannot read a second time

Solved!
Go to solution

Hi, I'm trying to develop my own VI to write and read from an iRobot Create.  I based my vi off the Basic Serial Write and Read.vi example I found (on LabView 8.0).  When I run my vi I am able to read the beginning information from the Create, but I am unable to read a second time (after writing a command).  The second read should be the same as the first (I checked using a different program that is linked to the Create).  I am new at using LabVIEW and I was wondering if there is a common mistake made when trying to implement a serial read and write.

 

Thanks.

0 Kudos
Message 1 of 9
(4,499 Views)
Did you check if there are characters to read with bytes available at port?
greetings from the Netherlands
0 Kudos
Message 2 of 9
(4,471 Views)
It says there are 0 bytes at port, but if the write works properly, it should read 135 bytes.  This is why I'm confused.  I know I'm not reading anything because the bytes at port = 0, but there should be bytes to read.  I'm really stuck and I don't know what else to try.
0 Kudos
Message 3 of 9
(4,452 Views)

Then it sounds like the write is not working. Don't make the assumption that the write is working if you don't get an error. You will seldom get a VISA error with a write. For example, you can be sending garbage to the instrument. The instrument will not process it and as far as VISA is concerned, no error has occured.

 

Attach your code.

0 Kudos
Message 4 of 9
(4,449 Views)
This is the code I've been trying to get things working.  Like I said, I'm new to LabVIEW so any insight would be helpful!
0 Kudos
Message 5 of 9
(4,444 Views)
I'm unsure of what you are doing. You are first doing a read without doing a write so what is the point of the write command after you've done the read? Does the instrument actually require you to do a write? If you do have to perform a write, is the command formatted correctly? You do not have the Write Buffer control set the same way as the basic example so that could be a major problem. You have not provided the actual command you are sending and it would be nice to see the instrument's programming manual.
0 Kudos
Message 6 of 9
(4,442 Views)

 

When I first turn on the iRobot, it sends some "welcoming/reset information."  I was using the first read to read that info.  The write is then supposed to send the reset command, I should then receive the same "welcoming/reset information" as before.  I can now do that.  I cannot send other commands to the iRobot successfully.  I'm thinking this is a problem I'm having with formatting the commands, but I have no idea how it's incorrect.

 

As for in LabView, is there an easy way to set up a "pause" until a button is pushed?  I'm thinking of a while loop that continues until a button is pushed and that will be the loop condition.  Is the best way to implement this pause?  (I have a large while loop around the write and read and want to send the write command only when I push a button.)

 

Thanks for all the help.

0 Kudos
Message 7 of 9
(4,432 Views)
Solution
Accepted by RachtheSabu

First, debug your commands with a program such as Hyperterminal. If it works there, then it should work in LabVIEW. You may need to send a carriage return and/or line feed (\r\n). Your code is not currently set up to do that.

 

Only doing something when a button is pressed is basic LabVIEW programming. You can use a simple while loop with a front panel Boolean wired to a case statement. If you have anything other than the base version of LabVIEW, you should be using the event structure. Look at the examples that come with LabVIEW.

0 Kudos
Message 8 of 9
(4,430 Views)
Using Realterm I was able to understand the commands better, thanks for the recommendation!  I have since been able to get the iRobot working.  Thanks for all your help.
0 Kudos
Message 9 of 9
(4,396 Views)