en-us_products:mpino_studio2:box_functions:conversion
This is an old revision of the document!
Table of Contents
MPINO STUDIO 2 Phase 4-7 · Conversion Box Functions
These commands invert bits or signs and convert BCD values.
This ladder screen contains INV and H2D.
1. INV and NEG
INV
Invert
Inverts every bit in the source WORD and stores the result. It performs the same operation as WNOT from the Conversion category.
Syntax: INV D0 D1
Arguments
- 1st = S: source address or constant to invert
- 2nd = D: result destination address
| Run condition | Before | Command entered | Expected result |
|---|---|---|---|
| Left condition ON | D0=0x0001 | INV D0 D1 | D1=0xFFFE |
NEG
Negate
Reverses the sign of the source value and stores the result.
Syntax: NEG D0 D1
Arguments
- 1st = S: source address or constant to negate
- 2nd = D: result destination address
| Run condition | Before | Command entered | Expected result |
|---|---|---|---|
| Left condition ON | D0=10 | NEG D0 D1 | D1=-10 |
2. H2D and D2H
H2D
BCD Decode (Hex to Decimal)
Interprets a source WORD containing four BCD digits as a decimal integer and stores the result.
Syntax: H2D D0 D1
Arguments
- 1st = S: source word address to interpret as BCD (D/C/T)
- 2nd = D: destination word address to store the decoded decimal value
| Run condition | Before | Command entered | Expected result |
|---|---|---|---|
| Left condition ON | D0=0x1234 | H2D D0 D1 | D1=1234 |
D2H
BCD Encode (Decimal to Hex)
Converts a decimal integer from 0 to 9999 into four-digit BCD and stores it in a WORD.
Syntax: D2H D0 D1
Arguments
- 1st = source: WORD address holding a decimal integer from 0 to 9999
- 2nd = destination: WORD address that stores the BCD result
| Run condition | Before | Command entered | Expected result |
|---|---|---|---|
| Left condition ON | D0=1234 | D2H D0 D1 | D1=0x1234 |
3. Troubleshooting
| Symptom | What to check |
|---|---|
| The H2D result is unexpected. | Check that every hexadecimal digit in the input WORD is from 0 to 9. |
| The D2H input has more than four digits. | Use the 16-bit BCD range from 0 to 9999. |
Related Documentation
en-us_products/mpino_studio2/box_functions/conversion.1788944071.txt.gz · Last modified: by 127.0.0.1

