Show Posts
Pages: [1]
1  Development / Other Software Development / Re: Arduino Libraries Census and Repository on: October 07, 2011, 03:25:14 pm
Howdy Massimo,

When I saw you were creating some kind of overarching, official (or semi-official) source hub I was so excited I almost wet my pants.  Then I wondered why no one had done it yet!

Anyway, I'm ready to drink the coolade and I've moved the two lib's I'm maintaining over to github from sourceforge.  After relearning how to do everything in git that I could do at sourceforge, Im now ready to add my repo's to your page.  Now I'm stumped.  Just how do I add my repo ( https://github.com/Ltalionis/PinChangeInt ) to your org?
2  Using Arduino / Programming Questions / Re: PinChangeInt not compiling on: July 23, 2011, 02:38:14 pm
Howdy, that compile error is due to using an older version of PinChangeInt with a newer version of Arduino. Get the latest version at the google code group: http://code.google.com/p/arduino-pinchangeint/downloads/list

As to debugging your encoder code, try adding an LED between each leg of the encoder so you can verify the high/low behavior you are looking for.
3  Community / Website and Forum / Re: Broken link in one of the tutorials. Who do I tell? on: July 22, 2011, 10:48:21 pm
Isn't reporting this sort of thing what this forum is for?  Thanks for the report, I hope someone gets too it.
4  Development / Suggestions for the Arduino Project / Playground Forum? on: July 08, 2011, 05:12:09 pm
Howdy, I'm wondering if there is a place to talk about work on the arduino wiki, arduino.cc/playground/ .  I've been looking though and making some edits and minor structural changes (turning [@ @] into (:source:) blocks is a particular fav of mine), but I'd like to collaborate with the wider community about the frontpage/sidebar and some general todo lists or style guidelines.  Oh, and thanks for all the hard work!  The arduino community has some great nuggets of code around.
5  Community / Exhibition / Gallery / Sketch for reading PPM output of a standard hobbyist RC Reciver on: June 24, 2011, 02:19:45 pm
I've created a very accurate PPM reading sketch though the used of the pinChangeInt and Timer1 libraries.  The sketch is available here.  The sketch is set up to read three channels, but could be expanded to as many as you'd like.

-Lex
6  Using Arduino / Programming Questions / Re: Configuring Timer1 Overflow Interrupts on: June 23, 2011, 05:38:04 pm
heya dottore11,

The alfredstate.edu link above has helped me decode much of the information about Timer1 and makes a great supplement to the datasheet.  Also, the Timer1 library is a great wrapper for accessing features of the timer.

To slow down the speed of the timer you can use the setPeriod(long microseconds) method.  The value passed to setPeriod should be at least twice the max delay between two events (pin changes or whatever you are measuring).  The Timer1 lib causes the timer to count up then down, if you read the timer value on the down stroke then it will give you erroneous results.

I'm not sure what you mean as to "using this timer1 as a global timer".  The timer is global in the sence that it's variables (aka registers) have global scope.  It's all about how you set up the timer for your use.

The actual count for timer1 is available by reading TCNT1. There are functions in the Timer1 lib that start, stop and reset the counter.  The value in TCNT1 is in ticks of the timer, from 0-65536.  To get this into microseconds you first multiply by the prescaler value (x1, x8, x64, x265, or x1024) to get the total number of clock cycles this represents, then divide by the number of clock cycles a microsecond, (F_CPU / 1000000).  There are a couple of handy macros defined by wiring.h here:

Code:
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) )
#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L )

Also, heres a little snippet of code that I use to read timer1's value in microsecs:

Code:
ulong readTimer1() //returns the value of the timer in microseconds
{ //rember! phase and freq correct mode counts up to then down again
switch (Timer1.clockSelectBits)
{
case 1:// no prescalse
return ((TCNT1 * 1000L) / (F_CPU / 1000L));
break;
case 2:// x8 prescale
return ((TCNT1 * 1000L) / (F_CPU / 1000L))<<3;
break;
case 3:// x64
return ((TCNT1 * 1000L) / (F_CPU / 1000L))<<6;
break;
case 4:// x256
return ((TCNT1 * 1000L) / (F_CPU / 1000L))<<8;
break;
case 5:// x1024
return ((TCNT1 * 1000L) / (F_CPU / 1000L))<<10;
break;
default:
return 0;
}
}

Pages: [1]