06-02-2020 02:47 AM
Hello everyone!
I'm new to labview and I'm trying to realise protocol communication between my computer program and microcontroller via VISA("Home-made" MODBUS protocol).
Now I can send the command from the computer and get the response, but just 1 command.
I cann't to understand the procedure of sequential messaging.
How it works now:
[Start]-> [command 1]-> [delay]-> [response to command 1]-> [close the programm]
What I'm trying to do:
[Start]-> [command 1]-> [delay]-> [response to command 1 ->... ->[command i]-> [delay]-> [response to command i] -> [close the programm]
Ofcourse I need to use the while loop structure in the programm. But the question is: How can I send the next message after the first message and get the response for them?
Labview allows me to make just one string line to the write buffer of VISA.
Thanks
06-02-2020 06:34 AM
First, as shameless plug: VIWeek 2020/Proper way to communicate over serial
I show a few frameworks in there based on how your device communicates. But if you are actually doing a MODBUS, there are a few toolkits floating around to do this already. Do a search through VI Package Manager.
You should also get in the habit of making a VI for each command. Things will get a lot simpler when you do.
06-02-2020 09:03 AM - edited 06-02-2020 09:04 AM
Here's a tip beginners should learn sooner rather than later.
Index Array is Expandable!
Instead of branching the array wire and using multiple Index Array functions and needing to wire up all those index constants, delete all but the first one.
Drag the bottom border downwards and you'll get multiple outputs.
With nothing wired to the first index, you'll get index 0 by default. For the rest of the indices, they'll be 1 index higher than the one above.
So where you have a 1, 2, 3, 4, ... You could wire a 1 constant to the top, and get rid of all the other constants.
Also, something is wrong with your labels. There are a lot of garbage characters in your labels and controls.
06-02-2020 09:24 PM
Dear Ravensfan, hello!
Your variant is much easier!!! I don't know about this opportunity.
Thanks:)
06-02-2020 09:32 PM
Dear crossrulz, hello!
Thank you for your link to the educational material.
I'm going to watch it right now. May be it helps me in my task.
06-03-2020 04:21 AM - edited 06-03-2020 04:23 AM
Well, I have changed the body of the programm a little bit.
Now it runs contiuously (because of while loop structure), and it's great.
Also I understood how I can write 2 message via VISA one by one.
but the problem is steel here. How I can read two messages from two read buffers using the similar indicators?
For example:
The first and the second messages have the similar parameters such as status register. It means, that I need to use just one indicator on the front panel.
What I chould to do to realise this?
Thanks!
06-03-2020 04:24 AM
I forgot to attach the file
06-04-2020 12:04 PM - edited 06-04-2020 12:04 PM
What is the difference between the two different Write commands?
If they are going into the same indicators, that tells me the write commands are probably the same.
If you want to just cycle between the two commands, use a select statement as to which command you want to use, and use a Quotient and remainder function on the i value of the while loop to alternate.
06-05-2020 01:45 AM
Dear RavensFan,
The communication protocol has 15 different commands. Some commands are used for request of different parmeters and anothers for the upload some data.
I think, that I found the solution of my problem. Shift register for while loop structure allows me to use the required indicators. URL for the possible solution: https://www.youtube.com/watch?v=Fgsa88g8m-M
I should check it.
Thanks!