LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to end write with RETURN

Hello

I made the attached VI. The aim is to communicate with a PIC controllern.  The PIC sends strings to Labview. This works so far quite well.
My problem is that I am also going to send strings back to the PIC.  
The PIC reads characters into a string until a  RETURN (value 13) is encountered.
So mz question is. How can I adjust the VISA write function to send at the end of every string a RETURN ( \0A. )
I tried to set up the termination character - but i still didn't get the right string.  
I connected the output directly to another PC and watched the incoming HEX datastrings.

BYE




0 Kudos
Message 1 of 8
(2,614 Views)

Hi LabLeo,

      I think only "read" termination is configured by your VI (see help for VISA Config Serial Port)

Try using a property node to set ASRL End-Out to "TermChar"...

Cheers

... by the way, that's an odd place to use a Local reference to the VISA reference! Smiley Surprised  Better, I think, to wire through the Write just as has been done with the read(?). 

 

Message Edited by Dynamik on 12-09-2005 02:32 AM

When they give imbeciles handicap-parking, I won't have so far to walk!
0 Kudos
Message 2 of 8
(2,600 Views)
HI

Ok I will try this with the property node.
I tried to wire the local reference directly at the output of the read VISA. I don't understand why, but because of any reason it didn't work like that.?!?


Thanx so far....
0 Kudos
Message 3 of 8
(2,589 Views)
Hy

This with the proberty note works. And I also was able to monitor the output string that I want to send from Labview to the PIC.
On the serial output monitor the string looks exactly like I want them to be.

The problem that I do have now is that when I connect the computer with the PIC the uC stops transmitting when I want to write the string.

The PIC programm works like it should if I simulate it on the PC.
For that I first write the string   123,456,   and than the Return in HEX   0D;
The programm also stops till it gets the Return value.

So I assume that there is somthing wrong with the termination character. 
I wonder if there is a mistake in the VI or the PIC-programm.

I really need some help at this.

Thanx so far

Bye

Download All
0 Kudos
Message 4 of 8
(2,582 Views)

Instead of using a property node, it might be easier to just concatenate the End of Line constant to the write buffer as seen in the attached picture.  Sometimes controllers are peculiar in what the end of line should be.  Sometimes carraige return works, sometimes line feed, sometimes both.  Fortunately Labview provides constants for all.  try each one to see which works best.  The picture is using the carraige return/line feed (0x0A and 0x0D)

Message Edited by tbob on 12-09-2005 09:15 AM

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 8
(2,570 Views)

Hi LabLeo,


LabLeo wrote:


The PIC programm works like it should if I simulate it on the PC.
For that I first write the string   123,456,   and than the Return in HEX   0D;
The programm also stops till it gets the Return value.


      You said in your first post that you wanted to send a 0x0A, but here say it supposed to work with 0x0D!  Smiley Mad

      With a little effort, you can figure this out - but BTW, I usually follow tbobs advice and add the term-char explicitly.

cheers!

When they give imbeciles handicap-parking, I won't have so far to walk!
0 Kudos
Message 6 of 8
(2,553 Views)
Hi

Dynamik:  I made a mistake in my first post. Smiley Sad   I still need a RETURN at the end of the string. And this should be a 0x0D.

Ok. I tried to
concatenate the End of Line constant to the write buffer.
After that I watched the serial output monitor.
It looks like expected.          \0A123,123,\0D
                                             \0A123,123,\0D     ........

So that should be fine so far.

I changed my PIC programm so that it reads and uses the string properly.
I want to write the  characters  1,2,3 and  5,6,7 to int variables.
If i simulate it it works perfectly.

 if (kbhit())                              //receive
      {
      gets (inputstring);
      }

      anglein3 = ((inputstring[1] - 0x30)*100);
      anglein2 = ((inputstring[2] - 0x30)*10);
      anglein1 = (inputstring[3] - 0x30);
      anglein =  anglein3 + anglein2 + anglein1;

      speedin3 = ((inputstring[5] - 0x30) * 100);
      speedin2 = ((inputstring[6] - 0x30) * 10);
      speedin1 = (inputstring[7] - 0x30);
      speedin  = speedin3 + speedin2 + speedin1;

      printf("%ld: %ld: %s: \n", anglein, speedin, inputstring);

But I still have the problem in hardware. After I press the write button the PIC stops.

????


Bye



0 Kudos
Message 7 of 8
(2,537 Views)
Hi

It works now. The problem was the read and write routine.

I made a completaly new VI.

Thanks for the help.


0 Kudos
Message 8 of 8
(2,528 Views)