LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with acquiring data from serial port

Yes. You now have the termination character set to carriage return.

 

I would probably change the byte count control to a constant and make it 1024 or larger.  That way someone cannot accidentially set it to a small value and cause problems. Setting to to a larger value (like 2000) does not cause any difficulties. The VISA Read terminates when the termination character is received or when byte count characters are received, whichever comes first.

 

Lynn

0 Kudos
Message 11 of 19
(1,557 Views)

Again, I agree with Lynn -- wire a constant (1024? 2000?) to your VISA Read, run your program, and tell us what happens.  I recommend putting an indicator on "Bytes Read", as this (along with the contents of the String) would be "clues" to what is happening.

 

What can you tell us about the instrument that is generating the Serial data?  Is there a manual for it on the Web?  If so, we could look at it and maybe determine (because they tell us) if there is a Termination character, and if so, what it is.  Who knows, they may use some other protocol (I've certainly got a serial instrument that "does weird things" and needs special programming to get the data in).

 

Bob Schor

0 Kudos
Message 12 of 19
(1,550 Views)

Hello,

 i have done as you said but still not working. And when i select the wrong port still the program is running( i dont know why)  and if  i select the correct port its running but not accquiring any data from putty, still it shows nothing on string read. sometimes it running but the data in putty is different from data in labview( i dont know from where it getting this false data) . if it is running, its not accquring data properly (eg: it counts as 54,53,54,55,53,53......very fastly to and fro,even serial data is in seconds) . This are the problems i am facing now. Please help to solve this problems.

 

Thank you

 

0 Kudos
Message 13 of 19
(1,523 Views)

This is very frustrating -- you are having difficulty, we ask questions that you don't answer, and neither you nor we are any closer to understanding the difficulty you are having.

 

It appears (to me) that you are attempting to read serial data from some Unknown Device.  You seem to be able to read data using PuTTY (but haven't told us how you configured PuTTY, nor what the data looked like), you've never heard of (nor tried) MAX, and when you use LabVIEW to do serial reads, it "doesn't work" (but, again, you don't exactly tell us what it does do).

 

Here are some very specific questions.

 

  1. What is the device generating the serial data?  Does it have a Model Number?  Is there a manual for this device on the Web we could view to get an understanding of how this device communicates?
  2. When you communicate with this device using PuTTY, how do you configure PuTTY?  Tell us all of the settings that you use.
  3. When you get data back from the device using PuTTY, what command did you use to read the data?  Tell us exactly what and how much data you received.
  4. Do you have NI MAX (National Instruments Measurement and Automation Explorer) on your PC?  I'm not sure it is possible to install LabVIEW and its associated Device Drivers without also installing MAX.
  5. If you do have MAX, are you able to connect to the Serial Port that you used with PuTTY, configure it the same way that you did with PuTTY, and do a VISA Read from the device (as you did with PuTTY)?  If so, tell us exactly what data were returned, and if not, what happened.

To summarize, tell us more about the device generating the Serial Data, tell us more about What Works, and try to exactly duplicate What Works, first with MAX and then with LabVIEW and VISA.  If you give us some data to go on, we can do a much better job of suggesting something that should work.

 

Bob Schor

 

0 Kudos
Message 14 of 19
(1,499 Views)

I agree with Bob - and his frustration.

 

If you want help, please make it easier for us to help you. 

 

In addition to all the things Bob asked, please do one more thing.  Run your VI until you get "something" returned. Stop the VI. From the Edit Menu select "Make Current Values Default" and save the VI with a new name. Then post that VI. It will contain some of your data which may give us a clue.

 

Bob: Item 4: Simply install on any non-Windows platfrom and you will not get MAX.

 

Lynn

0 Kudos
Message 15 of 19
(1,483 Views)

Lynn -- as you may have guessed, my only real experience with LabVIEW has been on the Windows platform!  My bad ...

 

BS

0 Kudos
Message 16 of 19
(1,470 Views)

Hello,

Sorry for the trouble. And many Thanks for Your patience.

 

  1. What is the device generating the serial data?  Does it have a Model Number?  Is there a manual for this device on the Web we could view to get an understanding of how this device communicates?       Psoc 4 (CY8CkIT-042 Psoc 4 Pioneer kit). Yes you can find a manual.
  2. When you communicate with this device using PuTTY, how do you configure PuTTY?  Tell us all of the settings that you use.    Putty confuguration Speed (baud rate) - 9600, Data bits - 8, Stop bits - 1, Parity - None , flow control - XON/XOFF    Settings:   i have attached the screen shots for clear undetstanding.
  3. When you get data back from the device using PuTTY, what command did you use to read the data?  Tell us exactly what and how much data you received.   The command i used to read the data  is:
  4.   /* Sprintf - to print values in pc */
    char buffer1[16];
    UART_UartPutString(buffer1);           // In this case i receive the seconds count (as 1,2,3......so on), till i stop the putty session.

    sprintf(buffer1,"%1u\r",secs);
    UART_UartPutString(buffer1);
  5.  
  6. Do you have NI MAX (National Instruments Measurement and Automation Explorer) on your PC?  I'm not sure it is possible to install LabVIEW and its associated Device Drivers without also installing MAX       Yes
  7. If you do have MAX, are you able to connect to the Serial Port that you used with PuTTY, configure it the same way that you did with PuTTY, and do a VISA Read from the device (as you did with PuTTY)?  If so, tell us exactly what data were returned, and if not, what happened.   Yes, I have connected the serial port and did a VISA READ from the device with the same confguration as putty. I am attaching a screen shot of NI MAX for the easy understanding of  data that has been returned.

Note: If i try to read on Basic read VI, I am able to read the data correctly (almost, sometimes single digit numbers are appearing in between the counts, while reading larger data). And when i connect the While loop, Waveform and write to spread sheet, then it's not working at all.

 

Thank you

 

Download All
0 Kudos
Message 17 of 19
(1,429 Views)

Hello Bob,

 

I have attaching the Vi as u asked. When i count seconds, it is repeating from 294 to 299 and the spreadsheet looks like the attached file.

 

 

Thank you

Download All
0 Kudos
Message 18 of 19
(1,426 Views)

Thanks.  I wrote a very simple Serial Test -- it reads 100 times, saving the data in an array (for viewing), and times how long it takes.  Here is the code:

Serial Test.png

Before you run it, make sure that the COM port going into the VISA Configure function is appropriate for your system (click the down arrow and choose the Port to which your PSoC is connected).

When you run this, it should read 100 times from your PSoC.  I also have two timers to allow me to compute the number of Reads per second.

 

Please run this on your system, and post the results.

 

The figure above is a LabVIEW Snippet (you can recognize it because of the extra elements in the upper corners).  If you drag it to a LabVIEW 2014 (or 2015) Block Diagram, it should become LabVIEW Code.  I am also attaching the Project from which it comes, and the VI itself.  I recommend you create a folder (PSoC?), drag both the Project file and the Serial Test VI into it, then double-click the Project.  If you don't (yet) know about LabVIEW Project, you should learn ...

 

Bob Schor

Download All
0 Kudos
Message 19 of 19
(1,391 Views)