LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Receive and send data through serial communication

Hi guys, I am new in the NI community and i just started learning labview few weeks ago. 
My project consists in two separate loop.

1) SEND LOOP. It is supposed to send from a labview interface to PSoC some strings in order to make a motor work. I have one loop (called 'send loop') with a case structure inside that take care of this request. This part of my project works properly.
2) RECEIVE LOOP. I want also to be able to read continuosly 2 bytes data sent by my PSoC to the same labview interface. I am trying to do this in the so called 'receive loop'. 

 

The PSoC part where i create the 2 bytes data is this:

BL = count_1 & 0xFF;
BH = count_1 >> 8;
data[0]= BL;
data[1] = BH;
USBUART_1_PutData((uint8*)data, length_data);

 

where length_data=2, count_1 is an int16 variable and BL and BH are int8 variables.
I think that the PSoC part is correct. 
Can someone help me to understand what is wrong in the receive loop? I think i am managing the VISA functions in the wrong way. 
Thank you all!

0 Kudos
Message 1 of 3
(1,622 Views)
  • Once start=True, your receive loop will terminate, because it is also wired to the loop termination terminal.
  • Your use of the COM port local variable makes no sense.
  • Your boolean shift register in the send loop does not do anything useful.
  • What's the purpose of Data 2 and why are you not using the terminal for wiring?
  • What loop rate do you want for the receive loop?
  • All your serial stuff seems completely wrong, but I'll let the serial experts comment on that. 😉
  • Code like in the picture below is complete Rube Goldberg. Think about it!

 

altenbach_0-1633008755667.png

 

0 Kudos
Message 2 of 3
(1,609 Views)

How often are the data being sent from the PSoC?  How do you know you have the right 2 bytes in the correct order?

 

I have a lot of concerns with your messaging protocol, especially since I am seeing ASCII and raw/binary/hex data being used.  You need to spend some time thinking through your messaging protocol.  It would probably be best to use ASCII on all sides.

 

You might want to watch this presentation: VIWeek 2020/Proper way to communicate over serial


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 3
(1,587 Views)