Sei sulla pagina 1di 22

PLC and HMI Counting Lab

The goal is to program the PLC and HMI to count with the following behaviors:
1. The counting should be started and stopped from buttons on the HMI
2. The direction of the count should be able to be toggled between up and down
3. The counting should reset when a maximum value is reached counting up or when zero is
reached counting down
4. The value of the current count should be displayed in binary and decimal
5. The value of the maximum limit should be set using the HMI
6. There should be a second screen containing an input for the counter period in milliseconds
The monitor function will be extremely useful for this lab; if more information is need on it reference the
Help in TIA Portal. The details of each block are not included in this document, for more information
highlight the block in question and press the F1 key to bring up the corresponding help document.
Instructions:
1. Open TIA


2. TIA Portal opens in Portal View, select Create New Project


3. Enter the name as HMI_Counting and click create


4. Select Configure a device


5. Click add new device


Choose the Unspecified CPU 1200 under S7-1200. This will allow the software to communicate
with the PLC and detect its particular hardware and firmware versions as well as any modules
connected to it. Otherwise each part would have to be specified individually. Click Add.


6. In the window that opens in Project View click detect


7. The hardware detection window will open and the network will be searched for any Siemens
hardware. Once the search is done select the PLC and click Detect. If multiple devices are
present on the network the Flash LED button can be used to flash the screen (for HMI) or LEDs
(for PLC) on the selected device.


8. If prompted for additional IP addresses click Yes


9. After detection the PLC will be shown with the RTD module, however the power supply and
communications module wont appear. These can be added manually but wont affect
programming either way. Properties of the PLC or modules can be brought up by clicking the
corresponding part on the picture. No additional properties need to be set but they can be
explored.


10. Double click Add new device from the choices on the left to add the HMI. The HMI in the lab is
the KTP600 Basic PN. Click OK.


11. The HMI will open and a window for Screen_1 will be shown, close this window for now


12. Open Devices and networks from the options on the left. This should show the PLC and HMI.


13. To connect the PLC and HMI drag and drop a connection between them by dragging and
dropping the Ethernet connection on either one to the other. The result will be a line between
the two ports signifying the connection. By default it will be named PN/IE_1, where PN stands
for ProfiNet and IE for Industrial Ethernet, both are standard communication protocols.

14. For reference the IP addresses can be toggled to display or not


15. Close view the device and networks view and open the PLC Tag table and enter the tags


16. Open the PLC_1 Program Blocks Main OB1


17. Network 1 will be the timer network. It will need the Timer, start condition, count output and a
reset to make the timer create a pulse at a given period. The timer will need a DB section for
internal settings, which can be named like a tag. Insert tags for each value needed, the Start tag
should be rewired an Input location for now, right click and rewire tags as desired. Note that RT
and Timer need to be set to %DB1. For now set the PT to 1 second by typing 1s. The reset
timer block (RT) is necessary because without resetting the timer the coil for Count would go
high and remain high and since the counter used later looks for a rising edge the timer needs to
pulse. For more information on RT, put the mouse on RT block, and press F1.



18. Compile all


19. If there are no errors download all

If prompted select the PG/PC interface type (PN/IE), the interface itself (network card),
connection to local subnet ((local)PN/IE or PN/IE_1). Select the device and click Load.




20. Go online


21. Open the force table and add Start to the table


22. To force start to be true, click force and Start Force. Inputs and outputs can be forced to be
certain values for testing, however memory locations cannot be used in the force table, which is
why the Start location was set to an input initially.


23. Begin monitoring in the Main OB1 window, if the timer is counting (a timer will be displayed
above the timer DB) then network is correct.


24. Stop forcing and go offline

25. Network 2 will be the counter, counting up or down within an upper and lower bound. Use a
Count_Direction memory value to store the direction of the count, 0 is up, 1 is down and have
the counter count whenever Count from the timer goes high. Add resets for low and high
limits, set a memory word to store the value of the counter, for now set the PV or counter limit
to 15.



26. Add lines with comparator operations for exceeding the upper or lower bound that trigger the
appropriate reset. Only positive numbers will be used so the lower limit can be fixed at 0. For
now set the upper limit to 10.


27. Compile, download, go online and start the force procedure from earlier. Start monitoring, you
should see the count increase and reset at 10, not reaching the limit programmed in the counter
but rather the limit from the Reset_Low rung of the network.


28. Go offline, open Screen_1 under the HMI


29. Add text boxes for Limit, Most Significant Byte (MSB), Least Significant Byte (LSB), Count
Value by dragging them from the windows on the right onto Screen_1.


30. Add I/O fields for Limit and Current Value


31. Add buttons for Start, Stop, and Reset and a switch for Direction. Explore the properties of the
buttons to see how to change their appearance.


32. Return to Main OB1 and change the hard coded limits to a value stored in MW6 in the counter
and reset rungs. Remember to keep the low limit to be 0 to avoid having to deal with negative
numbers.


33. Modify Network 2 to apply the proper reset (high or low) when the reset button on the HMI is
pressed.


34. Rewire the Start tag to a memory location to be tied to the start and stop buttons on the HMI by
right clicking it.


35. Return to Screen_1 and set the Limit I/O field to be input only, decimal form, and link the
process to the PLC tag Count_Limit


Clicking the for the Tag property will bring up this window where the PLC tag can be
selected:


36. In the same manner set the I/O field for Current Value to be output only and connected to the
PLC tag Count_Value


37. Set the Start and Stop buttons to only show one text string by disabling the On option


38. Under the Events tab add a Press event to SetBit and link it to the Start tag in the PLC. In the
same manner set the Stop button to reset the same bit. The other event options on the left
reflect different ways of interacting with the button to trigger the event.


39. For the reset button add both a Press and Release event to set and reset respectively the Reset
tag in the PLC.


40. For the direction switch set the text to display Down when the switch is in an off state and
Up when the switch is in an on state. This way when it is linked to the counter direction in the
PLC memory the text of the switch will show the state that will result from it being pressed
rather than the current state. It is not necessary to set events for this switch.


41. Compile the HMI


42. Download to the HMI if there are no errors


43. Select Overwrite all if given the option


44. Compile and download to the PLC.

45. You should see the screen appear on the HMI, press the start button to start the counter. Test
the direction, limit setting, and resetting ability of the HMI.

46. Add a circle for each bit in the LSB and MSB and create an Appearance Animation for each circle
that will change its color based on the corresponding bit of the byte. Tip: create one circle
completely, then cut and paste this circle only changing the index of the bit referenced in the
animation.


47. Compile, download and test. The circles should change color and represent the binary form of
the current counter value.

48. Return to Main OB1 and add a Date and time-of-day Extended instruction to convert a DInt to a
Time value. Name the variables appropriately and add a normally open connection that is set
on a positive edge before the conversion.


49. Change the timer in Network 1 to use the output of the conversion in Network 3 as the period.


50. Add a new screen to the HMI


51. Add an I/O field set to input and linked to Time_Step


52. Add an Apply button with an event to SetBitWhileKeyPressed linked to Apply.


53. Add a text box reading Enter time between counts in ms and a button with a click event to
activate Screen_1


54. On Screen_1 add a button that activates Screen_2


55. Compile and download to the PLC and HMI.

56. Now you should be able to go between screens and set the period of the timer. Note that times
less than a second may result in values being skipped on the display, the update rate of the
counter is too fast for the display.

Potrebbero piacerti anche