LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

New to labview - doing a serious project

Hi theseas,

LabVIEW can communicate with serial ports rather easily assuming you know the data format coming in and how to communicate with the device (both of which are usually in the user manual for that device). Once you know those things, refer to my post above for a LabVIEW example. Try to get a single command or operation to work and build your code from there.
Joe Friedchicken
NI Configuration Based Software
Get with your fellow OS users
[ Linux ] [ macOS ]
Principal Software Engineer :: Configuration Based Software
Senior Software Engineer :: Multifunction Instruments Applications Group (until May 2018)
Software Engineer :: Measurements RLP Group (until Mar 2014)
Applications Engineer :: High Speed Product Group (until Sep 2008)
0 Kudos
Message 11 of 46
(1,770 Views)
Joe, I was reading your reply to this question and came to my own. I use Basic Serial Write and Read.vi to issue an ASCII command such as p=1000\r\ss=10\r\sa=10\r\s^\r\r to control a motor. In asame VI, if I call this Basic Serial Write and Read.vi to control the motor twice with another ASCII command such as  p=0\r\ss=10\r\sa=10\r\s^\r\r. The first command is executed. The second is not. If I run my VI one more time, the second command is executed.
  It appears that Basic Serial Write and Read.vi does not quite release the serial port in the first run. It releases the port when the program stops. But, then why is that when the program is run again, the second command is executed?
  Please help. Many thanks.
 JQS
0 Kudos
Message 12 of 46
(1,730 Views)

You may want to start a new thread with your question since it seems to be different than the original poster's.  Post a copy of your VI and any information you have on the communication protocol as well.

The situation you describe just doesn't sound normal.  The basic write and read example closes the Com port at the end of its execution.  But even if it didn't, that shouldn't prevent you from writing to the same serial port at different times with the same or even a different LabVIEW program.  It would cause and issue if you were going to use another program as it would detect that the serial port is open.  Perhaps you have a timing issue where you are trying to send too many commands too fast?  The multiple carriage returns within the same ASCII command seems a bit unusual.

0 Kudos
Message 13 of 46
(1,726 Views)
Hi all
 
"Hi Shawn,

I'm a bit confused about how your data acquisition will flow. Your four sensors will connect to your DAQ device and your DAQ device will connect to your PC. It sounds like the DAQ device is the Phoenix Contact port board you mentioned, but I'm not sure. Also, how does the DAQ device connect to your PC? You mentioned both parallel and serial, so is it both?

At any rate, assuming that you use the RS-232 connection, LabVIEW has simple interaction with serial ports. There is a group examples that install with LabVIEW which I think would be great resources for you as you design your project. They can be found in the Example Finder under Help » Find Examples.... From there, navigate to Hardware Input and Output » Serial to see the different examples. The Basic Serial Write and Read.vi would be a good place to start.

 

Joe F.
National Instruments :: Applications Engineer :: High Speed Product Group
"
Yep now Im using serial connection.
Ok I followed what u said to start with one channel. At the moment I can monitor the voltage of the Microconntrollers channel :- > on labview front panel. Great. One big step into a forward direction.
stats are 1 stop bit, 2400bps, 8 bits.....
One thing is I am getting a bit of random errors now and then. By the way I did delete the error message VI, it was bugging me with the error message "VISA serial error - 1073807312 - user abort occured during transfer".
 
Im using following VI's
 
From the read buffer.... the following is connected one after the other.....
STRING TO BYTE.VI
ARRAY MAX & MIN.VI   
TO EXTENDED PRESSTION FLOAT.VI
FORMULA .VI
NUMRICAL INDICATOR   //to display the unsigned binary data converted to voltage.
 
 
 
Cheerio
 
 
Shawn
...:::Cheers:::....
0 Kudos
Message 14 of 46
(1,629 Views)
What Im finding really hard is working out what the array VI's actually do.... The help on them doesnt help that much... It doesnt really explain what each one does enough for me.
...:::Cheers:::....
0 Kudos
Message 15 of 46
(1,627 Views)
What Im finding really hard is working out what the array VI's actually do.... The help on them doesnt help that much... It doesnt really explain what each one does enough for me.
 
 
like INTERPOLATE 1D ARRAY.VI      If I put a 0 constant  at "fractional index x" and use y as our data output.... does that mean element 0 of the array is y???
 
Like all I want to do is take out of the unsigned byte array ... the channels 8 bit data.
 
 
 
 
cheerio
 
shawn
...:::Cheers:::....
0 Kudos
Message 16 of 46
(1,625 Views)
Hi Shawn,

Considering you want to break a binary number into its single bits, the better place to look is the boolean palette. The VI for you in this case is called "Number to Boolean Array". If the unsigned numbers are in an array, use a for loop to index through the array and make the conversion inside and re-group your data however you like.
Joe Friedchicken
NI Configuration Based Software
Get with your fellow OS users
[ Linux ] [ macOS ]
Principal Software Engineer :: Configuration Based Software
Senior Software Engineer :: Multifunction Instruments Applications Group (until May 2018)
Software Engineer :: Measurements RLP Group (until Mar 2014)
Applications Engineer :: High Speed Product Group (until Sep 2008)
0 Kudos
Message 17 of 46
(1,592 Views)
Well actually what I really want to do is extract binary number from one element of an array, say element 0 or 1 .
...:::Cheers:::....
0 Kudos
Message 18 of 46
(1,574 Views)

I just read this thread and I must say I'm a bit confused..

Are you still getting errors during your serial transfer?  Are your settings correct?  2400 seems a bit slow.  I would have expected (at least) 9600.  Was 2400 specified in the PIC's specs?  I may have missed which specific PIC you are using, which part no is it?

If you are still having issues with serial communication, then that should be resolved before moving on the the array..  😉

R

 

0 Kudos
Message 19 of 46
(1,563 Views)
Hi Shawn,

If you want a single element from an array, the best function for that is in the Array palette: Index Array. This will pull out an element from the array and return it to you. If you want to look at every single element in the array one-by-one, the best thing for you to do is use a for loop. With each iteration, the for loop will automatically index the array from beginning to end.

If you'd like to learn more about how to use LabVIEW functions and structures, I recommend the free online LabVIEW Introduction Course:

LabVIEW Introduction Course
http://zone.ni.com/devzone/cda/tut/p/id/5243
Joe Friedchicken
NI Configuration Based Software
Get with your fellow OS users
[ Linux ] [ macOS ]
Principal Software Engineer :: Configuration Based Software
Senior Software Engineer :: Multifunction Instruments Applications Group (until May 2018)
Software Engineer :: Measurements RLP Group (until Mar 2014)
Applications Engineer :: High Speed Product Group (until Sep 2008)
0 Kudos
Message 20 of 46
(1,539 Views)