16 bit serial data communication
Hello,
I want to acquire data serially which is 16 bit.
Learning from the post http://forums.ni.com/t5/LabVIEW/16-bit-receive-over-rs-232/td-p/1214869/page/3
I was succeeded in joining the two eight bits. But the problem i am facing is that the two eight bits some time interchanges each other from MSB to LSB. The Block diagram Code is same as that from the above thread infact i have also plotted the data on Waveform Chart.
To simulate the behavior, i have created a program of 16 bit addition and sending the data as LSB and MSB on the serial port.
Here i am sending you the pics that may help you to identify the problem.
This is the first picture that shows the serial port properties, The graph, and the resulting string that contains LSB then
MSB and than the Conversion Result i.e 16 bit output.
This graph is exactly following the Conversion result
But when the LSB and MSB are interchanged this can we viewed clearly from this. Here the incremented result is reflected on MSB in place of LSB and has disturbed the whole program
The graphical representation of the error
In such Cases it is noted that the return count does not counts correctly as shown
To check whether the error is not at the transmission end,
I made another program in which I first send
1 2
3 4
5 6
7 8
9 10
And the same problem came here too. as shown below
Here you can see that I didn’t send 0 but 0 is here as
the first received data. Also the data is transmitted in five cycles but
received in six cycles also the return count is 1 again.
Waiting for reply
Thanks
Note:- I request you to please don't consider my another thread of Multichannel data receiving as same. They both are for different objective. Thanks
As i wrote that i have got the idea of 16 bit communication from the thread http://forums.ni.com/t5/LabVIEW/16-bit-receive-over-rs-232/td-p/1214869/page/3
The Code of this is also the same which is as under
Spoiler (Highlight to read)
Spoiler (Highlight to read)
The Data is transmitted as two serial bits and joined at the end. Wel can you give me a more clear idea of what could be the easy technique of specifying the start bit and stop bits.
Do you think that the data starts transmitting when some character is send to it. And then two bits and transmitted. Do you think this idea can solve the problem.
Similar Messages
-
I am having a hard time finding a function that will help me convert an 8 bit serial data string I have received (say 01110101) into decimal format.
When you have your front panel displayed, you should a whole palette of controls that you can place on the front panel. If the palette is not displayed, thne just right click on your mouse and it should appear. The upper left most set of controls on the palette is Numeric. Go there and select Numeric Indicator to display a numeric output. On the diagram, you can also right click the output 1 and select Create>Indicator. The format string is %b (as in boy) for a binary string. As I said, this should be the value for the format string input. You can right click on the Scan From String and select Edit Scan String. This will bring up a dialog box in which you pick what you want to do (Scan Number) and how you want to do it (Scan Binary Integer
It sounds like you really need to take a course in LabVIEW programming. There are are links here to NI classes and some on-line tutorials. -
Hello, i am working on a project in which i want to transfer 16 bits serially through RS232 to the computer. I tried many techniques but didnt got the result. Anyone here can send the solution or the Code of it.
ThanksIntelligent wrote:
I want to plot these data on waveform chart. Basically these will be representing a signal, which to be plotted in the chart.
I am sending them from microcontroller 8052.
thnaks
Since you are Intelligent I do not want to take the joy of programming from you. But take a look at this palette. You will find many useful functions here. If you transfer the MSB and LSB in correct order you may use the cast function and cast the string directly to an array of I16 (or U16).
Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far) -
Searching Incoming Serial Data
Greetings!
I was trying to get visual studio to filter through the incoming serial data it is receiving from an Arduino. The program shows the incoming data, so I know the serial port is working, but I'm not sure how to get it to look through that data ( I was thinking
I could use StreamReader to do this). My goal is this: When certain data is received, change the background color of a textbox. I am very new at this and any direction would be appreciated! I feel like i'm throwing spaghetti at a wall...
Here is my current code:
Imports System
Imports System.Threading
Imports System.IO.Ports
Imports System.ComponentModel
Imports System.IO
Public Class Form1
Dim myPort As Array
Delegate Sub SetTextCallBack(ByVal [TEXT] As String)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
myPort = IO.Ports.SerialPort.GetPortNames()
portCmbo.Items.AddRange(myPort)
End Sub
Private Sub startBtn_Click(sender As Object, e As EventArgs) Handles startBtn.Click
SerialPort1.PortName = portCmbo.Text
SerialPort1.BaudRate = baudCmbo.Text
SerialPort1.Open()
startBtn.Enabled = False
closeBtn.Enabled = True
End Sub
Private Sub closeBtn_Click(sender As Object, e As EventArgs) Handles closeBtn.Click
SerialPort1.Close()
startBtn.Enabled = True
closeBtn.Enabled = False
End Sub
Private Sub SerialPort1_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting())
End Sub
Private Sub ReceivedText(ByVal [text] As String)
If Me.inputTxtBox.InvokeRequired Then
Dim x As New SetTextCallBack(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.inputTxtBox.Text &= [text]
End If
End Sub
Private Sub outputTxtBx_TextChanged(sender As Object, e As EventArgs) Handles outputTxtBx.TextChanged
Dim myReader As StreamReader = New StreamReader("Me.inputTxtBox")
Dim line As String = ""
End Sub
End Class
ps: If there is an easier way of doing this, please let me know!You should read a good book on "Communications". When processing received data (from any device) you need to wait until you get the end of message before parsing the data. The data will be received in chunks that can contain from 1
to a million bytes. When you get the word "Hello" you could get "H" then "ello" or "Hel" and then "lo". You can't start looking through the data until you get the entire word "Hello".
So you first have to define a protocol for sending commands to the device and the amount of data that gets returned. So normally you have to terminate a message using one of the following methods
1) Ascii : Terminate a message with a fix character like a return or EOM.
2) Ascii or binary : Includes a bytes count at the beginning of the message.
3) Ascii or binary : Each type message is a fixed length.
You can use combination of the 3 methods above.
jdweng -
Java and serial port communication
Hello,
In my code i have parsed a file through which i have extracted the port name and baud rate .
Now i want to open the port with this portname and baud rate.
I have a device moxa card which has 16 port and want to open each and and read and write data into it.
thanking you.RXTX seems to be a decent library for serial/parallel communication using Java.
[http://www.rxtx.org/] -
64 bit serial driver with 32 bit VISA causing problems?
I'm running LabView 2012 on Linux (kernel 3.10) on an x86_64 machine. I think that VISA is not playing nicely with my 64-bit serial driver. I have a few instuments connected through an NPort serial to ethernet converter. Instruments which output data constantly (unpolled) are working fine. I'm reading ASCII data from those using both minicom and LabView / VISA with no problem. Instruments which need to be polled for data are not working.
The same software and drivers are working fine on a 32-bit machine in the same lab (although I compiled the NPort serial driver for 32-bit on that machine). All I can think is that 32-bit VISA doesn't like the "bitness" of the 64 bit serial driver, and it's mashing anything I try to write to a serial port. This being the case:
1) Can I install 64-bit VISA for Linux in conjunction with 32-bit Labview? Would that work?
2) If I have to go for a 64-bit LabView, do I really need to downgrade my kernel to 2.x as suggested in a hidden NI compatibility document that I now can't find?
3) Why is Linux such an after-thought with NI?OK. Panic over. Could be down to differences in control codes that the newer version of the driver is acting on.
[james@IceMan ~]$ stty -a -F /dev/ttyr00
speed 9600 baud; rows 0; columns 0; line = 0;
intr = <undef>; quit = <undef>; erase = <undef>; kill = <undef>; eof = <undef>; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S;
susp = <undef>; rprnt = <undef>; werase = <undef>; lnext = <undef>; flush = <undef>; min = 0; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread clocal -crtscts -cdtrdsr
-ignbrk -brkint -ignpar parmrk inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke
[james@IceMan ~]$ stty -g -F /dev/ttyr00
18:0:8bd:4000:0:0:0:0:0:0:0:0:11:13:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
[james@IceMan2 ~]$ stty -a -F /dev/ttyr00
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
[james@IceMan2 ~]$ stty -g -F /dev/ttyr00
500:5:cbd:8a3b:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 -
Precise time stamping of serial data
I am having trouble with precise timestamping of incoming serial data recived on 4 ports using 4 separate threads that continually attempt to read a byte.
When the expected frame is recieved the data is tagged with a time stamp.
The issue seems to be windows xp or the serial ports themselves. I am using an xsens serial to usb, 2 lavaport serial cards and the built in serial port.
Any suggestions for precise timing?there is some hints:
-for milisecond precise timestamp, you can use GetLocalTime,GetSystemTime or GetTickCount.
But to achieve true milisecond scale, you need use timeBeginPeriod(1)/timeEndPeriod(1) otherwise you get 10-16ms scale depend on system
(please read help pages on msdn for timeBeginPeriod function)
- create your program to not use CPU too much(no pooling,just message and/or sync wait),
or even better, do not run any other apllication which consume lot of CPU/DISK resources on the same PC
- for serial communication (but this also depend on baud rate) you can try to set send/receive driver buffer to 1 (from windows device manager)
- try different serial port card/converter(with different drivers)
- if still need something to try, set higher process and thread priority (SetPriorityClass,SetThreadPriority)
After all of this, on windows, there are no precise timing.Even if you do everything you can do, there is still chance to get time gap, but you can detect it (in milisecond precision) -
Convert syncronous serial data into sequence of hex values
Hi,
I have a problem analysing captured data of a digital I/O board. I hope one of you can give me an advice/hint on this.
Used Software: Labview Express 7.0
Problem description:
The captured digital data contains on channel 0 a clock signal, on channel 1 a reset signal and on channel 3 a data signal. The data signal is syncronized to the clock and consists out of 8 serial data bits. My problem is, how to convert this clock syncronized serial data signal into a sequence (array) of bytes each represented by 2 hex digits?
More details on the problem environment:
- The captured data comes from an ASCII file which contains data samples of a 16bit digital I/O card. Every line contains one sample encoded as 4 hex digits
- The file is converted by a VI to a digital waveform and plotted by a digital waveform graph.
One of my core problem on the way to a solution lies in the area, of how to "Trigger and Gate" the digital waveform based on the rising edge of channel 0.
Thanks in advance for your help!
Tryber.I checked with the 7.0 express version we have loaded on an older computer still and the part that I think you can use was in that version. In the second loop I had made a note: Boolean Crossing PtByPt. This looks at a binary input and can output a true pulse (one iteration) based on the direction input condition. This has three options; False-True (rising), True-False (falling), or Either which is the option I had used in that vi. This should allow you to detect a false-true state change on the clock channel. Now, you say that the clock pulse is not consistant, but what about the information pulses? That was the reason for the first two loops on my program. To insure that the digital value was measured during one input pulse to avoid turning two or more input pulses into one digital value.
As far as your question about trigger functions between the two, I'm not too sure. I believe they offer the same options that I tend to use so I havnt had a problem with either. On your block diagram menu select All Functions > Analyze > Point by Point > Other Functions PtbyPt. There are some very handy tools in that menu. -
I was wondering if I might get some help in debugging some timing issues for my serial data recording. Currently I am trying to create a loop that records data from a meter that outputs a comma-delimited string every 5 seconds. I have attached the VI that I am currently trying to debug.
The problem I am facing now is that sometimes I am not catching the correct string. It is catching either the tail end of a previous print, and then the read buffer is never cleared, so the data needed array cells 5, and 11 are not correct.
I was thinking that somehow I could simply wait on the data to arrive, do the reading etc, then wait 5 sec for the next bit of data -> or simply wait for the next complete string. If anyone has any suggestions please let me know, and code examples would be great.
Please let me know if you have any questions.
Thanks
Attachments:
test_serial.vi 167 KBHi Vessel,
I noticed another point: I suppose, your meter is configured to send this string every five seconds. Since the timing of your meter and the PC is not exactly the same, you have some timing interference effects, so that after a while your "Bytes at Port"- node executes, while the meter is sending the data (9600 Baud is not very fast). That's why you get only parts of the string.
A better approach to this problem would be to periodically call the "Bytes at Port"- node until the expected amount of Bytes is given back (if you expect a defined number of bytes). Or you read in all data you receive in a short time loop and check for some end-of-String condition, after this you can parse the String for the coma-separated values.
Perhaps I could help you, maybe you post your solution to the problem,
Dave
Greets, Dave -
Hello All,
I am new to the forums here. I need help converting the following code for use in LabVIEW. The data is coming in using rs232 format in ASCII. The bits are manchester encoded. I have setup the normal vi for reading serial data but when indexing it in an array the data is all over the place and inconsistent. Your help would be greatly appreciated.
'SERIAL NUMBER
Cells(24, 3) = Chr(ReadValue(0)) & Chr(ReadValue(1)) & Format(Str((CVar(ReadValue(2)) * 65536) + (CVar (ReadValue(3)) * 256) + (CVar(ReadValue(4)))), "00000")
'PART NUMBER
PNRval = Format(Str(CVar(ReadValue(5)) * 65536) + (CVar(ReadValue(6)) * 256) + (CVar(ReadValue(7))), "00000")
Cells(25, 3) = "X" & Mid(PNRval, 1, 2) & "-" & Mid(PNRval, 3, 3)
'STATUS
Cells(26, 3) = CVar(ReadValue(8))
Cells(row, 24) = Cells(26, 3)
'Pressure
Cells(27, 3) = ((CVar(ReadValue(9)) * 256) + CVar(ReadValue(10))) / 100
Cells(row, 21) = Cells(27, 3)
'SensTmp
If (ReadValue(11) > 127) Then
Cells(28, 3) = (((CVar(ReadValue(11)) * 256) + CVar(ReadValue(12))) / 100) - 655.36
Else
Cells(28, 3) = ((CVar(ReadValue(11)) * 256) + CVar(ReadValue(12))) / 100
End If
Cells(row, 22) = Cells(28, 3)
'ElecTmp
If (ReadValue(13) > 127) Then
Cells(29, 3) = (((CVar(ReadValue(13)) * 256) + CVar(ReadValue(14))) / 100) - 655.36
Else
Cells(29, 3) = ((CVar(ReadValue(13)) * 256) + CVar(ReadValue(14))) / 100
End If
Cells(row, 23) = Cells(29, 3)
Cells(30, 3) = "PASS"
Cells(row, 25) = 1
'Cells(row, 26) = " "Preamble
1
Byte to stablise the DC component signal
serial number
5
Serial number of the unit:
- 2 Bytes for the 2 ASCII characters (AA to ZZ)
- 3 Bytes for the number (0 to 99999)
part number
3
Part Number of the unit( The last 5 numbers SSHHh):
3 Bytes for the number (0 to 99999)
Status
1
Byte indicating the status
Sensor pressure
2
Value of the measured sensor pressure :
2 Bytes (unsigned integer) with 16 significant bits, decimal value x100 (0.00 to 655.35 psi)
Sensor temp
2
Value of the measured sensor temp :
2 Bytes (signed integer) with 1 sign bit and 15 significant bit, decimal value x100 (-327.68 à +327.67°C)
E. temperature
2
Value of the measured E. temperature :
2 Bytes (signed integer) with 1 sign bit and 15 significant bit, decimal value x100 (-327.68 à +327.67°C)
Checksum
2
Arithmetic sum of Bytes on the message frame (without preamble and checksum) -
Dear Sir!
I want to plot my serial data of 8 bits on graph/plotter.The serial data is received from another PC at baudrate 115200.After setting serial port on reception side i start capturing serial data but the problem is that it is not continous it plots my continous constat data for example decimal number '5' in the form of gilitches which are also random in time space.I am using simple IN port.vi.
Another problem is that when i capture this data using VISA Read it caputre data correctly for only 7sec and or u can say that it doesnot update my data received from serial.Please help me in this regard as soon as possible through my email address [email protected]
ThanksWell, I can't debug it because I don't have anything to read from but I did make some changes. You might want to go back to a fixed byte count to read if the data sent is some constant.
Attachments:
test41.vi 78 KB -
Program to decode serialized data?
Is there a program around which displays the contents of a serialized data stream? Because I'm having a bit of difficulty in serializing some highly interlinked objects, and I suspect that a class is being serialized which shouldn't be. It would be good just to have a quick look at what objects are in the output file.
I've seen the spec, and should obviously write a one-off program to do the decoding, but if there's something out there already it would save a lot of time.
I tried doing a loop with
Object o=objectInputStream.readObject();but it complained that the UIDs were wrong. Which of course was true.If you were to System.out.println(objectInputStream.readObject(); in your loop instead of assigning it to an object, does/will it still generate the UID error?
I don't know of a program to do what you want, but I do know a tedious way to get around the UID error. When it gives you the error, copy down the UID number of the file, then go over to the class and declare private static final long serialVersionUID = /*the UID of the file followed by an L*/ I feel like it's almost a hack, but it will stop the UID mismatch, and you won't have to worry about it again. (I think. It worked for me when I had UID issues and realized it was because I wasn't declaring serialVersionUID like I should have been.) -
Serial port communication IRP_MJ_READ
Hello, i would like to ask you about serial port communication. I am currently trying to make application for communication with my stepper motor (Microcon), but it doesnt work. If i try to communicate with original software, my serial port monitor gives me values
IRP_MJ_WRITE when i write some values and
IRP_MJ_READ when i try to read from serial port
But when i am using LabView i am only able to send IRP_MJ_WRITE function using VISA write component (so this one works good), but when i use VISA read component my serial port monitor gives me only IRP_DEVICE_CONTROL. Have you any sugestion where can be problem? I have no idea how to get this IRP_MJ_READ function using LabView VISA component.
Solved!
Go to Solution.Are you monitoring the using PortMon software ? Only thing I can see here is that check the command what you send, there might be some space which you might have introduced while typing,
or
Are you still running stepper motor control software while running the labview ? In this case there will be conflict.
When you are using original stepper motor software and when you send command wirte down the hex value (see in portmon or anyother monitoring software) and try sending same hex values using labview. Sending command, sending hex are same but just give it a try,
Use bytes at port function before VISA read to read all the available data.
Search for Microcon drivers in Instrument driver network in NI website if you want easy & fast solution. -
DAQ vi to perform digital write and read measurements using 32 bits binary data saved in a file
Hi
DAQ vi to perform digital write and read measurements using 32 bits binary data saved in a file
Two main
sections:
1)
Perform
write and read operations to and fro different spread sheet files, such that
each file have a single row of 32bits different binary data (analogous to 1D
array) where the left most bit is the MSB. I don’t want to manually enter the
32 bits binary data, I want the data written or read just by opening a file
name saves with the intended data.
2)
And
by using test patterns implemented using the digital pattern generator or build digital data functions or otherwise, I need to
ensure that the
binary data written to a spreadsheet file or any supported file type
then through the NI-USB 6509 is same as the data read.
I’m aware I can’t use the simulated
device to read data written to any port but if the write part of the vi works I
‘m sure the read part will work on the physical device which I’ll buy later.
My Plan
of action
I’ve
created a basic write/read file task and a write/read DAQ task for NI USB 6509
and both combine in a while loop to form a progress VI which I’m confuse of how
to proceed with the implementation.
My
greatest problem is to link both together with the correct functions or operators
such that there are no syntax/execution errors and thus achieve my intended
result.
This
project is one of my many assignments for my master thesis, so please i’ll
appreciate every help as I’m not really efficient with LabVIEW programming but
I prefer it because is fun and interesting if I get to know it.
Currently I’m
practicing with LabVIEW 8.6/NI DAQmx 8.8 Demo versions and NI USB 6509
simulated device.
Please see
the attached file for my novice progress, thanks in
advance for the support
Rgds
Paul
Attachments:
DIO_write_read DAQ from file.vi 17 KBWhat does your file look like? The DAQmx write is expecting a single U32 value, not an array of I64.
Message Edited by vt92 on 09-16-2009 02:42 PM
"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal -
Using Digital I/O to generate serial data stream
Hello All,
I am in need to generate a serial data stream. HW I use is MIO-16E-10.
I am planning to use the digital line out to generate the serial data stream.
I seems that if I use the wait timer the minimum pulse width I can get is
1ms. But for my application the pulses have to be shorter than that. I was
wondering about an alternative way to achive this. Any one who has worked
with a similar application please help!
Thanks in advance!
Anand.Anand,
What you are looking to do is not possible with the digital lines on the board you have.
Depending on what other connections you have on the board, you could use one of the two analog outputs to generate your required serial data stream using pattern generation. Check the DAQ solution wizard=>Custom DAQ applications=>Analog Output=>Generate continuous sine wave. This example should give you a baseline to get started. Substitute the sine wave generator for your desired digital stream Logic 0 =0V, Logic 1=5V.
If you need more than 2 lines, or some form of handshaking, I would suggest using the PCI-6534 or (DIO-32-HS as it was previously called) This will give you the ability to generate serial data streams with timing and/or handshaking.
Maybe you are looking for
-
How do I use both a dtd and schema during parsing?
Hi I have this akward problem. I have created at schema for or DOM parser to validate up against. Thats all fine. The problem arise when I want to use entities in the xml like æ å which are special html esc. sequences for danish letters. Then I found
-
Premiere Pro CS6 No audio from Sony AVCHD
Please help, I import AVCHD/mts from any files on my PC but there is no audio/sound, not even the audio 1 track has anything in it, the sound is simply not there?? I know FCPX needs my Sony files converting is this the case with CS6 now as cs5.5 work
-
hi All Can anybody expalin me why we use F110 Transaction Automatic Payment Transaction. Please provide me step by step procedure to release payment to an vendor using transaction F110 Also let me know the prerequisites to run transaction F110. Usefu
-
Channel Grouping - Adjusting send levels simultaneously
Please help! I can happily select multiple channels (for instance 8 channels of a drum kit) and adjust all fadr levels simultaneously but can somebody please tell me how I may adjust all send levels (to a bus) simultaneously? An example: I wish to ad
-
UPK 11.1 Player not Playing in IE 10...
Dear Members, I am facing one issue with UPK 11.1 i Developed Content & when i tried to Play the Content after Publishing it, it is not Opening in Player just giving message as Topic is Loading......Please Wait but not opening anything, My Internet E