EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

*** F2013's SD16_A ***

Started by ez430project November 23, 2008
Hi, I'm trying to measure the voltage output from a circuit, and
convert this to digital using the SD16_A.

Is there a sample code I could use for ADC conversion using one pin.

Donald

Beginning Microcontrollers with the MSP430

--- In m..., "ez430project" wrote:
>
> Hi, I'm trying to measure the voltage output from a circuit, and
> convert this to digital using the SD16_A.
>
> Is there a sample code I could use for ADC conversion using one pin.
>
> Donald
>
Hi Donald,
Have you looked at this examples:
http://focus.ti.com/mcu/docs/mcuprodcodeexamples.tsp?sectionId&tabId68

I suggest to download them all. And just find code examples with SD16_A.
As i noticed, slac077c.zip contains some example codes, wich can be
helpful for you.

Regards,
Mark
Hi, I've already looked but they don't seem to provide a basic layout
for measuring a simple voltage coming in - does anyone have a basic
layout code?

--- In m..., "marek.gaik" wrote:
>
> --- In m..., "ez430project" wrote:
> >
> > Hi, I'm trying to measure the voltage output from a circuit, and
> > convert this to digital using the SD16_A.
> >
> > Is there a sample code I could use for ADC conversion using one
pin.
> >
> > Donald
> >
> Hi Donald,
> Have you looked at this examples:
> http://focus.ti.com/mcu/docs/mcuprodcodeexamples.tsp?
sectionId&tabId68
>
> I suggest to download them all. And just find code examples with
SD16_A.
> As i noticed, slac077c.zip contains some example codes, wich can be
> helpful for you.
>
> Regards,
> Mark
>

Here is a basic layout of a F2013 SD16_A example.

#include
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
// set up used and unused io pins
// ...
// set up all clocks if defalts are not applicable
// ...
// set up TA and WDT if used
// ...
// set up SD16_A controller
// ...
// set up interrupts and enable them if used
// ...
// set up and run in an endless loop, or go to LPM
// ...
}
// add interrupt service routines if applicable
// ...

There are lots of examples. But examples are just examples, they will
not be exactly what you want. What is the voltage range of the input?
What is the frequency range? How often do you want to sample it?

--- In m..., "ez430project" wrote:
>
> Hi, I've already looked but they don't seem to provide a basic layout
> for measuring a simple voltage coming in - does anyone have a basic
> layout code?
>
> --- In m..., "marek.gaik" wrote:
> >
> > --- In m..., "ez430project" wrote:
> > >
> > > Hi, I'm trying to measure the voltage output from a circuit, and
> > > convert this to digital using the SD16_A.
> > >
> > > Is there a sample code I could use for ADC conversion using one
> pin.
> > >
> > > Donald
> > >
> >
> >
> > Hi Donald,
> > Have you looked at this examples:
> > http://focus.ti.com/mcu/docs/mcuprodcodeexamples.tsp?
> sectionId&tabId68
> >
> > I suggest to download them all. And just find code examples with
> SD16_A.
> > As i noticed, slac077c.zip contains some example codes, wich can be
> > helpful for you.
> >
> > Regards,
> > Mark
>
The voltage has a max. range of (currently) 4V. I want to sample it
for every i = 50,000 delay. The voltage input does tend to change.

Currently all I seem to be getting is 2^16 value regardless of the
input, even when it changes.

--- In m..., "old_cow_yellow"
wrote:
>
> Here is a basic layout of a F2013 SD16_A example.
>
> #include
> void main( void )
> {
> // Stop watchdog timer to prevent time out reset
> WDTCTL = WDTPW + WDTHOLD;
> // set up used and unused io pins
> // ...
> // set up all clocks if defalts are not applicable
> // ...
> // set up TA and WDT if used
> // ...
> // set up SD16_A controller
> // ...
> // set up interrupts and enable them if used
> // ...
> // set up and run in an endless loop, or go to LPM
> // ...
> }
> // add interrupt service routines if applicable
> // ...
>
> There are lots of examples. But examples are just examples, they
will
> not be exactly what you want. What is the voltage range of the
input?
> What is the frequency range? How often do you want to sample it?
>
> --- In m..., "ez430project" wrote:
> >
> > Hi, I've already looked but they don't seem to provide a basic
layout
> > for measuring a simple voltage coming in - does anyone have a
basic
> > layout code?
> >
> > --- In m..., "marek.gaik" wrote:
> > >
> > > --- In m..., "ez430project"
wrote:
> > > >
> > > > Hi, I'm trying to measure the voltage output from a circuit,
and
> > > > convert this to digital using the SD16_A.
> > > >
> > > > Is there a sample code I could use for ADC conversion using
one
> > pin.
> > > >
> > > > Donald
> > > >
> > >
> > >
> > > Hi Donald,
> > > Have you looked at this examples:
> > > http://focus.ti.com/mcu/docs/mcuprodcodeexamples.tsp?
> > sectionId&tabId68
> > >
> > > I suggest to download them all. And just find code examples
with
> > SD16_A.
> > > As i noticed, slac077c.zip contains some example codes, wich
can be
> > > helpful for you.
> > >
> > > Regards,
> > > Mark
> > >
>
I seem to recall that with the 1.2 V for Vref, the maximum voltage which
can be measured is 600 mV. Please read the datasheet to make sure.

Emmett Redd Ph.D. mailto:E...@missouristate.edu
Professor (417)836-5221
Department of Physics, Astronomy, and Materials Science
Missouri State University Fax (417)836-6226
901 SOUTH NATIONAL Dept (417)836-5131
SPRINGFIELD, MO 65897 USA

Physicists always practice energy conservation.

> -----Original Message-----
> From: m... [mailto:m...]
> On Behalf Of ez430project
> Sent: Monday, November 24, 2008 3:31 PM
> To: m...
> Subject: [msp430] Re: *** F2013's SD16_A ***
>
> The voltage has a max. range of (currently) 4V. I want to sample it
> for every i = 50,000 delay. The voltage input does tend to change.
>
> Currently all I seem to be getting is 2^16 value regardless of the
> input, even when it changes.
>
> --- In m..., "old_cow_yellow"
> wrote:
> >
> > Here is a basic layout of a F2013 SD16_A example.
> >
> > #include
> > void main( void )
> > {
> > // Stop watchdog timer to prevent time out reset
> > WDTCTL = WDTPW + WDTHOLD;
> > // set up used and unused io pins
> > // ...
> > // set up all clocks if defalts are not applicable
> > // ...
> > // set up TA and WDT if used
> > // ...
> > // set up SD16_A controller
> > // ...
> > // set up interrupts and enable them if used
> > // ...
> > // set up and run in an endless loop, or go to LPM
> > // ...
> > }
> > // add interrupt service routines if applicable
> > // ...
> >
> > There are lots of examples. But examples are just examples, they
> will
> > not be exactly what you want. What is the voltage range of the
> input?
> > What is the frequency range? How often do you want to sample it?
> >
> > --- In m..., "ez430project" wrote:
> > >
> > > Hi, I've already looked but they don't seem to provide a basic
> layout
> > > for measuring a simple voltage coming in - does anyone have a
> basic
> > > layout code?
> > >
> > > --- In m..., "marek.gaik" wrote:
> > > >
> > > > --- In m..., "ez430project"
> wrote:
> > > > >
> > > > > Hi, I'm trying to measure the voltage output from a circuit,
> and
> > > > > convert this to digital using the SD16_A.
> > > > >
> > > > > Is there a sample code I could use for ADC conversion using
> one
> > > pin.
> > > > >
> > > > > Donald
> > > > >
> > > >
> > > >
> > > > Hi Donald,
> > > > Have you looked at this examples:
> > > > http://focus.ti.com/mcu/docs/mcuprodcodeexamples.tsp?
> > > sectionId&tabId68
> > > >
> > > > I suggest to download them all. And just find code examples
> with
> > > SD16_A.
> > > > As i noticed, slac077c.zip contains some example codes, wich
> can be
> > > > helpful for you.
> > > >
> > > > Regards,
> > > > Mark
> > > >
> > >
> >
The input voltage has to be within the power rail. That is, it has to
be above Vss (0.0V) and below Vcc (3.6V max). Otherwise, you may
damage the MSP430. Further more, the analog input has to be below
Vref. Otherwise, you always get the max digital reading.

--- In m..., "ez430project" wrote:
>
> The voltage has a max. range of (currently) 4V. I want to sample it
> for every i = 50,000 delay. The voltage input does tend to change.
>
> Currently all I seem to be getting is 2^16 value regardless of the
> input, even when it changes.
>
> --- In m..., "old_cow_yellow"
> wrote:
> >
> > Here is a basic layout of a F2013 SD16_A example.
> >
> > #include
> > void main( void )
> > {
> > // Stop watchdog timer to prevent time out reset
> > WDTCTL = WDTPW + WDTHOLD;
> > // set up used and unused io pins
> > // ...
> > // set up all clocks if defalts are not applicable
> > // ...
> > // set up TA and WDT if used
> > // ...
> > // set up SD16_A controller
> > // ...
> > // set up interrupts and enable them if used
> > // ...
> > // set up and run in an endless loop, or go to LPM
> > // ...
> > }
> > // add interrupt service routines if applicable
> > // ...
> >
> > There are lots of examples. But examples are just examples, they
> will
> > not be exactly what you want. What is the voltage range of the
> input?
> > What is the frequency range? How often do you want to sample it?
> >
> > --- In m..., "ez430project" wrote:
> > >
> > > Hi, I've already looked but they don't seem to provide a basic
> layout
> > > for measuring a simple voltage coming in - does anyone have a
> basic
> > > layout code?
> > >
> > > --- In m..., "marek.gaik" wrote:
> > > >
> > > > --- In m..., "ez430project"
> wrote:
> > > > >
> > > > > Hi, I'm trying to measure the voltage output from a circuit,
> and
> > > > > convert this to digital using the SD16_A.
> > > > >
> > > > > Is there a sample code I could use for ADC conversion using
> one
> > > pin.
> > > > >
> > > > > Donald
> > > > >
> > > >
> > > >
> > > > Hi Donald,
> > > > Have you looked at this examples:
> > > > http://focus.ti.com/mcu/docs/mcuprodcodeexamples.tsp?
> > > sectionId&tabId68
> > > >
> > > > I suggest to download them all. And just find code examples
> with
> > > SD16_A.
> > > > As i noticed, slac077c.zip contains some example codes, wich
> can be
> > > > helpful for you.
> > > >
> > > > Regards,
> > > > Mark
> > > >
> > >
>
I've tried feeding a constant 1.5V through Pin 6 (P1.4) using the
sample code of sd16_a3.c, but still get a max of 2^16. As soon as I
remove this voltage, there's still about 0.23V going through. I then
get numbers like 22, 365.

Even though P1.0 (Pin 2) has no voltage going through, it still shows
a value. As does P1.2 (Pin 4).

I'm confused as to why.

--- In m..., "old_cow_yellow"
wrote:
>
> The input voltage has to be within the power rail. That is, it has
to
> be above Vss (0.0V) and below Vcc (3.6V max). Otherwise, you may
> damage the MSP430. Further more, the analog input has to be below
> Vref. Otherwise, you always get the max digital reading.
>
> --- In m..., "ez430project" wrote:
> >
> > The voltage has a max. range of (currently) 4V. I want to sample
it
> > for every i = 50,000 delay. The voltage input does tend to change.
> >
> > Currently all I seem to be getting is 2^16 value regardless of
the
> > input, even when it changes.
> >
> > --- In m..., "old_cow_yellow"
> > wrote:
> > >
> > > Here is a basic layout of a F2013 SD16_A example.
> > >
> > > #include
> > > void main( void )
> > > {
> > > // Stop watchdog timer to prevent time out reset
> > > WDTCTL = WDTPW + WDTHOLD;
> > > // set up used and unused io pins
> > > // ...
> > > // set up all clocks if defalts are not applicable
> > > // ...
> > > // set up TA and WDT if used
> > > // ...
> > > // set up SD16_A controller
> > > // ...
> > > // set up interrupts and enable them if used
> > > // ...
> > > // set up and run in an endless loop, or go to LPM
> > > // ...
> > > }
> > > // add interrupt service routines if applicable
> > > // ...
> > >
> > > There are lots of examples. But examples are just examples,
they
> > will
> > > not be exactly what you want. What is the voltage range of the
> > input?
> > > What is the frequency range? How often do you want to sample it?
> > >
> > > --- In m..., "ez430project"
wrote:
> > > >
> > > > Hi, I've already looked but they don't seem to provide a
basic
> > layout
> > > > for measuring a simple voltage coming in - does anyone have a
> > basic
> > > > layout code?
> > > >
> > > > --- In m..., "marek.gaik" wrote:
> > > > >
> > > > > --- In m..., "ez430project"

> > wrote:
> > > > > >
> > > > > > Hi, I'm trying to measure the voltage output from a
circuit,
> > and
> > > > > > convert this to digital using the SD16_A.
> > > > > >
> > > > > > Is there a sample code I could use for ADC conversion
using
> > one
> > > > pin.
> > > > > >
> > > > > > Donald
> > > > > >
> > > > >
> > > > >
> > > > > Hi Donald,
> > > > > Have you looked at this examples:
> > > > > http://focus.ti.com/mcu/docs/mcuprodcodeexamples.tsp?
> > > > sectionId&tabId68
> > > > >
> > > > > I suggest to download them all. And just find code examples
> > with
> > > > SD16_A.
> > > > > As i noticed, slac077c.zip contains some example codes,
wich
> > can be
> > > > > helpful for you.
> > > > >
> > > > > Regards,
> > > > > Mark
> > > > >
> > > >
> > >
>
Hi, I'm really struggling here. Could anyone help me out - I've
lowered my voltage input to 0.3V and am feeding this through Pin 6
(P1.4).

I'm getting different values for each reading.

Could anyone provide a piece of code (that works) I could use to get
my program working - I would so appreciate it, beyond words.

Donald

--- In m..., "ez430project"
wrote:
>
> I've tried feeding a constant 1.5V through Pin 6 (P1.4) using the
> sample code of sd16_a3.c, but still get a max of 2^16. As soon as I
> remove this voltage, there's still about 0.23V going through. I
then
> get numbers like 22, 365.
>
> Even though P1.0 (Pin 2) has no voltage going through, it still
shows
> a value. As does P1.2 (Pin 4).
>
> I'm confused as to why.
>
> --- In m..., "old_cow_yellow"
> wrote:
> >
> > The input voltage has to be within the power rail. That is, it
has
> to
> > be above Vss (0.0V) and below Vcc (3.6V max). Otherwise, you may
> > damage the MSP430. Further more, the analog input has to be below
> > Vref. Otherwise, you always get the max digital reading.
> >
> > --- In m..., "ez430project"
wrote:
> > >
> > > The voltage has a max. range of (currently) 4V. I want to
sample
> it
> > > for every i = 50,000 delay. The voltage input does tend to
change.
> > >
> > > Currently all I seem to be getting is 2^16 value regardless of
> the
> > > input, even when it changes.
> > >
> > > --- In m..., "old_cow_yellow"

> > > wrote:
> > > >
> > > > Here is a basic layout of a F2013 SD16_A example.
> > > >
> > > > #include
> > > > void main( void )
> > > > {
> > > > // Stop watchdog timer to prevent time out reset
> > > > WDTCTL = WDTPW + WDTHOLD;
> > > > // set up used and unused io pins
> > > > // ...
> > > > // set up all clocks if defalts are not applicable
> > > > // ...
> > > > // set up TA and WDT if used
> > > > // ...
> > > > // set up SD16_A controller
> > > > // ...
> > > > // set up interrupts and enable them if used
> > > > // ...
> > > > // set up and run in an endless loop, or go to LPM
> > > > // ...
> > > > }
> > > > // add interrupt service routines if applicable
> > > > // ...
> > > >
> > > > There are lots of examples. But examples are just examples,
> they
> > > will
> > > > not be exactly what you want. What is the voltage range of
the
> > > input?
> > > > What is the frequency range? How often do you want to sample
it?
> > > >
> > > > --- In m..., "ez430project"
> wrote:
> > > > >
> > > > > Hi, I've already looked but they don't seem to provide a
> basic
> > > layout
> > > > > for measuring a simple voltage coming in - does anyone have
a
> > > basic
> > > > > layout code?
> > > > >
> > > > > --- In m..., "marek.gaik" wrote:
> > > > > >
> > > > > > --- In m..., "ez430project"
>
> > > wrote:
> > > > > > >
> > > > > > > Hi, I'm trying to measure the voltage output from a
> circuit,
> > > and
> > > > > > > convert this to digital using the SD16_A.
> > > > > > >
> > > > > > > Is there a sample code I could use for ADC conversion
> using
> > > one
> > > > > pin.
> > > > > > >
> > > > > > > Donald
> > > > > > >
> > > > > >
> > > > > >
> > > > > > Hi Donald,
> > > > > > Have you looked at this examples:
> > > > > > http://focus.ti.com/mcu/docs/mcuprodcodeexamples.tsp?
> > > > > sectionId&tabId68
> > > > > >
> > > > > > I suggest to download them all. And just find code
examples
> > > with
> > > > > SD16_A.
> > > > > > As i noticed, slac077c.zip contains some example codes,
> wich
> > > can be
> > > > > > helpful for you.
> > > > > >
> > > > > > Regards,
> > > > > > Mark
> > > > > >
> > > > >
> > > >
> > >
>
Check your clock source. Sometimes that seems to decrease the accuracy.

Also, if you have already applied 4V to the pins, you may have damaged the part. Try a new F2013 part in there. Use a resistor divider for measuring voltages above 0.6V

This is directly from the sample code zip file. I have used it and I know it works. It's been a while though. You may have to make some tweaks to suit your particular pin out etc:

//******************************************************************************
// MSP430F20x3 Demo - SD16A, Sample A1+ Continuously, Set P1.0 if > 0.3V
//
// Description: A continuous single-ended sample is made on A1+ using internal
// VRef Unipolar output format used.
// Inside of SD16 ISR, if A1 > 1/2VRef (0.3V), P1.0 set, else reset.
// ACLK = n/a, MCLK = SMCLK = SD16CLK = default DCO
//
// MSP430F20x3
// ------------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// Vin+ -->|A1+ P1.2 |
// |A1- = VSS P1.0|-->LED
// | |
//
// M. Buccini / L. Westlund
// Texas Instruments Inc.
// October 2005
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.40A
//******************************************************************************
#include

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
SD16CTL = SD16REFON + SD16SSEL_1; // 1.2V ref, SMCLK
SD16INCTL0 = SD16INCH_1; // A1+/-
SD16CCTL0 = SD16UNI + SD16IE; // 256OSR, unipolar, interrupt enable
SD16AE = SD16AE2; // P1.1 A1+, A1- = VSS
SD16CCTL0 |= SD16SC; // Set bit to start conversion

_BIS_SR(LPM0_bits + GIE);
}

#pragma vector = SD16_VECTOR
__interrupt void SD16ISR(void)
{
if (SD16MEM0 < 0x7FFF) // SD16MEM0 > 0.3V?, clears IFG
P1OUT &= ~0x01;
else
P1OUT |= 0x01;
}
----- Original Message -----
From: ez430project
To: m...
Sent: Tuesday, November 25, 2008 7:58 AM
Subject: [msp430] Re: *** F2013's SD16_A ***
Hi, I'm really struggling here. Could anyone help me out - I've
lowered my voltage input to 0.3V and am feeding this through Pin 6
(P1.4).

I'm getting different values for each reading.

Could anyone provide a piece of code (that works) I could use to get
my program working - I would so appreciate it, beyond words.

Donald

--- In m..., "ez430project"
wrote:
>
> I've tried feeding a constant 1.5V through Pin 6 (P1.4) using the
> sample code of sd16_a3.c, but still get a max of 2^16. As soon as I
> remove this voltage, there's still about 0.23V going through. I
then
> get numbers like 22, 365.
>
> Even though P1.0 (Pin 2) has no voltage going through, it still
shows
> a value. As does P1.2 (Pin 4).
>
> I'm confused as to why.
>
> --- In m..., "old_cow_yellow"
> wrote:
> >
> > The input voltage has to be within the power rail. That is, it
has
> to
> > be above Vss (0.0V) and below Vcc (3.6V max). Otherwise, you may
> > damage the MSP430. Further more, the analog input has to be below
> > Vref. Otherwise, you always get the max digital reading.
> >
> > --- In m..., "ez430project"
wrote:
> > >
> > > The voltage has a max. range of (currently) 4V. I want to
sample
> it
> > > for every i = 50,000 delay. The voltage input does tend to
change.
> > >
> > > Currently all I seem to be getting is 2^16 value regardless of
> the
> > > input, even when it changes.
> > >
> > > --- In m..., "old_cow_yellow"

> > > wrote:
> > > >
> > > > Here is a basic layout of a F2013 SD16_A example.
> > > >
> > > > #include
> > > > void main( void )
> > > > {
> > > > // Stop watchdog timer to prevent time out reset
> > > > WDTCTL = WDTPW + WDTHOLD;
> > > > // set up used and unused io pins
> > > > // ...
> > > > // set up all clocks if defalts are not applicable
> > > > // ...
> > > > // set up TA and WDT if used
> > > > // ...
> > > > // set up SD16_A controller
> > > > // ...
> > > > // set up interrupts and enable them if used
> > > > // ...
> > > > // set up and run in an endless loop, or go to LPM
> > > > // ...
> > > > }
> > > > // add interrupt service routines if applicable
> > > > // ...
> > > >
> > > > There are lots of examples. But examples are just examples,
> they
> > > will
> > > > not be exactly what you want. What is the voltage range of
the
> > > input?
> > > > What is the frequency range? How often do you want to sample
it?
> > > >
> > > > --- In m..., "ez430project"
> wrote:
> > > > >
> > > > > Hi, I've already looked but they don't seem to provide a
> basic
> > > layout
> > > > > for measuring a simple voltage coming in - does anyone have
a
> > > basic
> > > > > layout code?
> > > > >
> > > > > --- In m..., "marek.gaik" wrote:
> > > > > >
> > > > > > --- In m..., "ez430project"
>
> > > wrote:
> > > > > > >
> > > > > > > Hi, I'm trying to measure the voltage output from a
> circuit,
> > > and
> > > > > > > convert this to digital using the SD16_A.
> > > > > > >
> > > > > > > Is there a sample code I could use for ADC conversion
> using
> > > one
> > > > > pin.
> > > > > > >
> > > > > > > Donald
> > > > > > >
> > > > > >
> > > > > >
> > > > > > Hi Donald,
> > > > > > Have you looked at this examples:
> > > > > > http://focus.ti.com/mcu/docs/mcuprodcodeexamples.tsp?
> > > > > sectionId&tabId68
> > > > > >
> > > > > > I suggest to download them all. And just find code
examples
> > > with
> > > > > SD16_A.
> > > > > > As i noticed, slac077c.zip contains some example codes,
> wich
> > > can be
> > > > > > helpful for you.
> > > > > >
> > > > > > Regards,
> > > > > > Mark
> > > > > >
> > > > >
> > > >
> > >
> >
>



The 2024 Embedded Online Conference