06-30-2010 10:40 AM
Hi,
First of all I have to mention I have an amateur-ish knowledge and understanding of LABVIEW, so please don't get waaaaay to technical in your answers!
My problem is the following: I am trying to build a program which would communicate with a device we have in our lab. The interface is RS232. This program, according to the values you register to some slides, creates a txt file, which should then be sent to the device. After implementing that, I found out that the response of the device is not what it should be. So, by checking various things, I think my problem is (as is mentioned on the device manual):
"The format of a sample is 12 bit, 2 bytes, LSB first. In practice only 10
bits are used."
The problem is, that what I was sending to the device originally was the text file itself (i.e. ASCII) and binary of the format the device is supposed to be understanding. So, my question is, how could I make the code understandable to the device. i.e. 12 bit, 2 byte binary, LSB first?
PS: I could also attach the VI code if you want!
06-30-2010 11:03 AM
Hi,
A VI will always help to give you a hand much quicker, and will make things easier for everybody. Besides that, an example of the information to transmit will be useful too, with the protocol of the device. You need to check as well the settings of the serial port. If they aren't the same (in your computer and the device), it doesn't matter what you send, the device will not understand it.
Do you have the protocol of the device? How the device interprets the information received?
Dani
06-30-2010 11:12 AM
Hello,
Normally this VI should work (explanation in the diagram).
Best,
J.
06-30-2010 11:12 AM
Hi,
I've used the Serial Visa to set the protocol to "The baud rate is 9600,
8 data bits, 1 stop bit, no parity." as mentioned in the manual, so I guess that wouldn't be an issue.
The information to be transmitted are 1500 lines of numbers, most of which are zeros, and only 48 of them (which are controlled by the slides) take a value between zero and 2500.
I attach the VI to see what I mean for yourself.
Thank you for the quick reply!
06-30-2010 11:13 AM
And the code in LV8.6
06-30-2010 11:17 AM
Oups, maybe I have not understood clearly the problem, each of us answers about something different. My solution was about your device answer, but maybe it's not what you need... 🙂
06-30-2010 11:23 AM
Hi krsone,
I think your answer is close to what I am looking for. But, the trouble also is that I need to use the Visa write command to send the numbers to the device, which (the vise write command) is only compatible with strings! so...?what do you think?
06-30-2010 11:31 AM
Maybe I would also need to make the problem clearer:
Somehow, I create a text file. That text file needs to be transmitted to the device with the aforementioned protocol. So, what I am asking your help for, is how to convert that txt file (in ASCII code) to binary code and send it through the VISA WRITE module, to the device.
06-30-2010 11:34 AM
Why are you going through all those hoops. Instead of writing all of that data to a file, why don't you directly write to the instrument. Do you want to be constantly writing to the device or only when the control changes? Do you have to write all the control values or just the one that changed?
Your architecture is very strange. You do realize that the for loop will only execute once and your program will stop. I hope you are not using the run continuous button.
The ability of VISA Write to handle different data types has been endlessly discussed. You can convert anything you want to a string. Use typecase, byte array to string, etc.
06-30-2010 11:39 AM
Hi Dennis,
The way the device operates, is that you need to send it a file when something changes, which (the file) would contain the values for all the slots (all 1500 of them). So, I can't make it change just one value at a time. Also, yes, I am using the run continuously button: 1)is that bad? 2)would you recommend a change in the program so that I wouldn't have to us it?