Trig Functions

Ok, I've been trying to to find a way of using trig functions in my code, but I've been having nothing but problems.
I've been using the henson Float class, available at:
http://henson.newmail.ru/j2me/Float.htm
But the answers it gives me for the cos and sin functions are pure nonsense. I'm trying to convert the degrees to radians and then run the cos and sin functions on them.
It seemed to work fine for a test value of 60 degrees (1.047 radians), giving me the approximately correct results of cos 1.047 = 0.5001 and sin 1.047 = 0.866
But when I try it with anything else the results are utterly wrong. For example 45 degrees (2 radians), instead of getting 0.707 for both it gives me cos 2 = -0.416 and sin 2 = 0.909 ?
Why does it work for only the one value ?
Has anybody got this float class to work, ever ?
Has anybody got any alternatives ?
Please help me , I'm getting annoyed and desperate for a solution. I've also tried using MathFP, but that kept giving me wrong class name error.

It is giving you the correct values for what you give it. 45 degree is PI/4 radians, not 2. I would suggest you check your degree to radian conversion formula. Degrees*PI/180 has always worked for me. GIGO

Similar Messages

  • Grapher having trouble with trig functions

    Well I thought that I could make some cool visuals for my math class by using grapher instead of just making charts and graphs in Excel on my pc, but no dice with that idea. I created all the different variables (and how they related to x, ie x^2*(5-x6)/x=m) and it was pretty cool how it would all come together and I could use those variables in other equations instead of writing it all out (stuff like y=4x^m-m/5). (Those are examples, not anything I used)
    Everything seemed fine until I tried to use a cosine function in one of the equations. It seemed really intuitive and recognized cos as cosine and not the variables c, o, and s multiplied, so I thought "great!" Then when I entered it the graph didn't appear anything like it should have. It gave me a Richter scale instead of a slightly curved line. I spent about half an hour trying to find my own error but then realized maybe there was something wrong with the program. I tried just plain old cos(x) and found that it was completely off. Instead of traveling from 0,1 to 180,-1 like it should have, it went from 0,1 to 3.1475,-1. This was way off so I tried a sine function and that did the same exact thing (having a period of roughly 6.295 instead of 360!). These functions were way off, and I'm using an intel macbook from my school (with 10.5), so I thought maybe someone changed the settings, so I tried them them on my aunts g4 macmini (10.4.11 I think) and it gave me the same problem!
    Anyway what's wrong with the trig functions for Grapher and how can I fix them?

    Emzz, I'm running 10.5.5 (Intel) and Grapher v2.0. My version of Grapher supports changing Trigonometric Mode, so the absence of this option seems to have nothing to do with Leopard.
    But let's do some Math now. As you surely know the cosine has (besides others) a root at 90 Degrees in the unit circle. Now let f : (angle in Degrees) -> (length of the corresponding arc of the unit circle) be a mapping. For 90 Degrees f yields 0.5*Pi. That means cosine has a root at 0.5*Pi in Radian unit.
    Now, if you swith Grapher's Trigonometric Mode from Degrees to Radian, cosine will no longer have a root at 90 but at approximately 1.57. Hope that explains a bit...
    By the way, Radian is the standard unit of angular measurement when it comes to trigonometric functions. For more details about Radian see [this article at Wikipedia|http://en.wikipedia.org/wiki/Radian] (click the link to be redirected).
    I suggest you close this topic because, as you already noted yourself, your initial question is answered.
    Good computing.
    floba
    (MN576)
    Message was edited by: floba

  • Trig functions in the Math class

    One of the techniques suggested to master for the Java Programmer exam is using the trigonometry methods in the Math class. Does that mean that on the exam I would need a trigonometry knowledge or is it enough to be familiar with their signature ?

    No trig knowledge - just questions on the Java language, including method signatures. Check out the various mock exams such as at http://www.javaranch.com/certfaq.jsp

  • Using Trig Functions in java

    I am trying to use the fuctions of sin cosine and tangent in my program how would you implement them into a program.

    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Math.html

  • Error in running a function to convert coordinates in degrees to decimal for EXCEL VBA

    For your information, I have 3 cross-posts regarding this question - and all I can said there is still no firm solution regarding this error.
    1) http://stackoverflow.com/questions/27634586/error-in-running-a-function-to-convert-coordinates-in-degrees-to-decimal-for-exc/27637367#27637367
    2) http://www.mrexcel.com/forum/excel-questions/826099-error-running-function-convert-coordinates-degrees-decimal-excel-visual-basic-applications.html#post4030377 
    3) http://www.excelguru.ca/forums/showthread.php?3909-Error-in-running-a-function-to-convert-coordinates-in-degrees-to-decimal-for-EXCEL-VB&p=16507#post16507
    and the story of the error is as below:
    Currently I am working on VBA excel to create a widget to verify coordinates whether it lies under the radius of ANOTHER predefined and pre-specified sets of coordinates.
    In the module, I want to convert the coordinates from degrees to decimal before doing the calculation - as the formula of the calculation only allow the decimal form of coordinates.
    However, each and every time I want to run the macros this error (Run-time error '5', invalid procedure call or argument) will appear. Then, the debug button will bring me to below line of coding:
    degrees = Val(Left(Degree_Deg, InStr(1, Degree_Deg, "°") - 1))
    For your information, the full function is as below:
    Function Convert_Decimal(Degree_Deg As String) As Double
    'source: http://support.microsoft.com/kb/213449
    Dim degrees As Double
    Dim minutes As Double
    Dim seconds As Double
    Degree_Deg = Replace(Degree_Deg, "~", "°")
    degrees = Val(Left(Degree_Deg, InStr(1, Degree_Deg, "°") - 1))
    minutes = Val(Mid(Degree_Deg, InStr(1, Degree_Deg, "°") + 2, _
    InStr(1, Degree_Deg, "'") - InStr(1, Degree_Deg, "°") - 2)) / 60
    seconds = Val(Mid(Degree_Deg, InStr(1, Degree_Deg, "'") + _
    2, Len(Degree_Deg) - InStr(1, Degree_Deg, "'") - 2)) / 3600
    Convert_Decimal = degrees + minutes + seconds
    End Function
    Thank you.
    Your kind assistance and attention in this matter are highly appreciated.
    Regards,
    Nina.

    You didn't give an example of your input string but try the following
    Sub test()
    Dim s As String
    s = "180° 30' 30.5""""" ' double quote for seconds
    Debug.Print Deg2Dec(s) ' 180.508472222222
    End Sub
    Function Deg2Dec(sAngle As String) As Double
    Dim mid1 As Long
    Dim mid2 As Long
    Dim degrees As Long
    Dim minutes As Long
    Dim seconds As Double ' or Long if only integer seconds
    sAngle = Replace(sAngle, " ", "")
    mid1 = InStr(sAngle, "°")
    mid2 = InStr(sAngle, "'")
    degrees = CLng(Left$(sAngle, mid1 - 1))
    minutes = CLng(Mid$(sAngle, mid1 + 1, mid2 - mid1 - 1))
    seconds = Val(Mid$(sAngle, mid2 + 1, 10)) ' change 10 to 2 if only integer seconds
    Deg2Dec = degrees + minutes / 60 + seconds / 3600
    End Function
    As written the function assumes values for each of deg/min/sec are included with unit indicators as given. Adapt for your needs.
    In passing, for any work with trig functions you will probably need to convert the degrees to radians.

  • How to use some math functions?

    Hey everyone,
    In this days i building a calculator and i need to use so
    Trigo functions, how can i use them? have some table
    with all the math library functions?
    Thanks so much for the helpers!!

    To do trig in Objective-C you use the standard C trig functions. 
    double sin()
    double cosin()
    etc.

  • How to use drivers libraries functions

    I have 3 problems:
    1. I have downloaded the functions libraries of the hp plug
    and play drivers to comunicate with my PC via HPIB, but now
    I don't know how can I access to them. Can anybody help me?
    2. I am taking dates from several channels at a time, and
    the arrive as a array of dates for each channel. I need to
    represent at the same time each data comes the maximun and
    minimun value, but I can not because it is not one but a
    collection of values I get.
    3. When I open two screens at the same time, one of them is
    all the time blinking; i would like to avoid this but i
    don't know how.
    I will be very grateful is anyone could help me.
    * Sent from AltaVista http://www.altavista.com Where you can also find related Web
    Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful

    To do trig in Objective-C you use the standard C trig functions. 
    double sin()
    double cosin()
    etc.

  • Calculating trigonometric functions

    Hi
    sorry for my silly question but i am new in using multisim
    i have a voltage or it can be considered as an angle.i want to calculate the sine & cosine of this angle to use the result as inputs to another circuit.
    where can i calculate the trigonometric functions in the multisim?.

    Sounds like you need an ABM source.  If you angle is a voltage
    output, simply add an ABM for each trig function referencing your
    output.  Then change the "value" parameter to the following: 
    "sin(V(phase))"
    You can find the ABM_VOLTAGE component in the Master Database under "Sources".
    See here for more info on ABM usage.
     -J
    Attachments:
    abm_example.ms10 ‏81 KB

  • Doing something the DAQmx way that doesn't fit? (Triggered counter on PXI 6608)

    Hi,
    I want to create a counter with my PXI6608 that is triggered with an external input, then counts up. I then want to be able to read the count in LabVIEW and hence determine the time since the trigger. I have achieved this before with old-style code, but it is not clear how to do it the DAQmx way. In particular, I can't create a task because what I'm looking to do doesn't seem to fit in with any of the pre-envisaged DAQmx task templates.
    Can anyone help? I'm assuming there's some way to create an 'empty' DAQmx task so I can fill in the details with property nodes?
    Cheers
    Lee
    Solved!
    Go to Solution.

    You'll want to make an edge count task and set the source to be one of the internal timebases using a DAQmx property node (set it before starting the task):
    The trigging functionality you're looking for is called an "arm start trigger" in DAQmx.  It's configured through a property node (also before starting the task):
    I'm not sure what you're getting at with regards to the "empty" DAQmx Task.  Typically you'll use the standard API to set typical properties and the property nodes for more advanced functionality so you'll end up with a combination of the two.  In many cases you could replace the DAQmx API with property nodes (for a fun example of this, open up the DAQmx Timing VI), but odds are you might be forgetting something important so I would always suggest using the VIs and then tacking on property nodes for additional functionality when necessary.
    If you're using LV 2012, this example should get you started (or if not, the picture still shows you what the task would look like).
    Best Regards,
    John Passiak

  • Pre-Cal Program not working as expected

    Ok, my Pre-Cal teacher asked us the following question, and said that we can make a computer program to solve it if we want. So the question is:
    If your calculator reciprocal button (1/x) breaks, you can use a sequence of 4 trig and arc trig function butons to replace the reciprocal button. What is that sequence?
    So I made the following program, to test all of the possibilities (in an admittedly very inefficient way), and print out the correct one.
    public class Test
         public static void main (String[]args)
              int num = 2;
              int cnt = 0;
              double correctAnswer = 1/num;
              double x;
              int temp;
              String[] funcs = new String[4];
              boolean isSolved = false;
              while(!isSolved)
                   x = num;
                   for(int y=3; y>=0; y--)
                        temp = (int)(Math.random()*6+1);
                        if(temp==1)
                             x=Math.sin(x);
                             funcs[y]="sin";
                        else if(temp==2)
                             x=Math.cos(x);
                             funcs[y]="sin";
                        else if(temp==3)
                             x=Math.tan(x);
                             funcs[y]="tan";
                        else if(temp==4)
                             x=Math.asin(x);
                             funcs[y]="arcsin";
                        else if(temp==5)
                             x=Math.acos(x);
                             funcs[y]="arccos";
                        else if(temp==6)
                             x=Math.atan(x);
                             funcs[y]="arctan";
                   if(correctAnswer-.0025<=x && correctAnswer+.0025>=x)
                             isSolved =true;
                   if(++cnt %1000==0)
                        System.out.println(cnt);
              System.out.println(funcs[0] + " "+funcs[1] + " "+funcs[2] + " "+funcs[3]);     
    }A few side notes:
    int num can be anything, I just set it to 2 for simplification purposes.
    int cnt is just used so I can see how many times the while loop has been running.
    At this point, I don't want the answer to the question as much as I want the program to function properly.
    It's a basic program, yet I can't figure out why it doesn't work. Even if the while loop runs 13,000,000 times it still doesn't get the correct answer, any ideas?

    dk00111 wrote:
    Ah, I forgot to cast the correctAnswer as a double. Thanks, it works now! (disregard the username change)I sense you're still misunderstanding, so I decided to follow up.
    The issue isn't that you weren't casting your expression to a double before assigning to correctAnswer. That cast is implicit as an integer is automatically promoted to a double, since it is a widening conversion (see here).
    What you had before was like this:
    double d = 1 / 5;
    System.out.println(d); //0.0In this case, we have an integer divided by an integer, and so the result is (naturally!) an integer. Since 1 / 5 is truncated to 0, that's the result of the expression.
    "Casting to a double" would be this:
    d = (double)(1 / 5);
    System.out.println(d); //0.0But that's no different! The cast is pointless, as it happens anyway when you assign the result of the expression to d. 1 / 5 is still occurring with integer operands.
    Instead, based on the fact that it worked, I'm guessing what you did was this:
    d = (double)1 / 5;
    System.out.println(d); //0.2 That's not casting the result of (1 / 5), it's casting 1 to a double, and then dividing by 5. It's equivalent to this:
    d = ( (double) 1 ) / 5;Since now one of the operands is a double, the result of the expression is a double, so you get the expected 0.2.
    You could get the same result by doing this in your code:
    double correctAnswer = 1.0 / x;As the literal 1.0 is obviously not an integer, but a double, so x is promoted to a double and the division occurs on two doubles instead.

  • Geturl not working of ferris wheel effect

    Hi,
    Thanks to Rob i have managed to get the effect i want and he
    has kindly given me the code to add a geturl to each of the images
    on the ferris wheel effect. The only thing is that when i view it
    it does not work so maybe i am missing somthing, see what you guys
    think:
    // create an onRelease function for each of the movieClips in
    the
    //objectsInScene array...
    for (i in objectsInScene) {
    objectsInScene.onRelease = function() {
    useLink(this);
    // this function will figure out which pane was clicked on
    and execute a
    //getURL for a specific URL...
    //substitute your own urls...
    function useLink(thisOne) {
    switch (thisOne) {
    case theScene.pane :
    getURL("firstURL.html", "_blank");
    break;
    case theScene.pane1 :
    getURL("secondURL.html", "_blank");
    break;
    case theScene.pane2 :
    getURL("thirdURL.html", "_blank");
    break;
    case theScene.pane3 :
    getURL("fourthURL.html", "_blank");
    break;
    case theScene.pane4 :
    getURL("fifthURL.html", "_blank");
    break;
    case theScene.pane5 :
    getURL("sixthURL.html", "_blank");
    break;
    case theScene.pane6 :
    getURL("seventhURL.html", "_blank");
    break;
    case theScene.pane7 :
    getURL("eighthURL.html", "_blank");
    break;
    case theScene.pane8 :
    getURL("ninthURL.html", "_blank");
    break;
    case theScene.pan9 :
    getURL("tenthURL.html", "_blank");
    break;
    case theScene.pane10 :
    getURL("eleventhURL.html", "_blank");
    break;
    case theScene.pane11 :
    getURL("twelvthURL.html", "_blank");
    break;
    case theScene.pane12 :
    getURL("thirteenthURL.html", "_blank");
    break;
    break;
    case theScene.pane13 :
    getURL("fourteenthURL.html", "_blank");
    break;
    case theScene.pane14 :
    getURL("fifteenthURL.html", "_blank");
    break;
    default :
    trace ("uh oh");
    Any suggestions please post.
    Thanks,
    Neil

    This is all of my code:
    // create a scene movieclip to contain all 3D elements
    // and center it on the screen.
    this.createEmptyMovieClip("theScene", 1);
    theScene._x = 290;
    theScene._y = 220;
    // now we'r going to create an array to keep track of all the
    // objects in the scene. That way, to position all the
    objects
    // you just need to loop through this array.
    objectsInScene = new Array();
    var paneArray:Array = ["pane", "pane1", "pane2", "pane3",
    "pane4", "pane5", "pane6", "pane7", "pane8", "pane9", "pane10",
    "pane11", "pane12", "pane13", "pane14"];
    var paneArray:Array ;
    paneArray[0] = "pane";
    paneArray[1] = "pane1";
    paneArray[2] = "pane2";
    paneArray[3] = "pane3";
    paneArray[4] = "pane4";
    paneArray[5] = "pane5";
    paneArray[6] = "pane6";
    paneArray[7] = "pane7";
    paneArray[8] = "pane8";
    paneArray[9] = "pane9";
    paneArray[10] = "pane10";
    paneArray[11] = "pane11";
    paneArray[12] = "pane12";
    paneArray[13] = "pane13";
    paneArray[14] = "pane14";
    // no camera, but a rotation will be needed to keep track of
    the
    // spinning involved (though its the same as the camera)
    spin = 0;
    // focal length to determine perspective scaling
    focalLength = 250;
    // the function for controling the position of a friend
    displayPane = function(){
    var angle = this.angle - spin;
    var x = Math.cos(angle)*this.radius;
    var z = Math.sin(angle)*this.radius;
    var y = this.y;
    var scaleRatio = focalLength/(focalLength + z);
    this._x = x * scaleRatio;
    this._y = y * scaleRatio;
    this._xscale = this._yscale = 40 * scaleRatio;
    // on top of the normal scaling, also squish the
    // _xscale based on where in the rotation the pane is
    // since you would be looking at its side when at a z
    // of 0, it would be at its thinnest which would be
    // 0 since its a completely flat pane. So for that,
    // we can use the trig function of z (sin) to squish the
    // _xscale based on its position in z.
    this.swapDepths(Math.round(-z));
    // attach each pane in a loop and arrange them in a
    // circle based on the circumference of the circle
    // divided into steps
    angleStep = 2*Math.PI/15;
    for (i=0; i<15; i++){
    attachedObj = theScene.attachMovie(paneArray
    , "pane"+i, i);
    attachedObj.angle = angleStep * i;
    attachedObj.radius = 160;
    attachedObj.x = Math.cos(attachedObj.angle) *
    attachedObj.radius;
    attachedObj.z = Math.sin(attachedObj.angle) *
    attachedObj.radius;
    attachedObj.y = 30;
    attachedObj.display = displayPane;
    objectsInScene.push(attachedObj);
    panCamera = function(){
    // rotate camera based on the position of the mouse
    spin += this._xmouse/4000;
    // Now, with the camera spun, you need to perform the
    rotation
    // of the camera's position to everything else in the scene
    for (var i=0; i<objectsInScene.length; i++){
    objectsInScene.display();
    // make each figure run backAndForth every frame
    theScene.onEnterFrame = panCamera;
    // create an onRelease function for each of the movieClips in
    the
    //objectsInScene array...
    for (i in objectsInScene) {
    objectsInScene.onRelease = function() {
    useLink(this);
    // this function will figure out which pane was clicked on
    and execute a
    //getURL for a specific URL...
    //substitute your own urls...
    function useLink(thisOne) {
    switch (thisOne) {
    case theScene.pane :
    getURL("
    http://www.totalamber.com/default.htm",
    "_blank");
    break;
    case theScene.pane1 :
    getURL("secondURL.html", "_blank");
    break;
    case theScene.pane2 :
    getURL("thirdURL.html", "_blank");
    break;
    case theScene.pane3 :
    getURL("fourthURL.html", "_blank");
    break;
    case theScene.pane4 :
    getURL("fifthURL.html", "_blank");
    break;
    case theScene.pane5 :
    getURL("sixthURL.html", "_blank");
    break;
    case theScene.pane6 :
    getURL("seventhURL.html", "_blank");
    break;
    case theScene.pane7 :
    getURL("eighthURL.html", "_blank");
    break;
    case theScene.pane8 :
    getURL("ninthURL.html", "_blank");
    break;
    case theScene.pan9 :
    getURL("tenthURL.html", "_blank");
    break;
    case theScene.pane10 :
    getURL("eleventhURL.html", "_blank");
    break;
    case theScene.pane11 :
    getURL("twelvthURL.html", "_blank");
    break;
    case theScene.pane12 :
    getURL("thirteenthURL.html", "_blank");
    break;
    break;
    case theScene.pane13 :
    getURL("fourteenthURL.html", "_blank");
    break;
    case theScene.pane14 :
    getURL("fifteenthURL.html", "_blank");
    break;
    default :
    trace ("uh oh");
    }

  • Multiple use of the Indicator terminal

    I've developed a working calculator in LabView and for each of the mathematical operations on the two number control terminals, the result gets displayed on the separate indicator terminal for that particular operation. I've a final indicator terminal that is visible on the front panel, and it should show the result of the operation from the individual indicator terminals, if any of them has a true value. But the final indicator terminal doesn't work. I would like to know how can a result be displayed on the final indicator terminal for any of the operations being true. I've tried to build an array of each of the individual indicator terminals and I search the array for any indicator having a valid result and try to show it on the main indicator terminal, but it doesn't work. Kindly help me out.

    Hello Suhail,
    I looked over your calculator vi and can see there are many issues.
    1. Your while loop doesn't loop more than once because you have the "=" button wired to the "Run while True" terminator; you need to change the terminator to "Stop when True".
    2. Your function button text, which is the button's "Label", "covers up" a lot of the button space, you have to click a corner of the button to operate it. Use the button "Caption" property to display the text, do not show the label.
    3. You are trying to use the array search function to determine which function generated a non-zero result. The array search gives you the index into the array with your desired result, not the result itself. Even if you fix this, what happens if the result of the calculation is zero? It won't be found; even though the indicator will show zero, you may want a better way to determine which calculation was used.
    4. Some of your calculations, like the trig functions, are made in both the True and False case check on the function button, these functions always generate a value and cause the array search to return the wrong index.
    5. You may want to change the button mechanical actions to something like "latched when pressed" instead of "switch when pressed", then the vi will start with the buttons "off"; running this vi to test it requires you revert the buttons to default values before running again.
    You could simplify this vi by using the event structure in the while loop to perform the selected calculation when one of the function buttons switches to True. You could update a shift register in the while loop with the value from the most recent calculation. There are several options here, I'm not sure what functionality you really need and want - do you need a separate display for every type of calculation? Waht do you really want displayed in the main indicator before the "=" key is pressed?
    Good Luck - Brian

  • Waveform chart X-Axis reverses itself when upper limit is edited in Absolute Time - problem may be linked to Timestamp Control?

    I've seen this problem for some time now, and it still exists in the Silver toolset Waveform Chart in LV 2012.  If the chart is in strip mode, and you edit the upper limit value to a point in the future, the X-Axis will invert (higher values/ later time to the left), to the limit of the Chart History length.  This happens whether the chart is active (logging data on a compiled executable) or even when in design mode, though it's more consistent when there's data in the chart.  It's not history length related as far as I can tell, as I set the length to 7 days of sampling @ 1-second intervals (605K), and it happens when I try to set the end time to an hour in the future with only a few minutes of data collected - suddenly the right Absolute Time becomes the time my last sample point was collected, while the left Absolute Time becomes nearly 7 days in the future (so neither end point is what I was setting it to).
    It's nice that the chart gives the option of editing the limits, but as such, it's important that they work as you would expect them to.
    Also - until this is addressed, is there a way to lock it against editing?  Until a fix is made, my workaround is to put a transparent button over the range start & end points, and a transparent flat rectangle above all other mid-range points, and pop-up a data entry form with a Timestamp control to allow editing.  Unfortunately, this doesn't work as I would expect, as typing "11 AM" in the Timestamp control over a prior value of say "10:05:34.232 AM" ends up becoming "11:05:34.232 AM" instead.  ???  Another error - or is this by design?  If it's by design, is there an option to make it behave as I would prefer (11 AM = 11:00:00.000 AM), as Excel behaves with timestamps?  I can't help but suspect this may be linked to the chart axis issue.
    Also - I just built a simplified chart modeled somewhat on my current project, and could not get this to recur.  BUT... had the strangest thing happen:  My sample data was generated using the Trig functions for Sine and Cosine, and at one point my waveforms distorted on the display, so I'm attaching that here plus the simplified chart project.
    Last - my system is LV 2012 on Win7 Pro-x64.
    Thanks!
    Erik
    Attachments:
    Chart data distorted.png ‏45 KB
    Waveform Chart Flaw.zip ‏17 KB

    I am not so sure that this is a bug, and I have not been able to reproduce this behavior that you are describing. 
    But you can lock it from editing by right-clicking on the graph and go to Properties>>Appearance>>Enabled State --> Disabled
    Also, word of advice for the future: You will get more replies from the community with shorter posts and keeping it to one question per post. Summarize what the issue is, and put the detailed documentation and instructions to reproduce in the actual VI. 
    Huntington W
    National Instruments
    Applications Engineer
    ***Don't forget to give Kudos and Accepted as Solution where it is deserved***

  • What does the garmin45.vi actually do?especially all the stuff at the bottom of the diagram page.cheers

    see above
    Attachments:
    Garmin45.vi ‏621 KB
    timeset.bat ‏1 KB
    bargraph.llb ‏66 KB

    It is parsing the NMEA0183 text strings returned from the GPS receiver via the serial port and displaying the information.
    I am not sure what you are referring to at the bottom of the diagram page. The sequence structure in the lower right with the trig functions is displaying the satellite lock info on the satellite map.
    The set button sets the PC's clock to the satellite time using the System Exec to run a batch file called Timeset.bat
    The small while loop executes until it has a full NMEA 0183 sentence then the 'string subset' primitives strip out a portion of text from the sentence that identifies the type of sentence. It then matches the type of sentence to the various types possible (All the pink string stuff at the top). Depending on the type of sentence, it then passes the string to the appropriate part of the diagram where it is further parsed and converted to the relevant type of information.
    For example:
    The sentence for time, lat, long etc. from a Garmin45 must start with a $GPRMC in the string. All sentences start with '$' (and end with -). The '$' is stripped by the while loop, then a match is found between the first 5 bytes of the string and 'GPRMC'.
    The first 2 characters, 'GP', identify the talker. GP indicates global positioning system (as opposed to 39 other possible talker devices, icluding depth sounders, voyage data recorders, Loran C, etc. The NMEA standard identifies the means for different marine equipment to communicate with each other.)
    The next 3 characters, 'RMC', identifies the type of sentence. RMC is indicative of the "Recommended Minimum Specific GNSS Data". This identifies the structure of the information contained in the sentence.
    That particular structure is:
    $aaRMC,bbccdd.dd,e,ffff.ff,g,hhhhh.hh,i,j.j,k.k,llllll,m.m,n,o*pp
    where,
    aa = 2 character talker identifier
    RMC = Sentence formatter mnemonic code
    bbccdd.dd = Universal Time Code of position fix
    e = status (A=valid V=receiver warning)
    ffff.ff = lattitude
    g = lattitude North/South
    hhhhh.hh= longitude
    i = longitude North/South
    j.j = ground speed in knots
    h.h = course over ground, degrees True
    llllll = date (mmddyy)
    m.m = magnetic variation, degrees
    n = E/W
    o = mode (A,D,E,M,S,N or V)
    * = checksum delimeter
    pp= checksum
    = sentence terminator (ASCII 13 + ASCII 10 character)
    Important: I don't know if this sentence explanation actually is a byte count (as the author is parsing) or an explanation of the data format within the ","'s. Ground speed is identified as x.x knots, which would seem to indicate that 9.9 knots is the fastest if it is a byte count. On the other hand it may indicate that ground speed is a fractional representation between the nth and the nth+1 comma. As I stated in my earlier post) my receiver uses a Rockwell binary protocol (which is a lot more fun than this text - NOT!!) but my OEM software definitely reports ground speeds faster than 9.9 knots.
    Anyway you can see where the author is parsing this information for the RMC sentence type, based on byte position in the string, directly under the case statement for setting the PC's time.
    As written, er wired, it appears that the while loop continually processes the last received data for each sentence type each time it receives any new sentence and executes, regardless of whether the data for that type of sentence has changed or not. i.e. if a different type of sentence is received the old RMC sentence will again be parsed from the shift register where it is stored. Several types of sentences are identified and stored in their respective shift register but no parsing is performed and no information is gleaned from them.
    There are many types of sentences and some manufacturers have additional sentences identified as proprietary for additional info.
    Given this information you should be able to examine your received data for the basic GPS information. Note that my Delorme Earthmate receiver transmits some info (sentence types for NMEA 0183 receivers) on a regular basis while some is received only intermitently, so don't assume that what you are seeing coming in from the serial port is all that you will ever see.
    Hope this helps. Good Luck!

  • Calculator bugs

    The standard Mac Calculator v4.2 (the lastest version as of writing) has some basic bugs it seems...
    Try typing each of these. I'm using 15 decimal places in scientific mode, in Degrees, not in Reverse Polish (RPN) mode:
    1E1, x^2, x^2 Produces "Error" but 10, x^2, x^2 succeeds
    1,1/x,x!,x! Produces "Error". Fails on other initial numbers too.
    2,1/x,cos,cos Produces "Error".
    2,1/x,=,cos,cos is OK though.
    Similarly x!,1/x,x!,x! produces "Error"
    2,M+ causes all functions on the left (trig, power, exp etc) to stop (presumably this is as designed). But you can still press 1/x, if you press it before any other buttons.
    Any number,y^x,PI,= gives the result as PI
    Any number,y^1/x,PI,= gives the result as PI
    Any number 'q',y^x,RN,= gives the result as RN + 10q for q < 1E16
    Any number 'q',y^1/x,RN,= gives the result as RN + 10q for q < 1E16
    1E16,=,y^x,RN,= gives the random number, but 1E16,-,M+,C,MR,y^x,RN,= gives "1e+17"
    1E16,=,y^x,RN,= gives the random number, but 1E16,-,M+,C,MR,y^x,RN,= gives "1e+17"
    9.99999999999999E127, =, =, = Produces odd results: "1E+128","Not a Number","Error"
    And finally a harder one to get right:
    1E22,sin (in radians) gives 0 but the correct answer is -0.8522008497671888017...
    All the above work fine on the standard calculator for another OS I could mention. The command line 'bc' tool would work fine too I imagine.

    typewriter wrote:
    I'll add one more MAJOR calculator bug to the list.
    The trig functions are completely wrong.
    Examples :
    COS(135) --> .707 (in degrees - should be negative)
    I get - 0.707
    COS(3) --> .989 (in radians - should be negative)
    I get -0.99
    SIN(-45) --> .8509 (degrees - should be negative)
    I get -0.7091 - you are still in radians mode and even there the answer I get is -0.8509
    Wrong wrong wrong. I can't even conceive HOW these could go wrong. Wouldn't the COS button on the calc just use the cos() function in the code?
    You are correct about being wrong, but I cannot duplicate it on my calculator. The error is on your system. I believe you have a corrupt file somewhere.
    And after pressing the Cos button:
    Message was edited by: nerowolfe
    Message was edited by: nerowolfe

Maybe you are looking for

  • IOS 5.0.1 glitch with address book and text messages!

    Since updating to the newest software, my iphone 4s no longer recognizes contacts in my address book.  So when a text comes through it doesn't have a contact assigned to it.  Same thing when a call comes through, just the phone number shows up.  Also

  • Exporting DV back to a Samsung VP-D351

    Hi, Could anyone tell me if they have been successful in exporting DV back to a Samsung VP-D351 camera within iMovie? I can transfer DV from the D351 to the iMac but after editing the movie I cannot copy it back to the camera, I’ve tried all the sugg

  • Video Yearbook - how  to title photos

    I am making a video yearbook of my students. i try to make a title for the photos I got from I photo, but the kids name appears on all of the kids. How can I put a kids name only on that child's photo? Please help, I have a deadline!

  • Abnormal termination of runform when PROCEDURE is used as Query Data Source Type

    I created a package with a procedure that returns a table of records. This procedure tested OK in SQLPLUS. I then created a form and in this form a block that used this procedure as the Query Data Source Name, and of course the Query Data Source Type

  • Re: MB51 report

    Hi guru's. My end user wish to include some more fields in the MB51 standard  report, Is it possible to add fields like reference bill No, purchase invoice No, credit Note No, debit note No.etc., Please its urgent full points will be awarded. regards