Show Posts
Pages: 1 [2] 3 4 ... 10
16  Using Arduino / Programming Questions / Re: Strange error message on: April 14, 2014, 09:25:57 pm
Sorry for not replying sooner. The point is moot. I found out what was causing the error, and to answer your questions; The error occured at compile time, I beleive at the linker stage (not positve about that). I'm using a Mega2560 r2 and the latest IDE 1.5.6 r2. The program is a pool controller that uses the following libraries: DallasTemperature, OneWire, I2C, glcd and a modified (by me) version of DS1307. The sketch is large and will not fit here in the forum. I was going to put all the relative files in a zip to post however, I discovered the cause of the error. It is related to the glcd library and one of it's included fonts (Arial_bold_14.h). Once I changed the font everything's ok. If someone is really curious and likes to figure out problems, I'll take the time to zip all the files and post. There is still one thing I would like to know for future reference. What the error message means. I use interrupts in my sketch, but they have nothing to do with the glcd library or its fonts. Does it have something to do with the fonts being located in progmem? If so, why does it work after only changing the font used?

What I was asking in my OP wasn't "why isn't my code working?". It was "What does this error message mean?". For instance, you don't need to see any code to know what this error means,

error: new declaration 'uint8_t foo(uint8_t)'
error: ambiguates old declaration 'void foo(uint8_t)'

 Anyway the point is moot now, it's working. It's just curiosity that interests me.

Thanks for the reply.
17  Using Arduino / Programming Questions / Re: Strange error message on: April 13, 2014, 07:29:25 am
Has anyone ever seen this before? Anyone on the arduino team perhaps? Someone has to know what it means. Right?  smiley-roll
18  Using Arduino / Programming Questions / Strange error message on: April 13, 2014, 06:08:47 am
Can someone please explain to me what this error message means so I'll have a clue as to what is going on.

The error is:

c:/program files (x86)/arduino-1.5.6-r2/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o: In function `__vector_default':
(.vectors+0x3c): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_15' defined in .text section in c:/program files (x86)/arduino-1.5.6-r2/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o

I don't have any idea what it means, so any hints would help. Mostly, I would really like to understand what the message means. For instance, what is this (.vectors+0x3c): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_15' defined in .text section all about? Relocation... Huh?
19  Using Arduino / Programming Questions / Re: Why == works in an if statement? on: April 07, 2014, 01:36:10 pm
Also, it's a good habit to put the constant before the variable it's being compared to.
if (25 == a)
    // Some action here
The reason for doing this,
if (25 = a)
Will cause a compiler error. Because you're trying to assign a variable to a constant. This coding habit will catch your error where, if you put = but meant == (a very common mistake). If you do a = 25 it will compile, but obviously not what was intended.
20  Using Arduino / General Electronics / Re: Analogue/Digital ground planes on: February 02, 2014, 12:17:24 pm
Have a look at the file I've attached below. (Circut Board Layout Techniques.pdf) It's pretty informative.

I hope this helps,
21  Using Arduino / Programming Questions / Re: Questions about class syntax. on: February 01, 2014, 01:14:35 pm
Thanks for knowledge guys. As always, (I'm quoting South Park here) I think I've learned something today.  smiley-wink

22  Using Arduino / Programming Questions / Re: Questions about class syntax. on: February 01, 2014, 12:47:37 pm
I have another question (actually two). Can initializer lists be used with methods/functions? Can the x(y) syntax of assignment be used elsewhere as well? Not that I'd want to, because obviously for others like myself, it's function seemed to be ambiguous where as with y = x it's very clear what's going on. When I first saw it I thought it was as in mathmatics. Where x(y) would mean y multiplied by x. Now that I think about it, do you have to use that syntax in initializer lists, or can you use y = x instead?
23  Using Arduino / Programming Questions / Re: Questions about class syntax. on: February 01, 2014, 11:51:58 am
Thanks PaulS, I didn't see your first post until I was done writing my last post. Got it, constructor has same name as class.  smiley Another question, just out of curiosity. Consructors have no return type (not even void), but methods/functions must, correct?

24  Using Arduino / Programming Questions / Re: Questions about class syntax. on: February 01, 2014, 11:11:08 am

Thanks for your reply. I didn't assume it was a constructor, it was a guess. However, I did make that guess based on the empty brackets because I couldn't think of a reason for a method/function that does nothing. Now I know that empty brackets doesn't necessarily mean it does nothing. After taking another look, would it be correct to assume that it's a constructor because it has no return type?


Thanks to you too. I'm learning some very useful tips here  smiley. I know things like this will come in handy for coding future libraries. So, if I understand correctly, x(y) is an assignment of y to x? In a constructor, a colon after the parameter list denotes an initializer list, correct? Why isn't it called an assignment list? Aren't all of the variables (in this case) initialized in the parameter list and outside the method, or is that instantiation of the variables?
25  Using Arduino / Programming Questions / Questions about class syntax. on: February 01, 2014, 09:40:35 am
First, thanks in advance for any replies. I'm not having a problem with programming (at the moment  smiley-roll). I'm just curious and I like to learn things. So, I was going through the VoltageMeter library and noticed a couple things I hadn't seen before. I thought perhaps someone here could explain.

Here's the library (I removed the preceding comments to save space),

#include "WProgram.h"
#include "analog_reference.h"

class VoltageMeter {
  byte _pin;
  float _vMax;
  VoltageMeter(byte pin, float vMax)
    : _pin(pin), _vMax(vMax)
  int analogReadVoltage(int nSamples = 1) const {
    byte currentReference = getAnalogReference();
    float sum = 0;
    for (int i=0; i< nSamples; i++)
      sum += analogRead(_pin);
    return (sum / nSamples);
  float voltage(int nSamples = 1) const {
    return analogReadVoltage(nSamples) / 1023.0 * _vMax;


My first question, is VoltageMeter(byte pin, float vMax): _pin(pin), _vMax(vMax) {} listed under public: a constructor or a method? It looks like a constructor to me because there's nothing inside the brackets {}. Next question, what does : _pin(pin), _vMax(vMax) do? I've never seen variableX(variableY) before. I don't think it's a cast like int(variable) because a: neither is a type, and b: both variables used are of the same type. Last question, what does the const just before the opening bracket of the methods do, and why is it placed before the bracket as opposed to somewhere else?

Thanks again for any replies,
26  Using Arduino / Programming Questions / PROGMEM question on: February 28, 2013, 11:04:47 pm
I know storing strings in flash memory saves on RAM, but does the same hold true for numeric constants?

For example:

// Say you have a function that takes four numbers

void foo(uint8_t a, uint8_t b, uint8_t c, uint8_t d)
    /* do something here */

// Then for whatever reason it's used in a loop with data from an array

const uint8_t array[3][4] =
    {240, 54, 12, 53},
    {122, 8, 59, 22},
    {8, 0, 255, 127}

for (uint8_t i = 0; 3 > i; i++)
    foo(array[i][0], array[i][1], array[i][2], array[i][3]);

// This example is small, but let's say the array is much larger and with more loop iterations

Is there any benefit in putting the array in flash memory via PROGMEM, or is the array already stored there because it's a const data type?
Would it make a difference if it was not a const data type?

Thanks for any replies,
27  Products / Arduino Due / A question about the two USB jacks. on: February 18, 2013, 04:44:17 am
I recently received my DUE smiley-grin and I have a couple micro USB cables on their way. I was just looking over the board and noticed that the USB slots are shaped just slightly different. The native port is rectangular and the programming port id "D" shaped. Will I need two different USB plugs?

Thanks for any replies,
28  Using Arduino / Storage / Re: Very large bitmap to SD problem. [Solved] on: February 18, 2013, 04:36:21 am
Thanks PeteA,
  Actually, I figured it out yesterday and as you stated I needed to transfer the .raw image file to the card. Previously I was putting a .c file on the card. Thanks for the reply anyway.

29  Using Arduino / Storage / Very large bitmap to SD problem. on: February 15, 2013, 12:02:22 pm
I have a 5" TFT (800x480) w/ SD card (128MB), a Mega 1280 and a Mega 2560 (DUE on the way). I want to save a full screen bitmap to the SD card. However, none of the arduino's have enough memory (RAM or Flash) to store the bitmap to write it to the card. I noticed if I write a small bitmap to the card with the arduino and also write the same file to the card with my PC, it is not the same format. The data in the two files are different. Is there a way I can write a large bitmat to the card with my PC and be able to read the file with the arduino? I have very little experience with SD cards, but I learn quickly.

Thanks for any help,
30  Development / Other Software Development / Re: External Memory Interface library for the Mega. (can someone review my code?) on: December 31, 2012, 08:37:19 pm
I looked at the data sheet for the AT90USB1286 and the register names are the same so it should work.

Pages: 1 [2] 3 4 ... 10