Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

serial communication between labview and pic18f4520

Hello, I have a problem in visa write. The error code occurred is -1073807298: VISA: (Hex 0xBFFF003E) Could not perform operation because of I/O error.

 

well i have to interface labview with pic 18f4520 microcontroller using rs232.In that i have to provide frequency as well as duty cycle information to the microcontroller.but when i run labview it shows the above written error

Message 1 of 16
(6,588 Views)
There's about a half-dozen reasons (at least) for that error, and we're not going to guess each one. You need to start off by eliminating certain things. Like the cable and the serial port parameters. Try communicating with the PIC by using something other than LabVIEW. On Windows HyperTerminal is your best bet. Make sure you can talk to the PIC. This will help to verify the cable and the serial port parameters. If you can't do this, then there's no point in debugging the LabVIEW code.
0 Kudos
Message 2 of 16
(6,575 Views)


well i had checked with hyper terminal as well as proteus software it's working fine. the problem is within the ladview pls help me out to resolve the problem
0 Kudos
Message 3 of 16
(6,556 Views)
OK, since you seem to have ruled out the cabling, but there's still a lot of questions that need answering. Are you using the "Basic Serial Write and Read" example that ships with LabVIEW, or are you using your own code? What kind of serial port adapter are you using? Do you have a serial port on your computer, or are you using some sort of adapter, like a USB<-->Serial converter? If so, who's the manufacturer? If it's an adapter made by NI have you installed NI-Serial? Some third-party USB<-->Serial adapters don't work properly with VISA. Sometimes setting the buffer size works, sometimes it doesn't. Sometimes the adapters don't implement all of the VISA properties, so you can't use VISA Configure Serial Port. You would need to set each property separately until you see which one causes the error. That's the one that's not supported by the adapter. This is explained in this article: Error -1073807298 When Using a Third Party USB-Serial Adapter.
0 Kudos
Message 4 of 16
(6,546 Views)

well i had attached the block diagram of my task pls go through it.

 

thanks

Download All
0 Kudos
Message 5 of 16
(6,522 Views)

Several points:

  • The VISA Configure Serial Port and VISA Close belong outside the loop. You should not be reconfiguring the port every time.
  • You don't seem to understand the proper operation of Type Cast. In one case you're typecasting a U8 to a string and in another case you're trying to Type Cast using "%d", in the hope this will change it to an integer. The latter is not correct, and I'm not sure which one it is that you really want to do since I don't have the communication protocol for your program. I'm guessing your PIC is expecting the values as raw values, not as ASCII characters.
  • Why in the world are you setting the labels of controls and indicators to empty strings and then replacing them with free labels or moving the labels off into the wil blue yonder? This makes absolutely no sense. If you want to use short labels for the sake of the block diagram terminals, but have descriptive text to indicate their meaning, then hide the labels and make the captions visible.
  • You can change the formatting of numeric indicators to display in hex format, so there's no need to have a separate string indicator.
  • Your case structures serve no purpose. They're tied to hidden controls that have their value set to True.
  • The sequence frames are also completely unnecessary. 
  • Your conversion to U8 are also unnecessary. When you split a U16 you get 2 U8s, so the operation is redundant.

 

Please see attached cleaned up code.

0 Kudos
Message 6 of 16
(6,508 Views)

hi, thanks for your help got to learn many things about the mistakes which i was doing. but the code isn't working properly, for that i had verified it with proteus using two microcontrollers where 1 provide the data and the microcontroller receives the data and it works perfectly,but when using labview to provide data it doesn't work

 

so i think the problem is within the labview but don't know what it is and i am stuckng in it for the past 2 weeks.

 

shud i post the code written in pic

0 Kudos
Message 7 of 16
(6,460 Views)
Well, I have no idea what proteus is, and since you have not provided any information as to the communication or messaging protocol for the microcontroller, there's little else I can say. Don't you have this information?
0 Kudos
Message 8 of 16
(6,442 Views)

hi,

    i'll explain what my task is; i have to generate a signal 0f 1hz-200hz with pulse width of 5-50us and this information has to be given to microcontroller using rs232 through labview and the whole process is continuous i.e user can change the frequency or pulse width any time.Well regarding Proteus, it is simulation software for microcontroller where we design the circuit and load the hex file of our code and then we can verify our results.

 

here i am uplading the waveform which i require and the code which i wrote with and without usart initialisation code,i am getting the results when not using labview but as i use labview the problem starts.

Download All
0 Kudos
Message 9 of 16
(6,419 Views)
I don't think you're understanding what I'm saying. I'm referring to the commands you send over the serial port (RS-232). The code you uploaded is compleletely meaningless to me - I don't know assembly language, and with respect to LabVIEW code it's completely irrelevant. The PIC is expecting you to send some sequence of characters that tell it to do something. What is that sequence of characters? This is what you need to put in your LabVIEW code. If you don't know what that sequence of characters is then you will need to use something like PortMon (if you're on Windows - for other operating systems use something equivalent) to see what characters are being sent over the serial port by this other application to the microcontroller. This is what you have to duplicate in LabVIEW.
0 Kudos
Message 10 of 16
(6,398 Views)