[DIY观摩]基于MSP430-3D模拟加速度计[英]

楼主
[DIY观摩]基于MSP430-3D模拟加速度计[英]
Dear readers,

I have been away from the office for a while, and you know how it is
when you come back, lots of mails, bills to pay, etc...

Today, I would like to describe another development I made with the
Soroban board. I was in pilgrimage in Akihabara (the temple of
electronics in Tokyo), trying to find ideas for my next development.
I found a nice [URL=http://www.kionix.com/Product%20Sheets/KXM52%20Series.pdf][COLOR=#000080]3D accelerometer[/COLOR][/URL] and decided to evaluate it on the
Soroban board.

NB: the accelerometer I bought was mounted on a small PCB that allows
to use it easily on a universal PCB.

Hardware description
We are going to wire this acclelerometer on Soroban's extension board.
There are very few connexions to be wired. The small PCB is like a 8-pin
DIP circuit. Here is the pinout:
  1 VCC 2.7V〜5.5V
  2 PSD Power shutdown when low. We will keep it high.
  3 GND Guess what!
  4 Parity Don't know what it is. Leave unconnected.
  5 SelfTest Wire to ground
  6 OutX X
  7 OutY Y
  8 OutZ Z

it is possible to filter the outputs Y, Y and Z with capacitors. I will leave it
as is.

The wiring on Soroban's mezzanine board. It requires only 7 connexions,
but since 3 and 5 are together, and also 1 and 2, it was possible to make
the whole connection with only 5 wires.
Here is a view of the accelerometer mounted on the mezzanine board.

              [IMGA=0,absMiddle]http://passworld.co.jp/ForumImages/20070416/AccelTop.jpg[/IMGA]

Here is a view of the wiring which is pretty simple:

              [IMGA=0,absMiddle]http://passworld.co.jp/ForumImages/20070416/AccelBottom.jpg[/IMGA]

Now here is a view of the accelerometer hardware with the mezzanine
mounted on Soroban.
Click [URL=http://passworld.co.jp/ForumImages/20070416/Accel.jpg][COLOR=#000080]here[/COLOR][/URL] for a larger view.

               [IMGA=0,absMiddle]http://passworld.co.jp/ForumImages/20070416/Accel320.png[/IMGA]

Note that the SD card is not used in this application. It was just in order
to give an idea of the real size (80 x 40).
The Li-Pol battery is seen from the side. It is a 45 x 30 mm battery and
its thickness is about 5mm.

Software description
In this applications, there are basically 2 parts only:
- A data sampling part;
- A display part.

The sampling was taken from TI's reference examples. See at the head
of the software section of this forum to find the proper samples.

Here is the ADC configuration function:

[TABLE][TR][TD][B][COLOR=#404040]Code:[/COLOR][/B][/TD][/TR][TR][TD]
void configure_adc_interrupts(void) {
    // Configure P6.0, P6.1 and P6.2 as analog inputs
    P6SEL = 0x07;
    // Configure the ADS control register
    ADC12CTL0 = ADC12ON + MSC + SHT0_1;
    // Configure consecutive samples
    ADC12CTL1 = SHP + CONSEQ_1;
    // X axis, ref = VCC
    ADC12MCTL0 = INCH_0;
    // Y axis, ref = VCC
    ADC12MCTL1 = INCH_1;
    // Z axis, ref = VCC, End of Sampling
    ADC12MCTL2 = INCH_2 + EOS;
    // Z as a trigger.
    ADC12IE = 0x04;
    // Enable conversion
    ADC12CTL0 |= ENC
    // Start conversion
    ADC12CTL0 |= ADC12SC;
    // Enter LPMO, enable interrupts
    _BIS_SR(LPMO_BITS + GIE);
}

[/TD][/TR][/TABLE]

Now the interrupt function is pretty straightforeward:

[TABLE][TR][TD][B][COLOR=#404040]Code:[/COLOR][/B][/TD][/TR][TR][TD]
<INTERRUPT> {
    X = ADC12MEM0;
    Y = ADC12MEM1;
    Z = ADC12MEM2;
    UpdateGraphics(X, Y, Z);
    _BIS_SR(LPMO_bits + GIE);
}
[/TD][/TR][/TABLE]

Note: I have labeled this function <INTERRUPT> because the interrupt
declaration depends on the compiler you use.

As for the grapgics, we just display a single curve, either of X, Y or Z.
The curve is 80 pixels wide. Without display, it is possible to measure
quite quickly, but here, we refresh permanently the last value, and this
consumes a lot of clock cycles. We are around 250 samples per second
per channel.
NB: Although we have a function UpdateGraph taking 3 parameters
X, Y and Z, In this demo, we display one axis only. We can choose in
real-time by pressing SELECT if we want to display X, Y or Z.

Here is a result picture. For this picture, I had to reduce the sampling
frequency to about 20 Hz. Therefore it takes 4 seconds for a full curve
display, which gives me enough time to stop shaking the accelerometer,
aim with the camera and shoot the picture.

           [IMGA=0,absMiddle]http://passworld.co.jp/ForumImages/20070416/Shake320.jpg[/IMGA]

Conclusion
We have shown how easy it can be to implement real-time measurements
with the Soroban platform. An analogic accelerometer was mounted on
the daughter board in about 15 minutes and the programming was
exactly as described in TI's examples.


电脑版 Page created in 0.2188 seconds width 5 queries.