MP STUDIO 2 · Functions · V1.4.0 and later
MP STUDIO 2 · Bit Control Functions
The bit control functions are five functions (V1.4.0 and later): FF, BSFT, BRST and BSETN, which toggle bits, shift them one place at a time, or turn a range of them off or on at once, and the timer TFLK, which blinks with separately set ON and OFF times. In V1.5.0 and later, eleven more functions are available. BMOV and BSUM copy a range of bits or count the bits that are on, ROL and ROR rotate a word, LOADB, LOADBN, BOUT, BSET and BRESET read or write a bit whose number is given as a value, and SSET and SOUT move a process forward by step number. Circuits that used to take several rungs, such as turning an output on and off with a single push button, tracking the position of products and rejects on a conveyor, blinking a beacon, or running a process in sequence, can be written with a single function.
| Functions | Categories | Execution | Version |
|---|---|---|---|
| 16 | Bit Logic and 3 others | Edge, level, cycle, every scan | V1.4.0 and later (11 in V1.5.0 and later) |
- Toggles on each press
FFtoggles its bit only at the moment the condition turns ON, so you can connect it directly after a push button contact without a rising edge contact. - Shifts one place at a time
Each time the condition turns ON,BSFTshifts N bits by one place and puts a new value into the empty place. - A whole range at once
BRSTandBSETNturn off or turn on all N bits from the start bit. - Separate ON and OFF times
TFLKrepeatedly turns on for the ON time and off for the OFF time. - Bit number as a value
LOADB,BOUT,BSET,BRESETand the others read and write the bit of a word whose number you give as a constant or an address (V1.5.0 and later). - Processes run in steps
SSETandSOUTtreat the value of one address as the current step number and run a process in order (V1.5.0 and later).
On this page
Finding and Inserting the Functions
FF, BSFT, BRST and BSETN are in the Bit Logic category of the Functions panel, and TFLK is in the Timer category. Of the functions added in V1.5.0, ROL and ROR are in the Word Logic category, SSET and SOUT are in the Program Control category, and the rest are in the Bit Logic category. You insert them the same way as other functions: double-click a row in the Functions panel, or type the whole instruction on one line in the Insert Function window (Ctrl+E), as in FF P32. You can also find them by typing bit, flip, shift, flicker, rotate or step in the search box of the Functions panel.
| Function | Name in the Functions panel | Block cells (from the left) |
|---|---|---|
FF | FF: Flip-Flop (Toggle Bit) | OUT |
BSFT | BSFT: Bit Shift Register | BIT, N, IN, DIR |
BRST | BRST: Reset Bit Range | BIT, N |
BSETN | BSETN: Set Bit Range | BIT, N |
TFLK | TFLK: Flicker Timer (ON/OFF) | TIMER, ON, OFF |
LOADB | LOADB: Bit N Contact | IN, N |
LOADBN | LOADBN: Bit N Contact (Inverted) | IN, N |
BOUT | BOUT: Bit N Output | OUT, N |
BSET | BSET: Set Bit N | OUT, N |
BRESET | BRESET: Reset Bit N | OUT, N |
BMOV | BMOV: Copy Bit Range | IN, SB, OUT, DB, N |
BSUM | BSUM: Count ON Bits | IN, OUT |
ROL | ROL: Rotate Left | IN, N, OUT |
ROR | ROR: Rotate Right | IN, N, OUT |
SSET | SSET: Set Step (Sequential) | GROUP, STEP |
SOUT | SOUT: Step Output (Last Wins) | GROUP, STEP |
- ① Bit Logic category: the number on the right is the number of functions in the category (11).
- ② FF, BSFT, BRST and BSETN: double-click to insert the function at the cursor cell.
- ③ LOADB to BSUM: the Bit Logic functions added in V1.5.0.
- ④ TFLK: the last row of the Timer category.
- ① ROL and ROR: the last two rows of the Word Logic category.
- ② SSET and SOUT: the last two rows of the Program Control category.
In the Insert Function window, the argument order of TFLK is shown as [TFLK] [IN] [ON] [OFF], and the first argument (the timer address) goes into the TIMER cell of the block. For the functions added in V1.5.0, the argument order is the same as the order of the block cells, as in [BMOV] [IN] [SB] [OUT] [DB] [N].
Common Behavior
All bit control functions run on the condition to the left of the block. When they act depends on the function.
| Function | When it acts |
|---|---|
FF, BSFT | Once, in the scan in which the condition goes from OFF to ON (the same timing as a rising edge contact) |
BRST, BSETN, BMOV, BSUM, ROL, ROR, BSET, BRESET, SSET, SOUT | In every scan in which the condition is ON |
TFLK | Repeats the ON time and the OFF time while the condition is ON |
BOUT | In every scan (writes 1 when the condition is ON and 0 when it is OFF) |
LOADB, LOADBN | Checks the bit in every scan, like a contact |
- Except for
TFLK,LOADBandLOADBN, the functions pass the condition on the left straight through to the right of the block, so you can put a coil after them. The right side ofTFLKis the blinking output, and the right side ofLOADBandLOADBNis the result of checking the bit, as with a contact. FFandBSFTremember the previous condition separately for each block.- If the condition is already ON in the first scan after power-on or a download, it is treated as a change from OFF to ON. In that case,
FFtoggles once andBSFTshifts one place. - Inside an
MCSsection, while the section is off, the block works as if its condition were OFF, and the right side of the block is off too (other function blocks run regardless ofMCS). In that case,BOUTwrites 0 to its bit, andLOADBandLOADBNare false. If the condition is ON when the section turns back on, it is treated as a change from OFF to ON.
FF Flip-Flop
FF toggles the OUT bit (0 becomes 1, and 1 becomes 0) only in the scan in which the condition goes from OFF to ON. It does not toggle again while the condition stays ON. For example, FF P32 after a P0 contact turns P32 on and off each time P0 is pressed.
- OUT can be a
PorMbit, a bit inside a D word such asD10.5, or a#nameuser bit. - Two
FFfunctions can toggle the same bit. If you putFF P32after bothP0andP1, pressing either button changesP32. If both conditions turn ON in the same scan, the bit is toggled twice and stays as it was.
A coil on the same bit overwrites the FF result
If you also use the OUT bit ofFFin a normal coil, the coil writes that bit again in every scan, so the value thatFFtoggled does not stay. Like the bit of a SET coil, the OUT bit is not covered by the duplicate coil check, so the check does not report it either. Do not use the OUT bit ofFFin a normal coil as well.
BSFT Bit Shift Register
Each time the condition goes from OFF to ON, BSFT shifts the N bits from BIT by one place and puts the value of IN into the place that becomes empty. DIR sets the direction. Use it in circuits that move values along with a position, such as tracking and ejecting rejects on a conveyor, sequential lighting and process history.
| DIR | Shift direction | Where IN goes | Value shifted out and lost |
|---|---|---|---|
| 0 | Toward higher numbers | BIT | The value of BIT+N-1 |
| 1 | Toward lower numbers | BIT+N-1 | The value of BIT |
For example, each time the condition turns ON, BSFT M200 8 P2 0 moves the values of M200 to M206 up by one place (to M201 to M207) and puts the value of P2 at that moment into M200. The value that was in M207 is lost.
- BIT: the start bit. You can use a
PorMbit, or a bit inside a D word such asD10.0. Bits inside D words continue fromD10.15toD11.0. - N: the number of bits. Use a constant of 1 or more, or a byte or word address such as
D0orBD0. In V1.5.0 and later, you can also use a double word address such asDD0. - IN: the value to put in. Use 0, 1 or a bit such as
M5orP1. In V1.5.0 and later, you can also use byte, word and double word addresses such asBD0,D0andDD0, and any integer. A value of 0 puts in 0, and any other value puts in 1. - DIR: the shift direction. Use 0, 1 or a bit. In V1.5.0 and later, you can also use addresses and integers, as with IN, and any value other than 0 is treated as 1.
If IN or DIR is a bit or an address, its value in the scan in which the condition turned ON is read.
- ① BSFT block: the BIT, N, IN and DIR cells.
- ② Data Table: shows the values shifted into
M200toM207. - ③ Eject rung:
M207is on, soP33is on.
BRST and BSETN Reset and Set Bit Range
BRST writes 0 to all N bits from BIT, and BSETN writes 1 to all of them. They write in every scan in which the condition is ON, and writing the same value again and again does no harm. BIT and N take the same values as in BSFT.
| Example | Action |
|---|---|
BRST M200 8 | Turns off M200 to M207. |
BSETN D20.0 8 | Turns on bits 0 to 7 of D20. |
BRST M0 D0 | Turns off as many bits from M0 as the value of D0. |
TFLK Flicker Timer
When the condition turns ON, TFLK starts with the output on and repeats the cycle: on for the ON time, then off for the OFF time. The output is the power that continues to the right of the block, and the contact of the timer in the TIMER cell (for example T5) turns on and off with the same value, so other rungs can use the same blink.
- The current value of the timer in the TIMER cell is the time elapsed within one cycle. When it reaches the ON time plus the OFF time, it starts counting again from 0.
- When the condition turns OFF, the output turns off at once and the current value becomes 0. When the condition turns ON again, it starts again with the output on.
- If the ON time is 0, the output is always off. If the OFF time is 0, the output stays on while the condition is ON.
- The scan that turns the output on is counted too, so if the ON time is shorter than one scan, the output can turn off right after it turns on.
- A blink with equal ON and OFF times and a fixed period can also be made with the system bit
@Fn. UseTFLKwhen you want to set the ON time and the OFF time separately.
- ①
T5current value: the time elapsed within one cycle. - ② ON and OFF: the ON time (
20= 0.2 seconds) and the OFF time (180= 1.8 seconds). - ③
P34: the output ofTFLK. - ④
T5contact: turnsP35on and off with the same value as the output ofTFLK.
ON and OFF use the same units as the set value (SET VALUE) of TON. A number alone is in units of 10 ms (20 is 0.2 seconds), and a value with a unit, such as 200MS, 2S, 1M or 1H, is that time. A value shorter than 10 ms, such as 5MS, is entered as 50 ms, 10 times longer, and an orange warning is shown on the cell. You can also use byte, word and double word addresses such as BD0, D0 and DD0.
In a project whose timer base is set to 1 ms, numbers are in units of 1 ms. In the Change timer base window that appears when you change the timer base, the ON and OFF values of TFLK written as numbers are counted as set values too, and if you choose Adjust values too (keep the same time), they are also changed to match the new base.
As with TON, the TIMER cell can be BT5 (byte), T5 (word) or DT5 (double word), and the size of the timer sets the longest possible cycle (ON time+OFF time). The timer number must not be the same as that of another timer function. If it is, “Timer memory cannot be used more than once.” is shown when you compile.
| TIMER cell | Longest cycle (timer base 10 ms) | Longest cycle (timer base 1 ms) |
|---|---|---|
BT | 2.55 s | 0.255 s |
T | 655.35 s | 65.535 s |
DT | About 497 days | About 49.7 days |
BMOV and BSUM Copy Bit Range and Count ON Bits
In every scan in which the condition is ON, BMOV copies N bits of IN, starting at bit SB, to OUT in order, starting at bit DB (V1.5.0 and later). The bits of OUT outside the copied range keep their values. In every scan in which the condition is ON, BSUM writes the number of bits that are 1 in IN to OUT.
- IN: the value to read bits from. Use a constant or a byte, word or double word address such as
BD0,D0orDD0. - SB: the bit number in IN to start reading from (counting from 0).
- OUT: the byte, word or double word address to write the bits to.
- DB: the bit number in OUT to start writing at (counting from 0).
- N: the number of bits to copy (1 or more).
Bit numbers are counted within the size of the address in the cell. A byte has bits 0 to 7, a word has bits 0 to 15, and a double word or a constant has bits 0 to 31. SB+N must not exceed the number of bits of IN, and DB+N must not exceed that of OUT. IN and OUT can be different sizes and can even be the same address. If you write an address in SB, DB or N, the value is decided while the program runs (Out of Range and @IXERR).
| Example | Action |
|---|---|
BMOV D1 3 D5 0 4 | Copies bits 3 to 6 of D1 to bits 0 to 3 of D5. The other bits of D5 keep their values. |
BSUM D10 D20 | Writes the number of bits that are 1 in D10 (0 to 16) to D20. |
The result of BSUM depends on the size of IN: 0 to 8 for a byte, 0 to 16 for a word, and 0 to 32 for a double word or a constant. To check whether the result is 0, use a comparison contact such as D20=0.
ROL and ROR Rotate Left and Right
ROL writes IN rotated N bits to the left to OUT, and ROR writes IN rotated N bits to the right (V1.5.0 and later). Unlike with SHL and SHR, the bits shifted out of one end come back in at the other end. With ROL, the top bit moves to bit 0, and with ROR, bit 0 moves to the top bit.
- The rotation width is the size of OUT (8 bits for a byte, 16 bits for a word and 32 bits for a double word). If IN is smaller than OUT, the upper bits are filled with 0. If IN is larger, only the lower bits that fit in OUT are read.
- If N is equal to or larger than the width, the value is rotated by the remainder of N divided by the width (4 bits when N is 20 for a word). If N is 0, IN is written to OUT unchanged.
- To rotate a value in place, write the same address in IN and OUT.
- The value is rotated in every scan in which the condition is ON. To rotate it only once when the condition turns ON, put a rising edge contact in front of the block.
| Example | Action |
|---|---|
ROL D10 1 D10 | Rotates D10 one bit to the left. Bit 15 moves to bit 0. |
ROR D10 4 D11 | Writes D10 rotated four bits to the right to D11. D10 does not change. |
Figure 7 shows a rung in which a rising edge contact after P5 is followed by ROL D40 1 D40. D40 was 1, and P5 was turned on and off three times, so D40 changed to 2, 4 and then 8.
LOADB, LOADBN, BOUT, BSET and BRESET Bit N Contacts and Outputs
These five functions read or write a single bit, the one whose number is in N (V1.5.0 and later). If you write an address such as D0 in N, you can change the bit number while the program runs.
| Function | What it does |
|---|---|
LOADB | A contact that is ON when bit N of IN is 1. |
LOADBN | A contact that is ON when bit N of IN is 0. |
BOUT | Writes the condition to bit N of OUT in every scan (0 when the condition is OFF). Works like an OUT coil. |
BSET | Writes 1 to bit N of OUT when the condition is ON. The bit keeps its value when the condition is OFF. Works like a SET coil. |
BRESET | Writes 0 to bit N of OUT when the condition is ON. Works like a RESET coil. |
- Use a constant or a byte, word or double word address in IN, and a byte, word or double word address in OUT.
BOUT,BSETandBRESETdo not change the other bits of OUT. - N counts from 0 and must be smaller than the number of bits of the address in the cell (0 to 7 for a byte, 0 to 15 for a word and 0 to 31 for a double word). If IN is a constant, N is 0 to 31.
LOADBandLOADBNare blocks, but like contacts they can go anywhere in a rung. Connected in series with other contacts they work as AND, and in parallel as OR. The head of the block shows a contact symbol instead of the category abbreviation (┤ ├ forLOADBand ┤/├ forLOADBN).- If N of
BOUTis a constant, that bit (for exampleD10.3inBOUT D10 3) is covered by the duplicate coil check, like a coil. In a project with the duplicate coil check turned on, using the same bit in another coil orBOUTas well shows “A double coil of the same name was used.” when you compile.BOUTwith an address in N,BSETandBRESETare not covered by the check.
| Example | Action |
|---|---|
LOADB D10 D0 followed by coil P32 | Turns on P32 when the bit of D10 numbered by the value of D0 is 1. |
BSET D20 5 | Turns on bit 5 of D20 when the condition is ON. |
SSET and SOUT Step Control
SSET and SOUT use the one address in the GROUP cell as a step group and move a process forward in step number order (V1.5.0 and later). The value of that address is the current step number, and 0 means that no step is active. Because one address holds one value, only one step of a group is on at a time, and moving to another step turns off the previous step without a separate instruction.
| Function | What it does in a scan in which the condition is ON |
|---|---|
SSET | Writes STEP to GROUP only when the value of GROUP is one less than STEP (it moves to the next step only from the step just before it). If STEP is 0, it writes 0 to GROUP. |
SOUT | Writes STEP to GROUP regardless of the current step. If the conditions of several SOUT functions are ON in the same scan, the value from the later rung remains. |
- In GROUP, use a byte, word or double word address such as
BD100,D100orDD100, or a##nameor###nameuser variable. In STEP, use a constant or an address, up to the largest number that GROUP can hold (255 for a byte, 65535 for a word and 4294967295 for a double word). - GROUP keeps its value after the condition turns OFF. Write the work for each step as a coil after a comparison contact such as
D100=2. - If GROUP is an address outside the retentive range, the process starts at step 0 after power-on or a download.
- Several
SSETandSOUTfunctions in the same group are not covered by the duplicate coil check.
Steps can advance more than once in a scan
If the conditions ofSSET D100 1andSSET D100 2are ON in the same scan, the step moves from 0 to 1 and then to 2 within that scan, in rung order. To advance only one step per scan, place theSSETfunctions in descending order of step number, with the highest step number in the earliest rung.
Inputs That Do Not Compile
For the inputs below, the cell turns red and the program cannot be compiled. Select the cell to see the reason in the Inspector, or hover over it to see the reason in a tooltip.
| Cell | Inputs that do not compile |
|---|---|
OUT of FF | A system bit that the PLC sets in every scan, such as @BEGIN, a word address such as T0 or D10, or a comparison such as D0>3 |
BIT of BSFT, BRST and BSETN | A #name user bit, an @ system bit, a T, C or D word address, or a comparison |
N of BSFT, BRST and BSETN | A constant of 0 or less, a count that runs past the end of the area (for example BSETN M2040 9 when the M area ends at M2047), or, in V1.4.0, a double word address such as DD0 |
IN and DIR of BSFT | A real number such as 1.5, a real number address such as R0, a comparison, or, in V1.4.0, also a constant other than 0 or 1 and a byte or word address |
ON and OFF of TFLK | A negative value, or constants whose sum does not fit in the timer (for example 40000 and 40000 when TIMER is T1) |
TIMER of TFLK | A timer narrower than the value in ON (for example T1 when ON is DD0 or 70000) |
SB, DB and N of BMOV | A negative value, an N less than 1, or an SB+N or DB+N that exceeds the number of bits of IN or OUT (for example BMOV D1 13 D5 0 4) |
N of LOADB, LOADBN, BOUT, BSET and BRESET | A negative value, or a bit number equal to or larger than the number of bits of the address in the cell (for example LOADB BM25 8 or BOUT D10 16) |
N of ROL and ROR | A negative value |
STEP of SSET and SOUT | A negative value, or a number that does not fit in GROUP (for example SSET BD100 256) |
| OUT and GROUP of the functions added in V1.5.0 | A constant |
| All cells of the functions added in V1.5.0 | A bit address such as M0, a real number address such as R0, a real number such as 1.5, or a comparison |
The cells of the bit control functions cannot take an indexed address (D100[D0]).
For example, if you enter TFLK T6 40000 40000, the OFF cell turns red and “The ON time plus the OFF time of TFLK (80000) is more than 65535, the largest value timer T6 can hold, so the program does not compile. Shorten the times or use a wider timer (DT).” is shown.
If you enter LOADB BM25 8, the N cell turns red and “Bit number 8 of LOADB is outside bits 0 to 7 of BM25 (8 bits), so the program does not compile. Enter a number from 0 to 7.” is shown.
Out of Range and @IXERR
If you write an address such as D10 in N of BSFT, BRST and BSETN, or in the bit number, count or step number of the functions added in V1.5.0, the value is decided while the program runs. If it becomes one of the values below when the block runs, the PLC turns on the system bit @IXERR and handles the block as shown in the table.
| Function | Value treated as out of range | What happens |
|---|---|---|
BSFT, BRST, BSETN | N is 0 or less, or the N bits from BIT run past the end of their area (for M and D, the size set in Data Memory; for P, the end of the whole P area, P55 or P127 depending on the model, not the last real I/O terminal) | Skips the block and writes no bits. |
BMOV | N is 0, or SB+N or DB+N exceeds the number of bits of IN or OUT | Copies no bits. |
LOADB, LOADBN | N is equal to or larger than the number of bits of IN | The contact is false. |
BOUT, BSET, BRESET | N is equal to or larger than the number of bits of OUT | Does not write the bit. |
SSET, SOUT | STEP does not fit in GROUP | Does not change GROUP. |
- No bit is written to the wrong place, so no other memory is overwritten. Except for
LOADBandLOADBN, the right side of the block passes the condition through unchanged (unlike an indexed address that goes out of range, the power output does not turn off). - Except for
BOUT, the range is not checked while the condition is OFF (forBSFT, in any scan other than the one in which the condition turns ON), so@IXERRdoes not turn on.BOUTwrites its bit in every scan even while the condition is OFF, so it checks the range then too. BSUM,ROLandRORcannot go out of range.
If you write addresses in ON and OFF of TFLK and one cycle exceeds the maximum in the table in TFLK Flicker Timer when the block runs, @IXERR turns on, and the output stays off with the current value held at 0.
@IXERR is the same bit that turns on when an indexed address goes out of range, and it does not turn off by itself. You turn it off the same way as for indexed addresses. During monitoring or simulation, a notice appears when @IXERR turns on (“A value was out of range (such as an index, bit number, or count), so @IXERR turned ON and the instruction was skipped.”). In V1.5.0 and later, the notice appears even if @IXERR is not on the ladder screen or in the Data Table.
- ① N cell
D10: the value is 0, soBRST M300 D10was skipped. - ②
@IXERRrung:@IXERRis on, so the coilM1after it is on.
Monitoring and Simulation
All bit control functions work the same in simulation as on the PLC.
- When the condition is ON, the blocks of all functions except
TFLK,LOADBandLOADBNare shown in the power-flow color. A cell with an address shows the current value of that address, and a constant cell shows no value. - The value in the BIT cell is the value of the start bit alone. To see the whole range, add the addresses to the Data Table.
- The TIMER cell of
TFLKshows the current value of the timer. During the ON time, the block and the output are shown in the power-flow color. During the OFF time, they are shown without output, as while aTONis counting. - Like a contact,
LOADBandLOADBNshow the block and its right side in the power-flow color only when the condition on the left is ON and the bit check is true. - For
SSETandSOUT, when the value of GROUP equals the STEP of the block, “▶ Now N” appears in the head of the block and the head border changes to the power-flow color. If two or more blocks have the same STEP, all of them show it, and when the value is 0, “▶ Now 0” appears on the block whose STEP is 0. - To see a single moment of the blink, use Pause and Step one scan on the simulation bar.
- In Run → Used Data, if N is a constant, the N bits from BIT are painted as used, and if N is an address, only the start bit is painted (
MandDareas). For the functions added in V1.5.0, the addresses written in the cells are painted, regardless of bit ranges.
Examples
You can write Examples 1 to 4 in order in a new MPA-8A8R(T) project (default data memory) and check them in simulation. Example 5 uses P0 to P4 and P32 to P34 again, so create a separate new MPA-8A8R(T) project for it.
Example 1. Toggling a Lamp with a Single Push Button
In this example, each press of P0 turns the P32 lamp on or off.
- In Settings → Symbol, register LAMP_BTN for
P0and LAMP forP32. - Write the rung below.
| Rung | Input | Function | What it does |
|---|---|---|---|
| 0 | P0 | FF P32 | Toggles P32 each time P0 is pressed. |
Start Run → Simulation, and turn the P0 chip on the simulation bar on and off several times. Each time you turn P0 on, P32 switches between on and off (Figure 4), and it does not change while P0 stays on.
Example 2. Tracking Rejects on a Conveyor
In this example, each time the conveyor moves one place, the reject detection result is shifted into M200 to M207, and when a reject reaches the eject position at the eighth place (M207), it is ejected with P33.
- In Settings → Symbol, register MOVE_PULSE for
P1, NG_SENSOR forP2, CLEAR_BTN forP3, TRACK forM200and EJECT forP33. - Write the rungs below after the rung of Example 1.
| Rung | Input | Function or coil | What it does |
|---|---|---|---|
| 1 | P1 | BSFT M200 8 P2 0 | Each time the conveyor moves one place, puts the value of P2 into M200 and shifts M200 to M207 by one place. |
| 2 | M207 | Coil P33 | Ejects the reject that has reached the eject position. |
| 3 | P3 | BRST M200 8 | Clears all tracking records. |
During simulation, add M200 to M207 to the Data Table, and turn P1 on and off once with P2 on. Then turn P2 off and turn P1 on and off seven more times. The first reject reaches M207, and P33 turns on. Figure 5 shows the case in which the first and third products are rejects. Turning P3 on turns off all of M200 to M207, and because rung 2 comes before rung 3, P33 turns off in the next scan.
Example 3. Blinking a Beacon
In this example, while the alarm input P4 is ON, the beacon P34 repeatedly turns on for 0.2 seconds and off for 1.8 seconds (timer base 10 ms).
- In Settings → Symbol, register ALARM for
P4and BEACON forP34. - Write the rungs below after the rungs of Example 2.
| Rung | Input | Function or coil | What it does |
|---|---|---|---|
| 4 | P4 | TFLK T5 20 180 followed by coil P34 | Turns on for 0.2 seconds and off for 1.8 seconds. TFLK T5 200MS 1800MS works the same way. |
| 5 | T5 | Coil P35 | Gives the same blink on P35. |
During simulation, when you turn P4 on, P34 and P35 turn on for 0.2 seconds every 2 seconds, and the current value of T5 rises from 0 to 199 and then returns to 0 (Figure 6). When you turn P4 off, they turn off at once and T5 becomes 0.
Example 4. Counting Rejects on a Conveyor and Checking a Position
In this example, the tracking records shifted into M200 to M207 in Example 2 are used to count the rejects on the conveyor and to check whether there is a reject at a given position. The byte address BM25 holds the eight bits M200 to M207.
- In Settings → Symbol, register NG_COUNT for
D30, CHECK_POS forD31and NG_LAMP forP36. - Write the rungs below after the rungs of Example 3.
| Rung | Input | Function or coil | What it does |
|---|---|---|---|
| 6 | @ON | BSUM BM25 D30 | Writes the number of bits that are on in M200 to M207 (the number of rejects on the conveyor) to D30. |
| 7 | @ON | LOADB BM25 D31 followed by coil P36 | Turns on P36 if there is a reject at the position that D31 points to (M200 for 0, M207 for 7). |
During simulation, turn P1 on and off eight times, with P2 on only for the first and third times. Those two rejects reach M207 and M205, and D30 becomes 2. When you add D30 and D31 to the Data Table and write 5 to D31, P36 turns on (Figure 12), and when you write 4, it turns off. If you write 8 to D31, the bit number is outside bits 0 to 7 of BM25, so P36 turns off, @IXERR turns on and the notice appears (Figure 10). @IXERR stays on even after you change D31 back.
- ① OUT of
BSUM:D30shows 2, the number of bits that are on. - ②
LOADBblock head: shows the contact symbol. - ③ N cell
D31: shows the value 5.M205is on, so the contact is ON. - ④ Coil
P36: is on.
Example 5. Running Three Processes in Order with Steps
In this example, the start signal P0 starts process 1, each process moves on to the next one when its end signal comes in, and the sequence returns to process 1 when process 3 ends. The value of D100 is the current step number.
- Create a new
MPA-8A8R(T)project, and in Settings → Symbol, register START forP0, END1 forP1, END2 forP2, END3 forP3, STOP forP4, STEP_NO forD100, PROC1 forP32, PROC2 forP33and PROC3 forP34. - Write the rungs below.
| Rung | Input | Function or coil | What it does |
|---|---|---|---|
| 0 | P0 | SSET D100 1 | Moves from step 0 to step 1 on start. |
| 1 | P1 | SSET D100 2 | Moves from step 1 to step 2 when process 1 ends. |
| 2 | P2 | SSET D100 3 | Moves from step 2 to step 3 when process 2 ends. |
| 3 | P3 | SOUT D100 1 | Returns to step 1 when process 3 ends, regardless of the current step. |
| 4 | P4 | SSET D100 0 | Stops (step 0). |
| 5 | D100=1 | Coil P32 | Turns on process 1 during step 1. |
| 6 | D100=2 | Coil P33 | Turns on process 2 during step 2. |
| 7 | D100=3 | Coil P34 | Turns on process 3 during step 3. |
During simulation, turning P0 on and off makes D100 1, and P32 turns on. Then turning P1 on and off moves to step 2 (P33), and turning P2 on and off moves to step 3 (P34). An end signal does not advance the step unless the current step is the one just before, so turning P2 on during step 1, for example, does nothing. Turning P3 on and off returns to step 1, and turning P4 on and off goes to step 0 and turns all the outputs off.
- ① “▶ Now 2”: appears in the head of the block of the current step, and the head border changes to the power-flow color.
- ② GROUP cell
D100: shows the current step number, 2. - ③ Comparison contact
D100=2: ON because the step is 2. - ④ Coil
P33: process 2 is on.
Things to Check
- The bits that
FFandBSFTuse to remember the previous condition are set up automatically and do not appear in the symbol table, the Data Table or Used Data.
Cannot be opened or shows red cells in earlier versions
A.mpxproject that uses even one bit control function cannot be opened in V1.3.0 and earlier versions of the app. A project that uses even one of the eleven functions added in V1.5.0 cannot be opened in V1.4.0 and earlier. Some values in the cells ofBSFT,BRSTandBSETNare accepted only in V1.5.0 and later: a double word address such asDD0in N, and an address or an integer other than 0 or 1 in IN and DIR ofBSFT. A project that uses these values but none of the eleven functions opens in V1.4.0 with those cells shown in red.







