LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA write at 2 milisecond

Hello friends, i am making a simulator in Labview of my controller which transmits serial data at 2 millisecond and 460800 baud rate to another device, the reason of making simulator in Labview is that my controller is in procurement phase and i dont want to waste time so that i can integrate it with my another device. I made a program as per my experience, i use timed while loop and at start of 70 to 80 seconds i am succeeded to transmit successfully at 2 millisecond, means my device receive data and indicate that success in the form of LED Bus, note that my receiving device uses visual studio code composer and receives data at 2 millisecond , after 70 to 80 seconds the bus will start flickering means data not receive properly. kindly help me 

 

Plz see attachment files

0 Kudos
Message 1 of 10
(2,621 Views)

I see 2 major issues:

 

1. You have an additional 1000 msec wait inside your Timed Loop!  So you can't iterate any faster than once a second.  Get rid of this!!!

 

2. Every time you write to your serial port, you then immediately attempt to read 6 bytes from it.  Nothing in your description suggests that you should be expecting *any* bytes back, let alone exactly 6 instantaneously after each write.

   If indeed this is two-way communication whose protocol you get to design, I'd also *strongly* urge you to *enable* and use a sensible termination character (such as the default line feed or perhaps a carriage return)

   You'd be doing yourself a favor to check out this tutorial.

 

Further, you better make sure those 2 numeric inputs behave like you want.  They start as DBL types, you scale them by a factor of 255/50, then you convert to 8-bit integers.  Any value >= 40 will convert to 255 and any value <= 0 will convert to 0.

 

 

-Kevin P

 

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 2 of 10
(2,581 Views)

I m really sorry, the previous VI is not the correct one, i uploaded the correct VI

 

plz see attachment files

 

thanks

0 Kudos
Message 3 of 10
(2,577 Views)
Kevin, excellent response except for the math 50*5.1=255. Not 40

"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 10
(2,566 Views)

Oops, typo.  My head knew the multiplier in the code was 255/40 (as DBLs), it was my fingers that didn't cooperate.  😄

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 5 of 10
(2,549 Views)

The second version of code has neither the 1000 msec wait nor the VISA Read.

 

The Timed Loop is set to maintain original phase so I suspect that you'll get quite a few 4 and 6 msec intervals (and some other higher even #s) mixed in with your 2 msec intervals.  Nature of the beast with Windows timing, Timed Loop or no.

 

So that's not ideal, but it's not likely to be noticeable by looking at an LED bus.  At this point my bet is that your receiver code isn't properly handling the protocol you've implemented in your LabVIEW transmitter (6 byte binary message, no termination char, at 500 Hz nominal).  There's no way to guess what error(s) could be lurking in that entirely unknown code.  But that's where you should place your suspicions now.

   (Or possibly, the receiver code might be fine and it's the LabVIEW transmitter side that didn't implement the desired protocol correctly.   Still no way to know from here.)

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 10
(2,545 Views)

@Kevin_Price wrote:

Oops, typo.  My head knew the multiplier in the code was 255/40 (as DBLs), it was my fingers that didn't cooperate.  😄

 

 

-Kevin P


Oh, the 50 was wrong!  Remember I can't see a vi on my phone.  Keypads still have a way of changing our intentions.   Just yesterday I was referring to a seventh update as an "fu patch"


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 10
(2,535 Views)

plz see attachment files

 

i am calculating checksum of all 6 bytes and send it on 7th byte 

0 Kudos
Message 8 of 10
(2,524 Views)

So now you changed code on the LabVIEW transmitter side to work according to a different protocol than before.  And you didn't include the subvi that does the checksum calc.

 

The receiver side is still utterly unknown to me, so once again I do not (and *can* not) have any useful comments to offer.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 9 of 10
(2,511 Views)

@Akbar7110 wrote:

i am making a simulator in LabVIEW of my controller which transmits serial data at 2 millisecond and 460800 baud rate to another device


Ok, before we try anything else, what is the protocol of the data being transmitted (ie what does a message look like)?



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
0 Kudos
Message 10 of 10
(2,502 Views)