Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 433
61  Using Arduino / Microcontrollers / Re: ATMega168PA, problem with bootloader, message "Bootloader in Use: No" on: March 26, 2014, 07:40:11 pm
Quote
Bootloader in use: No
You have discovered a bug in Nick's program.  He's checking the wrong fuse word for the "reset to bootloader" bit (for the 168.  His code is assuming that the bit is in the same fuse for all chips, which isn't true.)

(so this doesn't explain anything about why your chips stopped talking.)
62  Using Arduino / Programming Questions / Re: Making this code more efficient and smaller... Possible? on: March 26, 2014, 07:29:13 pm
I don't see any glaring inefficiencies.
The biggest problem may be those oneWire sensors, which are relatively slow and "atomic" to read, as far as I know.
But reading four of them every 4 or five seconds shouldn't be a problem.
63  Using Arduino / Programming Questions / Re: Turning on and off States instead of physical output/imputs on: March 26, 2014, 07:23:08 pm
I don't understand whether you're asking about driving the pumps, or about managing the display/api of the pumps.
Your code should probably look like:
Code:
void loop() {
  update_touchswitches();
  update_display();
  drive_pumps();
}
and yes, each of those functions can probably be set up as an FSM, of greater or lesser formality, and none of them should use delay()
64  Using Arduino / General Electronics / Re: 5V vs. 3V operation on: March 26, 2014, 05:13:48 am
Quote
Is that because many components, like wireless modules, use 3.3V?
Yes.
65  Using Arduino / Programming Questions / Re: Editing Sketches and uploading without arduino software? on: March 26, 2014, 05:10:32 am
Sure, at least theoretically.
The arduino IDE isn't too much more than an editor.  It invokes other programs (avr-gcc and related components, avrdude) to do compilation and upload, and presumably you could invoke them in the same way.
66  Using Arduino / Microcontrollers / Re: Arduino Uno bootloader on Mega2560 on: March 25, 2014, 05:25:27 am
The UNO bootloader (optiboot) will NOT run on an atmega2560.  Neither it nor the protocol it uses supports more than 128k bytes of flash.
67  Using Arduino / Microcontrollers / Re: Size of HEX files on: March 23, 2014, 03:18:44 am
Quote
the Sketch file size the IDE reports isn't the real amount of data send to the chip?
Wait... The size reported by the IDE *is* the amount of flash storage you need.
But !   It's unrelated to the "size of the .hex file" as reported by most file commands and such.
For example, for the Blink example:

Binary sketch size: 1,116 bytes (of a 32,256 byte maximum) - 3% used

ll *.hex
-rw-r--r--  1 staff  3168 Mar 23 01:25 Blink.cpp.hex
68  Using Arduino / Programming Questions / Re: direct port manipulation --analogeWrite on: March 23, 2014, 02:20:27 am
Quote
Motors react slow compared to the speed of the Arduino.
I agree that the difference between "analogWrite()" and "direct port IO" is very unlikely to be the cause of motors being "slow to react" on a human-visible timescale.
69  Using Arduino / Microcontrollers / Re: basic stamp language to arduino language on: March 23, 2014, 02:13:20 am
Something pretty much like:

Code:
// XbandEnPin     PIN     9                     ' Enable pin
static const int XbandEnPin = 9;
// XbandOutPin    PIN     8                     ' Output pin
static const int XbandOutPin = 8;
// HalfSecond     CON     500                   ' ms in 1/2 s delay
static const int HalfSecond = 500;
// MoveThreshld   CON     2                     ' Motion threhold
static const int CON = 2;

// cycles         VAR     Word                  ' Cycle counter
// reps           VAR     Word                  ' Test repetitions
int cycles, reps;

void setup() {
// HIGH XbandEnPin                              ' Enable motion detector
  digitalWrite(XbandEnPin, High);
// FOR reps = 1 TO 360                          ' Check for 3 minutes
  for (int reps = 1; reps <= 360; reps++) {
//   COUNT XbandOutPin, HalfSecond, cycles      ' Count OUT pin transitions
//
//  Arduino has no direct equivalent of COUNT, as far as I know.  You'll have
//  to write it using more primitive primitives like digitalRead()

//   DEBUG HOME, "cycles = ",                   ' Display cycle count
    Serial.print(" "cycles = ");
//         DEC cycles, CLREOL
    Serial.println(cycles);
(note: neither Arduino nor its serial monitor support HOME, CLREOL, etc.
//   IF cycles > MoveThreshld THEN              ' Display motion/no motion
//     DEBUG CR, "Motion detected!"
    if (cycles > MoveThreshld) {
      Serial.println("Motion detected!");
    }
//   ELSE
//     DEBUG CR, "No motion", CLREOL
    else {
      Serial.println("No motion");
//   ENDIF
    }
//
// NEXT                                         ' Repeat detection loop
  }
// LOW XbandEnPin                               ' Disable motion detector
  DigitalWrite(XbandEnPin, Low);
// DEBUG CR, "Test done, motion detector disabled."  ' Display all done.
  Serial.println("Test done, motion detector disabled.");
// STOP                                         ' Stop the program holding EN
// (Arduino code will "stop" by running loop() continuously, doing nothing.
}

void loop() {}
70  Using Arduino / Microcontrollers / Re: Size of HEX files on: March 23, 2014, 01:56:58 am
Also, the binary size is always much smaller than the hex file size.
Your arduino .hex file with ~1900 bytes is probably about 800 bytes of code (sketch size should have been reported during the compile...)
71  Using Arduino / Programming Questions / Re: dissecting how natural log math function works on: March 22, 2014, 05:45:45 am
http://svn.savannah.nongnu.org/viewvc/trunk/avr-libc/libm/fplib/log.S?root=avr-libc&view=markup
72  Using Arduino / Programming Questions / Re: C or sketches? on: March 22, 2014, 01:59:53 am
If you really want to figure out what is going on, study C/C++ and "The arduino language" in parallel until you figure out exactly how they are different.  (hint: they are only VERY SLIGHTLY different.)
73  Using Arduino / Programming Questions / Re: Lifecycle of a variable? creation, initialization & access times within scopes? on: March 22, 2014, 01:56:00 am
In this case, it's because the local variables are mostly optimized away out of existence.  The compiler notices that you don't do anything with L2, L3, and L4, and just return 4*L1, so it just computes that.  Also, since you have relatively few variables and haevn't specified otherwise, it can keep them all in registers.
Code:
int Locally() {
  int L1;
 100:   0f 93           push    r16
 102:   1f 93           push    r17
  int L2;
  int L3;
  int L4;
  L1 = IO_TOGGLE;
  L2 = L1;
 104:   00 91 04 01     lds     r16, 0x0104     ;; L1 = IO_TOGGLE
 108:   10 91 05 01     lds     r17, 0x0105
  L3 = L2;    ;; L2, L3, L4  optimized away
  L4 = L3; 
  digitalWrite(IO_PIN, L4);
  return L4 + L3 + L2 + L1;
 10c:   8d e0           ldi     r24, 0x0D       ; 13
 10e:   60 2f           mov     r22, r16
 110:   0e 94 92 01     call    0x324   ; 0x324 <digitalWrite>
 114:   00 0f           add     r16, r16
 116:   11 1f           adc     r17, r17    ;;  2 *L1
 118:   00 0f           add     r16, r16
 11a:   11 1f           adc     r17, r17    ;; 2* (2*L1) == 4*L1 == L1+L2+L3+L4
}
 11c:   c8 01           movw    r24, r16
 11e:   1f 91           pop     r17
 120:   0f 91           pop     r16
 122:   08 95           ret

Code:
00000124 <Globally()>:
int G2;
int G3;
int G4;
int Globally() {
  G1 = IO_TOGGLE;
  G2 = G1;
 124:   60 91 04 01     lds     r22, 0x0104
 128:   80 91 05 01     lds     r24, 0x0105
 12c:   60 93 06 01     sts     0x0106, r22
 130:   80 93 07 01     sts     0x0107, r24
  G3 = G2; 
 134:   60 93 08 01     sts     0x0108, r22
 138:   80 93 09 01     sts     0x0109, r24
  G4 = G3;
 13c:   60 93 0a 01     sts     0x010A, r22
 140:   80 93 0b 01     sts     0x010B, r24
  digitalWrite(IO_PIN, G4);
 144:   60 93 0c 01     sts     0x010C, r22
 148:   80 93 0d 01     sts     0x010D, r24
  return G4 + G3 + G2 + G1;
 14c:   8d e0           ldi     r24, 0x0D       ; 13
 14e:   0e 94 92 01     call    0x324   ; 0x324 <digitalWrite>
 152:   20 91 0a 01     lds     r18, 0x010A
 156:   30 91 0b 01     lds     r19, 0x010B
 15a:   80 91 0c 01     lds     r24, 0x010C
 15e:   90 91 0d 01     lds     r25, 0x010D
 162:   28 0f           add     r18, r24
 164:   39 1f           adc     r19, r25
 166:   80 91 08 01     lds     r24, 0x0108
 16a:   90 91 09 01     lds     r25, 0x0109
 16e:   28 0f           add     r18, r24
 170:   39 1f           adc     r19, r25
 172:   80 91 06 01     lds     r24, 0x0106
 176:   90 91 07 01     lds     r25, 0x0107
 17a:   28 0f           add     r18, r24
 17c:   39 1f           adc     r19, r25
}
 17e:   c9 01           movw    r24, r18
 180:   08 95           ret
74  Using Arduino / Microcontrollers / Re: Optiboot on Arduino Pro Mini 5v 16MHz not available on: March 21, 2014, 01:01:06 pm
Isn't a pro mini at 16MHz the same as an UNO?
75  Using Arduino / Programming Questions / Re: How can i add function to arduino uno R3 bootloader to do some memory read/write on: March 21, 2014, 05:22:23 am
Optiboot and its makefiles (which include the fuse settings) has a size limit of 512 bytes.
You could "easily" change the limit to 1k, 2k, or even 4k, by changing the "section-start" for .text, and the BOOTSZ bits in HFUSE (on a 328)
(If you're using the IDE to burn the bootloader you'd have to change the fuses in boards.txt )
Pages: 1 ... 3 4 [5] 6 7 ... 433