Quixote Posted July 22, 2004 Report Share Posted July 22, 2004 I programmed a vi for the function sending information from com1 and receiving that from com2, but never did it success. I have upload my code, wish someone could provide advices. Download File:post-526-1090458548.vi Quote Link to comment
didierj Posted July 22, 2004 Report Share Posted July 22, 2004 Quixote, Did you connect com1 with com2 over a serial cable so called "null modem" (with rx pin on one side tied to tx pin on the other side vice versa). Such cables can be found in every computer shop or you could build it yourself if you're confident with soldering (just "google" the net for instructions). Another point would be to configure com2 before sending the data. Changing configurations on a port usually also clears the in-/output buffer. Also make sure both com-ports have the same baudrate, data- and stopbits, flow control. If it still doesn't work also wire the error code output of the serial-VIs to the "General Error Handler.vi". So you get an idea where the error occurs and what error it is. Didier p.s. For correct LV wiring rules ask Michael Aivaliotis, he is the better "picky b...." Quote Link to comment
James McAnanama Posted July 22, 2004 Report Share Posted July 22, 2004 Quixote, Your code works if you have identical settings for each port (and you have followed Didier's advice on cabling). Make sure you hit enter at the end of your "String to Write" - your serial read wants this \n as a termination. If I can make some suggestions: 1. Consider using the VISA Serial routines as they have the following benefits: -VISA routines provide a common interface to serial, GPIB, and VXI, so learning one helps if you use one of the other buses. -VISA routines give you enum inputs so you can select "COM1", "COM2" instead of 0,1. 2. Consider using a state machine approach to your design to better control the flow of data through the serial port - without hardware flow control, the data can arrive at the destination port in a nondeterministic way. As a result, you may "miss" the data at the buffer. Using timing delays may work, but can fall apart if you upgrade to a faster PC etc. I have attached my crack at it - the machine initiates itself when it is first launched. Then is sits doing nothing until you hit the GO button. At which time it writes to the serial port you specify, and then reads from the destination serial port. Then, it sits "Doing nothing" unless more data shows up at the destination serial port or you hit go or stop. If you like this style, consider getting Conway and Watts, "A Software Engineering Approach to LabVIEW". (further influence from that Michael Aivaliotis guy...) 3. If you are looking for other examples, check out those that come with LabVIEW - click, HELP, FIND EXAMPLES, and the search through the resulting dialogue. Cheers, James Download File:post-365-1090505063.vi Quote Link to comment
Michael Aivaliotis Posted July 23, 2004 Report Share Posted July 23, 2004 p.s. For correct LV wiring rules ask Michael Aivaliotis, he is the better "picky b...." 1198[/snapback] Hey! I heard that! 1. Consider using the VISA Serial routines as they have the following benefits: -VISA routines provide a common interface to serial, GPIB, and VXI, so learning one helps if you use one of the other buses. -VISA routines give you enum inputs so you can select "COM1", "COM2" instead of 0,1. 1201[/snapback] Actually James, If you look at the sub-vi's that Quixote is using, you will see VISA there. Presently this is the only way to use serial. As far as the coding style your improved re-write is great! Of course it can always be done better... Quote Link to comment
James McAnanama Posted July 23, 2004 Report Share Posted July 23, 2004 Actually James, If you look at the sub-vi's that Quixote is using, you will see VISA there. Presently this is the only way to use serial. Oh. But what he is using must be some legacy wrapper(?) - you still can't pop-up on a terminal and create an enum constant. I don't like remembering if COM1 is port 0 or port 1. As far as the coding style your improved re-write is great! Of course it can always be done better... 1205[/snapback] Yeah, my best code will probably always be the next bit I write -especially if it is after an Ontario LAVA user group meeting... :worship: Do you have any suggestions for handling timing at the serial port - is there a way to generate an interrupt for data received etc? Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.