Show Posts
Pages: 1 ... 48 49 [50] 51 52 ... 147
736  Using Arduino / Programming Questions / Re: Alternative serial monitor on: December 27, 2013, 12:49:40 am
The best monitor I have used is called Hterm. It is by far the most feature full monitor I have used ( far better than many paid alternatives ).

Here is a thread I started a while ago asking a similar question. Hterm was recommended there.
Free serial monitor / serial data capture applications. Recommendations?
737  Topics / Home Automation and Networked Objects / Re: router on: December 24, 2013, 09:21:50 pm
I have used this method for a while, its a nice and cheap alternative. Also very stable compared to the official Wifi shield as that does not properly support transport protocols and fails easily.

I have also wanted to try a router with multiple ports. Using an Ethernet to USB adapter ( for networked USB ) I'm hoping to be able to upload sketches remotely via Ethernet. Got my hands on an old goat (DSL-G604T) to test in the new year.
738  Development / Other Software Development / Re: Best way to determine CPU type at compile time? on: December 24, 2013, 08:49:53 pm
This is how I do it in one of my multi-platform libs ( the AVR section anyway ), I think fat16lib did the hard work of gathering up all the processor defines.

This is what it can detect now.
* ATmega
  - 32u4
  - 168
  - 168p
  - 328p
  - 644
  - 644p       
  - 1280
  - 1284p       
  - 2560

* AT90USB
  - 646
  - 1286

Code:
// 168 and 328 Arduinos
#if defined(__AVR_ATmega168__) ||defined(__AVR_ATmega168P__) ||defined(__AVR_ATmega328P__)
  #define CHIPSET ATmega_168_168P_328P
 
// Mega 1280 & 2560
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  #define CHIPSET ATmega_1280_2560
 
// Sanguino
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
  #define CHIPSET ATmega_644_644P_1284P
 
#elif defined(__AVR_ATmega32U4__)

  // Teensy 2.0
  #ifdef CORE_TEENSY
#define CHIPSET ATmega_32U4_A

  // Teensy
  #else
#define CHIPSET ATmega_32U4_B
  #endif
 
// Teensy++ 1.0 & 2.0
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
  #define CHIPSET AT90USB_646_1286
#endif

#include   INCLUDE_FILE_3(HARDWARE_PREFIX,GENX_PLATFORM,MAKE_DIR(CHIPSET),.pins)

You can remove the CHIPSET define and the file include, then fill in with your own design.
739  Using Arduino / Programming Questions / Re: Nesting vs Flow on: December 24, 2013, 02:08:28 am
Exceptions are actually quite the opposite. They provide a safe mechanism to recover from an error/loss of state by unwinding the stack ...

Unwinding the stack, and killing the stack, seem the same to me (in a sense). You are discarding stack entries.

Its not discarding it at all. The purpose of stack unwinding is to call the destructors of the objects that reside in the stack, allowing them to finish and free their memory and so on.
740  Using Arduino / Programming Questions / Re: variables global,local,static and constants on: December 24, 2013, 01:49:20 am
What pYro_65 said shouldn't been trivialized.

What exactly are you referring to?
Static locals have the same scope as auto locals, the benefit is persistence.
File scope/member static variables are limited to the scope they are defined in.
Also local statics have no implication on code size, how it is used determines the potential for optimization.
741  Using Arduino / Programming Questions / Re: Nesting vs Flow on: December 24, 2013, 01:40:26 am
Quite simply, you almost never need to do this. There are ways, exceptions is one of them (not available on the Arduino) and also non-local goto, however I recommend the state machine.

Exceptions are actually quite the opposite. They provide a safe mechanism to recover from an error/loss of state by unwinding the stack to the point of the first encountered exception handler. If it can resolve the error, the stack is intact and ready to go. If it cannot, the exception is re-thrown and the unwinding continues to the next handler.
742  Community / Bar Sport / Re: Can you actually buy these anywhere?? on: December 24, 2013, 01:27:50 am
Rarities... Arduino UNO R3 ATmega328P: $113.75 in eBay. Seems to be the OEM.

It clearly says its a clone, its just a claim to high quality.  It is a mistake, if you look at the previously sold list they went for $13.75

http://www.ebay.com/itm/UNO-R3-ATmega328P-ATmega16U2-Free-Cable-for-Arduino-FAST-US-QUALITY-SHIP-/181233924280?pt=LH_DefaultDomain_0&hash=item2a326238b8
743  Using Arduino / Programming Questions / Re: variables global,local,static and constants on: December 24, 2013, 12:38:49 am
Either variable is subject to optimization.

If the compiler can see that nothing writes to them it may evaporate into load data commands and use no ram at all.
The compiler can do the least with it if you take a reference/pointer that the compiler cannot follow; something like an array of pointers where the index used to access it may come from an external/interrupt source ( analogRead, switch,... ).

The compiler doesn't need "const" to optimize out things that are blatantly obvious either. Infact sometimes you have to use "volatile" to stop it from doing so.

EDIT: Globals have lots of things that can cause nasty headaches, if only one function/scope needs the persistent data then go for the local static.
744  Using Arduino / Programming Questions / Re: Nesting vs Flow on: December 24, 2013, 12:26:36 am
The stack space is used for this, each function call is "pushed" onto the stack, when it returns it is "popped" from the stack.
As the callee of a called function hasn't returned its data is still on the stack.

So the memory position ( in the stack ) before a function is the stack space for the function that called it, this may include saved register states between calls.

The stack actually starts at the end of RAM and grows backwards, just switch the meanings of before and after and you're fine smiley

The recursion limit is based on memory exhaustion, AVR's have the bonus of not having program space in ram so you can recursively call small functions many times before a considerable amount of memory is  used.
745  Community / Bar Sport / Re: Can you actually buy these anywhere?? on: December 24, 2013, 12:11:13 am
You've made  no mention of the price you wish to pay. Do you mean New York when you say big apple? If so I do not really believe that New York only has one reasonably priced retailer.

What about Ebay?
Whats wrong with these knock offs:
  • Pro Mini $2.95
  • Uno $5.99

    The board may be of a lesser quality ( quite good in my  experience ), but the processor is still made by Atmel.
746  Using Arduino / Programming Questions / Re: variables global,local,static and constants on: December 23, 2013, 11:26:29 pm
Using a static variable in a function has no different implications to a global variable ( to the function with the static var ). Everything else however will either not see the variable, or have access to it, depending on weather its static or global respectively.
747  Using Arduino / Programming Questions / Re: simple loop logic quesiton on: December 23, 2013, 06:19:26 am
Quote
what is the problem here?
 when SC=10, then SC-1=9, then stLED[9]=0 should go LOW

SC never has a chance to be decremented to 9, you set it to zero then subtract one:

Quote
if(SC==10){
SC=0;
stLED[9]=0;}

stLED[SC-1]=0;
stLED[SC]=1;
748  Using Arduino / Programming Questions / Re: PROGMEM array of structs on: December 23, 2013, 05:30:05 am
String literals need to be placed into memory separate, otherwise you still have it in RAM, but you can use an additional struct to combine the three, then you only need one array. Here is  an example using a single element ( not an array ). but expanding to an array is simple:

Code:
struct WordMap{
  char* name; // identifier
  uint8_t row; // the row number (0-7)
  uint16_t rowPos; // two bytes of positions that should be on or off (16 positions available)
};

struct HourMap{
  uint8_t name;
  uint8_t row;
  uint16_t rowPos;
};

struct MinuteMap{
  uint8_t name;
  uint8_t row;
  uint16_t rowPos;
};

struct Maps{
  WordMap Words;
  HourMap Hours;
  MinuteMap Minutes;
};

char het[] PROGMEM = "het";
Maps maps PROGMEM = { {het,    0,  0xe000}, {1, 3, 0xe000}, { 1,2,3 } };

To use in pgm_read_xxx, find the element you need then take its address. Say I want the row value from the WordMap:

Code:
x = pgm_read_byte( &maps.Words.row );

749  Using Arduino / Project Guidance / Re: EEPROM GUI development guidance on: December 23, 2013, 05:19:26 am
You write to the EEPROM while a sketch is running, I don't know of a program that can directly write the data ( it may well exist though ). You could either use a custom sketch to preset the data, or add in a one time function that will add the values if say an eeprom value is not set ( by the initial setup ).

If you like the hardware way, you could add a button to do a 'factory reset' which defaults the eeprom.

Here is some reading and a library that might help simplify access.
http://arduino.cc/en/Reference/EEPROM
http://playground.arduino.cc/Code/EEPROMWriteAnything

You can create a PC GUI to control the Arduino through the serial port ( or other comms ) using processing:
www.processing.org/

Any specific electrical questions can be directed to the General Electronics forum.
http://forum.arduino.cc/index.php?board=5.0
750  Using Arduino / Programming Questions / Re: strings / string literals on: December 22, 2013, 08:58:38 am
As you are using the print functionality you can avoid using the temporary buffer as the Print library can handle PROGMEM data.
It needs a little help, but still worth it if ram is tight.

Code:
//in file scope
#define PGMSTR __FlashStringHelper*

//In your code:
lcd.setCursor(0, j);
lcd.print( ( PGMSTR ) pgm_read_word(&menu_table[i]) );
Pages: 1 ... 48 49 [50] 51 52 ... 147