Binary math questions dl05 plc

notfet

Member
Join Date
Jan 2016
Location
texas
Posts
14
I've written a large program(300 rungs so far) and I am running into a problem with binary math. According to the DL05 manual DIVB and MULB says that the inputs must be 16bit and my inputs are 32bit(5 numbers EX 15.000) that's why I am multiplying by 10000 to compensate for the implied decimal places. For most of the program I am using BCD(MULD etc.) I have reached a stopping point because there is not a MULBD selection at all. Here is the formula I need to work out. ((((Time*10000)/Weight)*Error Weight)/10000) = Error time needed for shortage
Code:
sp0----LDD
       K10000
       BIN
       OUT V2000
SP1----LD TA5(TMRAF)
       BIN
       OUT V3000
SP1----LDD V3000
       MULB V2000
       DIVB V2002(Weight)
       MULB V2004(Error wt.)
       DIVB V2000
       OUT V2010(Error time needed)
I have tried POP after a divide to bring the values in the accumulator up to another Vmem but not sure what to do with it. I have tried BCD but the inputs are too large or small(Negative) The process vary's that's why I need resolution to 15.000 and the timer can get as high as 99.99 sec. I have tried to store a Vmem after each mathematical calculation. Nothing adds up to the same as my $2.00 calculator. There is not room for the DL06 or I'd use floating point math. I could change to a Click plc but Id hate to transpose the entire program over this since this is my last hurdle to overcome. Please any suggestions and if possible explain each step so I can understand
 
sp0----LDD K10000

BIN

OUT V2000

SP1----LD TA5(TMRAF) This is fine as long as no bigger than 9999, and make sure you aren't using T6

BIN

OUT V3000 If you change this to OUTD then you can keep LDD on the next line.

SP1----LDD V3000 --- If above is just OUT then ONLY USE LD (if anything in V3001 then error)

MULB V2000

DIVB V2002(Weight) --- It's this result that matters. Must fit into 0 - 65535

MULB V2004(Error wt.) --- result must be less than 655350000

DIVB V2000 --- This result must be 0 - 65535 for the OUT below to be valid

OUT V2010(Error time needed) --- remember this is binary. If you want to use it as a preset you will have to convert back to BCD.


As shown the critical number is V2002.
Can you give typical values for TA5, V2002 and V2004?
Oh - and this won't handle negative numbers, don't even try.
The POP after the DIVB will give the remainder in the accumulator. Are you sure you want that?
 
Last edited:
Above was a comment on the math. Now about the algorithm...

I assume the timer shows the time for the last load of product. You wish to derive a more accurate time based on the difference between the desired weight and what actually resulted from the previous action.

LD time
Mul by desired weight
Div by this weight
Out new time

Result is a time based on the proportion between the weights.

New_Time = (Previous_Time * Desired_Weight) / Actual_Weight
 
Bernie this is a general idea of what is happening. A motor runs while delivering product into a dispenser. at 50% desired weight it takes a reading and adjust T5 for the time to reach 100%. but due to the nature of the product it is never 100% mostly short so error weight = desired weight - actual weight.
this formula
New_Time = (Previous_Time * Desired_Weight) / Actual_Weight
is resulting in more time. maybe I am calculating this incorrectly.
also let me answer your questions in reverse order
no I wasn't sure if the remander wasn't the problem so there is not a need for POP
Here are typical values and the results I desire. TA5 30 secs(TMRAF = 3000), V2002 1.000 LB or 1000,V2004 .125 or 125 with a result of 3.75 sec or 375 into the formula to adjust t5.
the results cav vary wildly
the maximum limits are 90.00(9000) for t5 and 15000 for v2002 Almost all situations the result of v3000 * v2000 is always over 65535 so this may be my error?
 
I am sorry Bernie you were correct I was not thinking of it in the right manner
Adjustment Time = (Previous Time * Error Weight) / Current Weight
My mistake was thinking that Actual Weight was the implied Error Weight. So that solves my problem.
But now just out of curiosity, and since there is another equation that I just gave up on and entered the results into the algorithm, the problem would occur when someone changes the loadcell that number will be incorrect and the number will be too large.
result must be less than 655350000
The goal is to assign a tag for the new Mv/V for the loadcell
Since implied decimal places must be multiplied to get rid of them the figures exceed that number since readings are in the thousandth of a millivolt, every number has decimal places, simply rounding them up creates errors or a non-linear number. And although I can change the Plc to a CLICK PLC, I am already under a deadline and that delay will not make people very happy.
Here is the formula with the un-needed *100000 parts to truncate the decimal places.

loadcell bits/Pound = ((((220678 * 100000) / 390625) * 65535) / 220462) / 10
220678 is 2.20678Mv/v * 10Volts
390625 is 39.0625 the Max Mv of the module
65535 Resolution
220462 is 22.0462 Kg to Lbs

Even if I try to not use a large multiplier(100000) for the decimal places by using POP and storing that to a separate Vmem it seems to get rid of or round a few digits. And yes I am being careful no not make any number go negative as that is not tolerated.
Is there a way to use SHFL(Or SHFR) and POP to accomplish this? Thanks you have helped tremendously
 
Last edited:
Interfacing a loadcell to a PLC is typically done by way of an external load cell amplifier module. I don't think that the DL05 has an appropriate input module to handle the differential millivolt signal.

As far as changing a loadcell you wouldn't change in a working system to a dramatically different type cell. I typically work with 2 mv/v loadcells and they seem fairly common. Adjustment for the very small difference between individual loadcells of a particular type would be done by trimming adjustments att the loadcell amplifier or at the summing box in a multiple loadcell installation.
 
Yes the amplifier module is a F0-04THM thermocouple input module configured to read millivolts and the 10Volt supply for it is independent, also since there is always something on the loadcell, The wheatstone bridge will never read negative. if there is a trim pot on +EXCITATION and possibly +SIGNAL OUT, yes that will Zero balance the loadcell but people will almost always adjust them without knowing what they even do. I wanted to eliminate this by putting it into the algorithm. So far it's pretty accurate but that is only because I calculated this myself. You are right even the loadcell I work with is 2Mv/V.
 
Last edited:
If push comes to shove I will order an amplifier module. but if there is an adjustment pot they will turn it even if that's not the problem.
 
if you want to prevent it from being turned, alot of pots ive seen get nail polish on them after adjusted, that way it shows dont fcuk with me. lol. that or something that has the module locked inside.
 
the locked away thing would be great but there is not any space. And they will just turn the pot anyway( I go back all the time because people crank proportional valve pots with nail polish when there was a problem with the pump)(unrelated)
Back to the formula, Is there a solution?
 
Fair Enough. I agree that an operator will mess with anything he can when they are having issues and can make it worse.
 

Similar Topics

Hi folks, I'm trying to parse a binary string on a Red Lion DA30D using a Raw UDP/IP input port. I've done this before with ASCII strings so I do...
Replies
38
Views
972
So here's my situation, I have been tasked with modifying the logic to mimic a button press in the PLC. I have two identical machines however one...
Replies
6
Views
537
Hi, I want to extract every second bit of a double word and place it in a new word but the position of placement should be from 0,1,2......15...
Replies
17
Views
3,065
Hello, I am trying to convert a incoming string that is in Binary format (See attachment) to a DINT. Any ideas? When I use the STOD command it...
Replies
6
Views
2,206
How can I read individual binary bits from a SLC500 within FTH SE? With the Tag Browser I can get to the Binary Files and get each Integer from...
Replies
5
Views
1,598
Back
Top Bottom