Show Posts
Pages: [1] 2 3 ... 1300
1  Using Arduino / Programming Questions / Re: Coding an XOR on: February 26, 2014, 03:22:24 am
This is a general C++ question. The Arduino IDE implements C++. If you have a problem with the language you should address it to the C++ standards group.

I think that would still make sense, since XOR means only one, of however many inputs there are, is true.

What does that mean?
2  Using Arduino / Programming Questions / Re: Coding an XOR on: February 26, 2014, 03:19:13 am
Yes Nick, but I meant as a sibling to the && and || ones, not as a bitwise operator.

What is a sibling in this case?

The && and || operators will return 0 or 1. The ^ operator will correctly work with that. What is the problem?

As a matter of interest why is XOR not available as a Boolean operator, say XX, as in...

Well, it is.
3  Using Arduino / Programming Questions / Re: Coding an XOR on: February 26, 2014, 12:11:14 am
As a matter of interest why is XOR not available as a Boolean operator, say XX, as in...

if (((button1State == LOW) XX (button2State == LOW)) 

(Or if it is, it's not listed here.)

Apart from here on that page?

Bitwise Operators
    ^ (bitwise xor)

4  Using Arduino / General Electronics / Re: Arduino Basic Connections - lots of useful electronic info on: February 23, 2014, 02:27:16 pm
pighixxx seems to have removed his book from his site, rendering the links on this page useless. I'm not sure what the story is about that, however I will "un-sticky" this thread as it no longer leads to useful information.
5  Using Arduino / Programming Questions / Re: AVR STL on Mac OSX on: February 18, 2014, 02:51:49 pm
This compiled OK for me:

#include <iterator>
#include <string>

void MatchKW(std::string keyword)
if(keyword.find("on") != std::string::npos)
// Do stuff
else if(keyword.find("off") != std::string::npos)
// Do stuff

void setup () {}
void loop () { }

Please post all your code, that demonstrates a problem, not snippets.
6  Using Arduino / Programming Questions / Re: AVR STL on Mac OSX on: February 17, 2014, 03:58:06 pm
As I mention in bold type on the page linked above:

You need to include <iterator> or you will get compile errors.

This compiles OK (on a Mac):

#include <iterator>
#include <queue>

std::queue<int> q;

void setup ()
  }  // end of setup

void loop () { }
7  Using Arduino / Programming Questions / Re: keypad errors on: February 12, 2014, 03:47:51 am
This is my copy:
8  Using Arduino / Microcontrollers / Re: TIMER: difference between CTC and fast PWM when TOP=OCR1A? on: February 10, 2014, 03:24:02 pm
The benefit of PWM or fast-PWM is that it will toggle on and off a hardware port without needing interrupts. You can control the frequency and the duty cycle.

Doing it with interrupts must necessarily introduce a bit of jitter as the interrupt cannot necessarily always fire at exactly the same moment in the cycle (perhaps because of other interrupts, or because it is part-way through an instruction).
9  Using Arduino / Programming Questions / Re: SPI between 2 Arduinos one as master and one as slave on: February 08, 2014, 07:02:36 pm
The master may be sending too fast. SPI is much faster than serial comms.

I don't know about compiling for the Due, it is a completely different chip and I haven't attempted to compile the SPI stuff for it.
10  Community / Bar Sport / Re: Arduino working at 3.3volts on: February 03, 2014, 03:36:51 pm
Would you try and overclock a Mega328 to 25MHz? It will probably work but will you feel happy about doing it?

I've overclocked my Atmega328P. It seems to work. However as Mike points out if you operate out of spec, results are not guaranteed.

I've done other things that Mike disagrees with (like operating an LED without a resistor by using PWM). After some robust discussion I agree with Mike that doing things out of spec is likely to do one or more of:

  • Not work at all.
  • Be unreliable in ways we don't necessarily know at the time.
  • Fail prematurely.
  • Cause damage.
  • Work for some chips but not others.

If you are designing for something that you happen to want to work reliably (eg. a quadcopter, a fish feeder, a door opening system) then you should probably design inside the spec. Otherwise you might come home one day to some dead fish (if you can get the door open, that is!).

The engineers at Atmel will have done far more testing than half an hour running half a dozen sketches on a single chip.

I agree. I'm sure they would want to publish the best possible specs, and if they could get it to work reliably at 3.3V they would certainly brag about it. The larger chip surface probably causes some RF interference at the higher frequencies which interfere with its operation at lower voltages (I am guessing here but it would be something like that). They probably have certain "torture" tests that make the chips do what people might do in practice and see what voltages those tests fail at.

The things that fail may not necessarily be obvious. For example, processing interrupts from a timer whilst doing full-speed SPI, and also doing async serial at the same time, might be such a thing.
11  Community / Bar Sport / Re: Arduino working at 3.3volts on: February 02, 2014, 02:52:51 pm
Judging by the datasheet you can safely operate the Atmega2560 at 16 MHz down to 4.5V, but down to 2.7V at 8 MHz.

You may well have some code working at higher frequencies at 3.3V but some parts may not be guaranteed (eg. full-speed SPI for example).

These specs would also take into account manufacturing variances in the chips, so whilst one chip may work OK, another one with slightly different chemical composition (or trace thicknesses etc.) may not work.*

* if operated out of spec.
12  General Category / General Discussion / Re: A RESET can save your board (english/german) on: February 01, 2014, 11:34:24 pm
RESOLUTION:  execute a reset procedure, which is a sketch that sets all digital pins as INPUT.

To be more precise, load a sketch that sets all pins to input. Since the default is that pins are input, an empty sketch would do that.

void setup () { }
void loop ()  { }

Also, fairly obviously, you need to do this before connecting any hardware that might damage it. So if you have a spare Arduino lying around, load the above sketch before connecting up anything that might damage it.

Personally I would try to design my hardware layout so that it would not be damaged, even if the pins happened to be set to output.

Having said all that, since the you need to do this anyway before connecting hardware, and your new sketch presumably works with the new hardware, probably the simple thing is to load the new sketch and then connect the hardware afterwards (preferably after powering it off again).
13  Community / Bar Sport / Re: Arduino compatible ZIF socket, WTF? on: January 31, 2014, 03:51:17 am
Wait, I have it ...

  • Battery - Arduino compatible
  • USB cable - Arduino compatible
14  Community / Bar Sport / Re: Arduino compatible ZIF socket, WTF? on: January 30, 2014, 10:40:25 pm
How about: "This C++ code is Arduino-compatible."
15  Using Arduino / Programming Questions / Re: Micros equal multiple of four? on: January 30, 2014, 06:12:18 am
The prescaler for the timer (timer 0) is set to 64 so it ticks every 64 * 62.5 nS which is 4000 µS. 4000 nS (4 µS).

micros () then multiplies by a suitable number (4, presumably, in effect) to return microseconds (however, only accurate to the nearest 4 of them).

You can time to 62.5 nS precision if you set up your own timer (eg. timer 1).

Pages: [1] 2 3 ... 1300