Sign in to follow this  
Followers 0
professor_jonny

bit shifting clock area ascii to hex

2 posts in this topic

so i have bit shifted the clock area to get a month of 10 (000A) and i wish to output this to a printer which accepts ascii epl programming language. But i cant put it into an hex to asci function as the hex only reperesents half a letter of ascii. is there a way to convert a raw hex number into an ascii number? the only way i can think of doing it is using the compair command and put in an hex string in ascii format on each valid compair. that is fine for month where i only have 12 possible combinations, but i wish to store pulses of a flow meter into the plc and it will output a number up to 65535 total pulses as you can imagine doing that for every number combination would be a very big task. there must be a simple way i'm missing.

Share this post


Link to post
Share on other sites
Assuming that you are using a CJ (or equivalent) PLC, you can use the ASC instruction. However, it works on HEX characters, so with an integer value of 10, the hex value is A, so you would get a printed value of the ASCII character "A" or 41 Hex using only the ASC command in your example. To get around this, use the BCD command to convert #A to #10 and then use the ASC command as shown below: The end result (as you can see above is a hex value of 3130 which is the ASCII characters "10".

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0