Jump to content

commands from controls and write visa


Recommended Posts

I had taken the event structure for each control which are used to write the values to serial device. Problem is when i am reading data from serial device i am using same command and when writing to serial device u just want to appened user value to the existing read command and send it to serial port only on user entered sistuation. Otherwise the old command should run always for read values and only i need to send write commands when the user enter specific value in specific control.

More i want do also create send button that when user press the button after entering the values into controls(which are in event structure) then it should write those commands to serial port anr clear button to clear all the indicators and controls to zero.

Please can any one tell me how i can do this.its urgent for me,...please

Using labview8.5

newvi.vi

Link to comment

First of all, I'm going to recommend the Producer/Consumer design pattern for what I think you are trying to do. I basically split up your code into a GUI loop and a Serial Communications loop. When you change a value in the GUI, the corresponding event should trigger and you then tell the serial communications loop what to send/read using a queue. I'm hoping this will give you enough of a kick start to get you going the rest of the way.

Attached VI should be in 8.5.

newvi.vi

Edited by crossrulz
Link to comment

First of all, I'm going to recommend the Producer/Consumer design pattern for what I think you are trying to do. I basically split up your code into a GUI loop and a Serial Communications loop. When you change a value in the GUI, the corresponding event should trigger and you then tell the serial communications loop what to send/read using a queue. I'm hoping this will give you enough of a kick start to get you going the rest of the way.

Attached VI should be in 8.5.

newvi.vi

thank you so much for for your help but i am very new to labview and its not good for me to enter into new coding design waht you have given. Even the dead line is coming vesry soon for me to submit these project. so, i would like to stick to my code which is easy to understand for me and like to implement towards the final solution. Can you tell me how can i do this.

I have six monitoring commands which should always run continuously to get the answers. More I have 8 control commands(in event structure) which always user can set the values into them and written to the port parallel(like user enter some value in any of the 8 controls and press send button) and while writing these values to the port I want to append the user values to the existing command in hex (So far I have done it) but strucked with writing to serial device. I want to make a simple terminal instead of these controls and indicators to user can enter the command in write command box and he can see the result in read display box. Now read display box display the result of running command which I don't want and need to used same property in case of simple terminal creation. Errors are always hitting me when try to put write control to the write visa. Please can any one help me?

newvi.vi

Link to comment

I've been down that road too many times. When it comes to serial communication, you need to separate your GUI code from the serial communication (specifically the reading). The simplest way is to use a producer/consumer architecture. If you have questions about how it works, then I'll be more than happy to answer them. But from what I've seen, you are not going to get where you want to go with your current architecture.

Link to comment

I've been down that road too many times. When it comes to serial communication, you need to separate your GUI code from the serial communication (specifically the reading). The simplest way is to use a producer/consumer architecture. If you have questions about how it works, then I'll be more than happy to answer them. But from what I've seen, you are not going to get where you want to go with your current architecture.

HI,

I have a big problem now and need to change my code in another way. Please refer the new post i have written some in the forum which having title as"writing 3 times to write visa".

I am crying now and i can not able to do anything with the code. Please see the new post and can reply me there. please......

Link to comment

HI,

I have a big problem now and need to change my code in another way. Please refer the new post i have written some in the forum which having title as"writing 3 times to write visa".

I am crying now and i can not able to do anything with the code. Please see the new post and can reply me there. please......

Now, I changed my total code to event structures. Though, I have some errors and couldn't solve it.

First problem is I can't wire to close visa and it arises error.

In second event case currently I am writing command like 1088(here 10 is address) but I want to make if first case runs and displays all the available addresses user can select the any address and it should replace the existing address and write to port.

In Third event case, I would like to write user entered data to port by appending the data to existing command in String concatenation. In this case also selected address should replace the existing address always.

Please any one should suggest me. Thank you.

rajnew.vi

Link to comment

Now, I changed my total code to event structures. Though, I have some errors and couldn't solve it.

First problem is I can't wire to close visa and it arises error.

In second event case currently I am writing command like 1088(here 10 is address) but I want to make if first case runs and displays all the available addresses user can select the any address and it should replace the existing address and write to port.

In Third event case, I would like to write user entered data to port by appending the data to existing command in String concatenation. In this case also selected address should replace the existing address always.

Please any one should suggest me. Thank you.

Do not put an event structure inside of an event structure. Simply create the appropriate event cases to handle your events in the single event structure.

Disable the automatic indexing on the output from your loops. You are creating arrays of your VISA resource. Also, use shift registers to hold the VISA resource and error cluster in your loop. Wire the values through and connect them to the output tunnel on ALL of the cases of your event structure. Your unwired tunnels are set to the default value which is not a valid VISA resource name.

Link to comment

Do not put an event structure inside of an event structure. Simply create the appropriate event cases to handle your events in the single event structure.

Disable the automatic indexing on the output from your loops. You are creating arrays of your VISA resource. Also, use shift registers to hold the VISA resource and error cluster in your loop. Wire the values through and connect them to the output tunnel on ALL of the cases of your event structure. Your unwired tunnels are set to the default value which is not a valid VISA resource name.

Thanks a lot , After changing with shift registers there is no broken wires. Can you explaine me what exactly shift register is doing and why it is suited here.

I am very new to labview, Please can you tell me how can I do the follwing thing.

Now i am doing address search on my first case of event structure which will get address and display in dropdown list. In next other two event cases Right now i am sending commands with address as first databyte(example 1088 where 10 is address) but I need to make a program that will take the address from dropdownlist what user selected always and sending to the serial device.

Please could againe suggest me clearly what mistakes i am doing and guide me for the above question.

rajnew.vi

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.