LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sending multiple commands at once using visa write and visa read

Solved!
Go to solution

Hello everyone,

I developed code using cube IDE (Micro controller )and its working fine when Iam sending commands with putty(Single command at a time) then iam getting the results which i want. i want to implement the GUI with lab-view and control it.

 

Situation:

 I developed vi for single command at once previously and  with sending single command iam getting the the exact output which i want(visa read and write is working fine). Now i want to develop it further now i want to send all 14 the commands at a time using visa write. i developed VI as per my knowledge but its not showing any data at read buffer and also on chart.

Im writing 280 byte in total and reading 570 byte total.

VI is attached.

 

looking forward for help 

Thank you in advance 

0 Kudos
Message 1 of 16
(350 Views)

Are you sure your microcontroller can handle that?  I would probably just use a FOR loop to send the commands and get the responses one at a time as fast as the microcontroller can handle.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 16
(333 Views)

Thank you for the quick reply.

im not sure about that but i will look into it. please check my VI. am i doing right? if not please tell me for the corrections.

0 Kudos
Message 3 of 16
(328 Views)

So you are building up the 14 commands into a single string and send that large string 256 times at 200ms rate, then read, and process 1 value only to have it thrown away.  How does the microcontroller know when a command is done being sent?  Shouldn't you be reading after every write?  To really give any good advice here, I would need a lot more details on the communication protocol.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 16
(308 Views)

hello,

I can explain you situation in detail. 

There are 14 commands if i send one command there is specific value which i receive from the sensors which is  which are connected to micro controller. the command should be send one by one to the using putty and after 14 commands i will get the final value from the sensors. I designed VI for same for the commands same like putty i mean i can able to send single command and get and also receiving the output correctly after sending 14 commands. Now what i want to do is i want to send the all the 14 commands in one click and want to receive final value in one click. can you please help me with this? im stuck...

 

i updated for loop bit with N=14 now im receiving some data at read buffer.  so the all the commands sent as one string and getting error. so now i want to send these commands separately but in one click.

If you need anything else i can give you the information 

 

Thank you in advance 

0 Kudos
Message 5 of 16
(263 Views)

I doubt you wrote your program to handle one string with 14 commands at once, so you'll have to send each command separately as crossrulz already suggested.

 

As for the implementation with one button, just make a case that triggers when you press the button, within it a for loop going through all the commands and a bit of delay between them (i don't know the specifics of your system, but i think 20ms wait between commands would be more than enough).

0 Kudos
Message 6 of 16
(247 Views)

yes i have to send the command separately(at once i mean i wan to send all the 14 commands in one click, sorry for explaining  it i wrong way) Moreover i will explain it in detail. if i send command 1 then sensor  will detect the system after command 2 i will check its ROM then after command 3 its power and it will go on... till 14. moreover i did not get your suggestion actually. you mean i have to use 14 visa write block or what? can you tell me some in detail?   so i can do it. Iam attaching the vi which i did so far. tell me for the corrections in it. i used already case and for loop and delay in it. i used built array so it is adding all the commands to gather as a single command  but it should  to send separately but in one  click 

thank you in advance  

0 Kudos
Message 7 of 16
(238 Views)

Give this VI a try.  I did some massive cleaning up of your code (got rid of unneeded controls, changed some controls to constants, set fonts to normal, lined up items so wires are straight, eliminate dead space, etc.).  But the big thing I did was move the Concatenate String to be inside of the FOR.  This way you are appending each command individually when sending.  Considering you are using Putty, this is the most likely data protocol you want.

 

But I have a grave concern with how you are parsing the data.  Again considering you are using Putty, I seriously doubt you want to read raw bytes.  It is likely an ASCII formatted number.  But, again, we need to know your protocol in order to give any real advice here.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 16
(202 Views)

Hello, Crossrulzz....

Now its working  ALMOST FINE but now there is one small problem the all the  commands are not transferring in one click. i have to press the send button after every command then im getting answer for every command till final same like my previous VI but previously i was typing command manually im attaching my old VI which worked as putty. again will explain the situation.

 

my device is connected to micro controller and controller to pc using usb. before i was controlling it by using the putty and i was sending command one by one all the 14 commands. then i designed the vi for the same sending command one by one till 14 and it worked. 1st  command is like read then it will read the device then then second command is like read rom then i will read the rom of device and so on . all outputs are numbers and characters.

now  can you suggest me how can i get the output directly from the 14 command in one click so i do not need to press send button again again.

ps: the every command should be send but when i click on send button only once not every time for every command( 14 times ).  you get it now?  or should i explain again and more 

0 Kudos
Message 9 of 16
(183 Views)
Solution
Accepted by topic author jeet4230

@jeet4230 wrote:

again will explain the situation. 


Or you could just give us the actual protocol (this is the third time I've asked for it).

 


@jeet4230 wrote:

1st  command is like read then it will read the device then then second command is like read rom then i will read the rom of device and so on . all outputs are numbers and characters. 


So it appears your microcontroller does send a response to every command (I raised this question in my first response).  Therefore, do your reads inside of the FOR loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 10 of 16
(175 Views)