LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't get bytes from uC to read in LabVIEW *FTDI* *Serial Communication*

Solved!
Go to solution

Sorry - I missed that the error is now a non-error status update.  Try using a copy of my code, with the output text concatenating until you press the STOP button, and see what you get.  The code you have currently isn't waiting for data - it runs, and if it finds no data, returns no data regardless of what you feed into the Byte Count input.

 

Also - you don't need the Flat Sequence structure - the VISA Reference and Error cluster are enforcing dataflow.

 

 

 

 

0 Kudos
Message 11 of 23
(1,907 Views)

It is actually back to the error code. This is what i currently have

0 Kudos
Message 12 of 23
(1,902 Views)

Please send me your code.

Message 13 of 23
(1,899 Views)

Here it is.

 

I also found example C code that uses the header VISA.h to send data to LabVIEW. Should I use this instead of just writing to UART registers?


0 Kudos
Message 14 of 23
(1,897 Views)
Solution
Accepted by ipatka

Ipatka,

 

It's obvious you're new to LabVIEW though you also appear to be a quick learner, as although you missed a few things in my example (the shift register, and you didn't put the string concatenator in the case structure, and have only one Case in your Case statement, which you made Default to get the VI to run, but it was still trying to read even when there was nothing to read), you correctly switched from the Init Serial command to the Properties options to configure your port as per the help document.  Do you get an error on the output of the configuration command?  If so, try removing parameters one at a time until the error goes away, and see if you get it working.

 

Also, in my example, I should have showed my alternate Case of "0", with the String In tunnel connected to string out, and error in connected to error out, with a 10 ms Wait inside as well - to let the serial port start to buffer data while not burning unnecessary CPU cycles.  I also didn't have a VISA Close statement, though that occurs automatically when the VI terminates.  I'm attaching the example again using the Instrument Properties to configure the port.  See if it works for you.

 

 

 

 

 

0 Kudos
Message 15 of 23
(1,878 Views)

Thank you for your patience. This has been very helpful.

 

I get the error at VISA read, not at the configuration command.

 

Could this be an issue in the code for my uC?

0 Kudos
Message 16 of 23
(1,876 Views)

I think I found the problem. In my C code I forgot one set of parentheses which threw off my baud rate. Now I'm getting output but it is just empty boxes. There must be some issue with formatting.

0 Kudos
Message 17 of 23
(1,869 Views)

Is the data you're reading a string or a series of bytes?  If it's not a string, you should use the "String to Byte Array" converter to get the ASCII codes for each character.  I'm not sure of how familiar you are with ASCII, but most codes are non-printable characters.

0 Kudos
Message 18 of 23
(1,846 Views)

I actually just came to that conclusion when I converted the string to a byte array and displayed it. It is displaying an array of the ASCII code for the @ symbol (64) but what is strange is that I have my C code transmitting an unsigned char 1. What format do you think I should be transmitting?

0 Kudos
Message 19 of 23
(1,844 Views)

Do you think the byte I am transmitting could have gotten logically shifted so the 1 is in the 7th place on the bit giving a 64 ASCII?

0 Kudos
Message 20 of 23
(1,840 Views)