LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to get Parity Error Ni Visa Read

I want to receive 9 bit  serial data with parity bit as 9th bit. The problem is I am unable to  get Parity error in Ni Visa Read. I've tried with different Visa Versions but no Luck. I only get a warning message 1073676294. I've attached the vi please check and update.

0 Kudos
Message 1 of 11
(3,529 Views)

Your VI does not make too much sense to me. It could help if we know what kind of hardware you try to connect? Do you have a manual explaining the communication interface, like serial type, termination characters, etc?

Why do you use two serial ports , are there two different units you try to communicate?

0 Kudos
Message 2 of 11
(3,515 Views)

Well I am trying to Receive Rs-485 9 bit data using "USB to Rs-485 device". I don't have a manual about the communication interface. 

 

For the reception of 9 bit data, I got the idea of Parity Error check from below link. but I am unable to get the parity Error.

http://digital.ni.com/public.nsf/allkb/3BDC7FF03541F772862564990057F919

 

For demonstration I am using a software to create Virtual Serial Communication Ports and trying to Send 9 bit data using Virtual Serial Port COM2 and Receiving it on another Virtual Serial Port COM3. I've also tried it with "Physical USB to RS-485 device".

 

Note: Com port 2 and 3 are virtually connected, i.e data sent on COM2 will be available on COM3.

0 Kudos
Message 3 of 11
(3,498 Views)

Hi Asfandyar,

 

usually the parity is not used to transport an additional data bit, it's a check for errors in the transmission!

To read a 9-bit value from a serial port you usually (need to) read two bytes.

 

I don't have a manual about the communication interface.

That's bad. That's really bad.

Such a manual s the first step when you want to program a communication tool for your device! (With "device" I don't speak about your USB-2-RS485 converter, but about this external device with the RS485 port!)

Get that manual, read it and follow it's instructions for the serial communication!

 

Note: Com port 2 and 3 are virtually connected, i.e data sent on COM2 will be available on COM3.

How do you do that? How do you connect something "virtually"?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(3,471 Views)

Please check the Vi, I only want to receive 9 bit data as mentioned for reception in this link using a "usb to Rs-485" device.

http://digital.ni.com/public.nsf/allkb/3BDC7FF03541F772862564990057F919

 

 

 

0 Kudos
Message 5 of 11
(3,459 Views)

HiAsfandyar,

 

I only want to receive 9 bit data as mentioned for reception in this link using a "usb to Rs-485" device.

That AppNote is explicitely written for NI hardware.

Does your USB converter support all those features?

 

You still did not name the actual RS485 device you want to talk to! Are you really needing this (rather uncommon) 9 bit data transfers?

 

The AppNote is also talking about "external UART controllers:

2. Use a separate microcontroller that handles 9 bit frames:
Another option is to use a separate microcontroller with a UART that is made to handle 9 data bit frames and place it as an intermediary between the instrument and the computer. The computer would send two 8 bit data frames for each 9 bit frame, one with the first 8 bits, the second with the 9th bit, and have the UART reassemble this into one 9 bit frame to send to the instrument. Similarly the UART would receive a 9 bit frame from the instrument and return two 8 bit frames to the computer.

So did you try to read 2 bytes?

 

Btw. why don't you use the default parity enum that comes with VISAInitSerialPort? Why do you use your own ring constant?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(3,453 Views)

Yes, my usb support all features, I've tried with writing 9 bit serial data to that device and it works great. but in reception case I am unable to monitor or get the parity bit.

 

The AppNote provides two solutions for 9 bit reception. one is software based and another is external UART controller. I know this is possible with hardware solution, but I need to implement it in LabView. 

 

I've also tried reception with 2 bytes at a time. but the AppNote says to receive one byte at a time.

Reception: 

  1. Set the port up for 8 data bits with parity checking enabled, set as either Space or Mark. 
  2. Read one byte at a time.
  3. If you get any parity errors you know that the 9th bit is the opposite of what you set. 
  4. Append the appropriate bit.

 

Is there a way to receive the overall protocol bit wise, i.e start bit, data bits, stop bit, parity bit etc into a Boolean array?

 

why don't you use the default parity enum that comes with VISAInitSerialPort? Why do you use your own ring constant?

 

I don't get it? where is VISAInitSerialPort? Please change the vi accordingly and update.

0 Kudos
Message 7 of 11
(3,438 Views)

I guess you are using for your tests some serial port virtualization software like com0com (otherwise I don't know what you mean with virtual connection between COM2 and COM3).

If yes, are you sure that this software also emulates internal settings like parity and stop bits?

After all, with virtual ports both parity and stop bit checking make no sense.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 8 of 11
(3,399 Views)
Hello pincpanter. I've clearly mentioned in my previous post that I am using a software to create virtual ports. and the software emulates internal setting. For your information I've also tried with the Physical devices.
0 Kudos
Message 9 of 11
(3,375 Views)

Let me confess that I am totally confused.

 

When last I looked the start/stop bit(s) and parity are inserted by the hardware to frame and check a transmitted value and those are stripped off by the hardware when the value is received.

 

So...

 

Have you tried to set one physical comm port for even parity and then use it to transmit to another physical comm. port configured for odd parity.

 

That should return a parity error for every byte transmitted. 

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 11
(3,370 Views)