PLC TIME !!!

C

Thread Starter

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.
Thank you in advance,

Claudio Marques
 
<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
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
 
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
 
Top