Reference – Rockwell Automation 1761 MicroLogix 1000 Programmable Controllers User Manual
Page 381
Application Example Programs
E–31
Rung 2:1
Sets the rate measurement period. In this case we are calculating a new
rate value once every 100ms. Value N7:1 is updated once every 100ms with
the number of counts that have occurred in the last 100ms period. Note
that the preset value must divide evenly into 100 in order to accurately
determine frequency and RPM (determined later in this program).
| Rate Period | |
| Expiration | Rate measurement |
| Bit | period |
| T4:0 +TON–––––––––––––––+ |
|––––]/[––––––––––––––––––––––––––––––––––––––+TIMER ON DELAY +–(EN)–|
| DN |Timer T4:0+–(DN) |
| |Time Base 0.01| |
| |Preset 10| |
| |Accum 0| |
| +––––––––––––––––––+ |
Rung 2:2
Calculates and stores the number of counts that have occurred since the
last time that it was executed as true in N7:1 (last time=last rate
measurement timer (T4:0) expiration). The LES instruction allows for 10
counts of backlash to occur (you can adjust as needed). The add
instruction is configured for a 1000 count encoder using N7:2. (Change
this register to match the number of counts generated each Z reset.)
| Rate Period Counts last rate |
| Expiration Bit measurement period |
| |
| T4:0 +SUB–––––––––––––––+ |
|––] [––––+–––––––––––––––––––––––––––––––––+SUBTRACT +––––––+–|
| DN | |Source A C5:0.ACC| | |
| | | 0| | |
| | |Source B N7:0| | |
| | | 0| | |
| | |Dest N7:1| | |
| | | 0| | |
| | +––––––––––––––––––+ | |
| | If Counts last rate Counts last rate | |
| | negative measurement period measurement period | |
| | math flag | |
| | S:0 +LES–––––––––––––––+ +ADD–––––––––––––––+ | |
| +––] [––––––+LESS THAN +––+ADD +––––––+ |
| | 3 |Source A N7:1| |Source A N7:2| | |
| | | 0| | 1000| | |
| | |Source B –10| |Source B N7:1| | |
| | | | | 0| | |
| | +––––––––––––––––––+ |Dest N7:1| | |
| | | 0| | |
| | +––––––––––––––––––+ | |
Reference