LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with a RS232 LabView program

Okay so I found out about NI MAX. I can find the COM port there as well. And the message says that the "resource is valid" even though it cannot connect. I guess that can't be too bad as a start...And I was also to "validate" the port:

NI MAXNI MAX

NI MAX2.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Not sure if this is helpful at all...

Ni MAX3.PNG

0 Kudos
Message 11 of 44
(1,257 Views)

Here's a possible example to get you started.

It should be true that you can run this VI and read the temperature - if that works, you can create more subVIs like the code indicated in the boxes here, and modify them appropriately to handle different commands.

Example_VI_BD.png


GCentral
Message 12 of 44
(1,244 Views)

If cbutchers vi give no response (timeout error) ...

Do you have a proven (old) RS232  connection cable for that ciller?

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 13 of 44
(1,230 Views)

I noticed reading again that there's a slight mistake in my parsing of the response.

 

If you check the string coming out of the VISA Read node, you'll probably get "<LF>T xxxx" (the <CR> will be handled as a term char).

 

I didn't handle the T, and so you might want to try tweaking the value of the "1" going into String Subset (e.g. if there's a space between T and the value, perhaps try 3, otherwise, you could consider 2... trial and error will get you there although I think Hex String to Number will be ok with the leading space anyway (edit, tested)).


GCentral
Message 14 of 44
(1,224 Views)

I've spend the last hour trying to build a LabView script with your image....it is a mess. Just now I saw that you attached the file and I could have used this...well it was good training I guess.

Capture.PNG

What is up with SubVIs? creating these is messing up the whole structure

0 Kudos
Message 15 of 44
(1,219 Views)
@cbutcher wrote:

I noticed reading again that there's a slight mistake in my parsing of the response.

 

If you check the string coming out of the VISA Read node, you'll probably get "<LF>T xxxx" (the <CR> will be handled as a term char).

 

I didn't handle the T, and so you might want to try tweaking the value of the "1" going into String Subset (e.g. if there's a space between T and the value, perhaps try 3, otherwise, you could consider 2... trial and error will get you there although I think Hex String to Number will be ok with the leading space anyway (edit, tested)).


By the way...I don't understand a single word 🙂 What is <LF> and <CR>? and no idea what you are talking about the String Subset. I am so sorry but this a little bit too fast for me. Let me try to use your example and see what I get
 
Update:
Holy sh** it works. I changed the 1 to a 3 and it worked
itworks.PNG
You are a saint!
 
0 Kudos
Message 16 of 44
(1,221 Views)

@Henrik_Volkers wrote:

If cbutchers vi give no response (timeout error) ...

Do you have a proven (old) RS232  connection cable for that ciller?

 


Unfortunately I don't

0 Kudos
Message 17 of 44
(1,217 Views)

Ok, so the structure you used is pretty close looking to what I used, but not the same.

In my VI, I used flat boxes (from the Decorations subpalette of Structures) to indicate some grouping of bits within a VI that could be used to create a different VI.

In your VI (or at least this image below) you used Flat Sequence Structures, which have a functional behaviour (whereas mine were, you guessed it, decorative 😉 )


@Torracc wrote:

Capture.PNG

What is up with SubVIs? creating these is messing up the whole structure


To create a subVI from existing code, you can drag a box around it and go to Edit > Create SubVI..., and it will automatically connect it and make a new VI with an appropriate (or appropriate-ish) connector pane. This is the collection of bits in the top right of a front panel:

topRight.png

I'm not sure where in the tutorial material this is introduced, but it's like defining function parameters/arguments/return values in a text language - these are the inputs and outputs of a VI.

You just click on a box there, and then click on a control, and it is filled in. The colour indicates the data type. A small outline appears around outputs (indicators) to highlight them (here the blue icon, not really very visible). Usually put the inputs on the left and the outputs on the right for convenience when calling.

 

Double clicking on the icon opens the icon editor, which allows you to edit the icon (I know, right...).

The combination of these allow you to do something like the following with my example VI:

Example-ReadPlantTemp_BD.png

 

Project is attached (for 2015).

 

Edit: In response to your other questions, <CR> is carriage return and <LF> is line feed. These are marked as ^M and ^J respectively in your manual.

 

They are common line ending characters, on Windows the pair is used for an end of line (like <CR><LF>). On Linux, you commonly use <LF> and on Mac (at least previously, I believe modern Mac has changed to <LF>) you use(d) <CR>. This causes plenty of problems, but is an irrelevant aside for your LabVIEW driver.


GCentral
Message 18 of 44
(1,203 Views)

You have a first solution , but I'm curious why cbutchers solution with a 1 didn't work.

I added a small modification that reads every second and put that in a chart.

if only the first read works, you can change the offset on the fly.

make a screenshot and post the picture since it also show the complete response in hex

don't run it too long since it keeps all data in the long buffer 😉

My code added is not as nice commented as cbutchers

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 19 of 44
(1,194 Views)

@Henrik_Volkers wrote:

You have a first solution , but I'm curious why cbutchers solution with a 1 didn't work.


Because I didn't RTFM properly 😉 (that's F for full, btw...)

 

The command response is <cr>T xxxx<lf> and so with an offset of 1 you pass "T xxxx" to Hex String to Number. With an offset of 2 you get " xxxx" but the space is ok. 3 also removes the space.


GCentral
0 Kudos
Message 20 of 44
(1,164 Views)