Sign in to follow this  
Followers 0
Colin Carpenter

DEC2BIN

4 posts in this topic

Not strictly a PLC problem, but related. I have an FX2N that is CC Linked to a Q2AS which is then linked to a SCADA system. All works well. In the FX2N, the operator has the ability to set up around 80 operations, and can set numerous operations going at the same time, depending on the interlocks in the programme. I'd like the SCADA system to store the operations that are happening at any one time, so I've used the MOV K4M700 D100 command to move the status of 16 bits starting at M700 into the 16 bit data register D100 which is then accessed by the SCADA system as a decimal number. There are 5 of these data registers used, so the status of the 80 bits will be carried to the SCADA system as 5 decimal numbers. The SCADA system has no ability to convert the decimal number back into binary and then access the individual bits, so I'm looking for a long hand way of being able to convert the 5 numbers back into binary and show what operations where happening at any time. A spreadsheet is the obvious answer ..... just type in the 5 numbers and it will show you what bits were on at any one time, and I thought I'd cracked it when I found the DEC2BIN function in Excel, but it only appears to work for binary numbers with 10 digits, which leaves me about 6 short of what I need. So the question is, does anyone know a neat way of converting a decimal number into a 16 bit binary number in Excel? Thanks, Colin

Share this post


Link to post
Share on other sites
You can do it in 2 x 8 bit units: INT(Original no./256) = one set of 8 bits. Mod(originalno.,256) = other set of 8 bits. DEC2BIN each one. eg: 65000 Original decimal no. /256 = 253.90625 = 11111101 Binary Mod(dec,256) = 232 = 11101000 Binary Or something like that Edited by Veganic

Share this post


Link to post
Share on other sites
Hi Colin, http://www.bigresource.com/VB-Excel-decima...-5b46PZNNY.html Btw, what scada you have there? If it supports boolean operators you don't need conversion to binary, you should be able to test bits like "TagX & Mask" etc. You should also be able to read booleans (may have to define more tags)

Share this post


Link to post
Share on other sites
That works a treat ... many thanks, I'd never have thought of dividing by 256 and then working with the remainder, it seems far too easy, but it works well. Panic Mode - The SCADA system is called Prodigy and works very well. I've checked and there's no way of stripping out binary bits from a decimal number that they know of at the the moment. I could read each bit as individual tag, but it would use 20% of the site's "bought" tags. This way, it's 5 tags used instead of 80, which they're much happier with. Thanks

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