From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communicating with modem-please give some suggestions

Hi Every one....
 
We r having a real time system now and we r looking for a better idea for the same.
 
The real time system is developed using VB and now thinking of changing to labview.
The current system is ......Data from RTU is sent to serial device(modem) and VB application checks the modem
every 10 second and any new data found it inserts into relevant tables in the database and after insertion to the
database the data is fetched from the database for real time display.So in the real time dipay is getting delayed.
ie, a record that is newly obtained is displayed in the real time display after several minutes only. 
Think the display is delayed because of the fact that its getting displayed after inserting the data into the database
and then reading the data from the database.
 
What is the better idea to reduce the delay in display?I thought if v check the modem every 10 second and if new data got,fetch the data ,decode it ,display the information and then insert into the database,the system will be better.But if a single check of modem can give any number of messages which contain data.If v get 10 messages v have to decode 10 messages display 10 records and then insert 10 records into the database.Is there any better way for this?
 
I havent worked with serial communication applications.I havent thought abt the coding side now.Just thinking of theoverall idea only.
Thanks in advance for the suggestions.
 
 
0 Kudos
Message 1 of 8
(3,081 Views)


@user_1 wrote:
 
What is the better idea to reduce the delay in display?  I thought if you check the modem every 10 second and if new data got,fetch the data ,decode it ,display the information and then insert into the database,  the system will be better.  But if a single check of modem can give any number of messages which contain data.  If you get 10 messages you have to decode 10 messages display 10 records and then insert 10 records into the database.  Is there any better way for this?
 
I havent worked with serial communication applications.  I haven't thought about the coding side now.  Just thinking of the overall idea only.
Thanks in advance for the suggestions.
 
 


I think you already answered your own question.  Of course it makes sense to decode the data and display it immediately rather than writing it into and then reading it back out of a database.  I don't know of any other way to do this.  I'm a little confused as to what else your question might be.

Your subject is about communicating with a modem making it sound like you have modem communication problems, when actually you are asking about program architecture problems.  Is there anything special about this modem?  Are you dealing with the need to communicate with this other device over a phone line and you have to worry about dialing issues?  Or is the phone line just a hardwired, direct phone line to connect with the remote device?

To most software, a modem is basically a serial device to communicate with but you would just have to worry about some communication settings to write in order to get it to do certain things like pick up the line "ATH1", dial "ATDT" or hangup "ATH0".  Everything else is just writing characters to or reading characters from the buffer.  Look at the VISA examples for basic serial read/write to see how to do that.  Rather than reading the serial port every 10 seconds, you should just read it whenever bytes at port is greater than 0.

Message 2 of 8
(3,074 Views)
Hi,
 
Thank you so much for your reply sir.
Actually my question is related to modem communication .But sorry, in the first post i asked to know
whether my idea is correct or not.

In Our real time system,RTU send message to modem at any time.
So as in the previous post ,after decoding the data  v can display the data ad then can insert into proper table.
And nw i have to also add a module to store the data in a txt file also, sfter fetching the data frm the modem.
ie,as suggested by u i want to check the modem when data arrives at the modem(instead of checking 10second or something)
and i want just to append it to a string until i get one complete message.ie,i have to check for the end delimiter(which is carriage return in our system)and when i get the end delimiter from the modem,i have to write the entire string into the text file.As RTU send the data to modem it may be sending a part of a message or more than one message ....
I want my entire code to be executed only when data arrives at the modem.ie,rather than putting all the code in a while loop i want some other method the code will be executed only when there is data in the serial port.Just like event structure in which certain code is executed only when an event happens(for example code inside a time out event will be executed only when the time out occurs.it is free from loop also).Is it possible to code like that?
 
I just coded using bytes at serial port and putting the code inside a loop.Now my PC is not connected to modem.so i havent checked my idea is working or not.
 
I want to code using VISA events.I tried to code.But i think  it is not correct..The out put of VISA wait for event's status i am not sure.
I thought if the status is true it indicates the event occured.Can u help me regarding this?
I am herewith attaching my idea.I have put both methods in the same VI.Sorry for the inconvenience because of the bugs in the code.
 
Thanks once again....
0 Kudos
Message 3 of 8
(3,040 Views)
I actually haven't used serial events yet in any of my programs.  But what you have in the lower portion of your diagram looks like it would work.  Let me make a couple of comments.
 
1.  Delete the serial character hex constant.  Right click on the event terminal and select create constant.  This will create an enum constant.  There you can select serial charachter.
2.  The lower portion of your code will only execute once.  You need to have a while loop around it,  (left edge of the loop between the enable event and wait on event VI's.)
3.  Put your close com port VI outside of the loop in #2.  Right now you have it in the middle of everything.
4.  Don't use the value property node on the string control.  Use shift registers to maintain the contents of your string from one iteration of the loop to the next.
5.  Rather than looping through the string one character at a time to find the line feed constant, you could use the search/split string function to find it and break the string into the stuff before the character and everything after.  Loop on that with a normal while loop until the offset of match =-1.
6.  You may want to wire a timeout into the wait on events.  That way the code doesn't hang in the event you turn off the other device.  You could set a case that if bytes at port equals 0, it doesn't read the com port.  This will give a timeout that will allow the code a chance to read something like a stop button.
0 Kudos
Message 4 of 8
(3,022 Views)
Hi, I would like to ask something about modem communications. So if I have 2 PCs that are connected via each other's modem, these 2 PCs can communicate with each other using serial read/write commands (e.g. VISA) just as if they are connected directly through serial ports? How do I get 2 PCs to be connected using 2 modems?
0 Kudos
Message 5 of 8
(2,928 Views)
The 2 PC's will communicate directly as long as you are using a null modem cable.  The key feature of the null modem cable is that the receive and transmit wires are crossed so that the transmit pin of one PC connects to the receive pin of the other PC.  Depending on the communication, the handshaking wires may be crossed, or they may be looped back.
 
To use modems in between, obviously each PC needs a modem (either internal to the PC or an external modem with the appropriate connecting cable.)  Then the modems would be connected by the telephone cable.  The one thing that will make this setup more complicated is that each computer will need a little bit more software programming to control the modem.  Such as transmitting ATH1 to pickup the line and ATH0 to drop the line.  If they are connected over a real phone network, dialing commands such as ATDT will need to be added.
0 Kudos
Message 6 of 8
(2,918 Views)
Hi. thank you very much for the quick reply. Yes, in my application, 2 PCs are connected using real PSTN telephone network.

I am thinking of using some other dial-up program to do the dial-up and answering manually. Once the connection is established, LabVIEW on each PC reads and writes to serial port (where the modem is connected) for communication and data transfer. Is that possible? Or must the dial-up and answering be done by LabVIEW program?

Once the modem connection is established, there will be no difference in communication as compared with 2 PCs connected directly by serial ports using null modem cable right?

0 Kudos
Message 7 of 8
(2,908 Views)


@MaiMai wrote:

I am thinking of using some other dial-up program to do the dial-up and answering manually. Once the connection is established, LabVIEW on each PC reads and writes to serial port (where the modem is connected) for communication and data transfer. Is that possible? Or must the dial-up and answering be done by LabVIEW program?



I don't think this will work.  Because what will happen is that the other program will take the COM port.  It will block the accessing of the COM port from within labview.  Thus it would be necessary for the other program to close the COM port once it is done so that labview can access it.  I don't know for sure, but I think it is likely that once the other program closes the COM port, the modem may automatically hang up.  Even if it doesn't, you will still have the headache of syncronizing the two programs so they don't step on each other.

 


@MaiMai wrote:

Once the modem connection is established, there will be no difference in communication as compared with 2 PCs connected directly by serial ports using null modem cable right?



Correct.



 

0 Kudos
Message 8 of 8
(2,904 Views)