Author Topic: Programing BCD input and BCD output devices  (Read 10024 times)

wec

  • Guest
Programing BCD input and BCD output devices
« on: October 31, 2004, 10:15:59 PM »
Hi,

I am using the T100MD1616+ PLC for a project. I have searched through your website and read the manual that comes with the PLC, and couldn't find the answer to my question. Here is the question:

How to program the PLC to read BCD input signal from thumbwheels, and how to program the PLC to output  BCD signal to BCD devices? In other words, how to convert BCD to binary, and binary to BCD?

Regards,

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Programing BCD input and BCD output devices
« Reply #1 on: November 02, 2004, 07:41:02 AM »
BCD is just a special way of representing decimal number for human readability but is not a convenient representation for computer to work on directly.

If your thumbwheel switch gives you a BCD number, you need to convert it to an actual integer. First connect the thumbwheel switches to an input channel that start at either input 1, 5, 9 or 13.

E.g. if two BCD digit thumbwheel switches are connected to input 9-16, then

  A = INPUT[1]
  A = (A & &HFFFF)/256  ' mask out the upper 16-bit
                                      ' and shift to bit 0 to 7

The above statement captures the BCD input without the sign and shift it to bit 0 to 7. Next,

  DM[1]  = (A/16*10) + (A MOD 16) ' convert to binary

The first part of the above expression convert the ten digit to decimal number and the second part mask out the ten digit, leaving only the "one" digit. The resulting binary number is stored in DM[1].

BCD output will have to be done by a conversion from binary to BCD. You probably have the idea by now!

« Last Edit: November 02, 2004, 08:08:32 AM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

wec

  • Guest
Re:Programing BCD input and BCD output devices
« Reply #2 on: November 04, 2004, 06:19:50 AM »
Thanks for the reply.

So I have to write my own custom function using TBASIC program to do the BCD input and output, right?

I thought there is a single PLC instruction to execute the thumbwheel input reading. I must be missing something here. I am sure I have seen that on your website. Any way, I will try  TBASIC.