# 12 - DAC

> **PIC C Compiler CCS**
>
> [**PIC18F4550 / PIC18F45K50**](https://docs.microside.com/practicas/pic-c-compiler-ccs/pic18f4550-or-pic18f45k50)

<figure><img src="https://177299348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2FpYkYLtRUhgxu02T5UASA%2FDAC.png?alt=media&#x26;token=6ba555fa-13ad-4063-8614-52870ebdd6cf" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
**Nota:** Esta práctica solo es compatible con el **PIC18F45K50**
{% endhint %}

## **Introducción**

En esta práctica se implementa un control DAC (Convertidor Digital-Analógico) para variar el voltaje de una salida analógica y visualizar el resultado a través de un LED. Además el aumento de voltaje de la salida se visualiza a través de 5 LEDs.

## **Descripción**

En esta práctica se realiza un control DAC para regular la intensidad luminosa de un LED, mediante la salida de voltaje de un puerto analógico. Además el aumento de voltaje de la salida se visualiza a través de 5 LEDs, conectados a la tarjeta **X-TRAINER** con el **PIC18F45K50**.

**Materiales:**

1 x Tarjeta **X-TRAINER**. [**Manuales**](https://docs.microside.com/tarjetas-de-desarrollo/x-trainer) | [**Comprar**](https://www.microside.com/shop/category/entrenadores-pic-1)

6 x Resistencias 220 ohms.

6 x LEDs.

1 x Protoboard de 830 puntos.

1 x Juego de cables Dupont.

1 x Cable micro USB.

**Software:**

Windows 8.1 o posterior.

PIC C Compiler v5.069 o posterior. [**Descarga**](http://www.ccsinfo.com/ccsfreedemo.php)

X-TRAINER Suite v1.0 [**Descarga**](https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/microside_download_archive/main/Tools/X-TRAINER%20Suite/X-TRAINER%20Suite%20Setup.zip)

## **Procedimiento**

**1.** En el apartado de “[**Diagrama Esquemático**](#diagrama-esquematico)”, realiza las conexiones que se muestran en la imagen y conéctala a la computadora.

**2.** Ejecuta **PIC C Compiler**, crea un nuevo proyecto con el código fuente que se encuentra en el apartado "[**Código**](#codigo)" y compila el programa.

{% hint style="success" %}
Si tienes dudas de cómo realizar los pasos anteriores puedes encontrar un manual de **PIC C Compiler** a través del siguiente [**link**](https://docs.microside.com/practicas/ides/pic-c-compiler-ccs).
{% endhint %}

**3.** Abre el **Software X-TRAINER Suite v1.0** en el apartado **PIC18F4550/45K50**, selecciona el archivo .hex generado al compilar el proyecto y programa la tarjeta.

{% hint style="success" %}
Si tienes dudas de cómo realizar los pasos anteriores puedes encontrar un manual del **Software X-TRAINER Suite v1.0**. a través del siguiente[ **link**](https://docs.microside.com/tarjetas-de-desarrollo/software-x-trainer-suite).
{% endhint %}

**4.** Al terminar de programar, la tarjeta **X-TRAINER** se reiniciará automáticamente y se ejecutará el programa de esta práctica.

## **Diagrama esquemático**

Selecciona el modelo de tu tarjeta **X-TRAINER**

{% tabs %}
{% tab title="LITE M R2" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/12-DAC-CCS-PIC18F45K50/main/Diagrama%20de%20conexi%C3%B3n/X-TRAINER_Lite-M-r2_Practica-12_Microside_02.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="LITE M R3" %}

<figure><img src="https://177299348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2Fsmti2e6V66q1H3GnJdTh%2FDAC%20PIC18F44550%20o%20PIC18F45K50%20%20X-TRAINER%20LITE%20M%20MICROSIDE.webp?alt=media&#x26;token=597c1075-4f9d-4af3-b3f8-df248a6b9bb5" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="LITE F" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/12-DAC-CCS-PIC18F45K50/main/Diagrama%20de%20conexi%C3%B3n/X-TRAINER_LITE-F_Practica-12_Microside_01.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="DIP" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/12-DAC-CCS-PIC18F45K50/main/Diagrama%20de%20conexi%C3%B3n/X-TRAINER_DIP_Practica-12_Microside_01.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="DIP R3" %}

<figure><img src="https://177299348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2FMtCU5LIiJZXMkYpDG2b8%2Fhands-on-pic18f-dac-x-trainer-dip-r3.png?alt=media&#x26;token=6fb778f6-791e-4e13-9ffe-1b4c71099603" alt=""><figcaption></figcaption></figure>

{% endtab %}

{% tab title="PRO R2" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/12-DAC-CCS-PIC18F45K50/main/Diagrama%20de%20conexi%C3%B3n/X-TRAINER_PRO-r2_Practica-12_Microside_01-1.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="PRO R3" %}

<figure><img src="https://177299348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2FJ9R6vmDEhY5F6EKieCQA%2F12%20DAC%20%20X%20Trainer%20Pro%2018_MikroC.png?alt=media&#x26;token=6c742c95-ed5c-4a80-8538-a0b0cd0db02b" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="PRO R4" %}

<figure><img src="https://177299348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2FZugak4id4hQW5sfpp961%2FDAC%20PIC18F4550%20%20o%20PIC18F45K50%20X-TRAINER%20PRO%20R4%20MICROSIDE%20.webp?alt=media&#x26;token=ef1bf02b-92d4-4cb6-afae-596b8537497f" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## **Código**

{% tabs %}
{% tab title="PIC18F45K50" %}
{% embed url="<https://gist.github.com/microside-mx/458cc3d1b8ce72f6402cf4e2b84a55d6>" %}
{% endtab %}
{% endtabs %}

## **Descargas**

<table data-card-size="large" data-view="cards"><thead><tr><th align="center"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"><mark style="color:green;"><strong>Software X-TRAINER Suite v1.0</strong></mark></td><td><a href="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/microside_download_archive/main/Tools/X-TRAINER%20Suite/X-TRAINER%20Suite%20Setup.zip">https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/microside_download_archive/main/Tools/X-TRAINER%20Suite/X-TRAINER%20Suite%20Setup.zip</a></td></tr><tr><td align="center"><mark style="color:green;"><strong>Proyecto</strong></mark></td><td><a href="https://github.com/MICROSIDE-TECHNOLOGY/12-DAC-CCS-PIC18F45K50/archive/refs/heads/main.zip">https://github.com/MICROSIDE-TECHNOLOGY/12-DAC-CCS-PIC18F45K50/archive/refs/heads/main.zip</a></td></tr></tbody></table>
