View Full Version : writing my first program
June 6th, 2002, 12:27 AM
Ok, I decided to use a Modicon compact 984 (the price was right) to use on my cryogenic processor (a small home start up business), that currently just has a watlo temp controller. I want to make the freezer operate more efficient.
I have had some exposure to these compact PLC's and can read some of the logic and troubleshoot preprogrammed unit's with some confidence. The problem is I have never had to program a PLC from scratch.
Would anyone like to volunteer and help me write (teach me how) this small program in modsoft ? I don't want to just have someone write it for me, I am looking at this as a learning experiance and in the future build from it and help others.
I did buy the book and have read it several times, but more of a hands on learner.
June 6th, 2002, 08:53 AM
First off, try writing and downloading a simple program. Turn on an input and it turns on an output. That lets you get the basics of tying in, compiling, etc. out of the way without worrying about logic. After that it is really just more of the same.
Are you using hte 984 only software, or do you have the IEC compatible software? There is a big difference in program structure between the two.
June 6th, 2002, 08:21 PM
Thanks for the reply, I have modsoft 984 programming software.
I will be programming a modicon 984-130 compact.
The contacts, coils, timers and relay's I do understand, what I don't understand is adding analog inputs with math associated with them.
For instance read a temperature and then react accordingly to and turn on a heater or inject cold nitrogen via a modulated 4-20ma-output card so it will increase or decrease in temperature at a very consistent rate.
I am trying to bring down the temperature a down a degree every two minutes until I hit a target set point, when that set point (-300F) is obtained hold it for 4 hours and then bring the temp back up to another set point (+300) hold it for two hours then the cycle will be done.
I can do the blocks with relays and contacts just not sure how to incorporate the read & react analog inputs and outputs.
Thanks for you help
June 7th, 2002, 08:02 AM
I haen't done 984 programming in a couple of years, and my manuals are down in the archives, so I can't be specific on structure or command details. There are some guys here who can probably recite the actual key strokes from memory and maybe they can step in with the details.
However, if you look to your manual you should find info on the four functin math commands (add, subtract, multiply, and divide). You use these to take the input channel data (0-16,000 maybe?) and convert it to engineering units (degrees F maybe). To do this you use the formula:
DataOffset = Data at 4 mA (or zero analog signal of whatever range - for example, 0 VDC on 0-10 VDC transmitter)
DataSpan = Data at 20 mA - Data @ 4 mA
FACTOR = arbitrary factor (multiple of 10) needed to get proper resolution and accuracy
EU = Engineering units x FACTOR
EUOffset = Engineering Units @ 4 mA x FACTOR
EUSpan = (Engineering Units @ 20 mA - Engineering Units @ 4 mA ) x FACTOR
DATA = Actual data reading
EU = ((EUSpan x (DATA - DataOffset))/DataSpan) + EU Offset
(See http://www.plcs.net/cgibin/dcforum/dcboard.cgi?az=show_thread&om=2755&forum=DCForumID1&omm=5 for details)
Then you go to the section on comparisons. This will let you see if your actual is higher or lower than the target, and increment your valve or whatever. It also lets you set a bit or coil to alarm if the temp is too high or too low or whatever.
There are more sophisticated methods for ramping, but try programming and testing these basic functins. After you are done with that you should understand the basics of working with analog values.
June 7th, 2002, 08:42 AM
The exact keystrokes needed to bring in and manipulate analog I/O somewhat depends on the I/O card used. Some of them are configured using external jumpers and some by writing values into the setup registers of the cards. Your analog inputs will come into the processor as 3x registers, and the outputs will be 4x registers.
For software versions of the manuals got to http://wwww.modicon.com. The hardware manual is 890USE10900 and the command manual is GM-A120-LDR, you may also want to look at the "master" 984 Ladder Logic Block Library 840USE10100.
Your processor has the ability to do math in integer, double precision, and floating point formats.
I like to use subtract (SUB) blocks for comparing my math values, as these blocks provide seperate outputs for <, =, and > results
as well as perfoming the actual subtraction.