S7-300 Analog handling

steveinlags

Member
Join Date
Mar 2004
Posts
2
Hi all. Can anybody help? I am new to S7 and have been thrown in at the deep end. I need to look at a couple of analog inputs and drive an analog output depending upon the input values. Can someone please provide some sample code that shows which blocks are used and how the signals are handled?
I did the Step7 training course awhile back, but PID's were not covered.

(I need to control a pump speed to maintain a constant level in a tank.)
Many Thanks
[email protected]
 
Hello!
You can read the analog value direct from the input if you want to!
just type L PIW XXX and use the value same in the other direction T PQW XXX.
Or you could use the scale and unscale blocks (don´t remember the FC number check the library maybe fc104?)

max analog value is 27648 = 10V, 20mA depending on what settings you have in the hardware.
 
hello Steve;

If you want to do simple PID on S7 CPUs, try the PID blocks provided by Siemens: FB41 is the analog PID block, FB42 (with FB43) is the discrete version.

If you want to use FB41, call it in OB35 (cyclic interrupt, 100 ms); plug in the address of the analog input (PIWxxx) into the PV_PER parameter (proces value, periphery), set up the gain value, and integral and differential parameters, if needed. You will read an outpout value that you can send to your analog adfdress (PQWxxx)at parameter LMN_PER (manipulated value, periphery).

Of course, there are many other inputs and outputs to FB41; most of them are either set-up parameters (like I_sel, value=1 to use the integral parameter (as in a PI controller), value = 0 to not use it (as in a straight P controller)), or loop parameters. You will have to read through the documentation for the FB41 and determine the values for each parameter required for your process.

For most parameters you wish to use, it is best to set up a memory address thaqt you cam manipulate through your program or a VAT table (for example, the GAIN parameter (Kp) could be set-up at MD20(as a REAL variable); that way you can modify the value in runtime; if you write a constant value to the parameter (say 0,82) the parameter value cannot be modified unless you write a new value, save and download.

One element missing from the docs: parameter Com_Rst (complete restart) must be SET in OB100 (start-up OB), and the RESET in OB35 after the PID block has been launched. That way, FB41 will be restarted every time the CPU goes into run mode, and it will see a falling edge required for it to run.

Hope this helps,
Daniel Chartier
 
Hi, for scaling Analog Input Values FC105 and for Unscaling a real number for analogue output FC106. The variables used for these are fairly straight forward and an explanation can be found under the help.

Just a question on FB41

set up the gain value, and integral and differential parameters

Where would these values come from?. Do you get them in the item that's being controlled manual say an inverter or do you need to do some sort of experiment work with your devise to derive these. Sorry, just not fimiliar with PID.
 
Hi, You must type those values yourself.
eg. start with gain 1, I value eg. 10 sek, d value 0 and then you test how it works.
Siemens have a PID control parameter assigment program i S7 which will help you with those values. (don't remember if you need a license for it ?)

There are a lot of different programs and formulas how to tune the controller. Search the web

br. nicke
 

Similar Topics

I have a client who has asked for a pop-up for each of their analogs, which will display the alarm values. The values displayed in the pop-up...
Replies
5
Views
2,513
hi i am using s7-300(CPU 313c). when i try to use FC106 unscale function, i can change IN manually but there is no effect on OUT. i wrote PQW752...
Replies
4
Views
1,565
Hi guys, I have CPU S7-300-313C ( Cat No - 6ES7-313-5BE00-0AB0) DI24/DO16 and AI5/AO2. when I am trying to configure and use the AO channel PQW...
Replies
4
Views
2,519
I am a student. I can program PLC using LAD language using digital IO. But, I want to program using analog IO also. We have analog IO module with...
Replies
2
Views
2,023
Hi All I am using 2 x analog cards on my rack and they are described as 12bit cards in there title. The manual suggests that the resolution can...
Replies
6
Views
1,994
Back
Top Bottom