tombimuller Posted June 24 Report Share Posted June 24 Hi, I am a newby in this environment. I want to measure the amount of water flowing into a storage. I use the HSI counter and correct it with a constant value. it soon happens, that the MI is larger than 32767 and it start counting in the reverse direction. I tried with long integer (SB82) however, it does not work. I do not know why. does anybody has an example? Thank you indeed. Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted June 24 MVP 2022 Report Share Posted June 24 MIs are signed 16 bit integers. The most significant bit is the sign bit, and when the value gets greater than 2^15 (32,767) the sign bit is set and register reports as negative. What is the largest value you anticipate? A long integer example is installed with the U90 software. Did you look at Help->Sample U90 Projects->Long Integers..U90 ? Otherwise, upload your program with a more detailed explanation of your math. Joe T. Quote Link to comment Share on other sites More sharing options...
tombimuller Posted June 25 Author Report Share Posted June 25 Dear Joe Thank you indeed for your replay. I have checked the long integer help section. however, it seems, that long integers do not work in my script. I attached the file. I will divide the signal from the HSI (MI30) by 435, this will give me the cumulated amount in litres. I would expect litre-values of about 1000 . This would then give a value for MI30 (and MI31) of 435'000. Have a look at section 18 (the above mentioned calculation) and 17 (reset of the display) As in the help menu, I used MI30 and MI31 (input from HSI) MI32 and MI33 MI34 and MI35 MI36 and MI37 (display) as a long integer pair Thank you indeed and kind regards Thomas Teich Steuerung v70.U90 Quote Link to comment Share on other sites More sharing options...
tombimuller Posted July 23 Author Report Share Posted July 23 could the moderator please approve my content? thank you indeed. Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted July 23 MVP 2022 Report Share Posted July 23 4 hours ago, tombimuller said: could the moderator please approve my content? Other than this message, I don't see any unapproved content. Quote Link to comment Share on other sites More sharing options...
tombimuller Posted July 27 Author Report Share Posted July 27 On 7/23/2023 at 6:58 PM, Flex727 said: Other than this message, I don't see any unapproved content. Dear Flex727, Thank you indeed for your replay. I want to measure the amount of water flowing into a storage. I use the HSI counter and correct it with a constant value. it soon happens, that the MI is larger than 32767 and it start counting in the reverse direction. I tried with long integer (SB82) however, it does not work. I do not know why. I have a Jz20-R16 I checked the long integer help section. however, it seems, that long integers do not work in my script. I attached the file. I will divide the signal from the HSI (MI30) by 435, this will give me the cumulated amount in litres. I would expect litre-values of about 1000 . This would then give a value for MI30 (and MI31) of 435'000. Have a look at section 18 (the above mentioned calculation) and 17 (reset of the display) As in the help menu, I used MI30 and MI31 (input from HSI) MI32 and MI33 MI34 and MI35 MI36 and MI37 (display) as a long integer pair Thank you indeed and kind regards Thomas Teich Steuerung v70.U9079.76 kB · 3 downloads Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted July 29 MVP 2022 Report Share Posted July 29 Hi Thomas - I didn't have the U90 software on this computer so I finally downloaded the latest version (6.6.45) and installed it to look at your program. First I looked at your HSI configuration mapped to MI 30. The Jazz series has limited data type functionality and the HSC can only be mapped to a single MI. From the Help- You mention above that you have MI 30 and MI 31 mapped to the HSI input. I looked through the Help and I didn't see anything about the HSI input being automatically mapped to two consecutive registers. I think your basic assumption here is wrong. Please correct me if you have information indicating otherwise. So we're going to have to do it the ancient way. In the Long Ago (1980s and 90s) most PLCs only had 16 bit integer values and there were no Long Integers, so we had to come up with tricky ways to work with the tools we were given. The Jazz is a handy little PLC but it sucks at math, which always seems to come up in an application. I personally call this the "Jazz Wall" and it's the main reason I don't use them anymore. For your next application get yourself a Samba, which is a low cost Vision PLC that doesn't have issues like this. Anyway, moving on with what we have to work with here the first thing to do is address the 32767 count limitation of the HSI so we'll have to do some program gymnastics. We do this by counting to 1,000 and then incrementing another register (MI 100) and resetting the HSC (MI 30). This will give us two split integers representing up to 32,767,000 to work with. Note that you will be limited in the counter reset by the scan time of the PLC so you may lose a couple of pulses during the 5 ms or so that it takes the Jazz to reset the HSI counter. You'll have to tell us how fast the pulses are coming in. Since we will be using this in a Long Integer calculation, I clamped the High Byte of the HSI (MI 31) to 0. Now we can use the 1,000 counter with a Multiply function to get an actual Long Integer number containing the virtual high value of the counter. I also clamped the High Byte of the 1,000 counter (MI 101) to 0 so there are no surprises. We add the current HSI counter value to this number to get a full representation of your counter value - Now your divide by 435 block should work. I don't have a Jazz here to test this so I don't know if this will work for sure. I've attached the program. Load it into your unit and let us know how it goes. Joe T. Teich Steuerung v70 JT.U90 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.