Show Posts
Pages: 1 ... 50 51 [52] 53 54 ... 71
766  Using Arduino / Programming Questions / Re: ISP on: March 04, 2012, 06:39:47 pm
Does your chip say
767  Using Arduino / Programming Questions / Re: Byte to String weirdness on: March 04, 2012, 06:38:25 pm
Many people will tell you to not use the String class and to use c strings instead for various reasons.

If you do want to use the String class:
You want to do this:
String scmd(cmd);
Otherwise, you'll be calling the constructor twice, one time the real constructor and the second time the copy constructor.

However, I think scmd should be good, and you're just reading it incorrectly. How are you reading it?
768  Using Arduino / Programming Questions / Re: Sampling analogRead() highs and lows. on: March 03, 2012, 01:20:46 am
millis() returns the time since the arduino was last reset (essentially), so it looks like that will work once, but then millis() will be above 5 seconds and the loops will immediately terminate.

You need to store the time when you're about to start the 5 second loop, and then find how long it has been since that time.

Also, it's not too great an idea to use a delay in those loops, unless you only want 5 samples.

And wouldn't you want sampleLow to only be set to the analogRead value if the analogRead value was lower than the current sampleLow value?
769  Using Arduino / Programming Questions / Re: Arduino pwm on: March 01, 2012, 10:25:34 pm
I'm no expert at these multicopters, as I'm building my first one now. I've been reading up on the web about different firmware for the ESCs and the controller card. From what I've read, but not yet tried myself, an update rate of at least 100 Hz is desirable. It gives a more stable platform. The stock ESCs are slow on purpose. Too fast a ramp up can wreck the gears on a helicopter or similar use. Custom firmware optimize them for multicopter use. I don't know if it's clear, but we're talking BLDC motors here. Six outputs from the ATMega8 controlling six FETs, driving two wires at a given time, and measuring voltage on the third wire. It's way more complex than just outputting a single PWM signal.

Even so, you said the firmware was written for the "arduino language," so you could just incorporate that into your code. Unless, of course, it uses more than 32KB of program memory or 2KB of ram, which I find highly unlikely.

I would agree with you that a method should be added to the Servo library to change the update rate -- it could probably just be a really giant, crude switch statement. I'd google around and perhaps you could submit a patch.
770  Using Arduino / Programming Questions / Re: C++ aggregation/composition not working? on: March 01, 2012, 10:01:15 pm
The EverHelpfulĀ® IDE doing it's thing again by throwing obstacles in our path ... (it the IDE preprocessing your PDE file, not THE preprocessor).

Please explain how this is related to what the IDE is doing.

Your problem is that A a(24); in a class is meaningless. Are you trying to create a function that returns A, called a, and takes an int? Then you say A a(int a); Are you trying to have class B contain class A? Then you'd say A a; and construct it in your constructor's initialization list, like this:
class A {
  A(word x) {
    x; // dummy, just to have ... something

A x(40);

class B {
  A a;
  B() :

// These are not relevant to show my problem, just in so you can cut&paste to try it out.
void setup() {}
void loop() {}

I tried your version with standard g++ and it gives the same error, so not fault with the IDE.
I tried my version and it compiles.

tl;dr: you have to construct things in the constructor.
771  Using Arduino / Programming Questions / Re: How iterate parts of code at different rates? on: February 29, 2012, 11:57:01 pm
You should take a look at the blinkwithoutdelay example, which shows exactly what you want to do.

Essentially, you store the time that you last did something in a variable. Then you keep checking to see if the current time minus the last time (delta t) is greater than your period. If it is, you store the current time in your lastTime variable and do what you need to do.

With this method, loop() will execute thousands of times per second, so you can add as many things that should run at different periods as you want to.
772  Using Arduino / Programming Questions / Re: Arduino pwm on: February 29, 2012, 11:48:35 pm
If your ESC uses an atmega8, then why don't you just replace it with your arduino chip that's programmed to simple output PWM to the motors? It wouldn't add much to your sketch size (it may even subtract: analogWrite (hardware PWM) vs Servo (which is an ISR)), and you'd have a much faster update rate.

And since nobody is actually answering your question:
You're going to have to modify the servo library and change the function initISR. If they designed the library correctly, this should be easy, but they did a bad job. You could either modify the library slightly so that you can override the functions needing to be changed (add them to the class and declare them static and virtual) or you could just modify the library as you need it.
773  Using Arduino / Programming Questions / Re: Very newbie questions about C and Audrino on: February 29, 2012, 11:21:37 pm
The shiftOut function takes a byte value, which each bit will represent one output of a shift register.

So, you can just do this:

byte ledsToLight[] = {...};

void loop() {
  static int i = 0;
  shfitOut(9, 3, MSBFIRST, ledsToLight[i]);
774  Using Arduino / Programming Questions / Re: remote compiler how start.. on: February 29, 2012, 03:02:53 am
Don't bother with the IDE -- the GUI interface is stupid for scripts, and it's trivial to call the compiler directly. The only hard part is generating the correct include paths and creating function prototypes.

To find out what the compiler does, enable verbose compiling. It shows you exactly what the IDE does when it's compiling, so you just take the same things. Alternatively, you could steal some of the source code for the IDE.
775  Using Arduino / Programming Questions / Re: Undefined Reference on: February 29, 2012, 12:39:25 am
You have to include OneWire.h in your main sketch, or the arduino IDE won't link it in.

Also, it's not a great idea to #include "../OneWire/OneWire.h" because there are two places people can put libraries. Just say #include <OneWire.h> and the IDE will tell the preprocessor where to find it.

776  Using Arduino / Programming Questions / Re: Help counting number of times a pin is 'high' in set time. on: February 28, 2012, 09:38:58 pm
To tell the compiler that you want to do floating-point calculations, one of the operands must be a floating point number. Any variable you declare "float" or "double" is obviously floating point. Any constant with a decimal point is a floating point number

float var1 = 1; // float
double var2 = 5; //float
5; // int
8.2 // float
8.0 // float

5/8 != 0.625; // Integer arithmetic rounds down
var2/8 == 0.625; //var2 is floating point, even though 8 is an int
5.0/8 == 0.625; // 5.0 is floating point
5.0/8.0 == 0.625; // They're both floating point
777  Community / Products and Services / Re: 28 Pin IC Sockets Available on: February 26, 2012, 04:55:13 pm
Sorry, I think digikey has you beat:
778  Using Arduino / Programming Questions / Re: [Student] Having problems with figuring out getting button to work with build on: February 26, 2012, 04:31:41 am
That's not quite correct. You need to have the arduino pin connected through the resistor to ground AND the button. The other side of the button should be connected to Vcc (5V)

PIN --- resistor --- ground
  button --- 5V

The resistor should be "gently pulling" the pin to ground when the button is not pressed. When the button gets pressed, then it "strongly pulls" the pin to 5V, "overpowering" the resistor
779  Using Arduino / Programming Questions / Re: MSTimer Interrupt Code on: February 26, 2012, 03:59:59 am
wouldn't the value of it climb so high that I would overflow or cause the math behind the timing to take so long so as to actually interfere with the timing?

Ahh... no. Doing a subtraction on variables of the same type (so as long as they're ints) they'll take the same amount of time. And the timer will wrap around after 50 days, but if you program it right, you just have to make sure you don't have a period longer than that, and it'll "take care" of the wrap around.
780  Using Arduino / Installation & Troubleshooting / Re: How to install UNO Rev3 board with Arduino IDE 1.0 on: February 26, 2012, 03:46:51 am
Thanks for clarifying how the IDE functions for all versions of UNO.  How to I install the correct UNO R3.inf?  Do I manually use the control panel>hardware>device manager>update driver to re-install the UNO R3.inf?  And if I do that, how can I get my FTDI driver back to run my Duemilanove on the same computer?

If you installed it correctly the first time, it should be fine forever. But yes, that sounds like the correct way to reinstall the drivers. As for the FTDI drivers, your computer is smart enough not to try to run your mouse driver on a webcam, so it's smart enough to run your FTDI driver on a duemilanove and the other driver for your uno. It should "just work." If it doesn't, post back.
Pages: 1 ... 50 51 [52] 53 54 ... 71