Find The Needle Add My Company
TechTip: Large Numeric Display on Weintek HMI
This TechTip is about using a Weintek HMI as a large digit display with numbers bigger than the permitted “255” for a numeric object. In order to achieve this, we’ll split the number into ones, tens, hundreds and thousands using modulo operations in a macro and use the resulting digits with word lamps. Leading Zeros: No Leading Zeros: The 7 segment numbers (0-9 plus a blank) created for this project are available from on the links below: 0 1 2 3 4 5 6 7 8 9 Blank (open in new tabs) These were added into the Project Pictures for states 0-9, and state 10 uses “blank”. Leading Zeros Macro This macro splits “number” (LW-0) into ones, tens, hundreds, thousands, putting the resulting ones, tens, hundreds and thousands into LW-10, LW-11, LW-12 and LW-13 respectively. macro_command main() short number = 0 // input number short thousands = 0 // thousands variable short hundreds = 0 // hundreds variable short tens = 0 // tens variable short ones = 0 // ones variable GetData(number, "Local HMI", LW, 0, 1) // get the number to split into digits ones = number % 10 // get the ones number mod 10 tens = (number/10) % 10 // get the tens (number/10) mod 10 hundreds = (number/100) % 10 // get the hundreds (number/100) mod 10 thousands = (number/1000) % 10 // get the thousands (number/1000) mod 10 SetData(ones, "Local HMI", LW, 10, 1) // set LW-10 with value "ones" SetData(tens, "Local HMI", LW, 11, 1) // set LW-11 with value "tens" SetData(hundreds, "Local HMI", LW, 12, 1) // set LW-12 with value "hundreds" SetData(thousands, "Local HMI", LW, 13, 1) // set LW-13 with value "thousands" end macro_command No Leading Zeros Macro This macro splits “number” (LW-0) into ones, tens, hundreds, thousands, putting the resulting ones, tens, hundreds and thousands into LW-20, LW-21, LW-22 and LW-23 respectively but this time sets the value in the tens, hundreds and thousands to “10” to display the “blank” image if “number” is greater than 10, 100, or 1000, thus removing the leading zeros. macro_command main() short number = 0 // input number short thousands = 0 // thousands variable short hundreds = 0 // hundreds variable short tens = 0 // tens variable short ones = 0 // ones variable GetData(number, "Local HMI", LW, 0, 1) // get the number to split into digits ones = number % 10 // get the ones number mod 10 tens = (number/10) % 10 // get the tens (number/10) mod 10 hundreds = (number/100) % 10 // get the hundreds (number/100) mod 10 thousands = (number/1000) % 10 // get the thousands (number/1000) mod 10 if number < 10 then // if the number is less than 10 then tens = 10 // tens = 10 to display blank digit end if if number < 100 then // if the number is less than 100 then hundreds = 10 // hundreds = 10 to display blank digit end if if number < 1000 then // if the number is less than 1000 then thousands = 10 // thousands = 10 to display blank digit end if SetData(ones, "Local HMI", LW, 20, 1) // set LW-20 with value "ones" SetData(tens, "Local HMI", LW, 21, 1) // set LW-21 with value "tens" SetData(hundreds, "Local HMI", LW, 22, 1) // set LW-22 with value "hundreds" SetData(thousands, "Local HMI", LW, 23, 1) // set LW-23 with value "thousands" end macro_command As usual, a demo project is available to download here. Get in touch with our sales and support team on +44 203 026 2670
 
or via sales@lamonde.com to discuss your application.

For more information on TechTip: Large Numeric Display on Weintek HMI talk to Lamonde Automation Ltd

Enquire Now

  Please wait...

Location for : Listing Title