Chris Wilson Posted August 26, 2011 Share Posted August 26, 2011 combine('GPS LAT HW', 'GPS LAT LW') / 10000000 is the function I have had suggested, but as soon as I write it in my data logging maths section as a function to combine two 16 bit channels into one 32 bit and divide the result by 10000000 it barfs with: (0): Invalid number of arguments for function: 'combine'. 3 expected. What else does it want, anyone know? Thanks. Quote Link to comment Share on other sites More sharing options...
Chris Wilson Posted August 26, 2011 Author Share Posted August 26, 2011 Sorted it myself, well sort of. It should have been: combine16('GPS LAT HW', 'GPS LAT LW')/10000000 As Andy Blyth warned in another posting, negative numbers need care, unless a longitude of 427.1126709 has suddenly been created something is amiss converting negative values. Quote Link to comment Share on other sites More sharing options...
Andy Blyth Posted August 26, 2011 Share Posted August 26, 2011 Does the GEMS pro software offer an "IF" function? If it is available, you can check to see if the low word is negative before combining it with the high word. If it is negative, you need to add 65536 (0xFFFF), otherwise just use as-is. I tried the standard GEMS software but couldn't find any way to define maths channels. There doesn't appear to be any detailed documentation on the maths functions online. Quote Link to comment Share on other sites More sharing options...
Chris Wilson Posted August 26, 2011 Author Share Posted August 26, 2011 It does have an IF function, plus a whole caboodle more stuff. There's an issue though. The logger is seeing raw data off the CAN BUS, and none of the data GEMS sees is negative. Looking at the Motec stuff, before the maths in i2 does its stuff, some of the figures ARE negative. The ecu outputs what it outputs on the CAN, so I can't see how it's an ecu thing, somehow i2 is seeing negative figures and GDA is not, I'll attach tow screenshots, if I may, showing this. Both are from the same location within a few inches, albeit at different times, and at one point I move the GPS receiver around for a few feet in a pretty random way. If you can help at all I would be very grateful, I have now become obsessional about getting this working, but determination is being overcome by my pitiful grasp of the maths Cheers! If you like I can post screen shots of the maths function pages from the pro software, without the dongle (pay for to use the Pro version of GDA) you can't see it at all. Quote Link to comment Share on other sites More sharing options...
Andy Blyth Posted August 26, 2011 Share Posted August 26, 2011 If GEMS always sees positive numbers, that's not a problem. The high word can be negative or positive, the low word needs to be interpreted as positive. You need to create a maths function that if the high word is greater than 32767, subtract 65536. Then you can combine it with the positive low word. Quote Link to comment Share on other sites More sharing options...
Chris Wilson Posted August 26, 2011 Author Share Posted August 26, 2011 Thanks again Andy, what have I done wrong here? Quote Link to comment Share on other sites More sharing options...
Scott Posted August 26, 2011 Share Posted August 26, 2011 Try.. If(num>3267, num-65536, num) Not sure of the syntax of the program you are using though. Quote Link to comment Share on other sites More sharing options...
Andy Blyth Posted August 26, 2011 Share Posted August 26, 2011 try: combine16(if('GPS LAT HW'>32767,('GPS LAT HW'-65536),'GPS LAT HW'),'GPS LAT LW')/10000000 This compares 'GPS LAT HW' with 32767. If it's greater it feeds 'GPS LAT HW'-65536 into combine16, otherwise it just feeds the original value of 'GPS LAT HW'. Quote Link to comment Share on other sites More sharing options...
Chris Wilson Posted August 26, 2011 Author Share Posted August 26, 2011 I'll try that now, thanks guys! Here's the syntax page from the help file: The maths language has the following common syntactical elements: Comments Comments can be added to scripts as a memo of the authors intent or as an aid to other people understanding how the script works. A comment starts with a '#' character and the comment continues up to the next new-line character. Though it is not an error, it is good practice to start comments with capital letters and end them with a full stop. e.g. # Calculate Front Wheel speed. # avg_nonzero accounts for the fail-off # state of the wheel speed sensors. avg_nonzero('LF Wheel Spd', 'RF Wheel Spd') Numbers Floating point, integer and boolean numbers are supported. Integers can be specified as decimal (base 10) numbers by entering them naturally. e.g. 10 42 153 Integers may also be written in hexadecimal (base 16) notation by prefixing the number with '0x'. e.g. 0x1FFF 0xFFFFFFFF Floating point numbers are specified by including a decimal point. e.g. 0.1 5.6 5.0 Boolean numbers can be specified as 'true' or false' and are really handled as integers that are either zero (false) or non-zero (true). Numbers may also be explicitly cast to another type using one of the cast functions: int(5) real(0xFFFF) bool(false) Channel References Channels can be referred to in maths scripts by enclosing them in single quotes. e.g. 'Engine Speed' Unit References Units may be referenced within maths scripts by enclosing them in square brackets. e.g. [m/s] Additionally the quantity that a unit belongs to can be specified if the unit would otherwise be ambiguous: e.g. [speed:m/s] Units can be specified as conversions in scripts as a post-fix term to any expression. e.g. 10[m/s] 'Road Speed'[m/s] (5 * 8)[m/s] Operators The following operators are provided: Unary Prefix - Negates following number. e.g. -10 or -'Speed' + Has no effect, antonym of unary '-'. ! Logical NOT (boolean). e.g. true == !false Arithmetic + Addition - Subtraction / Division * Multiplication ** Exponentiation (i.e. x ** y === xy) % Modulo (remainder of integer division) Bitwise >> Right shift & Bitwise AND ^ Bitwise XOR | Bitwise OR Relational > More than >= More than or equal to == Equal to != Not equal to Logical && Logical AND (boolean) || Logical OR (boolean) Grouping Sub-expressions may be grouped by using parenthesis. An opening bracket '(' should be later followed by a closing bracket ')'. Bracketed expressions may be nested. e.g. 5 * (2 + (3 - 4)) Grouped expressions can be used to ensure that the order of evaluation is correct. e.g. (1 + 2) * (3 + 4) Is not the same as: 1 + 2 * 3 + 4 This is because multiply takes precedence over plus. As with normal algebra. Constants Constants are immutable named values. To use a constant in your script, refer to it by name. e.g. PI Functions Functions are referred to by name and are followed by an argument list, enclosed in brackets. Individual arguments should be separated by commas. e.g. cos(0.1) sin('Steering Angle') atan2('longitudinal G', 'Lateral G') Quote Link to comment Share on other sites More sharing options...
Chris Wilson Posted August 26, 2011 Author Share Posted August 26, 2011 Right! Now the figures have a correct sign, but the coordinates put the receiver about 60 miles south of where it really was, see the comparison with the Motec figures. Google Earth export shows the Motec figures to be spot on to a few yards, the GDA ones are way out (but in the same county, rather than in Russia's wheat belt, as they were before You patience is fabulous, so is my appreciation. Thanks again. Quote Link to comment Share on other sites More sharing options...
Scott Posted August 26, 2011 Share Posted August 26, 2011 That's the decimal thing I was talking about Chris. To go from decimal to mins and seconds you need to multiply the fraction by 0.6, to go the opposite way you divide by 0.6. That is the reason they are different, the answer you get from the function above gives you it in mins/secs whereas the other one is in decimal. In order to work it out you need to take everything after the decimal point and divide by 0.6 to get them both the same. Not sure exactly how you will do that in this program. What is the command list? In Excel I used "Fix" or "Rounddown",IIRC, to get it to shorten the 52.52665 (made up) to 52. I then subtracted 52 from the number giving 0.52665. I then divided by 0.6 and added to the 52 to get the decimal figure. Quote Link to comment Share on other sites More sharing options...
Andy Blyth Posted August 26, 2011 Share Posted August 26, 2011 Do you have a function along the lines of 'div()'? I think you'll need something like this to get the whole number of degrees. You'll need this to apply Scott's formula from the other thread. Failing that, is there a list of all the functions available? Quote Link to comment Share on other sites More sharing options...
Andy Blyth Posted August 26, 2011 Share Posted August 26, 2011 Do you have a function along the lines of 'div()'? I think you'll need something like this to get the whole number of degrees. You'll need this to apply Scott's formula from the other thread. Failing that, is there a list of all the functions available? What am I on about!? Scott's right, you need a function along the lines of RoundDown() or Floor(). Quote Link to comment Share on other sites More sharing options...
Chris Wilson Posted August 26, 2011 Author Share Posted August 26, 2011 Here we go: Quote Link to comment Share on other sites More sharing options...
Andy Blyth Posted August 26, 2011 Share Posted August 26, 2011 OK, it looks like you have a floor() function. Try this: (((combine16(if('GPS LAT HW'>32767,('GPS LAT HW'-65536),'GPS LAT HW'),'GPS LAT LW')/10000000)-(floor(combine16(if('GPS LAT HW'>32767,('GPS LAT HW'-65536),'GPS LAT HW'),'GPS LAT LW')/10000000)))/0.6)+(floor(combine16(if('GPS LAT HW'>32767,('GPS LAT HW'-65536),'GPS LAT HW'),'GPS LAT LW')/10000000)) Quote Link to comment Share on other sites More sharing options...
Scott Posted August 26, 2011 Share Posted August 26, 2011 Chris, can you see what "round(52.4)" and "Round(52.6)" gives. If they both give 52 then we're golden Edit: Missed floor lol. Quote Link to comment Share on other sites More sharing options...
Chris Wilson Posted August 26, 2011 Author Share Posted August 26, 2011 round(x) Returns the value of 'x' rounded to the nearest integer? Quote Link to comment Share on other sites More sharing options...
Chris Wilson Posted August 26, 2011 Author Share Posted August 26, 2011 OK Scott, I'll try plugging that in, thanks! Quote Link to comment Share on other sites More sharing options...
Scott Posted August 26, 2011 Share Posted August 26, 2011 Andy posted up what you need mate Quote Link to comment Share on other sites More sharing options...
Andy Blyth Posted August 26, 2011 Share Posted August 26, 2011 On a side note, that GEMS software looks great. I wish my ECU had a CAN output so I could use one of their loggers! I have to do it by hand with .csv files. Quote Link to comment Share on other sites More sharing options...
Chris Wilson Posted August 26, 2011 Author Share Posted August 26, 2011 No, round 52.4 gives 52, but round 52.6 gives 53, which sounds logical to me. Quote Link to comment Share on other sites More sharing options...
Scott Posted August 26, 2011 Share Posted August 26, 2011 No, round 52.4 gives 52, but round 52.6 gives 53, which sounds logical to me. Yeah, thats normal. No good to you though. Floor is what you're after Quote Link to comment Share on other sites More sharing options...
Chris Wilson Posted August 26, 2011 Author Share Posted August 26, 2011 On a side note, that GEMS software looks great. I wish my ECU had a CAN output so I could use one of their loggers! I have to do it by hand with .csv files. Did you get the Autronics? GDA Pro will import CSV files. Motec i2 pro will only import files from 3 other ecus / loggers, unless you buy a 10K licence to do what you will with it If you send me a smallish csv file I'll try importing it and see how it manages. GDA is very similar to i2. To be honest i2 is better, GDA will crash if you do funny things, i2 is solid as a rock. Quote Link to comment Share on other sites More sharing options...
Chris Wilson Posted August 26, 2011 Author Share Posted August 26, 2011 Floor works: Quote Link to comment Share on other sites More sharing options...
Scott Posted August 26, 2011 Share Posted August 26, 2011 I think you missed the main one mate lol. (((combine16(if('GPS LAT HW'>32767,('GPS LAT HW'-65536),'GPS LAT HW'),'GPS LAT LW')/10000000)-(floor(combine16(if('GPS LAT HW'>32767,('GPS LAT HW'-65536),'GPS LAT HW'),'GPS LAT LW')/10000000)))/0.6)+(floor(combine16(if('GPS LAT HW'>32767,('GPS LAT HW'-65536),'GPS LAT HW'),'GPS LAT LW')/10000000)) 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.