Programming Application - Dialing a Cell Phone with an Allen Bradley Micrologix 1500
This wasn't a normal "job" per say, but more like helping our machinist staff from babysitting the Japax Wire EDM machine. For those of you that don't know, a wire EDM can take a long time to make cuts in a part sometimes. There was a part that we made that took over 10 hours to make in the EDM, and the machinist guys ask me if there was anyway the EDM could call the cell phone when the EDM machine faulted. Mostly the EDM machine faulted when the wire broke, and that's where this project took over.
I came up with a package that involves a Micrologix 1500, a US Robotics modem, some ladder logic and a cell phone. I wanted the PLC to tell the modem to dial the cell phone when the EDM machine faulted. This alerted the machinist to come back into work and fix the EDM process.
To get started, I found the buzzer on the Japax Wire EDM machine just below the console when you are standing in front of the machine. I found out the buzzer was 12 volts and connected a 12 volt relay to this same output. This way when the EDM faulted, it would trip the relay which in turn would send a signal to an Allen Bradley Micrologix 1500 input point. I picked up a nice used PLC on eBay for this project. Make sure you get the LRP CPU. The LRP CPU has two communication ports on it, one for you to program through and another for, well in this case, a modem.
Ok so we talked about the scenarios and the events that take place, sounds easy enough right? Don't count on the Allen Bradley PLC "speaking" to you when it calls, but just know when it does call, that means a fault occurred. I wonder when Allen Bradley will give us a "voice" function in the PLC, wouldn't that be snazzy?
First thing we need to do in the PLC is make sure you setup your channel configuration in your PLC. I have setup mine to 9600 baud and ACSII just as the screen shot shows to connect direct to the modem. I used a null modem cable, DB25 to DB9 cable to connect my US Robotics External 56K modem to the side channel 1 port on the Allen Bradley PLC. This is almost the same way I would have done this if I was going to dial into this modem to remotely program the PLC from a distance.
See this article for reference.
The only difference is the channel settings. Channel 0 will be my programming port, and Channel 1 is my port connected to my modem.
Next we need to write some PLC logic, I wrote mine to behave this way:
If the fault occurred, send the ASCII strings I had stored in ST9:0 through ST9:2 in a logical sequence. Also wait for a few seconds and call the cell phone three times. Of course the PLC is not going to talk to you and say, "Hey my EDM wire is broken, come fix me" but my machinist guys were tickled pink that they could be home with their families on the weekend and when the cell phone rang, they knew to go into work, fix the EDM machine and return to their families. Once the problem was fixed they pressed the "reset" button I had wired up that would reset the alarm to cell phone logic. Keep in mind this is one of those throw it together projects with no money to spend budgets.
The next part about this project is your going to have to take a crash course in modem AT commands. Bear in mind that not all modems respond to the same AT commands. Please research your modem and know what commands control your modem brand name. When you start looking at the sample logic, you'll notice ST9:0 is loaded with a string: ATDT 7, 4506755^M. "ATDT" means dial the number in touch tone dialing for my US Robotics modem. So what you told the modem to do is pick up the line, and dial the number you are going to send. The rest of the numbers are normal telephone numbers. "7" is the number we have to dial to get an outside line in our phone system. The "comma" is a second delay before the modem dials the number. "^M" is what the default end string is the PLC sends. I don't believe it affects anything in the modem operations. The next string is ST9:1, you'll notice that it's loaded with: +++^M, all this does is switch the modem from data to command state; this command is not proceeded by AT. In layman's term, it's an escape sequence command. The escape sequence causes the modem to go to the off-line command state from the on-line data state. After this escape sequence, the modem can accept user's AT commands. Now that we have gotten the modem ready to accept more AT commands, we send the last string to hang up the phone. String ST9:2 is loaded with: ATH0^M, this means hang up the line.
Basically once you have mastered the AT commands, it's pretty simple to start dialing that modem any way you want. If you figure out how to make the PLC "speak" please let me know. I thought once that if I got bored that I could program touch-tone music pulses or something.
Wanna see my low budget box? Don't laugh, it was FREE.
As always download the RSS file and PDF file here:
GENERAL AT COMMANDS
AT - Gets the modems attention; this prefix must be included in all commands unless otherwise noted
+++ - Switches the modem from data to command state; this command is not proceeded by AT.
A - Instructs the modem to attempt to answer a call.
A/ - Re-executes the last modem executed command; this is not proceeded by at.
Bn - sets the operation standard 0=CCITT, 1=Bell
Cn - Turns the modem transmit carrier signal on and off 0=turn off the modem transmit carrier signal during normal operation; 1=Turn on modem transmit carrier signal during normal operation.
Dn - Dials the number, n; T - Touch-Tone dialing; P - Pulse dialing; , - pause 2 seconds; @ - Wait for 5 seconds of silence; R - Dial an originate-only modem; S=n - Dial one of four stored telephone numbers; : - Return to command mode after dialing; ! - Go on hook for 1/2 second.
En - Turns the command echo feature on/off so that your commands either are displayed or are not displayed on the screen 0=off, 1=on.
Hn - Causes the modem to hang up or pick up when in data mode 0=hang up, 1=pick up.
In - Identifies the modem code and the status of the ROM 0=display 3-digit product ID code (preset to 248); 1=display checksum; 2=display checksum and display OK or ERROR.
Ln Sets the internal speaker volume 0,1=lowest, 2=medium, 3=highest.
Mn - Determines when the speaker is on and off; 0=always off; 1=on during call and off when receiving data carrier; 2=always on; 3=off when receiving carrier and during dialing bu not when answering.
On Switches the modem from the command state to the on-line state; 0=returns the modem to the on-line state when a connection is still open, 1=returns the modem to the on-line state and initiates a V.22 bis retrain sequence.
Qn - Displays or suppresses (quiets) result codes 0=displays codes (default, 1=suppresses codes
Sr? - Read and display register r
Sr=n - Set register r to value n
Vn - Displays result codes in short form (numbers) or long form (test); 0=Send numeric responses; 1=send word responses.
Xn - Determines which result codes will be displayed following modem operations; 0=Basic response set, blind dialing; 1=Extended response set, blind dialing; 2=Extended response set, dial tone detection; 3=Extended response set, blind dialing, and busy signal detection; 4=Extended response set, dial tone, and busy signal detection.
Yn - Enables or disables the long-space disconnect 0=disable, 1=enable.
Zn - Resets the modem and recalls a user profile; 0=recall user profile 0; 1=recall user profile
Cn - Controls the Data carrier Detect signal, leaving the DCD interchange circuit on at all times or turning it on only when a data carrier is detected; 0=force DCD signal active, 1=DCD signal indicates true state of remote carrier signal.
&Dn - Controls data terminal ready (DTR) transition 0=Ignore DTR signal; 1=Return to command mode when after losing DTR; 2=Hang up, turn off auto answer, and return to command mode after losing DTR; 3=Reset after losing DTR.
&Fn - Returns the configuration to the factory settings; 0=Fetch default configuration; 1=Recall Microcom factory default configuration; 2=Recall Sierra factory default configuration for auto reliable MNP 3=Recall Sierra factory default configuration for auto reliable V.42bis.
&Gn - Selects the guard tone (not used on calls within the ); 0=Disable guard tone; 1=set guard tone on answering modem to 550 Hz; 2=Set guard tone to 1800 Hz.
&Mn - Sets operation; 0=Sets asynchronous operation.
&Pn - Selects the ratio of the make/break interval that the modem uses for pulse dialing; "make" refers to off-hook, "break" refers to on-hook; 0=39/61 for , 1=33/67 for .
&Sn - DSR override; 0=Force DSR signal active; 1=DSR active according to the CCITT specification.
&Tn - Test and diagnostics; 0=End current test; 1=Start local analog loop back test; 2=Unknown; 3=Start local digital loop back test 4=Grant remote request for remote digital loop back test; 5=Deny remote request for remote digital loop back test; 6=Start remote digital loop back test; 7=Start remote digital loop back test with self-test; 8=Start local analog loop back test with self-test.
&V - Displays the user profiles and stored numbers.
&Wn - Stores the current configuration as Profile 0 or 1 0=Profile 0, 1=Profile 1.
&Xn - Selects the synchronous clock source; 0=Provide synchronous clock on EIA pin 15.
Selects the synchronous clock source; 0=Provide synchronous clock on EIA pin 15.
&Yn - Selects which user profile will be the default at power -on and reset; 0=Profile 0, 1=Profile 1.
&Z=x - Stores telephone numbers x in location n (0-3) x=up to 32 characters. For pulse dialing, 0-9 and dial modifiers for touch dialing, 0-9, dialing modifiers, A-D, #, and *.
Article courtesy of MRPLC.com.