Show Posts
Pages: [1] 2 3 ... 90
1  Using Arduino / Project Guidance / Re: Senior Project Multi-Processor Arduino Board on: April 18, 2014, 05:40:58 pm
There's no built-in language construct for parallel processing, which means it would be up to the programmer to build task offloading into their sketches.  How that should be done depends entirely on the application.

E.g., an application might have one IC doing sensor management and another board doing computational stuff.  They might communicate via i2c.

OTOH, for something akin to a general-purpose computer, you would want them to be able to shuffle processes back and forth as needed.  Probably with a parallel data bus between them for speed, since i2c might take longer to transfer the relevant data than to just process it locally.

In other words, there's no one-size-fits-all load-sharing scheme, which would be the lion's share of the programming, and a significant part of the PCB design.  You save very, very little effort by designing a system generic enough to service either application, since it would have to be customized to the point of being nearly a complete redesign to be useful.  On the other hand, a specific implementation would only fit a very small number of people trying to use it in exactly the prescribed way.

In short, those who are interested... well, may or may not have the skill set, but if they were capable of doing anything meaningful with it, they would likely have the skills to design it themselves.  Arduino dev boards aren't difficult to design afterall...

Sorry if this comes across harsh.  I don't mean it to be, but there's a certain reality to this problem.  As is the case with many great ideas, if it were easy or desirable, it would probably be done already.   smiley-wink
2  Community / Bar Sport / Re: Mouser price error of offloading old stock? on: April 18, 2014, 01:25:33 pm
For $0.50, I might have to pick up a few of those.  I finally got started designing a 4xRS232 to Ethernet adapter I've had planned for a while.  Dial-up support would be a nice touch, especially if it's already an approved module.
3  Using Arduino / Project Guidance / Re: Video-out to a 640x480 LCD display on: April 17, 2014, 01:54:39 pm
They also have some new board that's around the size of an SD card.  I would assume it takes less power, but TBH I don't know for sure.  Nor what its capabilities are.  Just throwing an idea out there in hopes it might be relevant.
4  Using Arduino / Project Guidance / Re: Message in a Bottle on: April 17, 2014, 01:52:03 pm
A GPS bottle, what a great idea.
It makes it far easier to clean up the mess you made.

I kinda agree with this.  It sounds like a wonderfully romantic idea in theory, but then you have to consider the fact that you just threw 500-1000 bottles into the ocean, along with all the associated e-waste, and will likely not have the resources to reclaim most (or any) of them.  In these parts, we call that "littering".
5  Using Arduino / Project Guidance / Re: Video-out to a 640x480 LCD display on: April 16, 2014, 01:56:22 pm
Hehe.. Maybe an Intel Edison would be your ticket.

Side note:  I find it amusing how Intel is always trying to poke their heads into embedded space with x86.  Somehow I don't see them overthrowing the ARM as the hackers' darling for small form factor computing.
6  Community / Bar Sport / Re: The next big thing in battery technology on: April 16, 2014, 01:44:42 pm
I'm not familiar with toy helicopters as a measurement system.  What is that in metric?
7  Community / Bar Sport / Re: The next big thing in battery technology on: April 15, 2014, 09:01:23 pm
Amp-hours is amp-hours, regardless how you store it.

I guess you could, in theory, charge the "boost cap" at like 200V with suitably lower amperage, and then locally regulate that down to a few amps at nominal voltage for charging.  But good luck getting that approved for consumer use in any regulated country.
8  Community / Bar Sport / Re: Adafruit's new website on: April 15, 2014, 01:46:07 pm
Took 11 seconds to load for the first time in Chrome on a dual-core 3GHz box over a 1.2Gbps Internet connection.

It's pretty, but it's not any easier to navigate, the graphics just add weight, and the type is huge.  Definitely best viewed on a 1080 monitor from a few feet back.  Not an improvement, IMO, and it will make browsing by phone a real chore.  I really don't think the answer is to make "responsive" layouts, or design a separate site for mobile.  Mobile browsers have been doing everything they can to make normal desktop sites accessible on small devices, let's not rehash the power-strip / wall-wart plug orientation fiasco again with web site design.

Ah well, we'll see I guess.
9  Community / Bar Sport / Re: The next big thing in battery technology on: April 15, 2014, 01:31:57 pm
I'm quite OK with the seamless (and bulky compartment-less) design of new phones, but you have to subscribe to the portable charger paradigm.  Get a medium-capacity LiPo battery pack that can charge via USB, and keep that in your car / desk / purse / cargo pants.  When you're not actively using the phone, plug in your charger cable and keep on truckin.  smiley
10  Using Arduino / Project Guidance / Re: Hi I'm here data - heartbeat pulse on: April 11, 2014, 01:34:58 pm
Don't forget to bounds-check the heartbeat.  ;-)
11  Using Arduino / Project Guidance / Re: Audio spectrum analysis all in Software on: April 10, 2014, 05:25:42 pm
If you're looking to do this on an ATmega (Uno) class device, you'll most likely be disappointed with the results.  FFT is pretty heavy math for a 16MHz IC with no floating point support.  Also, the ADCs aren't really fast enough for "CD-quality" audio sampling either.  That may or may not matter to you, depending on what bandwidth you care to analyze.

Bipolar electrical signals aren't really a problem.  You can just provide a 1/2 Vcc ground reference and AC-couple the audio input (as you should anyway).

So that's where you're headed with this project.  If you still want to do this, you'll either have to be content with low temporal resolution telephone-grade audio bandwidth analysis, or use something ARM-based and with a suitably fast ADC.
12  Community / Bar Sport / The next big thing in battery technology on: April 10, 2014, 05:17:03 pm
This one's good for a chuckle:

http://www.iflscience.com/technology/quantum-dots-can-charge-your-smartphone-30-seconds

Uhhhhh huh.  2000mAh or so in 30 seconds?  Sure, sign me up.  smiley-roll  Now all I need is a USB port capable of providing 240A at 5v.
13  Using Arduino / Programming Questions / Re: "Hold" or "pause" command/statement. Many statements. Mixing "if", "&&" and "||" on: April 10, 2014, 03:02:48 pm
(Had to break this up into two posts due to message length restrictions.)

How to program a "hold" or "pause" command/statement.. or some workaround. Any ideas?  If i "delay" i also delay the whole loop!

I think the concept you're looking for here is the "state machine".  Given your pin reading example, you would do it like this:

Code:
void loop() {
    int sensorValue;
    int lastPinState = LOW;
    
    // Loop infinitely here:
    while (1) {
        sensorValue = analogRead(A0);
        
        if (sensorValue > 360) {
            if (lastPinState == LOW) {
                digitalWrite(4, HIGH);
                lastPinState = HIGH;
                
            // lastPinState == HIGH
            } else {
                digitalWrite(4, LOW);
                lastPinState = LOW;
            }
        }  // if (sensorValue > 360)
    } // while(1)
}

This is the logic that you described, but it's probably not going to do what you actually want because it's very likely you'll get a value over 360 with each loop iteration, meaning pin 4 is going to be twiddled back and forth at a super high speed.  That might be what you're looking for, but probably not.  Generally, you would want to only toggle the pin once the value at A0 goes over 360, then falls below 360, then goes back over 360 again.  Or maybe you want it to toggle as long as A0 is over 360, but not more than once every 100ms.  Or maybe you want the pin to go HIGH when A0 is over 360, and LOW again when A0 is over 630 (or whatever).

Let's assume you only want it to toggle each time it goes above 360, falls below, then goes back above 360 again:

Code:
void loop() {
    int sensorValue;
    int lastPinState = LOW;
    int lastSensorValue = 0;
    
    // Loop infinitely here:
    while (1) {
        sensorValue = analogRead(A0);
        
        if ( (sensorValue > 360) && (lastSensorValue < 360) ) {
            if (lastPinState == LOW) {
                digitalWrite(4, HIGH);
                lastPinState = HIGH;
            } else {
                digitalWrite(4, LOW);
                lastPinState = LOW;
            }
        }  // if (sensorValue > 360)
        
        lastSensorValue = sensorValue;
    } // while(1)
}

One more thing you might want to account for is called "hysteresis" -- which means, you might want there to be a "dead zone" to prevent the pin from toggling when the analog value hovers around, say, 358 to 362 for example.  Technically, it fell below 360 when it's 359, so the code will toggle the pin.  But the difference is negligible and you probably don't want it to change so close to the threshold value, since any amount of noise will set it off.  And there WILL be noise.

You only need to change one line to implement this kind of buffer area:

Code:
       if ( (sensorValue > 360) && (lastSensorValue < 350) ) {

That will provide a 10-value cushion where the analog value has to drop below 350 before it's considered "below the threshold" again.  You could tweak this value to be as large or small as you want.

There are a lot of ways this can be further optimized (not using ints when a single byte would work, or using the PINB register to toggle the pin instead of tracking its state, etc...) but this will get the job done.

Hope this short novel helps.  smiley-wink
14  Using Arduino / Programming Questions / Re: "Hold" or "pause" command/statement. Many statements. Mixing "if", "&&" and "||" on: April 10, 2014, 03:02:22 pm
Welcome to Intro to C Programming.  OK, here we go!  smiley

i think its hard to understand ... when to use curly baces more than in the beginning and at the end of a scetch.

Braces signify a "block" of code that is basically an atomic (inseparable) unit.  For example:

Code:
void loop () {
    // Everything in between these braces is part of the loop() function.
    // The '{' brace defines the beginning, and '}' defines the end.
}

// This is not part of loop()

There are many places where this construct is used.  Here are a few others:

Code:
if (x == y) {
    // Everything in these braces will be run if x is equal to y
}

else {
    // Everything in these braces will be run if x is NOT equal to y
}

Or ...

Code:
x = 100;
while (x > 10) {
    // Here, everything in the braces runs while x is greater than 10
    x--;
}

You don't always have to use braces.  Most of the examples above will work without them, but you're limited to one statement, like this:

Code:
// These two examples are the exact same
if (x == y) {
    x++;
}

if (x == y)
    x++;

// However, these two are NOT the same
if (x == y) {
    x++;    // Both of these lines will be executed
    y--;    // when x == y because of the braces
}

if (x == y)
    x++;    //  This line will be executed ONLY when x == y
    y--;    //  This line will be executed regardless

The example above illustrates the purpose of the braces.  It "contains" a block of code so that it is treated as a single entity.  The 'if' statement will either execute one single statement without braces, or it will execute everything within the braces.

You'll notice in the example above that the statement "y--;" is indented, so it looks like it matches the "x++;" statement right above it.  Well, in C (including Arduino sketches), spaces and tabs mean nothing.  In other words, these two statements are identical:

Code:
// This uses proper indentation (and line breaks)
if (x == y)
    x++;    // Part of the if statement

y--;    // Not part of the if statement

// This uses improper indentation, but is technically the same code
// and thus works exactly the same way.
if (x == y)
    x++;    // Part of the if statement
    y--;    // Not part of the if statement
            // though it looks like it was meant to be

The "x++;" line is part of the conditional statement.  Another way to write it is like this:

Code:
if (x == y) x++;
y++;

The C compiler doesn't care whether you use a line break, or indent with spaces or tabs.  The code is the same either way.  Which brings us to your other question:

How to put more statements after each other? Is it maximum two statements before";", or is it possible to add more statements/commands with a ","?

The semicolon ends a statement.  You can stack them up any way you'd like.  For example:

Code:
// This is how you usually see code written
x++;
y--;
x = y;

// But this is the same thing to the compiler
x++; y--; x = y;

The second example is usually poor form, but there's technically nothing wrong with it.  Using multiple statements on a single line is sometimes used (particularly with trivial statements like the assignments above) by coders who feel it's unnecessarily verbose to put each statement on a separate line.  It's purely aesthetic.  You risk confusing readers, or having them miss the fact that it's actually multiple statements.  (You could blame that on poor code reading skills, sure, but there's no reason to obfuscate your code.)

You also mentioned the comma operator.  In general, it would be wise to forget that even exists in C, with the possibly forgivable exception of multiple statements in a for loop initializer -- although even then there's probably another way to do it that is less obtuse.  For completeness, here's how the comma works:

Code:
// This line evaluates the first statement, discards any return
// value, then evaluates the second statement, keeping that
// return value
x = (y++, a + b);

// It is basically the same thing as this:
y++;
x = (a + b);

Since those two examples lead to the same result, why would anyone use the first?  It only confuses the reader into thinking there's something special about the relationship between x, y, a, and b -- there isn't.  While x ends up with the value of a + b, the value of y has nothing to do with anything -- it's just lumped in for no good reason.

As I said, you could argue that it might have a place in a for loop initializer like this:

Code:
for (x = a + b; x < 10; x++, y++) ...

Since you can't use multiple statements (terminated with semicolons) without breaking the three-statement syntax of the for loop initializer, you can squeak in some extra work by using the comma.  Then, you get the chance to increment both x and y every loop iteration.

On the other hand, you could just do this instead:

Code:
for (x = a + b; x < 10; x++) {
    y++;
    // whatever else your loop does ...
}

That's much more obvious.  The only thing it costs you is having to use braces when the for loop could otherwise be a one-liner like this:

Code:
for (x = a + b; x < 10; x++, y++) Serial.print("x = %u, y = %u\n", x, y);

Dubious benefit in my opinion, since many coders would look at that and have to remember what the comma does again.  Some people have the same complaint about the tertiary operator:

Code:
// This is the tertiary operator that some people hate for its "obscurity"
x = (a == b) ? a : b;

// It does the same thing as this
if (a == b)
    x = a;
else
    x = b;

I personally love the tertiary operator for its concise and obvious (to me!) syntax.  YMMV.  Same with the comma I suppose.  (Notice I didn't use braces in the if / else statement, since only one statement needed to be executed in each case.)
15  Using Arduino / Project Guidance / Re: Arduino Wi-Fi Hotspot on: April 10, 2014, 01:50:50 pm
Keep in mind, network stacks aren't exactly light.  Even DHCP, which is a simple protocol, requires several hundred bytes of memory just to generate the packet.  For even the smallest computer, that's negligible.  For an ATmega328P, that's a significant chunk of your available RAM.

Standard Ethernet MTU is 1500 bytes.  You could store exactly one full-size packet in RAM, with just a little left over for everything else your program has to do.  Now, in reality, ICs like the WizNet 5x00 will take some of the burden of processing the raw frame, so you'll be left with just the payload of the packet to deal with.  But still that's potentially up to 1400-some-odd bytes.

Not trying to discourage anyone, but you need to have realistic expectations about how "connected" a micro can be.  It would make a dreadful router, and has serious limitations as a network-attached device in general.  For really simple applications, that's OK, but you really have to be aware of the resource limitations.

I see a lot of posts like: "Hey, I'd like to write a server that allows configuration via a web page, any suggestions?"  There are Ethernet shield demo sketches that illustrate how connectivity works.  These can be used as a starting point to customize for the given application.  What other suggestions were you looking for?
Pages: [1] 2 3 ... 90