Show Posts
Pages: 1 ... 5 6 [7] 8 9 ... 29
91  Using Arduino / Project Guidance / Re: I2c sniffer on: March 08, 2014, 02:17:41 pm
This is not possible with ATmegaXXX processors and the internal TWI/I2C hardware but actually possible with ATtinyXXX or others that have internal USI. The problem has to do with the address matching. In TWI/I2C the slave address match is build-in. On USI this is done in software and you can implement a monitor.

Obviously you could implement this with soft TWI on any Arduino.

92  Using Arduino / Project Guidance / Re: Change SDA and SCL pins on Mega on: March 08, 2014, 02:11:38 pm
DHT11 is not an i2c device, so you could not use that with the rtc. The sht15 is i2c, that should work with your rtc.
Sorry to say this but both these devices, DHT11 and SHT1x, are NOT I2C. They have other protocols.
93  Using Arduino / Microcontrollers / Re: PCB Assembly house programming an ATtiny? on: March 08, 2014, 01:58:18 pm
That was an interesting question on this forum. Obviously it doesnt have anything to do with Arduino. Instead it is a question about how to OEM program AVR.

First of all there is no need to program a bootloader and upload. Typically an ATtiny is programmed with the ISP interface. If the PCB does not have a ISP connection and uses SMD components the programming will have to be done before the assembly.

The HEX file is just fine (if they can handle that ;-). That is a question to the PCB Assemby house.

Depending on where you plan to by the ATtinys you can actually get them pre-programmed. In some cases this is worth the extra cost. Your favorite web-search tools is as usual a good friend;

94  Using Arduino / Microcontrollers / Re: LCD 20x4 on ATTiny85 I2C problems on: March 07, 2014, 10:02:23 am
do you have a simple sample sketch?
When working with the 85 do you call pin 5 or Pin 0?
First of all I need to explain that Cosa is an object-oriented platform for Arduino with over 100+ classes. It is an Arduino core but supports all AVR processor based boards plus ATtiny and Mighty. It is also stand-alone and does not depend on any Arduino code more than the IDE build process.

The simplest example sketch is the LCD hello world that I use for footprint benchmarking.

The pin-out is described in the Board description file for ATtiny.
Pins in Cosa are symbols, e.g. Board::D0 instead of integers as in Arduino/Wiring.

You can basically develop on Mega, Uno, etc, and simply select ATtiny85 and compile-and-burn with more libraries than in any other Arduino package. SPI, TWI, 1-Wire etc are all support. LCD support is an abstract class that is implemented for HD44780, PCD8544, ST7565. The HD44780 driver also has an adapter layer for 4-bit parallel, Shift Register 3-wire (Pin or SPI), Shift Register 4-wire and a whole range of different I2C adapters. You can see how the configuration works in the CosaLCDsize sketch above.


95  Using Arduino / Microcontrollers / Re: LCD 20x4 on ATTiny85 I2C problems on: March 07, 2014, 08:24:24 am
Did you use external pullup resistors? The internal are too weak on the ATtiny. Some I2C LCD adapter modules do not have them at all and require external.

Please see

More info on

96  Development / Other Software Development / Re: "optimizing compiler" on: March 06, 2014, 06:02:23 pm
Great! Good luck with your project. Cheers!
97  Development / Other Software Development / Re: Cosa: An Object-Oriented Platform for Arduino programming on: March 06, 2014, 04:09:26 pm
The next increment of the ThingSpeak API support in Cosa is now available. This update contains an implementation of the ThingSpeak TalkBack API and allows execution of commands sent to the server command queue. See for more details.

The Cosa support allows easy extension of a command handler by basically sub-classing the ThingSpeak::TalkBack::Command class and implementing the virtual member function execute(). The application does not need to match command strings and dispatch command handlers. All that is provided by the Cosa ThingSpeak TalkBack classes.

Below is a snippet from the example sketch. This section shows how to define a command handler. In this case a generic command handler that traces the command string.
class Command : public ThingSpeak::TalkBack::Command {
  Command(ThingSpeak::TalkBack* talkback, const char* string) :
    ThingSpeak::TalkBack::Command(talkback, string)
  virtual void execute();

  trace << Watchdog::millis() << ':' << get_string() << endl;

const char LED_ON[] PROGMEM = "LED_ON";
const char LED_OFF[] PROGMEM = "LED_OFF";
const char REBOOT[] PROGMEM = "REBOOT";

// Talkback command
Command led_on(&talkback, LED_ON);
Command led_off(&talkback, LED_OFF);
Command reboot(&talkback, REBOOT);
The setup and loop functions are very simple. Basically intiating the ethernet driver, creating a ThingSpeak client and executing queued commands on the server.
ThingSpeak::Client client;
ThingSpeak::TalkBack talkback(&client, KEY, ID);
void setup()
  trace.begin(&uart, PSTR("CosaThingSpeakTalkBack: started"));

void loop()
  // Take a nap if there was nothing to execute
  if (talkback.execute_next_command() != 0) SLEEP(30);
Example sketch:
The TalkBack command queue can be connected to a ThingSpeak channel which is used as a log of the executed commands.

98  Development / Other Software Development / Re: "optimizing compiler" on: March 05, 2014, 07:17:17 pm
So where did you put the function attribute and did you update the platform.txt file?

I checked your code and you are not using header files right. Please check how to partition code into header and source files. Below is the correct pattern for the "noinline" attribute.

int func(int arg) __attribute__((noinline))

As all code is included into the build through the "header" files this actually signals to the compiler that the functions are inline. This is how C++ works. Member functions in header files are automatically inline (when possible). The compiler uses a few heuristics to determine if there is actually en benifit from inline and how much the function is allowed to grow.

If your really want to do something about your source code start by cleaning up the "header" file mess. This will also clean up the footprint problem.

99  Using Arduino / Project Guidance / Re: generating interrupt for running a specific code on: March 05, 2014, 06:54:26 pm

Unfortunately this question is poorly specified. We (at least I) simply do not know the full spec/use case/etc. Using digitalRead() does not say that it is 5V. It could be as low as 0.6VCC (3V typical). Below is the original question.

i want to generate an interrupt on detecting 5 volts and run any specific code

The function digitalRead does not generate an interrupt. All this depend on how we interpret the question; logical high signal, analog voltage theshold, button, etc. And an interrupt is intended.

But I fully agree Analog Comparator is the more complex and thus less likely (Occam). The interpretation of the question is then "how do it detect a logical high signal and execute a specific part of code". And the answer is:

if (digitalRead(PIN)) {
   // the specific code block to execute when the PIN is logical high/on/active/etc


[Update] After reading other forum posts by kazmi I am convinced that @Robin2 your interpretation is spot on. The usecase seems to be a trigger to capture an image and send to a mobile phone. But this is with some hand-waving.
100  Development / Other Software Development / Re: "optimizing compiler" on: March 05, 2014, 04:36:38 pm
I think we have answered your original question. To make it easier for others to find information please post a new question instead of continueing on this post. Please make an attempt to search for the information and share instead of just asking questions. For instance google on gcc function attributes, read the manual, and ask for an interpretation and/or examples.

101  Using Arduino / Project Guidance / Re: generating interrupt for running a specific code on: March 05, 2014, 04:32:34 pm
Actually ATmega has the perfect mechanism for this. Below is a section from the manual:

25. AC – Analog Comparator
The Analog Comparator compares the input values on the positive pin AIN0 and negative pin
AIN1. When the voltage on the positive pin AIN0 is higher than the voltage on the negative pin
AIN1, the Analog Comparator output, ACO, is set. The comparator’s output can be set to trigger
the Timer/Counter1 Input Capture function. In addition, the comparator can trigger a separate
interrupt, exclusive to the Analog Comparator. The user can select Interrupt triggering on com-
parator output rise, fall or toggle.

You can find out more on page 271 in the ATmega2560 manual.


Does Arduino/Wiring support this? No but Cosa does. Check github or my posting on the forum.

102  Development / Other Software Development / Re: "optimizing compiler" on: March 05, 2014, 12:18:44 pm
The next thing to do is to sort the symbol files;

sort xxx.sym > xxx.sorted.sym

And then check where the commented function size is larger than uncommented. Then you check the listing to see the assembly code. And my guess is that you will find the answer --- compiler function inlining.

I did all this and found that the menu functions became much larger in the commented version. This implies the compiler took the decision to inline some functions.

00002bb6 000007e6 T MenuGeneral()         commented
00002266 000001e4 T MenuGeneral()          uncommented

Hum, you need to know something about the file format. It is simply address, size, attribute and symbol. Nothing strange. Try using google and reading manuals ;-)

And, yes, you can force the compiler to not inline (for instance AddWord) to reduce footprint but that is a different line of QA.

103  Development / Other Software Development / Re: "optimizing compiler" on: March 05, 2014, 03:28:08 am
Replacing "avr-size" with "as" is not correct. Try removing that all together. Skip the size information for now and generate the symbol and listing file first. Then you have something to work on.

To implement the "avr-size" information I think it's easiest just to look at what the IDE for 1.5.X does as it produces that information at the end of the build.

104  Development / Other Software Development / Re: "optimizing compiler" on: March 04, 2014, 06:21:35 pm
Ok. I do not use a mac so this is hand-waving.

First you have to find the Arduino installation and locate the AVR tools bin directory. Add that to your PATH or simply execute the script from there. On my machine it is /opt/arduino-1.5.6-r2/hardware/tools/avr/bin.

Second check where the Arduino build puts the compiled files and replace the /tmp/build*/ etc with that path. Hint: Enable compiler printout in the Arduino IDE and look for the path when compiling.

When you get this working I will be waiting for the next question ;-)

105  Development / Other Software Development / Re: "optimizing compiler" on: March 04, 2014, 04:04:55 pm
So is there some way to understand what is going on? Yes, there are tools to this. Not in the Arduino library but in the AVR toolbox. You can check what goes into the build and understand the difference and thus find the source to the problem. Below is a Linux shell script that I use to generate a list and symbol file (to reduce the Cosa footprint, do not what to end up with this type of problems ;-)
avr-size -C /tmp/build*.tmp/$1.cpp.elf > $1.lst
avr-objdump -d /tmp/build*.tmp/$1.cpp.elf >> $1.lst
avr-nm -CS /tmp/build*.tmp/$1.cpp.elf > $1.sym
The script generates size information and an assembly listing but also a symbol file.

"Know your numbers",

Pages: 1 ... 5 6 [7] 8 9 ... 29