03-14-2021 01:32 AM
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
03-14-2021 05:38 AM
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
03-14-2021 05:44 AM
I m really sorry, the previous VI is not the correct one, i uploaded the correct VI
plz see attachment files
thanks
03-14-2021 06:56 AM
03-14-2021 09:52 AM
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
03-14-2021 10:07 AM
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
03-14-2021 11:43 AM
@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"
03-14-2021 01:39 PM
plz see attachment files
i am calculating checksum of all 6 bytes and send it on 7th byte
03-14-2021 06:02 PM
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
03-14-2021 07:41 PM
@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)?