# PLC TIME !!!

C

#### Claudio Marques

Can someone help me in the following situation.
I want to have in a word, with decimal format de total minutes of the PLC time:
Ex: %SW51: 16#2020 , I want to have in a word the following : %W1 = 20*60 + 20 = 1220 , but in decimal.

Claudio Marques

T

#### [email protected]

<P>I understand this question as asking how to convert a hexadecimal (base 16) number to decimal (base 10).</P>

<PRE>
3 2 1 0
16#abcd = d * 16 + c * 16 + b * 16 + a * 16

Example:
3 2 1 0
0x3A2C = 3 * 16 + 10 * 16 + 2 * 16 + 12 * 16
= 14892

</PRE>

<P>[email protected]</P>

R

#### Rich Weekly

You must first convert the time period to HHHH:MM:SS format using TRANS_TIME operation, then you can multiply the time in decimal format....There should be an example under the help file of the programming software

J

#### Jiri Baum

You probably don't want it in decimal, but if you do, look up BCD instructions in your manual. (BCD = Binary-Coded Decimal) Those will give you the number in decimal, four bits per digit.

Most of the time, it's better to leave things in binary/hex (whichever way the PLC likes them best), and only convert them to decimal at the last moment before displaying them. That way it's easier to do calculations.

HTH - HAND

Jiri
--
Jiri Baum <[email protected]> http://www.csse.monash.edu.au/~jirib
MAT LinuxPLC project --- http://mat.sf.net --- Machine Automation Tools

A

#### Anonymous

hi there;
i think 16#abcd =a*16(3)+b*16(2)+c*16(1)+d*16(0).

T

#### [email protected]

<P>I stand corrected.</P>
<PRE>
3 2 1 0
16#abcd = a * 16 + b * 16 + c * 16 + d * 16
</PRE>

<P>[email protected]</P>

A

#### Anonymous

hi there;
i think 16#abcd =a*16(3)+b*16(2)+c*16(1)+d*16(0).

#### PhilCorso

Terence:

You are to be lauded. Just a few List contributors would ever 'fess up to having made an error

Regards,
Phil Corso, PE
(Boca Raton, FL)