LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error: the number of samples must be > 0

 Sorry for the wrong version. Here is a vi saved as 7.0.
 
You should try some simple things. Test your communication by just sending "Hello" and see if you receive the correct string on the other computer, using HyperTerminal. Then you can proceed with LabVIEW. Remember that 95 % of serial communications problems are due to the cable and connector. I have lost hours trying to communicate with a PC which serial port was damaged...
 
Chilly Charly    (aka CC)
0 Kudos
Message 11 of 20
(1,540 Views)
CC,

Your program work well. I put your solution on my problem, first I´ve done a loop-back test (a short-circuit wtih Tx and Rx on a RS-232 cable) and it didn´t work satisfactory, perhaps I´ve got a mistake. Look...

Thanxs
0 Kudos
Message 12 of 20
(1,523 Views)

As I told you in my last post, you should verify your serial port.  Since you have a loop back, try something like this :

 

Message Edité par chilly charly le 01-11-2006 11:21 AM

Chilly Charly    (aka CC)
0 Kudos
Message 13 of 20
(1,508 Views)
CC,

Sorry for not telling you, but I´ve done this test, I´ve done a loop back test and a simple serial communication between computers, but not converting type signals (string to dynamic data and vice versa). I used an example on LV (7.0 my version) to perform this experience, search for: serial communications and select the first example...so conclusions: the two interfaces work well.

Thanxs...and sorry for expending your time!

0 Kudos
Message 14 of 20
(1,497 Views)

You need to make some modifications. The initialize serial port and the VISA Close should be outside the while loop. There's no reason to do either every time. I modified your example and increased the baud rate and decreased the number of samples being sent. That seems to work without an unreasonable timeout value for both the read and write.

What is the while point of this exercise? Is it just eventually to transfer data to another pc? If that's the case, you can use any baud rate you want since I presume you would be writing the program for the other pc as well. Also, using datasocket or TCP/IP to transfer data would be a much faster method.

whoops. forgot that you were using 7.0.

Message Edited by Dennis Knutson on 01-11-2006 07:40 AM

Download All
0 Kudos
Message 15 of 20
(1,496 Views)
Dennis,

Did you simulate your program?! Can you look at the frequency indicator?! The frequency read is not same that you sent because the sampling frequency (dt) is 1/1000 and you send 100 points only, so it's necessary to decrease the dt to 1/100 or increase the number of samples to 1000 and maintain dt = 0,001. When I change dt to 0,01 the frequency is also not same and when I change the number of samples to 1000 your inner while loop closes the signal. My objective with this exercise is to transfer data between computers using interface RS-232.

Thanxs...
0 Kudos
Message 16 of 20
(1,484 Views)
Yes, I ran it and I just re-ran it and if I specify a frequency of 10 Hz, the frequency indicator says 10 Hz. You do not change dt simply when you change the number of samples. If you were to change the sample rate in the Express VI, then you would change dt. 1/Sample Rate = dt. The number of samples only affects how sample cycles (or partial cycles) of the waveform you transfer.
 
Are you really stuck with RS-232? Network cards are really, really cheap and if the pc's are already on a network, you don't have to buy anything at all.

Message Edited by Dennis Knutson on 01-11-2006 12:36 PM

0 Kudos
Message 17 of 20
(1,482 Views)

Dennis,

I re-ran your program attempting your notes, and he works so so (make hard test, change the frequency to 1Hz ang go on). Other question, in your property node you select bytes at port and the reads at the output is never greater than 4096 (512 samples = 4096 / 8 (1byte)), and I belive that the error in the frequency indicator is about it, maintain dt=0,001 sampling rate=1000 and number of samples > 512, and your signal will be looked on inner loop, see it wirh HighLight Execution. So, How can I change this number (4096) on property node?!

I´m using RS-232 for educational objectives, learning how LV interacts with it. And your idea about network cards is good, the program run very slow!

Thanxs

0 Kudos
Message 18 of 20
(1,464 Views)

If you're trying to generate a 1Hz sine wave, then 100 samples is not enough for a complete sine wave and the frequency cannot be determined. You can increase the number of samples but when you do that, you run the risk of exceeding the serial port buffer. You can increase this by putting a VISA Set I/O Buffer Size right after the initialize serial port. I changed the buffer to 8192, frequency to 1 and number of samples to 1000. Ran it and the frequency measurement was correct. Just remember that the bigger the number of samples, the bigger the buffer that's required and the longer it will take to read and write. There is some max size of the buffer I'm sure, but offhand, I'm not sure what it is. My recomendation would be to limit the frequency to something higher that doesn't require a lot of time to read and write a large number of samples.

Message 19 of 20
(1,456 Views)
Dennis,

I´ve changed your modifications and the program run well, my next job is to create a program that perform a serial communications between two computers. This program is done but I don´t simulate it because inconvineances. My previous program don´t use a cast type polymorphic vi, and others veterans users said that my conversion (string <<--->> array) are incorrect, but my waveform its same a sinewave and the frequency measured is very close to 1 Hz. Please, look my conversion program said what´s wrong!

Thanxs

Message Edited by 8144-9199 on 01-18-2006 12:43 PM

0 Kudos
Message 20 of 20
(1,427 Views)