Best Microcontroller Projects


XML RSS
What is this?
Add to My Yahoo!
Add to My MSN
Add to Google

Home
LCD-KEYS OnePort
PIC Introduction
PIC Programming
Programmer Types
PIC Programmer
Schematic Tool
Tips & Techniques
PIC Tutorials
C Course
Digital Downloads
Store
My SECRET
Oscilloscopes
Contact Me
About Me
Terms of Use
Search This Site
Freebies
Articles
Problem?-Solution
MicroBlog
Books
Resource Links
Site Map
Your Projects
Video du Jour
Rant/Rave
Privacy Policy

I use and
recommend Firefox
for the best internet
browsing experience. Click below for your
free copy today:

CLICK THE IMAGE:


Note: I find it faster
and easier to use and
it has great plugins.  

It even imports all your current
browser settings!

There's no risk as your existing browser is not affected in any way - you can just choose which one to use.


<<<<< Back to  

Configuring the PIC pin for DAC output

Sign up for MicroZine:
''The'' Microcontroller Newsletter


:
:
Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine
Enter your first Name and primary email address in the form above:

And receive absolutely FREE a full project for:


"Measuring Analogue Voltages
Without An ADC"

(Using only one pin).

Instant Download:
You Can
Get It Right Now

Warning: This project could be Removed
at any time.  

It will NOT be
available indefinitely SO

To avoid
disappointment get it:

Now



Remember this is a project with full description and fully debugged C Source code - and it's not available from the main website.

You can only get it through this newsletter.


To get exclusive access Enter your first name Name and primary email address Now in the form above.:

But wait !

There's more...

You'll receive more
free and exclusive reports as well as site information and site product updates.

Scroll up to the form above and sign up NOW.  Don't forget it's FREE and if you don't like it you can unsubscribe at any time.

Click Here to use the form Now.

Social Bookmarking
Click & Add:
add to BlinkBlink
add to Del.icio.usDel.icio.us
add to DiggDigg
add to FurlFurl
add to GoogleGoogle
add to SimpySimpy
add to SpurlSpurl
Bookmark at TechnoratiTechnorati
add to YahooY! MyWeb
Find out Why social bookmarking is
Useful For You.

Readers comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."


- Ranish Pottath


"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com

Learn PIC C Now
Wondering how to program your next project using C and need a great start?


"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

Learn Microcontrollers
"Interested in
Microcontrollers?"


Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon





"Programming and using the DAC in C"

Download:

DAC voltage generator C code and hex file

Download the zip file containing the hex and source files and mikroC project files:

FREE Tools and Resources.
For Earning Online...
CLICK HERE NOW

More Resources...

Download :


Download ZIP file : Download here.

Programming

The following code lets you experiment with the DAC generating a staircase output and a trigger signal to synchronize an oscilloscope.

If you don't have an oscilloscope add a delay_ms(1000) in the for loop to let you measure the output on a DVM.

Shadow register

The use of CVRCON_shdw allows updates without changing the actual value of CVRCON - the final output is made just before the end of the for loop.  

This is done since setting CVRCON CVR[3..0] to zero immediately changes the output to zero i.e. making glitched output.  So using CVRCON_shdw gives glitch free operation.

//////////////////////////////////////////////////////////
//
// File: 16F88-voltage-reference-dac.c
//
// Author: J F Main.
//
// Description:
//
//   Testing voltage comparator output
//
// Compiler : mikroC, mikroElektronika C compiler
//            for Microchip PIC microcontrollers
//            Version: 6.2.0.0
//
// Note Testing:
//
//   Tested on 16F88
//
// Requirements:
//
//    Clock : 8MHz  (Internal)
//
// Target : 16F88
//
// Version:
// 1.00 - Initial release.
//
// Copyright : Copyright © John Main 2007
//   http://www.best-microcontroller-projects.com
//   Free for non commercial use as long as
//   this entire copyright notice is included
//   in source code and any other documentation.
//
//////////////////////////////////////////////////////////
#include "bit.h"

//////////////////////////////////////////////////////////
// Defines
#define RA2 2

//////////////////////////////////////////////////////////
// Start here
//
void main(void) {
unsigned char i=0;
unsigned char CVRCON_shdw = 0;

   /* Setup 16F88 */
   OSCCON  = 0x70;  // b6..4 = 110 (4MHz) 111=(8MHz).

   TRISB = 0;       // set as output

   ANSEL = (1<<RA2); // digital I/O except RA2 ana. I/O
   TRISA = (1<<RA2); // Set RA2 as input i.e. high Z

   // Setup the voltage reference
   // CVREN enable reference
   // CVROE output enable to pin
   // CVRR select coarse range
   CVRCON = (1<<CVREN) | (1<<CVROE) | (1<<CVRR);
   CVRCON_shdw = CVRCON;

   while(1) {      // infinite loop

      // Scope trigger
      setBit(PORTB,3);
      delay_us(1);
      resBit(PORTB,3);

      for(i=0; i<16; i++) {

         // Note working on the shadow register as
         // the register updates immediately
         // so here output would be zeroed.
         // (if not using shdw).
         CVRCON_shdw &= 0xf0; // clear lower 4, keep top 4

         // Update the voltage reference mux
         CVRCON_shdw |= (i & 0x0f); // OR  in lower 4 bits

         // Output to real register in one go.
         CVRCON = CVRCON_shdw;
      }
   }
}

Internal DAC Disadvantages

Disadvantages of the internal DAC are that it:
  • Can only drive high impedance.
  • Only has 16 steps also split into high and low ranges.
  • Only uses internal supply as a reference *.
  • Can not go fully to V+.
* Note: For the 18F2550 device range you can select the reference voltage from the pin at Vref+.

If you design a circuit
with these limitations
in mind then you're good to go!

Advantages:

  • Programmable.
  • Already inside your microcontroller (depending on device).
  • No extra wiring.
  • Free!


PIC DAC introduction
 
To start >>>>







Jump from DAC page to
Home page: Best-Microcontroller-Projects.com



Don't forget to Sign Up for your

Microcontroller Newsletter

With "Essential tips and techniques",

..."New Site Info" and more...

Including a free project :

How to drive an LCD and 12key keypad using "Only One 8 Bit Port" with no interface logic!...

(Works for any microcontroller)

This costs you : Nothing...
Just fill out the form below and you'll get full C source code and project schematic and description.



Email

Name

Then

Don't worry -- your e-mail address is totally secure.
I promise to use it only to send you MicroZine.
Google
 
  Best Microcontroller projects.