LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Basic Read write serial communication vi Required

Hi,

I Refereed Basic Read write Serial communication example but i want to read continuously from micro controller and write operation also(whenever use want to send command).

how to modify this example code.

 

 

PS:I am using stm micro controller.

0 Kudos
Message 1 of 5
(1,985 Views)

Please give more information about the code you're using and the device you want to communicate with.

One possible modification to the code it sounds like you're describing might be to add an Event Structure for the Write case with a button, and then Read in the timeout case (or check the available data in the timeout, and trigger reads in a separate case.

Producer/Consumer variants with the Producer always reading might also be possible but you might need care to avoid message collisions in that setup.


GCentral
0 Kudos
Message 2 of 5
(1,933 Views)

Labview 2010 and micro controller is stm32f4 discovery.

code i generated from stm32 cube

0 Kudos
Message 3 of 5
(1,880 Views)

Hi again, 

 

This question is now quite a bit beyond "LabVIEW", I imagine.

 

You say the code has already been "generated" for your board. Can you describe the interface (perhaps because you wrote it)?

 

The manual for the Discovery kit describes an embedded driver that may allow use as a virtual COM port - is that how you intend to use it?

 

A much more detailed description of the problem you're trying to solve with LabVIEW is needed for me to be able to provide any real help here. Serial communication is simple enough but what it sounds like you're describing requires a much lower level programming before you can get anything done.

 

If a sample ARM program for the board is already running on it, that may remove the need to separately write the code yourself, but you'll still need to know the interface (commands, responses, etc)


GCentral
0 Kudos
Message 4 of 5
(1,845 Views)

@engine_motor wrote:

Hi,

I Refereed Basic Read write Serial communication example but i want to read continuously from micro controller and write operation also(whenever use want to send command).

how to modify this example code.

 

Well my first question is: Are you writing the code that is running on the micro controller?

 

If so, then you have complete control over the format of the data the micro controller is sending and expects to receive. So that makes it easy because you can change the code as needed.

 

I would create a series of commands that you send the micro controller to have it reply with the data you desire. For instance of you want the value of a voltage on analog input 0 you might send the command V0? and the micro would reply with that value.

 

When the micro sends data append a common termination character (Line Feed) to the end of every data sent. 

 

Enable the Termination character in VISA Serial Setup and set it to match your character. Then set the VISA Read function in LabVIEW to read a larger amount of bytes than you eve expect to receive. Now LabVIEW will read until is receive the termination character or times out.

 

Search the board for "Bytes at Port" for several discussions on why you should not use it and more detailed explanations of what I just wrote about serial communications.

 

The read continuously part is as simple as sending a "default command" that get the continuous data you require if no other command is selected to send.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 5
(1,815 Views)