DAC Output with PIC16F1765

Discussion on both general simulation and Proteus VSM microcontroller simulation.
Post Reply
dmccric
Unlicenced User
Posts: 5
Joined: Mon 2018-03-05 10:55

DAC Output with PIC16F1765

Post by dmccric »

Has anyone managed to get a varying DAC Output (RA0, DAC1OUT) on the PIC16F1765?

I have tried everything, I know that the pin is shared with the ICSPDAT but I have disabled the DEBUG in MPLAB X IDE.

The port is an output (but it gets overridden by the DAC). I have tried to use the DAC1OUPT as an input to the Op Amp but this gives a simulation error (No PORTB4) after a successful compilation.

It should be simple but it has been a nightmare.

D
Ettore
Labcenter Staff
Posts: 2935
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: DAC Output with PIC16F1765

Post by Ettore »

The DAC1OUT output to RA0 works well on such the variant, as far as I can see. Attached screen shot depict it. If you believe there's still something wrong with DAC1OUT then attach your .pdsprj Proteus project including your source code and I will have a look.
Immagine 2022-04-14 172906.jpg
Immagine 2022-04-14 172906.jpg (101.18 KiB) Viewed 4694 times

About the second issue - no PORTB4 internal error - I actually have to confirm it. The fix will be released with next service pack.
Kind regards,
Ettore Arena - Labcenter Electronics.
dmccric
Unlicenced User
Posts: 5
Joined: Mon 2018-03-05 10:55

Re: DAC Output with PIC16F1765

Post by dmccric »

Sorry about the late reply, bank holiday weekend.

I am using the dac1.c/h files for this part and so I thought it would be straight forward.

Can you send me the code you tried?

I would be very grateful.

Regards
dmccric
Unlicenced User
Posts: 5
Joined: Mon 2018-03-05 10:55

Re: DAC Output with PIC16F1765

Post by dmccric »

I was under the impression that when the VREF pins are set to use the supply voltage, (+5V, GND), that the output voltage from 0-5V would be quantized by 1024 levels to give each DAC value a voltage of ~4.9mV.

My DAC1REF value was 258 and it only gave me an output voltage of 0.0124729V, I only saw this as I put a voltage probe on it as it gives more decimals places than output it on the debug console.

This must mean that the internal VREF is not working and that the DAC Resistor network does not have 5V connected.

Does this sound about right?


OSCCONbits.SPLLEN = 0b0; // Disable (unused) Oscillator Module PLL
OSCCONbits.IRCF = 0b01111; // INTOSC = 16 MHz (for simulation only)
OSCCONbits.SCS = 0b10; // INTOSC selected
OPTION_REG = 0x01; // PSA = TMR0, PS = 1:4, Timer 0 increments every (1/16,00,000 * 4) = 4uS

WPUA = WPUC = 0; // Disable weak pull-ups
SLRCONA = SLRCONC = 0; // Disable slew-rate limiting
ANSELA = 0x00;
RA0PPS = 0x00;
DAC1CON = 0xA0; // DACEN, DACOE, (VREF +:VDD, -:VSS)
DAC1REF = 512; // Output voltage is 2.5V
dmccric
Unlicenced User
Posts: 5
Joined: Mon 2018-03-05 10:55

Re: DAC Output with PIC16F1765

Post by dmccric »

I have multiplied the DAC1REF register and are now getting a reasonable output voltage

DAC1REF = (VIN << 9);

Regards
Ettore
Labcenter Staff
Posts: 2935
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: DAC Output with PIC16F1765

Post by Ettore »

dmccric wrote: Tue 2022-04-19 14:09 I was under the impression that when the VREF pins are set to use the supply voltage, (+5V, GND), that the output voltage from 0-5V would be quantized by 1024 levels to give each DAC value a voltage of ~4.9mV.

My DAC1REF value was 258 and it only gave me an output voltage of 0.0124729V, I only saw this as I put a voltage probe on it as it gives more decimals places than output it on the debug console.

This must mean that the internal VREF is not working and that the DAC Resistor network does not have 5V connected.

Does this sound about right?


OSCCONbits.SPLLEN = 0b0; // Disable (unused) Oscillator Module PLL
OSCCONbits.IRCF = 0b01111; // INTOSC = 16 MHz (for simulation only)
OSCCONbits.SCS = 0b10; // INTOSC selected
OPTION_REG = 0x01; // PSA = TMR0, PS = 1:4, Timer 0 increments every (1/16,00,000 * 4) = 4uS

WPUA = WPUC = 0; // Disable weak pull-ups
SLRCONA = SLRCONC = 0; // Disable slew-rate limiting
ANSELA = 0x00;
RA0PPS = 0x00;
DAC1CON = 0xA0; // DACEN, DACOE, (VREF +:VDD, -:VSS)
DAC1REF = 512; // Output voltage is 2.5V
With this code I get about 1.26V when DAC1REF=258 and 2.5V when DAC1REF=512. So everything is working as expected with DAC1.
Can you email your project along with your customer number to support@labcenter.com ?
Kind regards,
Ettore Arena - Labcenter Electronics.
Post Reply