adc dac mirror ... how could be done?


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2012
    Location
    Comodoro Rivadavia - Patagonia Argentina
    Posts
    51

    Default adc dac mirror ... how could be done?

    Hello, I have a doubt that while I can not solve ...
    As I can do to reflect a pwm and a filter (resistor 1k and capacitor 1uf on the output pin of the pwm), I read the voltage with analog port ...
    pwm control with two buttons to get a DAC 1 to 5Vdc is easy; For example:

    Code:
    menu:
             IF PORTC.6=0 THEN
             TIEMPO=TIEMPO+1
             IF TIEMPO>10 THEN TIEMPO=10 
             pause 150
          ENDIF
          
          IF PORTC.7=0 THEN
            TIEMPO=TIEMPO-1
             IF TIEMPO=255 THEN TIEMPO=0
             pause 150
          ENDIF 
    
    SALIDA_PWM:
           HIGH PORTC.2
           PAUSE TIEMPO
           LOW PORTC.2
           PAUSE (10 - TIEMPO)
           goto menu
    but how could I do to translate the tension that I read in the pwm and generate the same voltage? i have pic only: 16f628...16f876a...16f877a...18f2550


    EN ESPAÑOL:
    hola, tengo una duda que hace rato no puedo resolver...
    Como puedo hacer para reflejar con un pwm y un filtro (resistencia 1k y capacitor 1uf en el pin de salida del pwm), la tension que leo con el puerto analogico...
    controlar el pwm con dos pulsadores para obtener un DAC de 1 a 5Vcc es facil; Por ejemplo:

    Code:
    menu:
             IF PORTC.6=0 THEN
             TIEMPO=TIEMPO+1
             IF TIEMPO>10 THEN TIEMPO=10 
             pause 150
          ENDIF
          
          IF PORTC.7=0 THEN
            TIEMPO=TIEMPO-1
             IF TIEMPO=255 THEN TIEMPO=0
             pause 150
          ENDIF 
    
    SALIDA_PWM:
           HIGH PORTC.2
           PAUSE TIEMPO
           LOW PORTC.2
           PAUSE (10 - TIEMPO)
           goto menu
    pero como podria hacer para traducir la tension que leo en el pwm y generar la misma tension?
    solo tengo estos pic: 16f628...16f876a...16f877a...18f2550

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: adc dac mirror ... how could be done?

    Hi,
    Use the ADC to read the voltage, use the CCP module (I'm pretty sure all the models you list have at least one) to create the PWM signal. If you set the ADC resolution to 8 bits it'll match the resolution of the CCP module when using the HPWM command. You can get 10bit resolution from the CCP module but you need to set it up manually - plenty of examples around the forum avaiable.

    Basic idea:
    Code:
    DEFINE ADC_BITS 8
    
    Voltage VAR BYTE
    LastReading VAR BYTE
    Temp VAR WORD
    i VAR BYTE
    
    Main:
      ' Get a couple of readings and average them to reduce noice.
      Voltage = 0
      For i = 0 to 15    ' 16 readings
        ADCIN 0, Temp
        Voltage = Voltage + Temp
        Pause 5  
      Next
      Voltage = Voltage >> 4   ' Divide by 16, Voltage now 0 to 255
    
      ' Update output only if voltage has changed.
      If Voltage <> LastReading THEN
         HPWM 1, Voltage, 10000
         LastReading = Voltage
      ENDIF
    
    Goto Main
    /Henrik.

  3. #3
    Join Date
    Aug 2012
    Location
    Comodoro Rivadavia - Patagonia Argentina
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: adc dac mirror ... how could be done?

    thanks for the help; this is my project hardware (monitor voltage and current output proportional). The idea is to add the 0-5VDC output with pwm controlled to perform a transducer 0-5V / 0-10V / 0-10mA / 4-20mA configurable through jumpers ...

    Name:  trans4_20mA_10V.JPG
Views: 3261
Size:  167.8 KB

    First I start by controlling the input voltage and delivering a value similar to the output from your help ... and I will continue burning after the neurons to attack the current reading.
    Try not to make it so complicated, implement a unique port to read analog signals 4-20mA (I saw the topic that the voltage drop is calculated from the resistance of 250 Ohms).
    Now as soon as you finish what you offer me, I upload the program the microcontroller. regards

    PD: tags that make recommendation me search similar forum topics?...

    EN ESPAÑOL:
    gracias por la ayuda; este es el hardware de mi proyecto (un monitor de tension y corriente con salida proporcional). La idea es sumar la salida 0-5vcc con el pwm controlado para poder realizar un transductor 0-5v / 0-10v / 0-10mA / 4-20mA configurable por intermedio de los jumper...
    primero arranco controlando la tension de entrada y entregando un valor similar a la salida gracias a tu ayuda... y despues seguire quemando las neuronas para atacar la lectura de la corriente.
    Quizas para no hacerla tan complicada, implemente un puerto analogico exclusivo para leer señales 4-20mA (vi el topico que se calcula la caida de tension con la resistencia de 250 Ohms).
    Ahora ni bien termine lo que me propones, subo el programa del microcontrolador. Saludos

    PD: con que tags me recomendas realizar la busqueda de temas similares en el foro?

  4. #4
    Join Date
    Aug 2012
    Location
    Comodoro Rivadavia - Patagonia Argentina
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: adc dac mirror ... how could be done?

    well, succeed in making a mirror with the help of the LM358.
    Basically, what I do is with the first Ampop (12v source) is to convert the 4-20mA 0-5V input voltage ... that, I do mirror the output of a PWM pic and put it in a second Ampop (24v source) which transforms 0-5 in 4-20mA.
    While this project could be implemented to build a current source 4-20mA, the initial idea is to add it to a tank level sensor home made. ( The sensor consists of several magnetic sensors with 0 ohm resistors ... with a floating magnet, according to the water level switches enable me )

    Name:  sensor.JPG
Views: 1332
Size:  24.7 KB

    Name:  sensor_TK.PNG
Views: 1412
Size:  67.4 KB

    Name:  transductor_transmisor_uni420mA.PNG
Views: 2002
Size:  66.3 KB
    I think in the future, I will make the display and will try to take a pic 8 pins (just need an analog port and another port for pwm)


    sorry for my spanglish!!!!

  5. #5
    Join Date
    Aug 2012
    Location
    Comodoro Rivadavia - Patagonia Argentina
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: adc dac mirror ... how could be done?

    I leave a part of the program ... basically is the operating principle of the mirror (input voltage for the analog port = output voltage filter pwm)

    En español:
    les dejo una parte del programa... basicamente es el principio de funcionamiento del espejo (tension de entrada por el puerto analogico = tension de salida en el filtro del pwm)

    Code:
    DEFINE OSC 20 
    '****************************************************************
    TRISA = 1 
    ADCON1 = 0 
    ADCON0 = %11000001
    TRISB = %00000000  
    TRISC = %00000000
    '****************************************************************
    DEFINE ADC_BITS 8 
    DEFINE ADC_CLOCK 3 
    DEFINE ADC_SAMPLEUS 50 
    '****************************************************************
    ent420 var word
    tiempo var byte
    nivel var byte
    '****************************************************************
    INICIO:
    nivel= 1
    
    bucle:
    ADCIN 0, ent420
    nivel = ent420
    PWM PORTC.2,nivel,100  ;nivel PWM = (Vout * 255) / V.Fuente
    ;gosub grafica
    goto bucle
    
    end

Similar Threads

  1. MIBAM - (Mirror Imaged Bit Angle Modulation)
    By Darrel Taylor in forum Code Examples
    Replies: 2
    Last Post: - 15th February 2009, 17:02
  2. Looking for a DAC
    By RussMartin in forum Off Topic
    Replies: 4
    Last Post: - 25th November 2007, 07:21
  3. LCD Mirror image
    By Archangel in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th May 2007, 22:00
  4. Led scrolling display: How to mirror characters?
    By mahia2005 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th May 2007, 04:25
  5. dac
    By kaisersystems in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 10th June 2005, 21:23

Members who have read this thread : 1

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