Show Posts
Pages: [1] 2
1  Development / Suggestions for the Arduino Project / Re: Why is Ethernet so expensive? on: January 06, 2013, 04:13:35 am
Looking at the schematics, the Raspberry Pi seems to use a LAN9512 "Hi-Speed USB 2.0 hub and high-performance 10/100 Ethernet controller". On Digikey these are $3.80 for 100+.

The Wiznet ethernet chip used in the Uno Ethernet costs $4.76 for 100+ from Sparkfun.

These two solutions seem comparable to me. I still don't understand why adding Ethernet to an Arduino costs more than the Arduino on its own. I appreciate costs go down with volumes but an Ethernet shield is still at the top end of shield prices.
2  Development / Suggestions for the Arduino Project / Why is Ethernet so expensive? on: January 06, 2013, 03:22:18 am
An Arduino Uno costs $30. An Uno with Ethernet costs $65. A Raspberry Pi with Ethernet, 512MB RAM, HDMi video and an SD card slot costs $40. An Adafruit Ethernet shield sells for $45, more than the complete Raspberry Pi.

Presumably the adding Ethernet to a Pi cost a few dollars. Why is Ethernet so expensive with Arduino?

Julian
3  Using Arduino / Installation & Troubleshooting / Re: Can't upload sketch to Diecimila upgraded to 328 on: January 04, 2013, 01:32:17 pm
I've solved the problem by burning a new bootloader. I guess the one that was already present, which was three years old, was not compatible with the present upload software.

To burn a new bootloader, I used another Arduino as programmer. See instructions at http://arduino.cc/en/Tutorial/ArduinoISP
4  Using Arduino / Installation & Troubleshooting / Re: Can't upload sketch to Diecimila upgraded to 328 on: January 04, 2013, 12:51:22 pm
Thanks for those suggestions. I've now installed Arduino 1.0.3 and the problem is the same. Duemilanove is the same Board option on the menu as Diecimila, so I can't choose a different option. If I choose a 168 board it tells me I have specified the wrong processor, so it seems some communication is going on.

Julian
5  Using Arduino / Installation & Troubleshooting / Can't upload sketch to Diecimila upgraded to 328 on: January 04, 2013, 05:05:32 am
I have a Diecimila 168 (original, not clone) that works, I can upload sketches to it.

I also have a couple of 328 chips preprogrammed with the bootloader, which I bought about three years ago and never used. I'm trying to upgrade the Diecimila to the 328 chip.

When I plug in the 328 chip, it appears to be running the Fade example sketch, so seems to be working. However, when I try to upload Blink, I get "avrdude: stk500_getsync(): not in sync: resp=0x00"

I have selected the correct chip in from the Tools menu and, if I select the 168, I get a message "Wrong microcontroller found". This suggests the Arduino software is actually communicating with the chip, just not uploading sketches.

I'm running 1.5.1 Arduino software on OSX 10.8.2, so everything is up to date.

Any hints and suggestions for what to look at gratefully received.

Thanks,

Julian
6  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Compiler adds code twice on: February 03, 2009, 03:34:39 am
Here is the relevant output. I can email you the whole file if you let me know where to send it. There are three copies of this code at different addresses even though there is a single method in the source. I wonder if the default compiler switches in the development environment are forcing this to happen as part of some sort of speed optimisation.

Is this forum the best place to raise this with the developers of the development environment or do they hang out elsewhere?

Julian

Code:
void OneWire::reset_search()
{
    uint8_t i;
    
    searchJunction = -1;
 172:      8f ef             ldi      r24, 0xFF      ; 255
 174:      18 96             adiw      r26, 0x08      ; 8
 176:      8c 93             st      X, r24
 178:      18 97             sbiw      r26, 0x08      ; 8
    searchExhausted = 0;
 17a:      19 96             adiw      r26, 0x09      ; 9
 17c:      1c 92             st      X, r1
 17e:      19 97             sbiw      r26, 0x09      ; 9
 180:      87 e0             ldi      r24, 0x07      ; 7
    for( i = 7; ; i--) {
      address[i] = 0;
 182:      fd 01             movw      r30, r26
 184:      e8 0f             add      r30, r24
 186:      f1 1d             adc      r31, r1
 188:      10 82             st      Z, r1
      if ( i == 0) break;
 18a:      88 23             and      r24, r24
 18c:      11 f0             breq      .+4            ; 0x192 <_ZN7OneWireC2Eh+0x88>
{
    uint8_t i;
    
    searchJunction = -1;
    searchExhausted = 0;
    for( i = 7; ; i--) {
 18e:      81 50             subi      r24, 0x01      ; 1
 190:      f8 cf             rjmp      .-16           ; 0x182 <_ZN7OneWireC2Eh+0x78>
 192:      08 95             ret

Code:
void OneWire::reset_search()
{
    uint8_t i;
    
    searchJunction = -1;
 1fc:      8f ef             ldi      r24, 0xFF      ; 255
 1fe:      18 96             adiw      r26, 0x08      ; 8
 200:      8c 93             st      X, r24
 202:      18 97             sbiw      r26, 0x08      ; 8
    searchExhausted = 0;
 204:      19 96             adiw      r26, 0x09      ; 9
 206:      1c 92             st      X, r1
 208:      19 97             sbiw      r26, 0x09      ; 9
 20a:      87 e0             ldi      r24, 0x07      ; 7
    for( i = 7; ; i--) {
      address[i] = 0;
 20c:      fd 01             movw      r30, r26
 20e:      e8 0f             add      r30, r24
 210:      f1 1d             adc      r31, r1
 212:      10 82             st      Z, r1
      if ( i == 0) break;
 214:      88 23             and      r24, r24
 216:      11 f0             breq      .+4            ; 0x21c <_ZN7OneWireC1Eh+0x88>
{
    uint8_t i;
    
    searchJunction = -1;
    searchExhausted = 0;
    for( i = 7; ; i--) {
 218:      81 50             subi      r24, 0x01      ; 1
 21a:      f8 cf             rjmp      .-16           ; 0x20c <_ZN7OneWireC1Eh+0x78>
 21c:      08 95             ret

Code:
0000021e <_ZN7OneWire12reset_searchEv>:

//
// You need to use this function to start a search again from the beginning.
// You do not need to do it for the first search, though you could.
//
void OneWire::reset_search()
 21e:      dc 01             movw      r26, r24
{
    uint8_t i;
    
    searchJunction = -1;
 220:      8f ef             ldi      r24, 0xFF      ; 255
 222:      18 96             adiw      r26, 0x08      ; 8
 224:      8c 93             st      X, r24
 226:      18 97             sbiw      r26, 0x08      ; 8
    searchExhausted = 0;
 228:      19 96             adiw      r26, 0x09      ; 9
 22a:      1c 92             st      X, r1
 22c:      19 97             sbiw      r26, 0x09      ; 9
 22e:      87 e0             ldi      r24, 0x07      ; 7
    for( i = 7; ; i--) {
      address[i] = 0;
 230:      fd 01             movw      r30, r26
 232:      e8 0f             add      r30, r24
 234:      f1 1d             adc      r31, r1
 236:      10 82             st      Z, r1
      if ( i == 0) break;
 238:      88 23             and      r24, r24
 23a:      11 f0             breq      .+4            ; 0x240 <_ZN7OneWire12reset_searchEv+0x22>
{
    uint8_t i;
    
    searchJunction = -1;
    searchExhausted = 0;
    for( i = 7; ; i--) {
 23c:      81 50             subi      r24, 0x01      ; 1
 23e:      f8 cf             rjmp      .-16           ; 0x230 <_ZN7OneWire12reset_searchEv+0x12>
 240:      08 95             ret

00000242 <_ZN7OneWire4crc8EPhh>:
}
7  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Compiler adds code twice on: February 02, 2009, 04:24:29 pm
That's very odd. A couple of questions:

1. You say the linker will remove the unwanted copies. At what stage does it do this? My .hex file appears to have a size (from avr-size) that is the same size diplayed by the development environment when you compile or upload. If I move code from, say, setup to a class constructor, the size of the resulting hex file is bigger. This would seem to indicate that the code is in the hex file twice if it's in a constructor and once if it's in setup. I assume the hex file is post-linker. Is that correct?

2. A workaround would seem to be to make sure class constructors have nothing more than a call to another function to perform class initialisation, assuming that doesn't get duplicated as well.

3. If I add the OneWire library to my test class above, the "reset_search" method (not a constructor) appears three times in the output. I made a temporary change to this function (added a call to another function) and the reported size went down! The objdump output now only has a single copy of reset_search, which would seem to explain why the size has gone down.

I can't help thinking that the compiler is making the code needlessly bigger than it should be.

Julian

8  Forum 2005-2010 (read only) / Bugs & Suggestions / Compiler adds code twice on: February 02, 2009, 05:49:27 am
Apologies for cross posting but this is probably better here under software.

Looking at the compiler output of a sketch, I noticed that some class members seem to have been compiled twice. i.e. Exactly the same code is generated at two different places, taking up twice the memory needed. I first became aware of this when moving code from a sketch to a class file - it increased the code size, which seemed odd. I have reproduced this in a very simple example.

Make a copy of the Blink sketch (called Test) and add two files:

MyClass.h
Code:
class MyClass {
  private:
    int _val;
  public:
    MyClass (int val);
};
MyClass.cpp
Code:
#include "MyClass.h"

MyClass::MyClass (int val) {
  _val = val;
}

Look at the output from avr-objdump (thanks mem!) created using:
Code:
avr-objdump -S -t Test.elf > temp.txt

It has:
Code:
0000013a <_ZN7MyClassC2Ei>:
#include "MyClass.h"
#include "WConstants.h"

 13a:      fc 01             movw      r30, r24
MyClass::MyClass (uint8_t val) {
 13c:      71 83             std      Z+1, r23      ; 0x01
 13e:      60 83             st      Z, r22
  _val = val;
 140:      08 95             ret

00000142 <_ZN7MyClassC1Ei>:
#include "MyClass.h"
#include "WConstants.h"

 142:      fc 01             movw      r30, r24
MyClass::MyClass (uint8_t val) {
 144:      71 83             std      Z+1, r23      ; 0x01
 146:      60 83             st      Z, r22
  _val = val;
 148:      08 95             ret

In other words, the constructor is being compiled once at location 13a and again at location 142. The symbol table has two entries for the method with slightly different suffixes.

Can anyone explain what is happening here?

Thanks,

Julian
9  Forum 2005-2010 (read only) / Syntax & Programs / Re: Function pointer to non-void function on: January 17, 2009, 05:07:33 pm
You are a genius! Thanks very much. Using uint8_t, uint16_t, etc. works as expected.

Julian
10  Forum 2005-2010 (read only) / Syntax & Programs / Function pointer to non-void function on: January 17, 2009, 01:40:05 pm
What am I doing wrong here? This compiles:

Code:
void myfunc(int a, char *s) {
}

void test2(void (*process_function)(int, char *)) {
}

void test1() {
  test2(myfunc);
}

However, when I change myfunc to return an integer, I get a compile error. i.e.

Code:
int myfunc(int a, char *s) {
  return 1;
}

void test2(int (*process_function)(int, char *)) {
}

void test1() {
  test2(myfunc);
}

The error is "error: variable or field 'test2' declared void In function 'void test1()':". It doesn't seem to like the function pointer referring to a function that returns a value. Any ideas?

Thanks,

Julian
11  Forum 2005-2010 (read only) / Development / Class code added twice to compiler output on: February 01, 2009, 01:19:53 pm
Looking at the compiler output of a sketch, I noticed that some class members seem to have been compiled twice. i.e. Exactly the same code is generated at two different places, taking up twice the memory needed. I first became aware of this when moving code from a sketch to a class file - it increased the code size, which seemed odd. I have reproduced this in a very simple example.

Make a copy of the Blink sketch and add two files:

MyClass.h
Code:
class MyClass {
  private:
    int _val;
  public:
    MyClass (int val);
};
MyClass.cpp
Code:
#include "MyClass.h"

MyClass::MyClass (int val) {
  _val = val;
}

Look at the output from avr-objdump (thanks mem!) created using:
Code:
avr-objdump -S -t Test.elf > temp.txt

It has:
Code:
0000013a <_ZN7MyClassC2Ei>:
#include "MyClass.h"
#include "WConstants.h"

 13a:      fc 01             movw      r30, r24
MyClass::MyClass (uint8_t val) {
 13c:      71 83             std      Z+1, r23      ; 0x01
 13e:      60 83             st      Z, r22
  _val = val;
 140:      08 95             ret

00000142 <_ZN7MyClassC1Ei>:
#include "MyClass.h"
#include "WConstants.h"

 142:      fc 01             movw      r30, r24
MyClass::MyClass (uint8_t val) {
 144:      71 83             std      Z+1, r23      ; 0x01
 146:      60 83             st      Z, r22
  _val = val;
 148:      08 95             ret

In other words, the constructor is being compiled once at location 13a and again at location 142.

Can anyone explain what is happening here?

Thanks,

Julian
12  Forum 2005-2010 (read only) / Development / Re: Displaying generated code on: February 01, 2009, 10:13:42 am
That's fantastic. Just what I was looking for.

Thanks,
Julian
13  Forum 2005-2010 (read only) / Development / Displaying generated code on: February 01, 2009, 09:13:13 am
Is there any way of showing the assembler code generated from compiling a sketch. A list of assembler commands against each C++ line would be really nice  smiley. I know some compilers do this but is there any way to make the Arduino compiler do it? I would like to work out where the memory is going and get an idea for what's efficient and what's not.

Thanks,

Julian
14  Forum 2005-2010 (read only) / Interfacing / Re: Sensor suggestions wanted on: May 02, 2009, 01:06:00 am
Thanks very much for all those comments and suggestions. I'm going to experiment with resistive touch sensors and the hex inverter suggested by Mike.
15  Forum 2005-2010 (read only) / Interfacing / Re: Sensor suggestions wanted on: April 30, 2009, 04:07:58 pm
Thanks Mike. Is there any info on the circuitry for your Arduinocaster. I can find plenty of Google links but nothing that explains the details. Which optical switches do you use?

Mike and Anachrocomputer, I have a question about optical switches. I tried one of these and had a problem. When my finger was a short distance away, it reflected the light back to the photodiode. However, it also detected ambient light when my finger wasn't there. Do you use pulsed light to get around this? With needing 10 or so, I was hoping to keep the electronics as simple as possible.

Julian
Pages: [1] 2