Pages: 1 2 [3] 4   Go Down
Author Topic: Arduino 0012 available.  (Read 4812 times)
0 Members and 1 Guest are viewing this topic.
Austin, TX USA
Offline Offline
God Member
*****
Karma: 5
Posts: 998
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, mem.  I tried to think of what compatibility reasons would preclude the typedef'ing of boolean==bool and couldn't think of any, but that certainly doesn't mean there aren't any.  About all I can say is they are both sizeof == 1.

Cheers, and aren't you up a little late, Mr. London? smiley

Mikal
Logged

New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

FWIW I had the misfortune of trying to get my USB library working in a hurry with 0012 and ran into the int() issue.

I'd +1 keeping the main constants file in such a state that it can be imported by libraries without clashing with stdio etc.

--Phil.

P.S. I was using 0012 for the per-board programmer setting functionality which was useful, thanks. :-)
« Last Edit: September 30, 2008, 08:28:14 am by follower » Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

mikalhart: I had no idea that C++ supported function-style casts.  In that case, we can certainly remove the macros (at least for the built-in types).
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all!

I checked out the trunk on 2008-09-26 (searched for also a 0012 tag but not found...) and compiled it on Ubuntu 8.04 with the stock gcc-avr, avr-libc, and sun 1.6.0_06 JRE installed. you can download the result from home.sch.bme.hu/~keresztg/arduino-0012-ubuntu.tgz (yep, it's over HTTP, but YaBB doesn't allow link in first message...)

It may or may not work on other linux distros, YMMV.

And be aware: it uses the gcc-avr and avr-libc from your distro (on Ubuntu 8.04 its 4.2.2 and 1.4.7 respectively) and not the one included eg. in the windows build...
Logged

Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey all, just tried out the new 0.12 release on osX Leopard.

First off, good to see this pushing forward and including many improvements!

The downside is I get the following error when trying to compile this example: arduino.cc/en/Tutorial/PlayMelody. (which compiles fine in 0.11)

Code:
In file included from /Applications/arduino-0012/hardware/cores/arduino/WProgram.h:10,

/Applications/arduino-0012/hardware/cores/arduino/wiring.h:110: error: expected ',' or '...' before numeric constant
No idea what it means, but if I comment out the line in the wiring.h file, the code compiles just fine.

Although I'm not sure of the correct solution, I am sure that commenting out this line is not a good solution.
Logged

Birmingham, AL
Offline Offline
Jr. Member
**
Karma: 2
Posts: 91
Arduino, disobey me.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

KeresztG,  Thanks for the arduino 0012 for Ubuntu.  It's working well for me.    I'm running Ubuntu 8.04..
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The Linux version of Arduino 0012 is now available: arduino-0012-linux.tgz.  Sorry it took so long.
Logged

The Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone!

First post, so please don't flame me for my ignorance...
I've got a piece of code that worked just fine in Arduino 0011 (MacOS X), but it causes crashes when compiled with Arduino 0012.

Code:
// variable declarations
volatile unsigned long pulseTimer = 0;
volatile unsigned int pulseCounter = 0;

// in setup()
attachInterrupt(0, interruptCounterIncrement, RISING);

// the ISR:
void interruptCounterIncrement(void)
{  pulseTimer = millis();
   pulseCounter++;
}

I think it has something to do with the "improved millis()" but I'm not sure how to resolve this problem. For now I'm sticking to Arduino 0011 which allows this code to run flawlessly.
The code increments pulseCounter, an integer in which I store the number of pulses (interrupts) that have been received on pin 2 (interrupt 0). I use this code to accurately capture the number of pulses I receive on a TSOP2238 infrared receiver. Furthermore, pulseTimer keeps track of the last time a pulse was received.

Thanks for your time,
-Dr. D.
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the report.

Can you post a complete but minimal sketch that exhibits the problem and explain what you mean by crash?  We did change how millis() works in Arduino 0012, and that could be causing problems.  
Logged

The Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your quick response!

Here's an extremely stripped down version of my sketch exhibiting the problem I'm describing:
Code:
// constant declarations / definitions:
#define IRINPIN 0   // infrared receiver is connected to this interrupt, value + 2 = actual pin number on the Arduino

// variables for IR signal detection and processing:
volatile unsigned long pulseTimer = 0;
volatile unsigned int pulseCounter = 0;

// function prototypes //
void interruptCounterIncrement(void);  // when called, this function increments pulseCounter and sets pulseTimer to the current value of millis()

// + + + SETUP CODE + + + //
void setup()
{  pinMode(13, OUTPUT);  // using LED on Arduino Diecimila board
   attachInterrupt(IRINPIN, interruptCounterIncrement, RISING);  // interrupt is attached to pin 3 (hardware interrupt 0) for counting pulses coming from the IR receiver.
}

// + + + MAIN LOOP + + + //
void loop()  // using the LED on the Arduino Diecimila board to indicate the main loop is still running (not crashed/hanging)
{   delay(100);
    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
}

// + + + FUNCTION DEFINITIONS + + + //
void interruptCounterIncrement(void)
{  pulseTimer = millis();
   pulseCounter++;
}

By "crash" I mean that the main loop is stuck / not running anymore. You can upload this sketch on a Diecimila and reproduce the infrared receiver input on interrupt 0 (pin 2) with a switch that it normally pulled up, and connects pin 2 to ground when activated. To see what happens to pulseTimer and pulseCounter you could print them to the serial port in the main loop.

Thanks,
Dr. D.
Logged

0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Isn't there some advice to not call millis() inside an ISR?

-j

Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 5
Posts: 998
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Isn't there some advice to not call millis() inside an ISR?

I think the only advice I've seen is not to call delay() (or repeatedly call millis()) in an ISR.  Since millis() simply returns the value of a counter which is updated via (another) ISR, you'd expect the value it returns to be correct when you enter this ISR.  But because interrupts are disabled while IN the ISR, the value will never change until after you leave.

I don't immediately see how the new millis() code could be causing this crash, but it might be instructive from a debugging standpoint to replace

Code:
{  pulseTimer = millis();
with
Code:
{  extern volatile unsigned long timer0_millis;
   pulseTimer = timer0_millis;
just to see what happens.

Mikal
« Last Edit: October 15, 2008, 10:44:48 am by mikalhart » Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 5
Posts: 998
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dr. D--

I tested your unmodified code on my Diecimila with Arduino 0012 alpha and LadyAda's prototype shield.  I attached the general purpose pushbutton to digital pin 2 and I'm afraid I didn't experience any "crash".  To get good values for pulseCounter, I had to employ the internal pullup resistor, so I added the digitalWrite below.  (I also like to explicitly set a pin's mode to INPUT even though this is the default.)

void setup()
{  pinMode(13, OUTPUT);  // using LED on Arduino Diecimila board
    pinMode(IRINPIN+2, INPUT); // *** my addition: explicitly set INPUT mode for pin
    digitalWrite(IRINPIN+2, HIGH); // *** my addition: use the internal pullup resistor
    attachInterrupt(IRINPIN, interruptCounterIncrement, RISING);  // interrupt is attached to pin 3 (hardware interrupt 0) for counting pulses coming from the IR receiver.
}

Anyway, with these two additions, and monitoring the pulse stuff with Serial, I'm afraid it worked exactly as I expected.  Sorry!

Mikal
Logged

The Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for testing my code mikalhart! I've tried your modified code on my Diecimila and there are a few things I noted. If you push the button at a relatively low frequency, say, 1x per second, there is nothing wrong and the program seems to run just fine. But as you start pressing the button more frequently (say, 10x per second or more) the program stops running at a certain point. I tried this with a non-debounced switch, with an external pull-up resistor (and the internal pull-up resistor was also enabled by the two lines of code you added).
The problem is that the pulses the IR receiver sends to the Arduino are only about 300 microseconds in length, and the pulses are spaced about 400 microseconds. This means that the frequency on the interrupt pin is about 1.43kHz.
Maybe the Arduino (with the new millis() implementation) can't cope with such a high frequency of interrupts?

-UPDATE-
I've tried to disable the "pulseTimer = millis();" line, and with that disabled the ISR can easily cope with the pulses being sent at 1.43kHz. So my conclusion is that the problem lies within the millis() function, or the use of the millis() function from within the ISR at such a high frequency.

thanks for your effort, regards,
Dr. D.
« Last Edit: October 16, 2008, 04:56:57 am by drdistortion » Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 5
Posts: 998
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I've tried to disable the "pulseTimer = millis();" line

Hmm... Then a key experiment would be to replace that line with the two I suggested a couple of posts back:

Code:
{  extern volatile unsigned long timer0_millis;
   pulseTimer = timer0_millis;

This code is identical to what millis() does, except that it doesn't disable interrupts.

Mikal
Logged

Pages: 1 2 [3] 4   Go Up
Jump to: