03-15-2012 05:38 PM
Hello,
I wanted to add this VI where it can be seen how is it that I'm planning on getting the data from our devices. I hope that this way the questions that I posted earlier and thoughts are better understood.
Thanks
Jose
03-15-2012 07:57 PM
Why do you have the number of bytes written in the VISA Write wired to the number of bytes to read in the VISA Read?
03-16-2012 10:09 AM
Well Im not exactly sure what to put in those terminals. I know that byte 3 of the first array is suppose to have the total number of bytes. I'm guessing that this would be the the same number on the "number of bytes to write" in the VISA write. But I don't know the number of bytes that the VISA read will see. Is this the same as the total number of bytes? or is that the same as the number of data bytes that are between byte 3 and the checksum?
Jose
03-16-2012 10:34 AM
Don't guess! Read the manual!
If you are dealing with text-type data coming in where there is a termination character defined, then you enable the termination character and wire in a number to your read function much larger than you need it to be. The read would automatically terminate when it gets the termination character.
Since is sounds like you are dealing with binary type of data where a given byte value can occur anywhere, the protocol can't use a termination character. In my experience, the number of bytes written will never correlate with the number of bytes to read. A typical command would send X bytes that might include some long data, and the device with send back a much shorter message acknowledge it received it. Or you send a short message requesting data, and the device sends back a much longer message that includes all the data.
Since it sounds like your messages are variable length, and you say byte 3 includes the length of the message. Then do a VISA read for 3 bytes. Use the value of that 3rd byte to calculate how many more bytes you need to read on the next VISA read message. Whether that value is how many more bytes are there to read, whether it includes the checksum, or includes header information, that is something the protocol will tell you.
03-16-2012 10:35 AM
The number of bytes to read would be the number of bytes that an instrument sends to the pc's receive buffer and you can get that information by using the VISA Bytes at Serial Port function.
There is absolutely no relationship between the number of bytes written and the number of bytes to recieve. You seem to be lacking some of the fundamental knowledge of serial communication. For example, your first post mentions .NET and there is nothing at all about .NET in this thread. There are many tutorials available including this.
03-16-2012 01:07 PM
Dennis,
The protocol that was send to us is tittled "ASNET" so I this made me think that I might need to get familiar with .NET; however, when I checked this blog there were things that looked similar to what I needed to do to communicate with our devices. I'm more familliarised with Modbus communication. In this case is not Modbus, but something simmialr in that we send and recieve bytes in order to communicate with our devices.
For a moment I got to see trafic from the devices with a program that I found on the internet. Lately I don't see anything though.
Jose
03-16-2012 01:16 PM
Ravens Fan
I've read the protocol and yes it does require the number of bytes and checksum. I made my VI so that it calculated the number of bytes and checksum automatically and added to the array of bytes. I'll need to see if I can get more details on the protocol, because I still have my doubts.
Thanks though,
Jose
07-04-2017 10:43 AM
Hi,
I have the same problem and after doing what you said it didn't get solve. I am trying to read 3 signals in labview but this signals come too slow. I added the function millis in arduino and try to read it from labview to see what was going on and the thing is that the seconds were going much slower in labview. After five seconds i could see in labview how the value of variable related to millis had only increased in one second...
I am using labview in my MAC...
thank you in advance
Here I add my arduino code...
// put your setup code here, to run once:
Serial.begin(230400);
}
char Buffer[16];
int sensor0 = 0;
int sensor1 = 0;
int sensor2 = 0;
int sensor3 = 0;
void loop() {
// put your main code here, to run repeatedly:
sensor0=analogRead(0);
sensor1=analogRead(1);
sensor2=analogRead(2);
sensor3=millis()/1000 ;
sprintf(Buffer,"%04i\t %04i\t%04i\t%04i",sensor0,sensor1,sensor2,sensor3);
Serial.println (Buffer);
delay(1000);
}
07-04-2017 06:11 PM
At this point you should just start a new thread instead of hijacking old threads.
And did you follow my advice from here: https://forums.ni.com/t5/LabVIEW/how-to-read-multiple-values-on-VISA-READ/m-p/3654728#M1026803
07-05-2017 03:12 AM
Yes. I did follow it.