From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting with a button



@robin171 wrote:
Thank you very very much!! I really appreciate your help!
 
Can you explain how the code in the last flat sequence works? I understand that you substract the system time from the time set in the array. How does it exactly work ?
 <SNIP>


The last sequence looks more complicated than it is.  The time boxes (input and output) are formated as relative time (right-click and choose "Format and Precision").  This means they are relative time from the beginning of the day (midnight), but they actually keep that data in seconds from the beginninf of the day (midnight).  For example 01:00 (1AM) becomes 3600 (60 min*60sec/min).
What we do is take current time (this is time, in seconds, from Jan 01, 1904), and convert it using "
Seconds To Date/Time" to an array of useful numbers, the five most important are seconds, minutes, hours, day of month, and year.  I assume the day of month that we want to change is greater than the current day of year and therefore calculate the difference in days between set and current day necessary (based on day of week), and the day of month is adjust accordingly.  This might not work over a month change or change of year, but I will leave that for you to check.  I then convert the seconds to hours, minutes, and seconds of this day (using simple arithmetic) and feed that back to the the array that we got from the "Seconds To Date/Time" conversion.  This is converted back into a time stamp (seconds since 12 midnight, Jan 01, 1904) and the difference between this new number and the current time stamp is the number of seconds you have to wait before executing the next step (which is where the vi pops up a message box). 

Let me think more about how to fix the year/month problem.  Maybe I will post something else that will fix it.  On a side note, don't be afraid to rate these posts (yes, a shamless plug).

Message 11 of 21
(959 Views)
In this one, I simply added everything in seconds, accounting for a week roll-over (and year roll-over, for that matter).  Because everything is done in seconds since Jan01, 1904, things are unique so there is no issues with deciding whether the user means this Monday or last Monday.
Message 12 of 21
(960 Views)

Thank you! I rated your posts!

I almost got the complete program working now 🙂 There are a few things that don't work perfectly, but i'll try to figure them out myself first. I'll let you know if i encounter any problems again!

Again .. thank you very very much! Labview is new to me and i must get used to this type of programming. With Delphi or C I can easily make this kind of programs, but Labview is hard for me.... I guess i have to practice a lot to become as good as you 😉

Message Edited by robin171 on 09-23-2005 04:50 PM

0 Kudos
Message 13 of 21
(955 Views)
I encountered another problem, I inserted my own code that controls the heating. When I save some start times and I press the stop button, the program crashes 😞
 
Maybe i'm doing something very stupid, my knowledge of labview isnt that good so far 😛
 
Can someone fix this ?? thank you
 
 
0 Kudos
Message 14 of 21
(940 Views)
I am unable to reproduce your error or "crash".  Can you be more specific on what is happening?

Message 15 of 21
(926 Views)

After i save some starttimes/days, I press the stopbutton to put the starttimes/days in the array. The program should stop when i do so, but it keeps running.

And i have another problem with my temperature control. I placed an simulate signal block to simulate the input of a temperature, just for testing. It doesn't run at all 😞

0 Kudos
Message 16 of 21
(916 Views)
When you hit "stop", this should simply halt the creation of the starttimes/days in the array.  Once it does this, *then* it begins running the temperature set part.  So at that point, the simulate signal block (simulating the temperature) begins to run.

To test this out, I set up a temperature routine that changes once a minute (beginning today).  I have also changed the graphing such that it shows more than one point per update.

However there is something that may not operate as expected.  Note that your temperature setting "for" loop only repeats N times (where "N" is the number of steps that you have set the temperature).  If you set the temperature once a day (say seven settings, each at midnight to the following midnight), then over a week, you will only repeat that loop seven times.  This means that, in turn, the graph will only update seven times, and your "Heating on/off" indicator will only change seven times a week.  This may not be what you intended.  So for my thermostat at home, even though there is a schedule (it sets to a different temperature durring the day than it does at night), the air conditioning/heating will kick on multiple times during the day to maintain the set temperature (it may probe the temperature once a minute, for example). 



@robin171 wrote:

After i save some starttimes/days, I press the stopbutton to put the starttimes/days in the array. The program should stop when i do so, but it keeps running.

And i have another problem with my temperature control. I placed an simulate signal block to simulate the input of a temperature, just for testing. It doesn't run at all 😞





Message Edited by Robert.Bedford on 09-26-2005 01:16 PM

Download All
Message 17 of 21
(910 Views)

thanks for your help again!

I still got the problem. The stop just keeps pressed and nothing happens. I had the program run for about 25 minutes. After pressing the stop button i can't press anything in the VI. Only the abort execution button can stop the program. 

I included an screenshot with this post to make it more clear. Am I doing something wrong, or is it my labview? I got version 7.1 prof edition.

Message Edited by robin171 on 09-26-2005 04:46 PM

0 Kudos
Message 18 of 21
(902 Views)
I am not sure what the problem may be.  If you were to put a probe on the input to the "time delay" (right-click and chose "probe") then run.  The number that is reported in this box is the delay (in seconds) until the next step in the program.  In your case, when processing step 1, it should be about 1 minute (~60) depending on exactly when you hit the "stop" button.  When processing step 2 and on, it should be negative because you are going back in time (because today is Monday, it choses today, even though the time is in the past).

So what does that probe return?  It may have something to do with a change to an unexpected value.  My clock is time-shifted by four hours (for some reason) so I added  14400 seconds to "today" to compensate for this (see in the code comments "add mysterious 4 hours lost somewhere").  I assumed this was an issue with LabView, but it may simply be my computer?  See the attached picture where I highlight the time shift.




Message 19 of 21
(893 Views)
I tried to remove the 4 hours, but it has no effect. When i put a probe on the time delay it says 0. I tried putting probes on other points, but everything after the while is 0 or uninitialized. It seems the code just crashes when i hit stop.
0 Kudos
Message 20 of 21
(881 Views)