[C.CC USERS] AREF

Matt Jadud matt at jadud.com
Sat Jun 23 15:54:25 BST 2012


Hi Aaron,

On Sat, Jun 23, 2012 at 1:56 AM, Aaron Ryan <bringfire at gmail.com> wrote:
> I am putting together an IMU with my two axis gyro and three axis
> accelerometer. I was wondering if there is any way to implement an
> "analogReference()" equivalent in occam.  I'm uncertain how the Atmega328
> uses it's AREF pin, so any help on the simple concepts behind the function
> will help...PORT info, etc..

Actually, in the same place some of your code lives...

http://projects.cs.kent.ac.uk/projects/kroc/svn/kroc/trunk/tvm/arduino/community/

is the "gatoruav" directory. That is where the code for our UAV
project lives. We spent the last year redesigning (and then
redesigning again) the physical aircraft, and prototyping control code
against a simulator. So, while it isn't "new", it still is the code
that flew the actual aircraft.

In the Trac browsing interface:

http://projects.cs.kent.ac.uk/projects/kroc/trac/browser/kroc/trunk/tvm/arduino/community/gatoruav/

you can see where we do an ADC read; there's an umber of constants and
channel arrays there, but put simply:

    adc(GYRO.X, AREF, sig.gyro[X]?, gyro.out[X]!)

or, you can dig down into the Plumbing libraries, and find the ADC
code there, which is more procedural (vs. concurrent):

http://projects.cs.kent.ac.uk/projects/kroc/trac/browser/kroc/trunk/tvm/arduino/occam/include/arch/m328p/adc.module

note that you'll want to look at the *architecture specific* code (in
the "arch" directory), because we had to do different things on the
328, 1280, and 2560 (as the ADC is hardware dependent).

If that doesn't get you started, please ask away. I guess the short
answer is "Yes, AREF is a parameter to the ADC read call."

Cheers,
Matt



More information about the users mailing list