leuzierre Posted July 2, 2021 Report Share Posted July 2, 2021 google traduction Hello, I have been stuck on my project for several days and I specify that I am a beginner in programming. My plan is that I have to sound a buzzer several times during the day is this setting made by HMI. On my HMI, I create 2 variables. Variable 1 is the hour and variable 2 is the minutes that I need to subtract. The problem, this variable that I created on the HMI, time function should I convert it to seconds in the ladder program? If it is necessary to convert it in second, for the obtained result I must use the block rtc to utc to compare it with SI31? I tried to do a comparison but it doesn't work for me. Thank you in advance for your help. Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted July 2, 2021 MVP 2022 Report Share Posted July 2, 2021 Following up from your other post - I think the easiest thing for you would be to enter the hours and minutes for everything separately, which puts everything into decimal land. Post your PLC program and I'll edit an example into it. Joe T. Quote Link to comment Share on other sites More sharing options...
MVP 2022 Ausman Posted July 2, 2021 MVP 2022 Report Share Posted July 2, 2021 Further on from what Joe is saying, I think you need to go down 2 other steps at present in your learning curve. 1). Have a look at the attached vlp which may need to be written out again for your plc...it may not run on your model immediately. The vlp is actually just demonstrating what can be done with UTC, which is the method Flex and I were suggesting earlier. 2). I often say on the forum that counters based on SB13 or 15 are a much better way of achieving some time functions needed. People always seem to go "must use Time functions" when thinking of "Time". A counter based on time works in a totally different way and is ideal for your need. I think that SB 13 would be enough accuracy for your need. You either set the counter as an increment or decrement, the example below is increment. Being an actual number rather than what Joe has explained about the complexities involved with time numbers, this idea gets you immediately into decimal land like he says. The count can then be manipulated very easily with various compares, subsequent stores, or maths functions. As Joe says, you then do simple maths to arrive at relevant numbers. 2 hours 30 minutes based on using SB13 as your trigger pulse is number (60(seconds) x 60(minutes) x 2(hours)) + (60(seconds) x 30(minutes)) = 9000. Don't forget that if you need to get into numbers larger than MIs can handle, you then need to use operands of larger capacity. cheers, Aus UTCideas.vlp Quote Link to comment Share on other sites More sharing options...
leuzierre Posted July 3, 2021 Author Report Share Posted July 3, 2021 google traduction Thanks for your help Me, I had to try it during the weekend. I can see that I am far from the mark. As you asked me Joe Tauser, I enclose my program example.vlp Quote Link to comment Share on other sites More sharing options...
MVP 2022 Ausman Posted July 3, 2021 MVP 2022 Report Share Posted July 3, 2021 I've had a quick look at your program. I can't run it as I don't use that type of plc, but I strongly believe my counter method (point 2. above) would make things far easier. cheers, Aus Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted July 4, 2021 MVP 2022 Report Share Posted July 4, 2021 I think you're running into trouble because the project you're working on isn't exactly beginner level. Time is more complicated than it looks. UTC is going to throw you for a loop because it's the absolute number of seconds since some reference point. You don't really care about this, you're more interested in how much time has passed today. Then you'll do it again tomorrow. I propose determining the number of minutes past midnight and referencing your time setpoints to that. You'll enter your time setpoints for hours and minutes separately as regular MIs and then combine them into minutes behind the scenes in your code. Then comparison becomes straightforward. You'll see in the SI registers that there are additional ones available for RTC hour and minute (SI 35 and SI 36), so we'll use those for actual current time calculation. The language barrier is a bit of a problem as I don't speak French, but I tried putting comments in the program using Google translate. I've attached the beginning of the program with modifications to the Main Routine and the Start-Up Display to show what I'm talking about. Also - you have nine subroutines in your program. I don't know if you've gotten that far but you have to put Call Subroutine blocks in for them to work. At your programming level I wouldn't use subroutines at this time as they only add to the confusion. Put all your code into the Main routine and then break it up later. Let us know if this clears things up a bit. Joe T. example JT.vlp Quote Link to comment Share on other sites More sharing options...
leuzierre Posted July 9, 2021 Author Report Share Posted July 9, 2021 Google traduction Thanks Joe Taucher and Ausman for your help. Sorry for not having answered earlier, I am working hard on this project. I found out why I couldn't subtract, it was due to the memory format to use. When there were hours, minutes and seconds (ex: 13h30mn50s), I did the calculation to convert in seconds then I save in ML (32 bits). And my variable which contained the minutes, second (ex: 20mn30s), I converted it into second and I save it in MI (16 bits). If I don't put these 2 values in ML, the value was wrong. Lack of time, i haven't try in BCD if that will work too. I just got some BCD encoding lessons, I will be working on it this weekend. For the subroutines in my program, which I had put on this site, I had purposely put an example in the hand for simplicity. My program is progressing well, and if you want it so that its help has someone else i will post it on this site. LJ 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.