DAC voltage output


+ Reply to Thread
Results 1 to 4 of 4

Thread: DAC voltage output277 days old

  1. #1
    Junior Member glenlivet's Avatar
    Join Date
    Nov 2004
    Posts
    46
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    102.10 MB

    0 Not allowed!

    Default DAC voltage output

    Is there a command to output a DAC voltage on a pin or do I have to bit bang it in the registers?
    I don't see it in the manual- am I missing something???

  2. #2
    Senior Member Henk57's Avatar
    Join Date
    Jan 2014
    Posts
    401
    Thumbs Up
    Received: 40
    Given: 35
    Total Downloaded
    192.60 MB

    0 Not allowed!

    Default Re: DAC voltage output


  3. #3
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,212
    Thumbs Up
    Received: 18
    Given: 0
    Total Downloaded
    614.99 MB

    0 Not allowed!

    Default Re: DAC voltage output

    I don't see any DAC commands but it is relatively easy, when I get a few moments spare I am working on a 16F1718 DAC
    My RAM is failing

  4. #4
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,212
    Thumbs Up
    Received: 18
    Given: 0
    Total Downloaded
    614.99 MB

    0 Not allowed!

    Default Re: DAC voltage output

  5. Turned out to be very easy, just two registers - one for DAC setup and one for the DAC value

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2018 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 02/03/2018                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : For PicKit 2 with new device file select          *
    '*          : Device Family = Midrange/1.8v min ID-14           *
    '****************************************************************
    ' 16F1718 28 pin DIP
    ' RA.2 pin 4 = DAC 1 output 1 of 8 BIT DAC
    ' RA.5 pin 7 = DAC 2 output 1 of 5 BIT DAC
    ' RB.7 pin 28 = Dac 1 output 2 or DAC 2 output 2
    ' RB7 is used by PicKit
    ;-------------------------------------------------------------------------------
    ;**** Added by Fuse Configurator ****
    ; Use the Fuse Configurator plug-in to change these settings
    
    Device = 16F1718
    Xtal 32
    
    Config1 FOSC_INTOSC, WDTE_OFF, PWRTE_OFF, MCLRE_ON, CP_OFF, BOREN_ON, CLKOUTEN_OFF, IESO_OFF, FCMEN_ON
    Config2 WRT_OFF, PPS1WAY_OFF, ZCDDIS_ON, PLLEN_ON, STVREN_ON, BORV_LO, LPBOR_OFF, LVP_OFF
    
    ;**** End of Fuse Configurator Settings ****
    ;-------------------------------------------------------------------------------
    
    Declare LCD_Type 0
    Declare LCD_Interface 4
    Declare LCD_Lines 2
    Declare LCD_DTPin PORTB.4
    Declare LCD_RSPin PORTB.3
    Declare LCD_ENPin PORTB.2
    Declare LCD_CommandUs 200
    
    Symbol DAC1EN  = DAC1CON0.7     ' DAC 1 enable
    Symbol DAC1OE1 = DAC1CON0.5     ' DAC 1 output enable 1 on RA2, pin 4
    Symbol DAC1OE2 = DAC1CON0.4     ' Dac 1 output enable 2 on RA5, pin 7
                                    ' for other bits see page 260 of data sheet
    
    Dim Buttons As Byte
    Dim Mode    As Byte
    Dim Temp    As Byte
    Dim x       As Byte
    Dim DAC_Value   As Byte                     ' 
    ' ----------------------------------------------
    ' interrupt goes here
    ' ----------------------------------------------
    
    ' if using INTOSC don't put any delays before OSCON is set !
    ' Bits 7,1,0 ignored depending on CONFIG, Bit 2 not used - refer to data sheet
    ' for more information
    ' Bits 6,5,4,3 Internal Oscillator Frequency Select bits
    OSCCON = 110000                  ' 8MHz internal oscillator + 4 * PLL = 32MHz
     
    DelayMS 100
    Cls
    Print At 1,1," 16F1718"             
    DelayMS 500                         ' increase time only when testing board
    Cls
    High PORTB.1                        ' LED and supply for buttons
    Print At 2,2,"1   2   3   4"
    DAC_Value = 100
    
    DAC1CON0 = 100000            ' DAC 1 8 BIT enabled on DAC 1 output, 
                                    ' DAC ref pos, VDD, DAC ref neg to VSS
    DAC2CON0 = 100000            ' DAC 2 5 BIT
    TRISA.2 = 0                     ' output pin DAC 1
    
    While 1 = 1
    'DelayMS 10                          ' = 50Hz squarewave to confirm
    'Toggle PORTB.1                      ' OSC frequency on 'scope
    GoSub Read_Buttons:
    Print At 1,1,"DAC = ",Dec DAC_Value,"    "
    DAC1CON1 = DAC_Value
    DelayMS 500
    Wend
    
    
    ' ############################ Subs #############################
    Read_Buttons:
        TRISB = 110000                   ' enable BUTTONS
        Buttons = 0                         
        DelayMS 1                           ' without a delay there are errors
        Temp = PORTB & 110000            ' read port
        If Temp > $F Then                   ' button pressed?
                                            ' Yes, so change selected button
           Select Case Temp
                Case 16
                    Buttons = 1             '
                    If DAC_Value >= 10 Then DAC_Value = DAC_Value - 10 
                Case 32
                    Buttons = 2
                    If DAC_Value < 250 Then DAC_Value = DAC_Value + 10
                Case 64
                    Buttons = 3
                    DAC_Value = 50
                Case 128
                    Buttons = 4
                    DAC_Value = 200
                Case Else
            End Select
    '        For X = 1 To 4                      ' clear old pointer, 4 line display
    '            Print At X,1,"  "
    '        Next
    '        Print At Buttons,1,126              ' set new pointer
        EndIf
        DelayMS 25
        
        Return
    My RAM is failing

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Replies: 0
    Last Post: 19th May 2012, 10:48
  2. Replies: 3
    Last Post: 12th January 2012, 23:29
  3. HPMW to give output voltage -- circuit help
    By nigelstephens in forum Proton Plus Compiler v3
    Replies: 8
    Last Post: 25th March 2010, 16:26
  4. Controlling Output Voltage
    By t0pP8uZz in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 5th November 2009, 10:10

Members who have read this thread since 11th November 2018, 18:46 : 0

Actions :  (Set Date)  (Clear Date)

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

Tags for this Thread

Posting Permissions

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