Show Posts
Pages: 1 ... 247 248 [249] 250 251 ... 844
3721  Using Arduino / Programming Questions / Re: Reassigning pointers on: November 05, 2013, 06:52:42 pm
Hi guys, I have a very enigmatic question. I have function which acts on different "settings" variables which are stored in a struct. The struct stores settings for 3 seperate sections in EEPROM. To conserve working memory, I assign the variables in the struct to pointers and then operate on those pointers. Then I want to reassign the pointers to the next set of variables and operate on those.

I haven't looked at your code, but based on your description what you need is a pointer to the struct and then normal pointer dereferencing to access the individual fields within the struct being pointed to.
3722  Using Arduino / Project Guidance / Re: Raspberry Pi or Arduino for Drone? on: November 05, 2013, 06:48:04 pm
Yes, but not all can be altered with the Arduino IDE.

They would all be designed to work in some development environment, and converting any of them to work in an Arduino environment would be simple enough. Although, once you have tried any other environment you will realise that there's no particular reason to use the Arduino IDE - it's not especially good, it's just a convenient way to get started.
3723  Using Arduino / Project Guidance / Re: Help with a shield on: November 05, 2013, 06:44:32 pm
You say you have found a sketch that reads a string in from the serial port and sends it in an SMS. I assume you have tried it and confirmed it works. So just replace the serial port reading stuff with sending a single hard-coded string, and you're home and dry. You need to take stuff out, not put it in.
3724  Using Arduino / Project Guidance / Re: I NEED HELP! arduino uno R3 with motor shield 1.2 on: November 05, 2013, 06:40:11 pm
I suggest you don't use pins 0 and 1 for the sensor inputs. Use any other available digital pins. Then use the Serial port to print out the values you're reading from the sensors and see whether they're working correctly.
3725  Using Arduino / Project Guidance / Re: Time synchronization between arduinos ? on: November 05, 2013, 06:37:21 pm
I love Unix timestamps.

That's a common representation of a wallclock time, and there are plenty of other similar formats that have the same characteristics. However you represent it, you still have to deal with the fact that wallclock time is not the same as real time and can speed up, slow down, jump backwards and forwards.
3726  Using Arduino / Project Guidance / Re: Choice of steppermotor for automated blind on: November 05, 2013, 06:34:02 pm
If you need 3 Kg-cm and the servo applies 11Kg-cm then the servo ought to be sufficient. If it isn't sufficient then perhaps it isn't actually producing as much torque as it's claiming. The most likely reason for that would be that it doesn't have an adequate power source. You could measure how much torque it's actually producing in the same way you measured the weight needed to operate the blinds.
3727  Using Arduino / Project Guidance / Re: Arduino Testbed for testing watches. on: November 05, 2013, 06:30:42 pm
Moving a mechanism a controlled distance/angle at defined intervals, and measuring the mechanical resistance to that movement, would be within the capabilities of an Arduino with the appropriate sensors and actuators. You probably wouldn't want to rely on the Arduino to timestamp or log the data, but it would be feasible to connect an arbitrarily big number of these devices to a PC via USB hubs and have the PC do the logging. If this is for long term use you would probably want to write an application on the PC to monitor the set of Arduinos plugged in and start/stop logging for each one as they were connected/disconnected.

If I were you I'd log the data to a local relational database - that enables a wide variety of reporting/display methods and keeps that aspect decoupled from the basic data acquisition mechanism.
3728  Using Arduino / Project Guidance / Re: How to make a heating soure (with the arduino board) on: November 05, 2013, 06:24:36 pm
If you want the heating source to be carried by the balloon, I think you're wasting your time. However, if you want to use a Montpellier style balloon that is held down until it is hot enough and then released, that would be feasible. A balloon suffers from economies of scale though due to the squared/cubed relationship between surface area and volume; the smaller it is, the harder it is to make it fly. Something no bigger than your head will be *really* difficult and would need your balloon to consist of a soap bubble or similar with no extra structure. So you need to start with the balloon itself, figure out what volume it will be and how much it will weigh, then calculate from that the average air temperature needed inside the balloon for it to float. Once you know what air temperature you're aiming for you need to know what power sources you have available (will it be indoors with access to mains power, or battery powered?) and finally you can design your heating mechanism.
3729  Using Arduino / Programming Questions / Re: help with PWM soft motor pull timing on: November 05, 2013, 02:04:49 pm
If you need to keep synchronised with external events you should not just use delay() or delayMicroseconds() to control the execution speed. You need to manage the timing based on the value of millis() or micros().

You have a fundamental choice to make at the outset - whether your code is going to be blocking or non-blocking. Blocking code is easier to write for simple jobs but is only suitable for doing one thing at a time. If your sketch needs to control more than one thing concurrently then a non-blocking design would be more appropriate.

Do you need to measure the actual position/movement of each motor to keep them exactly in sync, or would it be sufficient to just make each motor change direction at the same instant so that they tend to stay roughly in sync?
3730  Using Arduino / Programming Questions / Re: output format question - XML? on: November 05, 2013, 01:59:10 pm
I don't know much about the opening/closing whatever's in this, is all new to me.

The idea of XML is that it is a tree structure of elements. Each element consists of an opening tag "<something>" and a closing tag "</something>" with the element content in between them. The name in the opening and closing tags must match. It's all very much like the structure of compound statements in C++ if you think of opening tags as being a named '{' and closing tags being a named '}' which must pair up with the opening tag.

(The code to print this out will be very repetitive - it would be much shorter and simpler if you implemented the repeating behaviour as functions.)
3731  Using Arduino / Programming Questions / Re: Hi, can someone help me with my code?? on: November 05, 2013, 01:49:37 pm
by processes i mean functions.
Maybe if i do change the void so i can return values

There's no general rule on whether it's right or wrong to return a value except that you must return one when you need it and should not when you don't. If you want to know whether a particular function should return a value, you need to explain what the function does and in particular what data needs to be passed into and out of the function.
3732  Using Arduino / Programming Questions / Re: Problem in Serial communication between 2 arduinos ! [SOLVED] on: November 05, 2013, 01:45:26 pm
as i said before the array has nothing to do with the problem here because i am just using the array for virtual wire for the transmitter

That's your assumption, but it's not a safe assumption. If the array size is wrong and you are overflowing the bounds of the array then you may be causing memory corruption. In that case, all bets are off. Until you know what is causing the problem, don't make any assumptions about what is not causing it.
3733  Using Arduino / Programming Questions / Re: Dual Ultra Sonic Sonar - Distance Reading Issue on: November 05, 2013, 01:41:06 pm
I have no idea how that shield is supposed to work or what the jumpers are for, and I don't see any technical information on the site you linked to.

Perhaps the shield is doing something with pins 0, 1 and perhaps that's why you need to use the jumpers to isolate those pins before you can use the serial port. That would explain the problems uploading, and the strange serial behaviour. But it's only speculation - you ought to look at the technical data supplied with the kit, which should have explained all this.
3734  Using Arduino / Programming Questions / Re: creating an averaging function correctly on: November 05, 2013, 01:34:07 pm
public int mean(int in){
   avg += in;
   avg = avg/count;
  if(count >= numberReadings){
    count = 0;
    avg = in;
  return avg;

This seems to be trying to average every N samples, starting again for the next N samples. It is not producing a rolling average. Did you intend it to start again every N samples?

In order to calculate an average over a number of samples you need to record the sum and the count. You don't need to record the previous average. Instead of this:

   avg += in;
   avg = avg/count;

You want:
   sum += in;

The result is then sum / count.

If what you want is a rolling average you can do that easily using an exponential decaying average, e.g.:

average = (0.9 * average) + (0.1 * newValue);
3735  Using Arduino / Programming Questions / Re: Order of functions and function prototypes? on: November 05, 2013, 01:27:00 pm
The Arduino does various mucking about with code in your .ino file before it compiles it. Among other things, it tries to generate function prototypes for all the functions you have defined and puts them somewhere near the top of the sketch, in a location which is usually correct but sometimes not.

When you put your code in a 'C'/C++ source or header file it doesn't have this mucking about done and needs to conform to the usual 'C'/C++ requirements to be compilable. Among other things that means that all types and functions have to be declared or defined before they are used.

Putting executable code in header files is unconventional and not recommended. What you should do is put the code in a C++ source file, and put the corresponding external declarations in the associated C++ header file, and #include the header file in any other files that need visibility of those declarations.

Bear in mind that due to the mucking-about, the source code invoked by the compiler is not in the same directory as your original sketch and will usually be in a temporary directory, so any relative file references are likely to be problematic. If you implement the shared code as an Arduino library this works out much cleaner.
Pages: 1 ... 247 248 [249] 250 251 ... 844