# Tia Portal Programming Help PLEASE

## 4 posts in this topic

Hello

I am having some difficulty writing code for a specific function using Tia portal and a S7-1200.

I 10 Digital inputs and 1 analogue output set for 0-10V. When 1 DI is high I need the AQ to be at 1V, when any 2 DIs are high I need the AQ to be at 2, When any 3 DIs are high I need the AQ to be at 3V and so on....

I just can't work out the best way to do achieve this.

For a bit more info the to what the project entails the digital inputs are all coming back from DOL starters for woodworking equipment at workstations. When one of these starters is turned on a signal is sent back to the PLC DI card, this open a solenoid in extraction pipework and also increases the frequency at a VSD to extract the dust. So when more workstations are in use the higher the frequency of the VSD will be and the faster the motor will run allowing adequate extraction at all stations

##### Share on other sites

My first thought isn't very sophisticated but is simple to follow and *should* work. You would use a counter, which could just be a memory or DB word declared as an integer. I would probably just use a memory/DB register for this.

1) Reset the counter so its accumulator is 0. Use a RES instruction for an actual counter, or MOV if you're just using a memory/DB word. This step is critical to make sure your count is accurate and that you don't overflow the register!
2) If DI1 = 1, add 1 to the counter. If not, leave the counter alone.
3) If DI2 = 1, add 1 to the counter. If not, leave the counter alone.
...
11) If DI10 = 1, add 1 to the counter. If not, leave the counter alone.
12) Look at the counter accumulator. With 10 digital inputs, you should have a count from 0 - 10. Use the final count result to figure out the VSD speed setpoint and set the analog output accordingly.

##### Share on other sites

This is how I would do it in Rockwell.  But would require something else to scle the 0-10000 value to actual counts applicable to the analog output.

Edited by pcmccartney1

##### Share on other sites

so now we are doing homework assignments?