Show Posts
Pages: [1] 2 3 ... 844
1  Using Arduino / Programming Questions / Re: Dynamic array in arduino on: August 07, 2014, 04:44:49 am
instead of the arrays amplitude and duration being static, I want to give their length in the argument of the function then create them inside

If the arrays are local to the function then there's nothing stopping you from declaring them as local automatic variables - as long as you have enough memory available for the stack. The size can be dynamic in the sense that it is determined within the function at runtime but is fixed in the sense that within a given execution of the function, once the variable has been declared the size is fixed.

If the arrays are persistent or global then you could allocate them from the heap and store the address in your static or global variable (wherever you would have declared the array if it had been a fixed size) but I don't know enough about your project to know whether that's a sensible approach to take. If you take the approach you have to design your code to know whether the array has been allocated and what size it is.
2  Using Arduino / Programming Questions / Re: Sending Data over Serial Interrupted by Stepper on: August 07, 2014, 04:38:38 am
It looks to me as if the stepper motor is being driven correctly and your call to stepper.runToPosition() should move the stepper by the number of steps you specified and block until the stepper reaches that position (the call to run() is redundant but harmless). I think you're saying that the stepper is moving correctly but perhaps you can confirm that.

I think the problem is that the serial output you're expecting isn't being sent. This code looks like a disaster waiting to happen and probably accounts for that problem:

     for(value_place =0; Serial1.available()>0; value_place++) // while data available - byte at a time as single character
      value[value_place] =;

I think you need to add code to receive the response from the probe and wait until you have received the complete response, and not just assume that the data you expected arrived when you expected it.
3  Using Arduino / Programming Questions / Re: Make an Array "On the Fly" on: August 07, 2014, 04:24:49 am
that approach would probably lead to a loss, and requires more code anyway...
Is there no way to do it inline?

I don't understand your objections. The approach you showed is a nice simple way to do it, and I don't see what 'loss' you're referring to or why the amount of code is excessive - it's a single line of code a couple of dozen characters long; how much shorter do you think you're going to get it?

It would be possible to work out the location of the two arguments in the calling frame and pass the address and byte count to your sending function, but it would be a horrible approach to take and just to avoid two byte assignments I don't see the justification.
4  Using Arduino / Project Guidance / Re: Wifi Tracking (bit of a brain fart...) on: August 07, 2014, 04:17:29 am
beyond reasonable doubt is the phrase they use!

I don't see how you would ever eliminate reasonable doubt given the approach you're suggesting - I don't think a DIY solution based on obscure communications technology would be taken seriously, let alone accepted as proof beyond reasonable doubt. Something providing recognisable video/pictures of the intruder would be far more useful IMO.
5  Using Arduino / Project Guidance / Re: High and Low = 5V and ground? on: August 07, 2014, 04:13:17 am
Use a relay.

A fet is likely to get killed by the back emf on the motor when you switch off

You will have the same issue driving the relay - either way, you need a driver circuit between the Arduino and the load which will amplify the current and provide flyback protection.
6  Using Arduino / Project Guidance / Re: Long range data transport on: August 07, 2014, 04:07:45 am
An antenna makes a pretty good lightning rod, and an outdoor cable can get incredibly high spikes from nearby strikes.

That's a very good point.
7  Using Arduino / Project Guidance / Re: What´s the best Arduino for my project? on: August 07, 2014, 04:05:49 am
The simplest design would be to design the furniture so that sitting on it caused a switch to close. For example you could design the furniture with an unglued loadbearing joint and include a membrane switch inside the joint so that it operated when the weight on the seat exceeded some threshold. Then use the switch to power up a recording/playback device. I don't know what sort of volume/duration you're aiming for, but cheap recordable greetings cards only cost a few quid. This approach doesn't need any form of microcontroller, just a few off-the-shelf components.
8  Using Arduino / Project Guidance / Re: Using SPDT on-off-on Rocker Switch on: August 07, 2014, 03:55:57 am
You can't - need a separate switch for that.

I think you could do it by connecting the two switch outputs via a couple of diodes to produce a common output which you can use to power the Arduino - one of the 'raw' switch outputs can then be connected to a digital I/O pin so that the Arduino can tell which way the switch was operated. You would need to make sure that you don't ever end up with power applied to the I/O pin without the Arduino as a whole being powered.
9  Using Arduino / Programming Questions / Re: Handle millis()/micros() overflow in task manager on: August 06, 2014, 04:39:14 pm
Please look at the code, and run it yourself.
The if statement has nothing to do with Serial.print statements for the variables.

    if (ms - prevms >= interval) { d++; }
    else { Serial.print("================="); }

In that case you need to explain what part of the code's behaviour you think demonstrates this:
the compiler is automatically (at least when using Arduino IDE 1.5.7) casting the subtraction to a signed value

It doesn't happen, and apart from the call to println(), which we know converts the argument to a signed integer before printing it, I don't see anything to suggest that it does.
10  Using Arduino / Project Guidance / Re: reading 10 incremental rotary encoder with one Arduino Due on: August 06, 2014, 04:30:48 pm
I want to count pulse and determine direction. The final purpose is to calculate speed and direction.

Then you're back to the first question: Calculate the signal frequency you need to support, and estimate how many CPU clock cycles you will need to handle each signal..
11  Using Arduino / Project Guidance / Re: Wifi Tracking (bit of a brain fart...) on: August 06, 2014, 04:28:50 pm
I don't believe it will work with WiFi unless the phone has associated with the network (either because the person has manually selected that, or you have set up an unsecure WiFi and the person was foolish enough to configure their phone to associate with unsecure networks automatically).

I think Apple did something similar using BlueTooth LE with their iBeacons product.
12  Using Arduino / Project Guidance / Re: Having Arduino and Gobetwino wait for eachother to continue on: August 06, 2014, 04:22:20 pm
The evidence you describe suggests that Gobetwino is sending the keyboard events to the main window and not to the dialog which has the focus. Does the dialog respond to any other keyboard events - tab, for example? If so, you could test this theory by sending a tab and seeing whether the dialog responds to it.

If that's what's happening there are a few approaches you could try. The Arduino is capable of emulating keyboard / mouse devices directly. How easy this is to do will depend which Arduino you're using, but for a UNO I think it would involve reprogramming the Atmega 16U2 chip that implements the USB controller. With this approach the input from the Arduino would behave exactly as if you had hit the corresponding key on a physical keyboard. This feels like overkill to me, but it's definitely feasible.

You can work out how the spreadsheet works and find a way to achieve the same thing without using the dialog. (This is the approach I'd take.)

You can write your own program to generate the key sequence, and do it in a way that sends the events to the dialog. I don't have your spreadsheet here to test, but for example here's a jscript implementation that sends the same key sequence (as far as I have understood your description). You could run this manually to see whether it works.

Code: (SendKeys.wsf)
<?xml version="1.0" ?>
<job id="SendKeys">
<script language="JScript">

    var WshShell = new ActiveXObject("WScript.Shell");

    WScript.Sleep(1000); // brief delay to give you time to give keyboard focus to the target window
    // alt+x,y,down,space, enter
    WshShell.sendKeys(" ");

13  Using Arduino / Programming Questions / Re: Handle millis()/micros() overflow in task manager on: August 06, 2014, 03:52:38 pm
One very interesting fact is that for the example you provide:
"millis() - previousMillis >= interval"
the compiler is automatically (at least when using Arduino IDE 1.5.7) casting the subtraction to a signed value, so you are comparing apples to oranges depending on the magnitude of the values returned by the function and variable.

No, the compiler does not do that. The expression is evaluated using unsigned arithmetic, which produces the correct behaviour as I have described. You're confusing the evidence by using Serial.println|() to format the result of your own subtraction; println() takes a signed integer argument which causes the value you're printing to be cast to a signed integer at the point you print it. That is nothing to do with the behaviour of the arithmetic expression we are discussing and is just an error in the way you are displaying the value.
14  Using Arduino / Programming Questions / Re: Handle millis()/micros() overflow in task manager on: August 06, 2014, 01:55:24 pm
You are correct that proper unsigned arithmetic will always give the elapsed time if one is lower than the other

Your proviso is not required. The unsigned arithmetic using subtraction gives the correct behaviour regardless of overflow, without any special code to handle the overflow condition.
15  Using Arduino / Project Guidance / Re: High accuracy servo, various component selection on: August 06, 2014, 01:48:08 pm
PeterH, what do you mean by "mark 2"?

I mean that after you have the first prototype working to demonstrate the basic functionality using a standard servo, you can create a better solution based on a discrete DC motor/gearbox and rotary encoder that is better at meeting your durability requirements.
Pages: [1] 2 3 ... 844