How to count the number of cycles in sine wave
Hi,
I am new to Labview. I have labview 8.2 version and my dataacquisition is NIDAQPAD6015. I could write a program to generate a sine wave of desired frequency through simulate signal. My question is how do i measure the number of cycles for this sine wave as soon as I run the program. Hope my question is clear.
Ravi Mokirala
To find the offset (which in this case is the Y value midpoint around which the sine wave is symetrical):
Capture more than one cycle. Find the min and max values. Subtract Min from Max and divide by 2. Then subtract this result from the Max value (or add the result to the Min value). This is the offset.
To count the number of cycles where the offset is unknown, just use the first data point value as a reference. If the next data point is more positive, then count the number of times that the first data point is repeated and the next data point is more positive. Of course with DBL data type, you probably would not get the exact same value as the first data point, so you need to use In Range with a very tiny limit. It all depends on your signal amplitude, frequency, and sampling rate.
Example: Lets say your first data point value is 0.5 and the 2nd point is 0.55. You need to look for another value that is between 0.48 and 0.52. Then read the very next data point value. If it is greater than the previous value, add one to the cycle count. If it is less than, you are at half a cycle, do not add to the count.
- tbob
Inventor of the WORM Global
Similar Messages
-
How to count the number of rows in a resultser object?
hi there
how to count the number of rows in a resultser object which may contains millions of rows? besides using a while loop? thanksYou don't, you execute a query whose result is the record count of those records that match the search and then you execute the actual query to create your record set. Typically you do
select count(id) from YourTable where [filter]
from the resulting ResultSet do
int res.getInt(1);
which gives you the count and then
select id from YourTable where [filter]
to produce the actual result set.
in the second query the id part can be substituted with the actual fields you want. -
How to count the number of lines dynamically,
In the below code am trying to read the lines which are selected using a check box, also am categorizing the contents depending on the follow up material.
after displaying one category contents am displaying a line
which also counts to a line in the internal table.
My question is how to count the number of lines(ULINE) displayed dynamically.
FORM GET_LINES .
DATA: LV_LINES TYPE I,
LV_TIMES TYPE I,
LV_TABIX TYPE SY-TABIX.
DESCRIBE TABLE IT_REC LINES LV_LINES.
DO LV_LINES TIMES.
LV_TIMES = SY-INDEX .
READ LINE LV_TIMES FIELD VALUE IT_REC-CHECK INTO GV_CHECK.
IF SY-SUBRC EQ 0 AND GV_CHECK IS NOT INITIAL.
LV_TABIX = LV_TIMES.
READ TABLE IT_REC INDEX LV_TABIX INTO GWA_UPDATE.
IF SY-SUBRC EQ 0.
APPEND GWA_UPDATE TO GT_UPDATE.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. " GET_LINESIn the below code am trying to read the lines which are selected using a check box, also am categorizing the contents depending on the follow up material.
after displaying one category contents am displaying a line
which also counts to a line in the internal table.
My question is how to count the number of lines(ULINE) displayed dynamically.
FORM GET_LINES .
DATA: LV_LINES TYPE I,
LV_TIMES TYPE I,
LV_TABIX TYPE SY-TABIX.
DESCRIBE TABLE IT_REC LINES LV_LINES.
DO LV_LINES TIMES.
LV_TIMES = SY-INDEX .
READ LINE LV_TIMES FIELD VALUE IT_REC-CHECK INTO GV_CHECK.
IF SY-SUBRC EQ 0 AND GV_CHECK IS NOT INITIAL.
LV_TABIX = LV_TIMES.
READ TABLE IT_REC INDEX LV_TABIX INTO GWA_UPDATE.
IF SY-SUBRC EQ 0.
APPEND GWA_UPDATE TO GT_UPDATE.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. " GET_LINES
The display function is:
FORM DISPLAY_DATA .
ULINE.
WRITE : /1 SY-VLINE, 'check',
10 SY-VLINE, 'Plant',
20 SY-VLINE, 'Material number',
50 SY-VLINE, 'Follow up material',
70 SY-VLINE, 'Safety stock',
100 SY-VLINE, 'Partc'.
ULINE.
LOOP AT IT_MARC.
MOVE: IT_MARC-WERKS TO IT_REC-WERKS,
IT_MARC-MATNR TO IT_REC-MATNR,
IT_MARC-NFMAT TO IT_REC-NFMAT,
IT_MARC-EISBE TO IT_REC-EISBE,
IT_MARC-PARTC TO IT_REC-PARTC .
APPEND IT_REC.
CLEAR IT_MARC.
ENDLOOP.
DATA: GV_TABIX TYPE SY-TABIX.
LOOP AT IT_REC.
GV_TABIX = SY-TABIX.
READ TABLE GT_TOTAL WITH KEY WERKS = IT_REC-WERKS
NFMAT = IT_REC-NFMAT.
IF SY-SUBRC EQ 0.
IT_REC-PARTC = GT_TOTAL-PARTC.
MODIFY IT_REC INDEX GV_TABIX TRANSPORTING PARTC.
ENDIF.
ENDLOOP.
LOOP AT IT_REC.
WRITE : /1 SY-VLINE, IT_REC-CHECK AS CHECKBOX,
10 SY-VLINE, IT_REC-WERKS,
20 SY-VLINE, IT_REC-MATNR,
50 SY-VLINE, IT_REC-NFMAT,
70 SY-VLINE, IT_REC-EISBE,
100 SY-VLINE, IT_REC-PARTC.
AT END OF NFMAT.
ULINE.
ENDAT.
ENDLOOP.
ULINE.
ENDFORM. " DISPLAY_DATA
Solved -
How to count the number of wins?
I have a tic tac toe simulator that simulates a game of tic tac toe (obviously). I press the 'play' button, and 1 random X and O is placed in 9 of the labels. Then the application says if X or O wins, or if the game was a tie/no winner. So,
what I want to do is when I click the 'exit' button, I want a message box telling the user how many times X won, O won, and how many ties there were. I am not too sure how to count the number of wins.
-ThanksThanks for the reply. I could be wrong, but I do not think that is exactly what I am looking for. Here is the code that I have that determines the winner:
switch (checkWinner())
case 'T':
winnerLabel.Text = "It was a tie!";
break;
case 'O':
winnerLabel.Text = "O Wins!";
break;
case 'X':
winnerLabel.Text = "X Wins!";
break;
private char checkWinner()
char WinnerChar = ' ';
int winning_line = 0;
if (GameBoardCellChar[0].Equals(GameBoardCellChar[1]) && GameBoardCellChar[0].Equals(GameBoardCellChar[2]))
WinnerChar = GameBoardCellChar[0];
winning_line++;
if (GameBoardCellChar[3].Equals(GameBoardCellChar[4]) && GameBoardCellChar[3].Equals(GameBoardCellChar[5]))
WinnerChar = GameBoardCellChar[3];
winning_line++;
if (GameBoardCellChar[6].Equals(GameBoardCellChar[7]) && GameBoardCellChar[6].Equals(GameBoardCellChar[8]))
WinnerChar = GameBoardCellChar[6];
winning_line++;
if (GameBoardCellChar[0].Equals(GameBoardCellChar[3]) && GameBoardCellChar[0].Equals(GameBoardCellChar[6]))
WinnerChar = GameBoardCellChar[0];
winning_line++;
if (GameBoardCellChar[1].Equals(GameBoardCellChar[4]) && GameBoardCellChar[1].Equals(GameBoardCellChar[7]))
WinnerChar = GameBoardCellChar[1];
winning_line++;
if (GameBoardCellChar[2].Equals(GameBoardCellChar[5]) && GameBoardCellChar[2].Equals(GameBoardCellChar[8]))
WinnerChar = GameBoardCellChar[2];
winning_line++;
if (GameBoardCellChar[0].Equals(GameBoardCellChar[4]) && GameBoardCellChar[0].Equals(GameBoardCellChar[8]))
WinnerChar = GameBoardCellChar[0];
winning_line++;
if (GameBoardCellChar[2].Equals(GameBoardCellChar[4]) && GameBoardCellChar[2].Equals(GameBoardCellChar[6]))
WinnerChar = GameBoardCellChar[2];
winning_line++;
if (winning_line == 0 || winning_line > 1)
WinnerChar = 'T';
return WinnerChar;
Do I have to include something extra in here to get the count or no?
The code I posted is the coding in my play button. -
How to count the number of text boxes that are data entered
How to count the number of text boxes that are data entered in visual basic form.
Here is an Iterator that expands on my previous response:
''' <summary>
''' Iterator for form controls
''' </summary>
''' <param name="onlyControlsOfType">specify type if a certain type of controls needed</param>
''' <param name="onlyTopLevel">if true don't search containers within the form</param>
''' <returns></returns>
''' <remarks></remarks>
Private Iterator Function AllControls(Optional onlyControlsOfType As Type = Nothing, _
Optional onlyTopLevel As Boolean = False) As IEnumerable(Of Control)
Dim ctrl As Control = Me.GetNextControl(Me, True)
Do Until ctrl Is Nothing
If onlyControlsOfType Is Nothing OrElse ctrl.GetType = onlyControlsOfType Then
If TypeOf ctrl.Parent Is Form OrElse Not onlyTopLevel Then
Yield ctrl
End If
End If
ctrl = Me.GetNextControl(ctrl, True)
Loop
End Function
Some sample uses:
For Each
For Each c As Control In AllControls()
Debug.WriteLine(c.Name)
Next
List of all controls, including controls in containers i.e. Groupbox
Dim l As List(Of Control) = AllControls().ToList
List of all Textbox controls, including Textboxes in containers i.e. Groupbox
l = AllControls(GetType(TextBox)).ToList
List of all Textbox controls, don't include Textboxes in containers i.e. Groupbox
l = AllControls(GetType(TextBox), True).ToList
'Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it.' JohnWein
Multics
My Serial Port Answer -
How to improve the number of cycles on my MBA
What is better to charge you MacbookAir every time you can find power or just when the battery is totally discharged? I need to know how to improve the cycles of my battery
I would really like to avoid reducing the number of cycles
Actually... you probably want to reduce the number of cycles, not "avoid" reducing the number of cycles. As CW mentioned, you probably don't need to worry too much about your cycles and you should just generally use your MacBook Air as you need to. However, if you want to prolong your battery life, you should run it plugged in the majority of the time. You should not run the battery all the way down before recharging it again. It is necessary to do this when calibrating the battery, but this is something which only needs to be done ever few months:
http://support.apple.com/kb/ht1490
The more you run on battery, the more your cycle count will go up. In general, going through a cycle or so a week is a good minimum. A cycle is a full discharge and then full charge of your battery. So... if your battery is at 100% and you let it discharge to 0% and then fully charge it back up to 100% again, that would be once cycle. Likewise, partial discharge & recharges count as partial cycles. For example, if your battery were at 100% and you let it discharge to 90% and then recharged it back up to 100%, that would be 1/10th of a cycle. You would need to do that 10 times in order for it to count as one cycle. So, you can see that you will increase your cycle count much faster the more you allow your system to run on battery before recharging it.
These are really just general guidelines. There may be times when you're just not by a power outlet so you have no choice but to run your battery down. Regularly doing this will shorten the overall life of your battery. But, once in a while will have little impact.
Here are Apple's guidelines for battery care:
http://www.apple.com/batteries/notebooks.html -
How to count the number of rows in a cube!!??
Experts,
I can somebody tell me how do I count the number of rows in my cube when i am using listcube???..
Thanks
AshwinHi,
have a look ath this theard too
Number of Records in Cube
regards -
How to Count the number of TAB chars value '0A' in a line?
I have a requirement to count the number of TABs in a text file that I am processing (they must equal 75) to ensure that all the fields have been submitted on the file I am reading?
How do I identify the TABs in a line?
I have this so far:
CONCATENATE gv_unix_file gv_lstfiles-name INTO gv_unix_file.
OPEN DATASET gv_unix_file for INPUT IN TEXT MODE ENCODING NON-UNICODE.
IF sy-subrc <> 0 .
message e000(zz) with 'Cannot access in_uk files'.
ENDIF.
CONCATENATE gv_unix_file_arc gv_lstfiles-name INTO gv_unix_file_arc.
OPEN DATASET gv_unix_file_arc FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
IF sy-subrc <> 0 .
message e000(zz) with 'Cannot access in_uk files'.
ENDIF.
DO.
READ DATASET gv_unix_file into lv_str.
IF sy-subrc <> 0.
exit. "exit do loop, file is done.
else.
TRANSFER lv_str to gv_unix_file_arc.
ENDIF.
ENDDO.Here is a sample code:
DATA: lv_string TYPE string,
lv_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
lv_i TYPE i.
DATA: result_tab TYPE match_result_tab.
DO 3 TIMES.
CONCATENATE 'A' lv_string INTO lv_string SEPARATED BY lv_tab.
ENDDO.
" this is how you need to find how many tabs are in your transfer work area...
FIND ALL OCCURRENCES OF lv_tab IN lv_string RESULTS result_tab.
DESCRIBE TABLE result_tab LINES lv_i.
WRITE:'No. of tabs found:', lv_i. -
How to count the number of Rows to be Updated before Update takes place..
Hi all,
I have a requirement, where i have to count the number of rows to be updated before updating it. SQL%ROWCOUNT gives the no. of rows updated ( after update takes place). How do i get to know the count of no. of rows to be updated/inserted/ deleted. I was looking for a simple solution, as above SQL%Rowcount. But i couldn't find any. I can use a Function and Return the value which will give me number of rows to be updated, But is there any Simple Logic other than this.. or any count function. Your Help is Appreciated. Thanks!If you really want to do this (I have no clue why you would need it), then you can piggy back on any existing pessimistic locking you may already have in place.
However, it would require two loops through the records of which you want to know the count before you update, and a second pass to update them.
I would really re-think the need for this, though.
SQL> create table t0304(c number);
Table created.
SQL> insert into t0304 select rownum from all_objects where rownum <= 10;
10 rows created.
SQL> commit;
Commit complete.
SQL> select * from t0304;
C
1
2
3
4
5
6
7
8
9
10
10 rows selected.
SQL> declare
2 cursor mycursor is select * from t0304 where mod(c,2) = 0 for update;
3 i number := 0;
4 begin
5 for r in mycursor loop
6 i := i + 1;
7 end loop;
8 dbms_output.put_line(i);
9 for r in mycursor loop
10 update t0304 set c = c + 20 where current of mycursor;
11 end loop;
12 end;
13 /
5
PL/SQL procedure successfully completed.
SQL> commit;
Commit complete.
SQL> select * from t0304;
C
1
22
3
24
5
26
7
28
9
30
10 rows selected.
SQL>Edited by: Steve Howard on Mar 4, 2011 5:57 PM -
How to count the number of 'True' outputs from an 'Equal?' function?
In my program, I have an 'Equal?' function which returns 'True' whenever x=y. How can I count the number of 'True' and display? I mean, for example, when it say True, the counter should display '1', when it say true next time the counter should display '2', like wise 3, 4.... so on. Can any one help me to do this? Is there any function which conts and display the number of 'true' outcomes?
Is your event structure in a while loop? Then that's where the shift register can go. But for portability a feedback node can be used if the VI is not reentrant.
Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously. -
How to count the number of deleted rows processed
Sybase ASE version: 15.7-SP52
Hi all,
I have a delete statement that will potentially delete millions of rows
DELETE from TAB_A where COL_A='Y'
The delete is long, at some point I'd like to know how many rows were deleted.
If I do SELECT COUNT(*) from TAB_A where COL_A='Y', the query should be locked because of the exclusive-lock held by the DELETE in progress.
If this is the case, how can I actually count the number of rows deleted so far?
Thanks all
SimonSimon
For deleting significant number of rows best practice is to delete rows in small batches of known size (e.g. 10 K) inside a while loop.
This keeps transaction log from filling up as well.
Also between two iterations of delete you can give some wait to make sure that you do not monopolize the server. Sleep could be for a fixed number of seconds (e.g. 5) or for randomized number say from 1 to whatever makes sense.
Typically "set rowcount " is used to set up the batch size and "waitfor delay" to sleep between iterations.
Global variable @@rowcount gives yo actual rows deleted. For the last batch this may be lower than the batch size you set up.
HTH
Avinash -
How to count the number of instances a record appears in a string
I have a move that imports Name, Department and Site from an
external CSV file, this part I managed to get working after many
weeks. I would like to be able to count the number of instances of
a specific Site “Glasgow” appears in the String. This
way I know how many lines to set.
Also can you add Dynamic text to a rollover button? I can get
the the text to display on the root but not on a button.
I am new to programming and Flash so apologies in
advance.Those which took time to read carefully *_iWork Formulas and Functions User Guide_* are aware of the availability of wildcard characters.
=COUNTIFI(range;"=text")
will do the trick.
Yvan KOENIG (VALLAURIS, France) lundi 26 avril 2010 17:36:34 -
How to count the number of Fridays and Saturdays between two dates
Hi every one ... If we want to count the number of Fridays and Saturdays between two dates, how would we do that ? !
Dates are ( 11-Feb-2010) to (19-May-2010)
how to do it in SQL
Edited by: khalidoracleit on Jul 28, 2010 5:51 AMsome nice coding here, I'm still amazed with what some people can do with "connect by". But I agree with some statements here that this can take "time", and to be honest, it's funny to see it working, but if you do not have a computer, just a calendar and some paper, would you go for "counting" so there must be a better solution?
The best working math in here is done by Aketi Jyuuzou, who writes so good English that I wonder why he still insists that he doesn't ;-)
Anyhow I "translated" that code to English, and I really like that math. Math is math and data is data.
ALTER SESSION SET NLS_DATE_LANGUAGE='ENGLISH';
WITH my_dates AS (
SELECT to_date('20100211','yyyymmdd') start_date,to_date('20100519','yyyymmdd') end_date FROM DUAL
UNION ALL
SELECT to_date('20100211','yyyymmdd') start_date,to_date('20100214','yyyymmdd') end_date FROM DUAL
UNION ALL
SELECT to_date('20100211','yyyymmdd') start_date,to_date('20100213','yyyymmdd') end_date FROM DUAL
UNION ALL
SELECT to_date('20100211','yyyymmdd') start_date,to_date('20100212','yyyymmdd') end_date FROM DUAL
SELECT to_char(start_date,'DD.MM.YYYY') start_date,to_char(end_date,'DD.MM.YYYY') end_date,
to_char(start_date,'DAY') start_weekday,to_char(end_date,'DAY') end_weekday,
end_date-start_date day_difference,
(next_day(end_date,'FRIDAY')-7
-next_day(start_date -1,'FRIDAY'))/7+1
+(next_day(end_date,'SATURDAY')-7
-next_day(start_date -1,'SATURDAY'))/7+1 as count_of_fr_and_sat
FROM my_dates;
START_DATE END_DATE START_WEEKDAY END_WEEKDAY DAY_DIFFERENCE COUNT_OF_FR_AND_SAT
11.02.2010 19.05.2010 THURSDAY WEDNESDAY 97 28
11.02.2010 14.02.2010 THURSDAY SUNDAY 3 2
11.02.2010 13.02.2010 THURSDAY SATURDAY 2 2
11.02.2010 12.02.2010 THURSDAY FRIDAY 1 1 -- andy -
How to count the number of AAA clients
Hi,
As we know, ACS5.2 is required with a base license-- supporting 500 network devices.
Sometimes there are lots of AAA clients or network devices that are authenticating simultanious. So my question is, how to count the network devices allowed to auth on ACS5.2? Does that only include network devices, or including both any network devices or AAA clients?
Rgds,
Laowu5017Hi,
ACS 5.x counts the number of AAA clients that are configured on the ACS.
Please note that AAA clients and networks devices is the same and they comply switches, routers, WLCs, or whatever other device configured under
Network Resources >
... >
Network Devices and AAA Clients
AAA Clients are NOT the AAA suplicants.
The end user clients PCs are the AAA suplicants, and for this there is no limit number.
HTH,
Tiago
If this helps you and/or answers your question please mark the question as "answered" and/or rate it, so other users can easily find it. -
How to count the number or rows in file
Hi Experts,
I am file as source and Oracle as target. My file containing the some data which is going to load to the target.
My requirement is that I want to count the number of rows which my file contains. Please help me how to count the total number of rows in file.
Thx,
Sahadeva.Hi,
You won't give a name DEST_USER_NAME:ODI will get these information.
it is important Command on source and Command on Source side .
-Pls write jython code on Command on Source side
-And Command On Target side Choose technology as Oracle and set logical schema to HR_logical
Sorry my mistake.İt is related jython syntax.Here is code:
import java.lang as lang
import java.sql as sql
import java.lang.String
import os
lang.Class.forName("<%=snpRef.getInfo("DEST_JAVA_DRIVER")%>")
cons=sql.DriverManager.getConnection("<%=snpRef.getInfo("DEST_JAVA_URL")%>", "<%=snpRef.getInfo("DEST_USER_NAME")%>", "<%=snpRef.getInfo("DEST_PASS")%>")
dblinks= cons.createStatement()
file1=open('EMP.txt','r')
count=0
line=file1.readline()
while line !='':
count+=1
line=file1.readline()
file1.close()
sqlQuery = "insert into HR.ETL_FILE_LOG (FILE_COUNT) values (count)"
rqQuery= dblinks.execute(sqlDBLink)
cons.close()
Regards
Maybe you are looking for
-
How to contact Apple in cases where Apps don't provide features they display
An App names "SB Settings" showed fake images of their product. Just want to know where to report such apps or should we just chargeback the transaction done at Apple Store.
-
After Effects Project with MOV. (RLE) files keep freezing system
Windows 8 Pro 64-bit Intell i7 processor AMD FirePro V7900 32 GIG DDR5 RAM After Effects CS6 runs perfectly smooth unless there are MOV.s with Animation Codec (RLE) present in a composition. The project will open up, it will display what looks like a
-
Where exactly is the 8i JVM?
I installed iAS 1.0.1 for NT, and chose the standard edition. This supposedly means that I should have gotten the 8i JVM, among other things. But where exactly is the VM located? The only copy of java.exe that I can find within the Oracle directory i
-
Where to get your home button fixed
my home button is broken on my ipod and i have assistive touch. but i am getting an iphone soon and would like to sell my ipod. how can i fix it or were can i get it fixed and for how much?
-
How can I copy my ipad2 contacts to iphone3
How can I copy my ipad2 contacts to iphone3s?