Jump to content

Recommended Posts

Hi all,

currently stuck on the following

I am doing a labview assingnment that entails duplex serial port communication between 2 VIs. So I write a string to the com port on one machine/vi, then on the other read the stream one byte at a time (i've included start and stop bits for the packet) - so the other machine reads a start bit, then loops round and reads each byte at a time from the stream until it hits the stop bit and then this is where the problem starts

with auto indexing on, the while loop then chucks out an array of all the bytes that have been read

how would I go about turning this array into a string? As i need to do string manipulation etc on it?

hope someone can help

many thanks

Link to comment
I think you have several ways to do this.....Array to String.

1)Use Array "To Spreadsheet String Functions"(Functions>>String>>Array To Spreadsheet String).

2)Use For loop and Shift Register. See attach image.

post-705-1099452776.png?width=400

Hope this can help you.

2535[/snapback]

thanks Jimmy

using a shift register i've managed to extract the read string from the start and stop bits

does this look like the best way to do this?

one of my lecturers suggested the use of a local variable, but i'm not grasping how to do this and achieve the same results.

Many thanks

post-892-1099490358.jpg?width=400

Link to comment
thanks Jimmy

using a shift register i've managed to extract the read string from the start and stop bits

does this look like the best way to do this?

one of my lecturers suggested the use of a local variable, but i'm not grasping how to do this and achieve the same results.

Many thanks

2538[/snapback]

Hi boyracer

why read one bit at a time ??

Use read bye count vi !

With regard to you block diagram- you are assuming that the serial port init occurs before you read loop :nono:

Use sequence to ensure that occurs :worship:

Also recommand that you add a short delay so that initialisation

of port complete before event.

At present you loop structure is hogging CPU process time, put a wait in the loop with say 20ms (experiment)

chow

xseadog

post-577-1099495673.gif?width=400

Link to comment

hey xseadog

thanks for the idea - will try it out

i'd read one byte at a time because before i tried to just do a 'serial port read' without a 'bytes at serial port' and sometimes the string was getting read in a funny order :thumbdown:

so, to add a delay, would i put that in the sequence that does the read?

also, I want to add something so that it writes back to the other machine as well. As i want to read string from serial port, do stuff with it and alter settings on front panel accordingly then write back the change of settings and other things. Fundamentally, both machines will need to read and write - duplex communication over serial. Do i just add another sequence below this so that they run in unison?

sorry to ask so many questions - got a big assignment and this is a small foundation of it, without which I cannot progress

many many thanks

PS I am not actually 'boyracer38' - he is my housemate, I did register as bUrGe and Michael Burgess, neither of which I received an activation e-mail for :(

cheers,

Mike

Link to comment

The simplest way that I've found to concatenate a string array is to just wire the array to a concatenate primitive.

post-584-1099547480.png?width=400

As far as the serial reading I've developed a serial read vi that not only used the buffer count but also includes timing functions and other useful items.

I also included a 7.0 version

Download File:post-584-1099547750.llb

Download File:post-584-1099548148.llb

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.