Charmsec® (Characterized Remainder Set Error Correcting code) is an error-correcting block code invented by the author. Its mathematical essence lies in the generalized mapping of remainder domains onto arbitrary discrete symbol spaces. This implementation demonstrates its deployment as a mapping onto a constrained set of 7-bit ASCII printable characters.
Since Charmsec is inherently agnostic to the underlying symbol representation, it can be mathematically extended to any physical states or discrete dimensions—such as quadrature amplitude modulation (QAM) constellations, OFDM subcarriers, or even quantum states—provided a mapping to the remainder set is defined.
In this implementation of the mathematical mapping to ASCII codes, non-printable codes are intentionally excluded.
Therefore, when treated as electromagnetic signals in the physical layer, the exclusion of NUL (0x00) and DEL (0x7F) limits the maximum consecutive identical digits (CID) to within 12 bits, enabling reliable clock recovery without scramblers.
When assuming the use of an out-of-code control character, such as LF (0x0a), as a delimiter, excluding characters within a 1-bit Hamming distance of that control character from the valid code characters allows it to be utilized as a 1-bit error-tolerant delimiter.
When this delimiter is used for macro-level structures, such as a delimiter for multiple code blocks, reliable block synchronization can be achieved without the overhead of sync words or their acquisition processing. This makes it widely applicable not only to asynchronous serial communications such as RS-232, RS-422, and RS-485, but also to custom synchronous buses.
Furthermore, by utilizing the surplus of information entropy (super-data), auxiliary metadata or independent heterogeneous data can be embedded within the same code space. For example, it is possible to interleave timestamps, various control codes, or sporadic and independent datasets within a data stream, making it well-suited for low-latency systems where both real-time performance and transmission efficiency are required, such as control signal transmissions for industrial robots and vehicles.
Since the output consists entirely of printable characters, logging and email attachments are easily handled.
The runtime memory resource requirement is lightweight at less than 8 KB, making it suitable for resource-constrained embedded processors. Additionally, since the remainder system and majority-voting operations in Charmsec can be processed in parallel, further acceleration can be achieved through implementation in FPGAs or SoCs.
LF delimiter, with \ (0x5c) excluded as an error placeholder.
LF (0x0A) character can be used as a robust code block delimiter with 1-bit error tolerance,
as all characters within a 1-bit Hamming distance of LF are excluded from the valid code characters.
Note 2: Since the backslash \ (0x5C) is also excluded from the code characters,
it can be safely utilized as a visual placeholder to indicate error positions without code collision.
Charmsec7_5C—Single-character error correcting characterization code.
Encodes 44-bit data into a 9-char ASCII string. Excluded characters are ∖ (0x5c).
The encoding rate is about 0.698. Compared to Base64, the encoded character is increased by approximately 22%.
Charmsec7_5c_demo : Rev.1.98 (2026-07-17) (c) 2004 Takayuki HOSODA, Finetune co., ltd.
Charmsec7_5c_demo : Using charmsec7_5c - a subset of the Charmsec CoDec library.
Charmsec7_5c_demo : '\' is to be used as the error position indicator here.
Charmsec7_5c_demo : txdata = 0x0000badcafebabe -> txcode = hNcWuw'op
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = \NcWuw'op - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = h\cWuw'op - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = hN\Wuw'op - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = hNc\uw'op - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = hNcW\w'op - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = hNcWu\'op - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = hNcWuw\op - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = hNcWuw'\p - Corrected an error
Charmsec7_5c_demo : rxdata = 0x0000badcafebabe <- rxcode = hNcWuw'o\ - Corrected an error
Charmsec7_5c_demo : txdata = 0x000141d4a551717 -> txcode = jlrvxz{en (saturated)
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = \lrvxz{en (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = j\rvxz{en (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = jl\vxz{en (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = jlr\xz{en (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = jlrv\z{en (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = jlrvx\{en (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = jlrvxz\en (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = jlrvxz{\n (superdata) - Corrected an error
Charmsec7_5c_demo : rxdata = 0x000141d4a551717 <- rxcode = jlrvxz{e\ (superdata) - Corrected an error
Download archive : charmsec7_5c_demo-1.98.tar.gz [4kB tar.gz]
One of the features of Charmsec is the use of super-data to send one-shot data or control codes in between data streams, It can also be used for end of data stream, check bits, timestamps, etc.
The figure below shows an example of using Charmsec7 in RS-485 multi-drop communication between a device and a robot.
Majority-vote error correction based on the Chinese Remainder Theorem (CRT) is founded on the following idea. Given a set of n + 2t mutually orthogonal unit vectors, if an original number can be represented in 1 + 2t different ways as a set of n values obtained from inner products with these vectors, then up to t errors can be corrected by applying a majority decision to the corresponding decoding results.
This structure of decomposing a number and mapping its components is also hoped to provide some insight for future research on orthogonal modulation schemes and quantum error correction.
Patent Gazette Patent No. 7142977 — Data Communication System, Transmitting Device, and Receiving Device