TN - BCD ASCII Conversions CJ

Modified on Tue, 14 Oct at 8:30 AM

Summary/Issue Description

CJ2 How to Convert BCD to and from ASCII



Root Cause

This example is for the simplest format of 4 a single WORD of ASCII to/from single UINT_BCD. There are also 8 digit (3 byte) and 16 digit (4 byte) variations. 



Solution

STR4 Instruction

Test0Input is a trigger to convert a single UINT_BCD to a WORD of ASCII

DataValue is the UINT_BCD to be converted to a single WORD of ASCII using STR4

ASCII1 is the WORD of ASCII that is the result of Numeric to ASCII Instruction


Once converted from UINT_BCD to ASCII, the sample program converts the ASCII back to UINT_BCD


NUM4 Instruction

Test1Input is a trigger to convert one WORD of ASCII to a single UNIT_BCD using STR

Here, ASCII1 is the WORD of ASCII that is to be converted to a single UNIT_BCD

the result of Numeric to ASCII Instruction

ConvertedDataUINT is the UINT_BCD that is the result of of the ASCII to Numeric instruction


Here are screen shots of included sample program.



Date/Revision History

First review 9/30/2025 V1.0


Author:

Ed Gallagher - Technical Support Specialist


References

SYSMAC CS/CJ/NSJ Series Programmable Controllers Instruction Ref Manual 


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article