This is impossible in my eyes:Can anybody show how to solve these equations to get 0 to 5V DAC voltage = +/-18V to +/-2V Output?
Note: this is against Common mode input voltage specification of your OPAMP, because IN+ = 18V but it´s specified to be +Supply -2V which is 18V-2V = 16V
When DAC output toggles between 0 and 5V the OPAMP otput should toggle between -18V to +18V.
When DAC output toggles between 0 and 2.5V the OPAMP otput should toggle between -9V to +9V.
When DAC output toggles between 0 and 0.1V the OPAMP otput should toggle between -0.72V to +0.72V.
Thus the overall formula shuld be: V_out = V_in * 14.4 -18V
Hi,
You are still wrong.
Klaus
Yes, but only if you use an ADC which can handle negative input voltages.Can DC offset be GND?
With the given formula "gain2= ..." (next to R24 in the schematic)How to find out R24?
You talk as if it is a DC voltage...like 2.3V,How can I know what will be the max voltage at OPA2P2 pin?
I recommed to learn basics of hardware...The sensor that now we are using gives only 0 to 2.5V max = 0 to 250 mmHg BP. So, the output of HPF will not be negative, right? Then I can use GND as DC_OFFSET?
I don´t understand this completely. But for the problem it is meaningless.My sensor signal is similar to a Half Wave Rectifier output that is we are using a Syringe instead of a pump to take the measurement and when the syringe is pushed the reading goes max 2.5V. If the syringe is not pushed it is 0V.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 #define _XTAL_FREQ 32000000UL // PIC16F1779 Configuration Bit Settings // 'C' source line config statements // CONFIG1 #pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator: I/O function on CLKIN pin) #pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled) #pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled) #pragma config MCLRE = ON // MCLR Pin Function Select (MCLR/VPP pin function is MCLR) #pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled) #pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled) #pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin) #pragma config IESO = ON // Internal/External Switchover Mode (Internal/External Switchover Mode is enabled) #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled) // CONFIG2 #pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off) #pragma config PPS1WAY = ON // Peripheral Pin Select one-way control (The PPSLOCK bit cannot be cleared once it is set by software) #pragma config ZCD = OFF // Zero-cross detect disable (Zero-cross detect circuit is disabled at POR) #pragma config PLLEN = ON // Phase Lock Loop enable (4x PLL is always enabled) #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset) #pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.) #pragma config LPBOR = OFF // Low-Power Brown Out Reset (Low-Power BOR is disabled) #pragma config LVP = OFF // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming) // #pragma config statements should precede project file includes. // Use project enums instead of #define for ON and OFF. #include <xc.h> #include <stdio.h> #include <stdlib.h> unsigned int timer1ReloadValue = 15536; unsigned int dacValue = 1023; char toggleDacOutput = 0; //Timer1 //Prescaler 1:4; TMR1 Preload = 15536; Actual Interrupt Time : 25 ms void InitTimer1() { T1CON = 0x21; PIR1bits.TMR1IF = 0; TMR1H = 0x3C; TMR1L = 0xB0; timer1ReloadValue = 15536; PIE1bits.TMR1IE = 1; } void __interrupt () my_isr_routine (void) { if((PIE1bits.TMR1IE) && (PIR1bits.TMR1IF)) { PIR1bits.TMR1IF = 0; TMR1H = timer1ReloadValue >> 8; TMR1L = timer1ReloadValue; toggleDacOutput = ~toggleDacOutput; if(toggleDacOutput) { DAC1REFH = dacValue >> 8; DAC1REFL = dacValue; DAC6REFH = dacValue >> 8; DAC6REFL = dacValue; } else { DAC1REFH = 0; DAC1REFL = 0; } DACLDbits.DAC6LD = 1; DACLDbits.DAC1LD = 1; } } void initailizePorts() { TRISA = 0x33; TRISB = 0x08; TRISC = 0x21; TRISD = 0x00; TRISE = 0x00; PORTA = 0x00; PORTB = 0x00; PORTC = 0x00; PORTD = 0x00; PORTE = 0x00; LATA = 0x00; LATB = 0x00; LATC = 0x00; LATD = 0x00; LATE = 0x00; ODCONA = 0x00; ODCONB = 0x00; ODCONC = 0x00; ODCOND = 0x00; ODCONE = 0x00; WPUA = 0x00; WPUB = 0x00; WPUC = 0x00; WPUD = 0x00; WPUE = 0x00; HIDRVB = 0x00; SLRCONA = 0x00; SLRCONB = 0x00; SLRCONC = 0x00; SLRCOND = 0x00; SLRCONE = 0x00; } void initailizeADC() { ANSELA = 0x37; ANSELB = 0x0A; ANSELC = 0x60; ANSELD = 0x00; ANSELE = 0x02; ADCON0 = 0x00; ADCON1 = 0b11100000; ADCON2 = 0x00; } void initailizeDAC() { FVRCON = 0x00; DAC1CON0 = 0xA0; DAC1REFH = 0x00; DAC1REFL = 0x00; DAC1CON0bits.DACOE1 = 1; DACLDbits.DAC1LD = 1; DAC6CON0 = 0xA0; DAC6REFH = 0x00; DAC6REFL = 0x00; DACLDbits.DAC6LD = 1; } void initailizeOPAMP() { OPA1CON = 0x80; OPA1ORS = 0x00; OPA1NCHS = 0x00; OPA1PCHS = 0x00; OPA2CON = 0x90; OPA2ORS = 0x00; OPA2NCHS = 0x00; OPA2PCHS = 0x00; OPA3CON = 0x90; OPA3ORS = 0x00; OPA3NCHS = 0x00; OPA3PCHS = 0x00; } int main(int argc, char** argv) { OSCCON = 0xF3; OSCSTAT = 0x51; OSCTUNE = 0x00; initailizePorts(); initailizeDAC(); initailizeOPAMP(); DAC1REFH = dacValue >> 8; DAC1REFL = dacValue; InitTimer1(); INTCONbits.PEIE = 1; INTCONbits.GIE = 1; while(1); return (EXIT_SUCCESS); }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?