07-04-2012 12:55 PM
Well right now, my "different" Vi's for each command are simply
Input Address
Command CST String
Input Value
And i have a simple concatenate to merge them all and send them to 1 write and read command (with a True or False switch to turn this on and off).
The real problem is that they each have different outputs, which is why I want a multitude of VI's. But that will cause me to have a large case structure, which is annoying. I'm hoping I can find a way to simply call the right function based on the nature of the command I'm sending (this is where I beleive OO kicks in as mentionned above) I'm looking at OO programming right now to see if I can fix this problem.
07-04-2012 01:19 PM
What do you mean different outputs? Do you mean a different data type and/or connector pane?
07-04-2012 01:27 PM
07-04-2012 02:13 PM - edited 07-04-2012 02:22 PM
Well if you open the spreadsheet I have attached (There are no macros by the way - incase you don't like opening spreadsheets...) you can see the commands I need to be able to use on demand.
You'll notice some of their Response (what I will end up reading after a write) are strings while others are numbers (nnnnnnnn is a number whiel *R is a char output for example).
You'll also notice the syntax to write to my device (RS 232 btw), is
<a> = address,
XXX = String
nnn = number
with some of the commands using all and others using only a few of these instances. (Reset for example is a simple % while setting the Distance is more complex).
For writing, I could use one write to RS232 function with a bunch of unbundles, and concatenate. By this I mean, % would be represented as _%_\r\n
And become %\r\n when I write while Buffer Status Command would become 1BS\r\n
For post-reading however, I'll need to operate on the output on a case by case fashion. Depending on what I write, a different data type will come out of device. I'll need to account for that to read and convert appropriately. I could hardcode this, with just a case for each different type of output and bundle a True/False with my command about the data type of the output. That would work I guess.
07-04-2012 02:23 PM
This is probably very trivial... I've already worked with RS232 and I'm confortable with all the reading and writing, as well as the bundling. case structures and property nodes. I just had 10 commands when I communicated to another device so didn't feel the need to not hardcode it.
07-04-2012 02:57 PM
07-04-2012 03:33 PM - edited 07-04-2012 03:34 PM
"If it returns data, add a VISA Read."
You mean with a property node that checks if there are bytes at port? Yeah that works lol. I'm stupid.
"If returns a numeric value, convert it"
How can I check if it's a numeric value? Unless I preembed a true or false value in the initial cluster containing in part my data to write.
07-04-2012 03:36 PM
On driver guidelines.
I need to send a simple ASCII command through RS232. I've done it using the basic read write and I'm getting correct response, now I'm just moving on to getting the commands to do it on call through an array.
07-04-2012 03:56 PM
07-04-2012 05:37 PM - edited 07-04-2012 05:38 PM
Unfortunately, that is the limit of my knowledge. I've been using the basic Write and Read and expanding it.
How would you suggest I go about it?
What I'm doing is essentially sending in a cluster of data (Address + CMD + Numerical). Then concat, and then sending it to write. Based on what the cmd is, I use a case statement to convert what is read.
Is that not the best way to do it?
:S
Which example should I use to guide myself?
Thanks again by the way. I'm still learning!