Show Posts
Pages: 1 ... 42 43 [44] 45 46 ... 99
646  Using Arduino / Project Guidance / Re: Fastest possible search in small arrays with different methods on: December 18, 2013, 03:13:47 pm
smoes:
you can ignore the sample data. It is just an example and does not relate to the real data, as the OP says.

It will work fine for a search algorithm, but not a hashing one like you provided.
647  Using Arduino / Programming Questions / Re: What does the "?" and ":" do in this Code on: December 18, 2013, 10:23:03 am
Really cjdelphi?

How do I know what variable gets assigned to in your syntax?
What if you want to assign to a variable that doesn't show up anywhere else in the expression?

i.e.
Code:
y = (x>10)?(30):(40);

Your syntax is the one that makes no sense.
648  Using Arduino / General Electronics / Re: Calculating inductance on: December 18, 2013, 10:00:51 am
The impedance is:
Z=2*pi*f*L

so if you want the inductance at a given impedance:

L = Z/(2*pi*f)

In this case:
16/(2*3.14159*1000) = .00255

so .0033 is the closest standard value.
649  Using Arduino / Project Guidance / Re: Fastest possible search in small arrays with different methods on: December 17, 2013, 05:47:12 pm
holmes4:
If addr is the correct type, the sizeof() is not required and will in fact cause problems. The compiler is smart enough to know that when using pointer arithmetic the jump is scaled to the size of the array, so if you add 2 to a pointer it will point to the second object whether a byte *, long * or float *.

650  Using Arduino / Project Guidance / Re: Fastest possible search in small arrays with different methods on: December 17, 2013, 05:10:12 pm
wildbill:
From the OP:
Quote
The code example below is only showing test data and not real values. Worth to mention the arrays only hold around 60-80 values each.

You might try a large switch/Case. If it implements as a jump table it could be pretty fast.

You might try precalculating the indexes for the binary search and use an if/else chain to figure out the starting point for binary search.  (Or use the top 3 bits to index into a table).
651  Using Arduino / Project Guidance / Re: Fastest possible search in small arrays with different methods on: December 17, 2013, 04:40:56 pm
Sedgwick "Algorithms in C" is the the bible here. Binary search should only take log(N) + 1 searches.

You might try a tree approach with left and right branches, with each node a struct with the value of the second array. That way, when you find your data, you have what you need.
652  Using Arduino / Programming Questions / Re: Serial Monitor won't print values inside loop on: December 16, 2013, 06:51:09 pm


You can simplify things by calculating prev - now and adding 360 if it less than zero.

ie
Code:
goal = degree_prev - degree_now

goal = (goal >= 0) ? (goal) : (goal + 360);

653  Using Arduino / Programming Questions / Re: Serial Monitor won't print values inside loop on: December 16, 2013, 06:16:10 pm
I don't think this is your problem, but you don't want an else if with only two cases, an else will do fine. I think two that braces are better style when using else-ifs.
654  Using Arduino / Programming Questions / Re: Invalid operands of types... on: December 13, 2013, 01:26:45 pm
No but if you have a*b where b is a pointer, you can choose between two errors. Either an invalid type for multiplication, or a missing operator between two compatible types.
655  Using Arduino / Programming Questions / Re: Automatic generate source code on: December 13, 2013, 10:06:28 am
Not an arduino solution, but the picAxe has Logicator which is a flowchart based language.
656  Using Arduino / Programming Questions / Re: Invalid operands of types... on: December 13, 2013, 10:05:18 am
This is an interesting case of parsing. since the *newAngle would make sense, it could also have complained about a missing operator.
657  Using Arduino / General Electronics / Re: figuring out resistors for SMA on: December 12, 2013, 04:35:57 pm
Don't worry, Hilukasz, it happens to all of us. I was in a meeting where I questioned whether a smallish 50 ohm termination resistor could handle the power required since it had -5 V on it. The reply was "It's OK, it's digital!"
658  Using Arduino / Project Guidance / Re: constant stream of bits on: December 12, 2013, 04:15:27 pm
10MB/s with a simpleminded program might be hard, but in general this would be easy.
659  Using Arduino / General Electronics / Re: figuring out resistors for SMA on: December 12, 2013, 04:08:05 pm
.4*.4*22 is 3.5 W, so you need a pretty big resistor to handle the power.
660  Using Arduino / Project Guidance / Re: GPS Tracker for Camera on: December 12, 2013, 03:14:38 pm
How far away are you from the camera?

Check out the GPS tracking dog collars for a ready-made solution.
Pages: 1 ... 42 43 [44] 45 46 ... 99