Usage of built-in DAC ?


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,124

    Default Usage of built-in DAC ?

    Hello.

    Certain PICs have built-in DAC. Is it possible somehow use it via picbasic?

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Usage of built-in DAC ?

    Very simple for PIC16C782 you set the register DACON0 to ENABLE the dac and simply set the register DAC with a byte value for the analog output desired.

    DAC = 128 will generate an analog output of 2.5 volts if your reference was Vdd (5V)

    That's all.

    Cheers

    Al.
    All progress began with an idea

  3. #3
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Usage of built-in DAC ?

    So if I want alternating output, I have to update DAC register in the loop?

    which statement will do that write?

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,159


    Did you find this post helpful? Yes | No

    Default Re: Usage of built-in DAC ?

    Did you try DAC=255 for 100%?

    (Or whatever register name is stated in datasheet)

    I would stay from 0 to 255 (fits in 1 byte)

    Robert

  5. #5
    Join Date
    Aug 2004
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Usage of built-in DAC ?

    Hi:
    I made this program and I can only get from 0 to 3.77 volts in the DAC output.

    '************************************************* ***************
    '* Name : EJERCICIO_16F1783.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 11/28/2014 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    '************** CONFIG PARA 16F1782/83/84/86/88 *********************
    #CONFIG
    __config _CONFIG1, _FOSC_INTOSC & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_ON & _IESO_OFF & _FCMEN_OFF
    __config _CONFIG2, _PLLEN_OFF & _LVP_OFF & _BORV_25 & _VCAPEN0_OFF & _VCAPEN1_OFF & _STVREN_OFF
    #ENDCONFIG
    @ ERRORLEVEL -306 ; turn off crossing page boundary message (dt)
    @ ERRORLEVEL -305 ; turn off crossing page boundary message (dt)

    '************************************************* ************************
    '*********** REGISTER SETUP **********************************************
    '************************************************* ************************
    ANSELA = 01 'DESHAB ADC _INTRC_OSC_NOCLKOUT RA.0 PIN2
    ANSELB = 0 'DESHABILITA ADC
    '************* OPCIONES OSCILADOR INTERNO *******************************
    OSCCON = $72 '$F8 int osc de 16 mhz $72 PARA 8 MHZ, $6A PARA 4 MHZ.
    '************************************************* ************************
    CM1CON0 = 0 'DESHAB. COMPARADORES 1
    CM2CON0 = 0 ' Y 2
    OPA1CON = 0 ' DESHABILITA OP AMPSX
    OPA2CON = 0 ' DESHABILITA OP AMP
    DACCON0 = $90 '1001 0000 DAC ENABLED,DACOUT2 ENABLED RB.7 PIN 28
    CCP1CON = 0 ''NO COMPARE OR PWM
    FVRCON = $00 'DISABLED
    ADCON0 = $00
    ADCON1 = $00
    ODCONA = 0
    ODCONC = 0
    CMOUT = 0
    DEFINE OSC 8
    DEFINE ADC_BITS 8
    DEFINE HSER_RCSTA 90H 'SERIAL INIT
    DEFINE HSER_TXSTA 20H
    DEFINE HSER_BAUD 1200
    TRISA = $01 ' 0000 0001
    TRISB = $00
    TRISC = $80 '1000 0000
    PORTA = 0
    PORTB = 0
    PORTC = 0
    PAUSE 200

    LED var porta.7
    OUTSER VAR PORTC.6
    VALOR VAR WORD
    CHAR VAR BYTE
    AUX VAR BYTE




    START:
    FOR AUX = 0 TO 4
    LED = 1
    PORTA = 255
    PORTC = 255
    PAUSE 500
    LED = 0
    PORTA = 0
    PORTC = 0
    PAUSE 500

    NEXT AUX
    HSEROUT ["PRUEBA A 8 MHZ",13,10]
    FOR AUX = 0 TO $FF
    DACCON1 = AUX 'send from 0 to 255 to DAC
    HSEROUT ["AUX=",DEC3 AUX,13,10]
    PAUSE 300
    NEXT AUX
    GOTO START
    *****************************************
    Somebody can tell me what I am doing wrong.?
    Thanks in advance...
    Ruben de la Pena

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,159


    Did you find this post helpful? Yes | No

    Default Re: Usage of built-in DAC ?

    Are you checking voltage on pin A.2?

    I see nothing, as long as you're checking B.7.

    What happens if you move DACCON0 after the other registers, just before DEFINE OSC?

    Maybe you are disabling DAC accidentally.

    Robert
    Last edited by Demon; - 4th December 2014 at 22:06.

  7. #7
    metemoine's Avatar
    metemoine Guest


    Did you find this post helpful? Yes | No

    Default Re: Usage of built-in DAC ?

    Very simple for PIC16C782 you set the register DACON0 to ENABLE the dac and simply set the register DAC with a byte value for the analog output desired.

Similar Threads

  1. Anybody built one of these yet?
    By Byte_Butcher in forum Off Topic
    Replies: 1
    Last Post: - 21st April 2010, 16:44
  2. Skipping link step. Not all sources built successfully
    By Jalves in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th March 2009, 19:25
  3. Looking for a DAC
    By RussMartin in forum Off Topic
    Replies: 4
    Last Post: - 25th November 2007, 06:21
  4. Using PWM built in Module 16F628
    By earltyso in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th October 2007, 06:40
  5. how to built a device that can be interface using sms?
    By fazan83 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 21st January 2007, 02:23

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts