The time stamp is a special numeric control that does not exist in earlier versions of Labview , but may appear after 8.X. This special type of numeric control contains all the time and date information we need.
In the Timing Function palette, LABVIEW provides many time-related functions, including functions for converting time and date to strings. In fact, the Format Write String function fully supports time tags, and its conversion functions are more extensive and comprehensive.
Similar to converting numbers to strings, the key to converting time stamps to strings is also to format the string. LabVIEW provides many special time-related time format codes . These format characters can not only be used to convert to strings, but also to display them in time stamp controls. The following example will use both string and time stamp display controls to display the time and date we need.
1. Get system time and date (year, month, day, hour, minute, second)
Getting the system time and date (year, month, day, hour, minute, second) is the most commonly used time operation. LABVIEW specifically provides a format time/date function that can directly get the current time and date without adding any time code. The default time code is %c.
The time in LABVIEW is divided into absolute time and relative time. Absolute time is simply what we call system time and date, and relative time can be used to represent elapsed time, such as the difference between two absolute times (system times).
The time format code for absolute time is %<>T, which is the container of the time format code. Other format codes should be located in <>.
The time format code %c displays the date and time according to the format specified by the local computer language.
For the time label display control, its time and date display format is generally set through the property dialog box. In order to illustrate the time format code, I used the property node setting.
2. Get the time and date strings separately
Often, we need to obtain the time or date separately. LABVIEW provides a special function to obtain the date/time string. This function returns two strings, representing the time and date respectively. See the figure below for specific usage.
The formatted string function can also be used to obtain time and date, and you can define the display format yourself, such as the separators between year, month, and day and their display order, as well as the hours, minutes, and seconds.
1. Get the date (year, month, day)
The time format code for the year is: %y for two-digit year (such as 97), %Y for four-digit year (such as 1997). The time format code for the month is: %m. The time format code for the day is: %d
2. Get time (hour, minute, second)
There are two time format codes: 24-hour system --- %H, 12-hour system --- %I;
The time format code for minutes is: %M; (lowercase represents month)
The time format code for seconds is: %S.
3. Get year, month, day, hour, minute, and second arbitrarily
Through the time format codes of year, month, day, hour, minute and second, we can get any one or several of them, which is very common in timed monitoring or timed data recording.
The following example uses the Format Write To String function to perform an operation once per minute, such as an alarm, writing to a file, etc. To ensure that the operation is performed only once per minute, the operation must be performed on the rising edge of the minute change.
4. Get the decimal (millisecond) number
This can also be achieved using the formatted write string function, as shown below:
5. Get information related to "week"
The time mark in LABVIEW contains all the information of the system time, and of course also includes several time format codes related to "week". In some European joint ventures, weeks are often used to represent working hours, such as today is the first week and the first day of the year, etc., which can be easily achieved using the time format codes related to the week.
The time format code %A represents the full name of the day of the week (such as Monday), and %a represents the abbreviated name of the day of the week (such as Monday).
For Chinese operating systems, %A and %a have exactly the same effect, but for English operating systems they are completely different.
The time format code %w returns the day of the week in decimal (0-6), where 0 represents Sunday.
The time format code %U returns the week number of the year (0-53), with Sunday as the first day.
The time format code %W returns the week number of the year (0-53), with Monday as the first day.
6. Relative Time
Absolute time generally refers to system time, which has a time of 0. In many cases, we do not care about the current absolute time. For example, basketball games, test program running time, etc., these are all "experienced" times, which are actually the difference between two absolute times. We call this time difference relative time.
Relative time is usually expressed as a double-precision number, indicating the number of seconds that have passed. For relative time, it may also be necessary to express it in days, hours, minutes, seconds, etc. For these needs, we do not need to calculate them ourselves, and relative time can be used for automatic conversion.
The time format code for relative time is: %t. %<> indicates a container for relative time.
文章内容结束
Previous article:LabVIEW programming skills: copying conditional structures and event structures
Next article:LabVIEW Programming Tips - How to Implement Aggregate Functions
- Popular Resources
- Popular amplifiers
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- In what situations are non-contact temperature sensors widely used?
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Trump administration "blacklists" Xiaomi, Xiaomi using Qualcomm chips is a "military-related company"???
- 『Anxinke Bluetooth Development Board PB-02-Kit』-3: Start Docker
- lan8720A strange reset problem?
- FAQ_How to calculate the response time from shutdown state to READY state
- Battery and external power switching circuit, MOS on and off conditions
- [NXP Rapid IoT Review] Low Power Consumption Experiment & Summary
- NVC voice ic offline commonly used models!
- The single-chip microcomputer has a built-in LCD driving function, and an external resistor drives the LCD screen. Please tell me the impact of external resistors and capacitors on the display
- Zigbee-IO port configuration
- There is something wrong with the program, please solve it