Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Memory Question on: February 04, 2013, 09:22:39 am
Code:
char *buffer;         // the actual char array
unsigned int capacity;  // the array length minus one (for the '\0')
unsigned int len;       // the String length (not counting the '\0')
unsigned char flags;    // unused, for future features
Is the storage requirement of the String class, plus, of course, whatever "buffer" points to.
(from WString.h")
So, theoretically speaking if the String class would not have these fields, but it does have its methods (subString, Replace, etc...)
It would require just as much memory as the *buffer 's size to store an instance of String?
Sorry if I'm asking annoying questions, but I'm new to c/c++ ...  I've been taught programming with VB6/java/c# and computers that have so much memory all these little differences don't matter.
2  Using Arduino / Programming Questions / Re: Memory Question on: February 04, 2013, 08:32:44 am
Quote
"Ofcourse it's the same size cause the base data is the same and only some methods are added" ?
How could that possibly be true?
If seems possible to me that when you create a class/type , in this case String, you define the extra methods you want only in the source file of the class. You include that source file once, so the methods are defined once.
I would presume when you create an instance of this class, the base data (a field of your class) would still be a string but you can use
the extra methods (that were defined in the String class source file once) on the instance of the String class.

I think it's weird that when you create an instance it stores the methods in the memory again for each instance... the methods don't change...
With a class that has extra fields I understand it's bigger, because for each instance these fields could have a different values... Therefore it needs more space in the memory...
3  Using Arduino / Programming Questions / Re: Memory Question on: February 04, 2013, 07:51:24 am
Quote
Is there a difference in memory size between string and String?
A String is a class that wraps a string. What do you think the relative sizes will be?
I don't know for sure, but what I do know is that there are no stupid questions, but there are stupid answers. Do you expect me to come to some kind of conclusion by telling me that String wraps string? So what is the conclusion then?  "Ofcourse they are bigger because it wraps around a string and adds methods/fields" or "Ofcourse it's the same size cause the base data is the same and only some methods are added" ?
Quote
Or should I define these as 2 dimensional char array's?
That differs from an array of strings how?
I don't know if it differs, maybe because string wraps an 2 dimensional char array and something magically happens (or doesn't), but I wouldn't know that...

Quote
Note that these values will never need to change...
Then a foray into the wonderful world of PROGMEM is in your future (and the only way you will store that volume of data).

Quote
When the user select "save" in the menu, is there a way I can trigger a function in my main sketch from within my Menu class?
The class could have a method to register a callback. That callback would be a function in the sketch.
Thanks for answering these 2 questions, allready found pretty good information about PROGMEM. I'm going to look into that.
Could anybody direct me to a link were they explain the callback functions? It seems to be working kind of like the way delegates do in the realm of C#...
4  Using Arduino / Programming Questions / Memory Question on: February 04, 2013, 06:33:40 am
Hello,

I've just started writing my menu for my Arduino project. I was wondering what the best way of storing a large amount of text is.
I need 2 large array's of text for my menu. One array has 128 values which are strings with max. length around 30 chars and one with 60 values. I need these lines of text to display menu item options on a LCD screen, so i might change the values to a max length of 16 so it fits one line of my LCD.

Is there a difference in memory size between string and String? Or should I define these as 2 dimensional char array's?
What is the least memory consuming way of storing them? Should I just declare them as a field of my menu class?
Note that these values will never need to change...

Another question I have is this :
I have my sketch, in this sketch I use my custom class Menu. When the user select "save" in the menu, is there a way I can trigger a function in my main sketch from within my Menu class?

Kind regards.
5  Using Arduino / Audio / Piano sounds frequencies and tone function questions on: January 16, 2013, 09:57:51 am
Hi,

I'm new to Arduino and I've been playing around with sound.
I just found this site http://jarv.org/files/midi-avr/arduino_all_piano_tones.html
It has a table for all the piano note frequencies. Now I see that those frequencies have a decimal.
example : C8 (Eighth octave) = 4186.01
But the tone() function only accepts an unsigned int as the frequency parameter.
Could I just drop the decimals and use the rounded values? Will this still sound good?

I've read ton's more about generation audio with an Arduino, including wavetable synthesis combined with envelopes, but for now I've realised that that way of generating sound is too complicated for me. So I'll settle with the tone() function and the Tone library that allows playing 2 tones at the same time...

Also if one presses a piano key, the sound it produces will fade out over time instead of abruptly stopping.
Is this possible to simulate this with the tone() function? Or does that require wavetable synthesis too?
Or could I maybe achieve some effect like this with a circuit at the output useing 555 timers/capacitators/whatever... ?
 
Thanks for reading & kind regards,
Memorex
6  Using Arduino / Installation & Troubleshooting / Re: Broken/unprogrammed UNO R3? =( on: January 08, 2013, 01:43:39 pm
Hi Louis,

First of all, I would like to make it clear, the Arduino behaved like this out of the box.
I just now flashed my atmega16u2  with the hex code you mentioned.
First I had to install the driver for it (which is in a folder in the install path of the FLIP program)
Then I was able to use FLIP to write the program.
Unplugged it, plugged it back in. (The L LED still doesn't blink, it's still ON all the time).
Tried to install the Arduino drivers, and this time it worked.
Now the Arduino lists under COM ports as Arduino UNO(COM3) .
I started up the IDE, opened the Blink.ino file, selected COM3 as port and Arduino UNO as board.
Pressed upload,  and now I get another error :
"avrdude: stk500_getsync(): not in sync: resp=0x00"

While uploading the RX led flashed, But the L led is still on, and the TX led doesn't do anything.
Found a thread on this subject :
http://forums.adafruit.com/viewtopic.php?f=21&t=32708&start=30
But nothing suggested in the thread worked, I get the same 'advanced output' as in the thread.

So yeah, I think mine came with both chips unprogrammed. Manged to 'fix' the atmega16u2 but I have no device to burn the bootloader onto the main chip. I have ordered a second Arduino Uno from another site. I read i could use a working arduino to burn the bootloader on another one. If the guys at Iprototype can't help me out, I'm gonna try to fix it with another Arduino. smiley

Thanks everybody for trying to help, now I'm gonna ask Iprototype what to do.
7  Using Arduino / Installation & Troubleshooting / Re: Broken/unprogrammed UNO R3? =( on: January 08, 2013, 05:02:02 am
Hi Coding Badly,

Yes, i've followed the instuctions to the point I was able.
I did this :
-Download the software
-Plug in Arduino UNO ==> Power led goes on (green), L LED (yellow, close to pin 13) goes on but doesn't blink at all, it goes on and remains on as long as the board is plugged in.
-Device Manager lists it as under "Other device" instead of "Ports (COM & LPT)" and it is called "atmega16u2". When I try to install the driver and point to the correct folder. Windows says it can't find the driver.
-I despite tried to use the IDE to upload the blink program, but the serial port known to the IDE remains there even if I uplug the arduino. So it's not the right one...

Linux doesn't even seem to recognize an USB device was added (but i'm not familiar with these kind of things under Linux so i'm not sure...) and the drivers of my Linux machine might be a mess...

Before messing with the bootloaders, and the FLIP thing. When I leave work today, i'm taking it to my dad's place to test it on a iMac and see what happens...

Thanks for trying to help!
Kind Regards

8  Using Arduino / Installation & Troubleshooting / Re: Broken/unprogrammed UNO R3? =( on: January 08, 2013, 04:26:48 am
Hi Lefty,

Thanks for the fast reply.
I've bought it at www.iprototype.be
They are an offical reseller listed on : http://arduino.cc/en/Main/Buy
I'm pretty sure it's an offical UNO REV3.

But i've also read about using FLIP to fix the bootloader, do I need any hardware for this?
If not, I'm willing to try to fix it. I've bought the Arduino to learn, and these types of issues are very annoying but it's also very rewarding if you can fix it.

9  Using Arduino / Installation & Troubleshooting / Broken/unprogrammed UNO R3? =( on: January 08, 2013, 03:23:37 am
Hi,

Yesterday my brand new (and first) Arduino Uno R3 arrived.
But when 1 plug it in the USB, i don't get the expected blinking led.
Instead the power led and the led close to pin 13 both stay on all the time. The power led is green, the other one is yellow.
I've read some things online that this might mean this Arduino is unprogrammed. Could this be the case?
Also I've tried this on 2 Windows PC's and 1 Linux PC. Same result everywhere.
On windows, the board in the device manager isn't recognised as "Arduino Uno" like i've seen on screenshot's of other people online. Instead it is recognized as "atmega16u2" under 'other devices'. I think this also might be an indication that my board came unprogrammed. When I try to install the driver for the atmega16u2 device , i point to the correct Driver folder supplied by Arduino, the ArduinoUno.INF file is there, but windows says it can't find a driver in that location...
On Linux i don't see anything listed (but i'm still a Linux Noob)
Tonight I'm gonna try the board on a MAC.
This is quite demotivating, and i'm now left wondering if i'm doing something wrong or it it might be the board itself, so any help or info is greatly appreciated!

Hmm just found this in the troubleshoot: "Make sure there's a bootloader burned on your Arduino board. To check, reset the board. The built-in L LED (which is connected to pin 13) should blink. If it doesn't, there may not be a bootloader on your board. "
In my case the L LED comes on and stay's on...
Do I need hardware to try and fix this? Or should I just ask the shop for a replacement?

Kind Regards
Pages: [1]