Anda di halaman 1dari 20

INSTRUMENTACION MDICA

MOMENTO 4- Diseo de un sistema de instrumentacin teraputica.

PRESENTADO POR:
JHON JAIRO FERNANDEZ MORALES
CODIGO: 1090376353

GRUPO: 299016_4

TUTOR:
SAULO ANDRES

UNIVERSIDAD NACIONAL ABIERTA Y A DISTANCIA (UNAD)


ESCUELA DE CIENCIAS BSICAS, TECNOLGIA E INGENIERA - ECBTI
ABRIL DE 2016
INTRODUCCION

Los equipos teraputicos aplican diferentes tipos de energa al cuerpo (elctrica,


magntica, electromagntica, mecnica de vibraciones, ultrasonido, fotnica, etc)
buscando un efecto curativo. Es por esto que los ingenieros electrnicos deben
estar en la capacidad de Entender el funcionamiento de tales equipos, para poder
disearlos y calibrarlos, como tambin hacerles mantenimiento preventivo,
correctivo y predictivo. Adems, deben estar en la capacidad de disear y construir
cualquier otro equipo teraputico que le permita al mdico e investigador biomdico
desarrollar nuevos tratamientos para lograr el avance de la ciencia mdica y por lo
tanto el mejoramiento de la salud humana.
La intencin del curso de instrumentacin medica es la de apoyar a los estudiantes
del curso, en el desarrollo y diseo de los instrumentos electrnicos de medicin de
variables biolgicas utilizados en la medicina moderna, para lograr el avance de la
ciencia mdica y por lo tanto el mejoramiento de la salud humana, adems de
fortalecer en los estudiantes, los conceptos bsicos de la ingeniera biomdica, a
travs del diseo de sistemas de instrumentacin biomdica diagnstica y
teraputica.
Es por esto que en este trabajo el grupo debe desarrollar el software de
programacin de un microcontrolador en lenguaje asembler o lenguaje C, aplicado
al mdulo de puente H de un equipo de electroterapia del captulo 10, numeral 10.5
para generar las ondas electroteraputicas de las figuras 121 a 125, que cumpla
con ciertas condiciones que sern descritas ms adelante en el trabajo.
DESCRIPCIN DE LA ACTIVIDAD
El grupo debe desarrollar el software de programacin de un microcontrolador en
lenguaje asembler o lenguaje C, aplicado al mdulo de puente H de un equipo de
electroterapia del captulo 10, numeral 10.5 para generar las ondas
electroteraputicas de las figuras 121 a 125, que cumpla con las siguientes
condiciones:
a. El microcontrolador ser el PIC16FXXX.
b. Debe simularse con Proteus.
DESARROLLO
Microcontrolador: Circuito encargado mediante programacin de generar las
formas de onda requerida. Tiene dos pines de salida donde genera las tensiones
VB1-2 y VB2-3 que controlaran los terminales de puerta de los transistores MOSFET
1-2 y 2-3, respectivamente. Las ondas de salida dependen de la teclas de seleccin
que se pulsen en el panel frontal del equipo y que se encuentran conectadas a los
pines de un puerto configuradas como entradas y la tensin de alimentacin de +5V.
El microcontrolador usado es el pic16f877A en donde se usa el puerto A como
entradas de los cuatro potencimetros con los que se ajustan el Ton, Toff, Ton2, y
Toff2. El puerto B se usa como entrada del switch rotativo de seis posiciones en
donde se selecciona el tipo de pulsos a aplicar para obtener la onda de salida
requerida. El puerto C se usa como salidas para activar los terminales de puerta de
los MOSFET del puente H.
Optoacoplador: Separa elctricamente al microcontrolador del resto del circuito,
para protegerlo de posibles cortocircuitos. Se usa el circuito integrado 4N26
recomendado en el mdulo del curso.
Se usan dos optoacopladores, uno para cada una de las salidas del
microcontrolador. Se conecta una resistencia en serie con el circuito del LED del
optoacoplador para limitar la corriente que lo atraviesa, y se calcula de acuerdo a la
ley de Ohm. Corriente 13.63mA. Resistencia 220.

Preamplificador de corriente: es un circuito Par Darlington de alta ganancia de


corriente que se encarga de entregar la corriente necesaria a los terminales de
entrada del circuito de salida, sin cargar la salida del optoacoplador.
Se usa el TIP122 que es un compuesto de par darlington con parametro de
operacin de = 100 y = 5.

Puente H: Circuito de salida, basado en cuatro transistores MOSFET, conectados


en puente, en donde los transistores son MOSFET de enriquecimiento, canal P
para 1 y 4 y canal N para 2 y 3. Los transistores se activan al mismo tiempo por
parejas, 1/3 o 2/4, de acuerdo con las tensiones aplicadas a los terminales de
entrada (puertas o Gate) para lograr una determinada onda a la salida.
Se usa el circuito integrado ZXMHC10A07N8 debido a que es el nico con el que
se encuentra en la versin de Proteus que tengo instalada, cuyas caractersticas
son = 100, por lo que se aliment con una fuente de 100VDC. A los pines
de salida que seran los electrodos del equipo de electroterapia, se les denomino
S1 y S2.
Esquema general del diseo del circuito implementado en proteus:
Programa de programacin en lenguaje ensamblador implementado en el
microcontrolador en lenguaje C:
//*************************************************************** #define MX_PWM_1_PIN 2
********************* #define MX_PWM_2_PORT portc
//** #define MX_PWM_2_TRIS trisc
//** Autor: Jhon Jairo Fernndez Morales #define MX_PWM_2_PIN 1
//** Fecha: 16 de abril de 2016
//** //Funciones
//*************************************************************** #define MX_CLK_SPEED 8000000
********************* #ifdef _BOOSTC
#define MX_PIC #include <system.h>
#endif
#define MX_USES_UINT8 1 #ifdef HI_TECH_C
#define MX_USES_SINT16 0 #include <pic.h>
#define MX_USES_CHAR 0 #endif
#define MX_USES_FLOAT 1
#define MX_USES_SINT32 1 //Datos de configuracin
#define MX_USES_BOOL 1 #ifdef _BOOSTC
#define MX_USES_UINT16 1 #pragma DATA 0x2007, 0x3f72
#define MX_USES_UINT32 0 #endif
//Definiciones para el microcontrolador #ifdef HI_TECH_C
#define P16F877A __CONFIG(0x3f72);
#define FC_CAL_PIC #endif
#define MX_ADC
#define MX_ADC_TYPE_1 //Macro function declarations
#define MX_ADC_BITS_10
#define MX_EE
#define MX_EE_TYPE2 //Variable declarations
#define MX_EE_SIZE 256 #define FCV_FALSE (0)
#define MX_SPI_1 #define FCV_TRUE (1)
#define MX_SPI_1_MISO_PORT portc MX_BOOL FCV_PMMP;
#define MX_SPI_1_MISO_TRIS trisc MX_UINT16 FCV_TON1;
#define MX_SPI_1_MISO_PIN 4 MX_FLOAT FCV_TON2;
#define MX_SPI_1_MOSI_PORT portc MX_FLOAT FCV_ADC1;
#define MX_SPI_1_MOSI_TRIS trisc MX_FLOAT FCV_ADC2;
#define MX_SPI_1_MOSI_PIN 5 MX_UINT16 FCV_TOFF1;
#define MX_SPI_1_CLK_PORT portc MX_BOOL FCV_PB;
#define MX_SPI_1_CLK_TRIS trisc MX_FLOAT FCV_TOFF2;
#define MX_SPI_1_CLK_PIN 3 MX_FLOAT FCV_ADC3;
#define MX_SPI_1_SS_PORT portc MX_FLOAT FCV_ADC4;
#define MX_SPI_1_SS_TRIS trisc MX_BOOL FCV_PAN;
#define MX_UART_1 MX_BOOL FCV_PAP;
#define MX_UART_1_TX_PORT portc MX_UINT16 FCV_TOFF21 = (0x0);
#define MX_UART_1_TX_TRIS trisc MX_FLOAT FCV_TOFF;
#define MX_UART_1_TX_PIN 6 MX_BOOL FCV_TP;
#define MX_UART_1_RX_PORT portc MX_SINT32 FCV_TON21;
#define MX_UART_1_RX_TRIS trisc MX_BOOL FCV_PMMN;
#define MX_UART_1_RX_PIN 7 MX_FLOAT FCV_TON;
#define MX_I2C MX_UINT16 FCV_TOFFPB;
#define MX_MI2C
#define MX_I2C_1
#define MX_I2C_1_SDA_PORT portc
#define MX_I2C_1_SDA_TRIS trisc
#define MX_I2C_1_SDA_PIN 4 //ADC(0): //Defines:
#define MX_I2C_1_SCL_PORT portc
#define MX_I2C_1_SCL_TRIS trisc /**** Macro Substitutions ****
#define MX_I2C_1_SCL_PIN 3 a = Unique Reference
#define MX_PWM b = Which ADC Channel
#define MX_PWM_CNT 2 c = Acquisition time
#define MX_PWM_PSCA1 d = Conversion Speed
#define MX_PWM_PSCA4 e = VRef+ Option
#define MX_PWM_PSCA16 f = VRef Voltage x 0.01V
#define MX_PWM_1_PORT portc ******************************/
#define MX_PWM_1_TRIS trisc
//Common Defines #define ADC_2_MX_ADC_VREFOP 0
#define ADC_2_MX_ADC_VREFVOL 50
#define ADC_1_MX_ADC_CHANNEL 0
#define ADC_1_MX_ADC_ACTIME 40 #ifndef MX_ADC_CHANNEL_1
#define ADC_1_MX_ADC_CONVSP 3 #define MX_ADC_CHANNEL_1 //Inform CAL
#define ADC_1_MX_ADC_VREFOP 0 ADC channel 1 is now in use.
#define ADC_1_MX_ADC_VREFVOL 50 #endif

#ifndef MX_ADC_CHANNEL_0 #ifndef MX_ADC_REF //Inform CAL ADC


#define MX_ADC_CHANNEL_0 //Inform CAL peripheral is now in use
ADC channel 0 is now in use. #define MX_ADC_REF
#endif #endif

#ifndef MX_ADC_REF //Inform CAL ADC extern void FC_CAL_Enable_ADC (MX_UINT8 Channel,
peripheral is now in use MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8
#define MX_ADC_REF T_Charge);
#endif extern MX_UINT16 FC_CAL_Sample_ADC (MX_UINT8
Sample_Mode);
extern void FC_CAL_Enable_ADC (MX_UINT8 Channel, extern void FC_CAL_Disable_ADC (void);
MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8
T_Charge);
extern MX_UINT16 FC_CAL_Sample_ADC (MX_UINT8
Sample_Mode);
extern void FC_CAL_Disable_ADC (void); //ADC(1): //Macro function declarations

void FCD_ADC1_SampleADC();
MX_UINT8 FCD_ADC1_ReadAsByte();
MX_UINT16 FCD_ADC1_ReadAsInt();
//ADC(0): //Macro function declarations MX_FLOAT FCD_ADC1_ReadAsVoltage();
void FCD_ADC1_ReadAsString(MX_CHAR*
void FCD_ADC0_SampleADC(); FCR_RETVAL, MX_UINT8 FCR_RETVAL_SIZE);
MX_UINT8 FCD_ADC0_ReadAsByte(); void FCD_ADC1_ADC_RAW_Configure_Channel();
MX_UINT16 FCD_ADC0_ReadAsInt(); MX_UINT8
MX_FLOAT FCD_ADC0_ReadAsVoltage(); FCD_ADC1_ADC_RAW_Sample_Channel_Byte();
void FCD_ADC0_ReadAsString(MX_CHAR* MX_UINT16
FCR_RETVAL, MX_UINT8 FCR_RETVAL_SIZE); FCD_ADC1_ADC_RAW_Sample_Channel_Int();
void FCD_ADC0_ADC_RAW_Configure_Channel(); MX_UINT8
MX_UINT8 FCD_ADC1_ADC_RAW_Average_Channel_Byte(MX_UI
FCD_ADC0_ADC_RAW_Sample_Channel_Byte(); NT8 NumSamples, MX_UINT8 DelayUs);
MX_UINT16 MX_UINT16
FCD_ADC0_ADC_RAW_Sample_Channel_Int(); FCD_ADC1_ADC_RAW_Average_Channel_Int(MX_UIN
MX_UINT8 T8 NumSamples, MX_UINT8 DelayUs);
FCD_ADC0_ADC_RAW_Average_Channel_Byte(MX_UI void FCD_ADC1_ADC_RAW_Disable_Channel();
NT8 NumSamples, MX_UINT8 DelayUs);
MX_UINT16
FCD_ADC0_ADC_RAW_Average_Channel_Int(MX_UIN //ADC(2): //Defines:
T8 NumSamples, MX_UINT8 DelayUs);
void FCD_ADC0_ADC_RAW_Disable_Channel(); /**** Macro Substitutions ****
a = Unique Reference
b = Which ADC Channel
//ADC(1): //Defines: c = Acquisition time
d = Conversion Speed
/**** Macro Substitutions **** e = VRef+ Option
a = Unique Reference f = VRef Voltage x 0.01V
b = Which ADC Channel ******************************/
c = Acquisition time
d = Conversion Speed //Common Defines
e = VRef+ Option
f = VRef Voltage x 0.01V #define ADC_7_MX_ADC_CHANNEL 2
******************************/ #define ADC_7_MX_ADC_ACTIME 40
#define ADC_7_MX_ADC_CONVSP 3
//Common Defines #define ADC_7_MX_ADC_VREFOP 0
#define ADC_7_MX_ADC_VREFVOL 500
#define ADC_2_MX_ADC_CHANNEL 1
#define ADC_2_MX_ADC_ACTIME 40 #ifndef MX_ADC_CHANNEL_2
#define ADC_2_MX_ADC_CONVSP 3
#define MX_ADC_CHANNEL_2 //Inform CAL #ifndef MX_ADC_REF //Inform CAL ADC
ADC channel 2 is now in use. peripheral is now in use
#endif #define MX_ADC_REF
#endif
#ifndef MX_ADC_REF //Inform CAL ADC
peripheral is now in use extern void FC_CAL_Enable_ADC (MX_UINT8 Channel,
#define MX_ADC_REF MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8
#endif T_Charge);
extern MX_UINT16 FC_CAL_Sample_ADC (MX_UINT8
extern void FC_CAL_Enable_ADC (MX_UINT8 Channel, Sample_Mode);
MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8 extern void FC_CAL_Disable_ADC (void);
T_Charge);
extern MX_UINT16 FC_CAL_Sample_ADC (MX_UINT8
Sample_Mode);
extern void FC_CAL_Disable_ADC (void);
//ADC(3): //Macro function declarations

void FCD_ADC3_SampleADC();
MX_UINT8 FCD_ADC3_ReadAsByte();
//ADC(2): //Macro function declarations MX_UINT16 FCD_ADC3_ReadAsInt();
MX_FLOAT FCD_ADC3_ReadAsVoltage();
void FCD_ADC2_SampleADC(); void FCD_ADC3_ReadAsString(MX_CHAR*
MX_UINT8 FCD_ADC2_ReadAsByte(); FCR_RETVAL, MX_UINT8 FCR_RETVAL_SIZE);
MX_UINT16 FCD_ADC2_ReadAsInt(); void FCD_ADC3_ADC_RAW_Configure_Channel();
MX_FLOAT FCD_ADC2_ReadAsVoltage(); MX_UINT8
void FCD_ADC2_ReadAsString(MX_CHAR* FCD_ADC3_ADC_RAW_Sample_Channel_Byte();
FCR_RETVAL, MX_UINT8 FCR_RETVAL_SIZE); MX_UINT16
void FCD_ADC2_ADC_RAW_Configure_Channel(); FCD_ADC3_ADC_RAW_Sample_Channel_Int();
MX_UINT8 MX_UINT8
FCD_ADC2_ADC_RAW_Sample_Channel_Byte(); FCD_ADC3_ADC_RAW_Average_Channel_Byte(MX_UI
MX_UINT16 NT8 NumSamples, MX_UINT8 DelayUs);
FCD_ADC2_ADC_RAW_Sample_Channel_Int(); MX_UINT16
MX_UINT8 FCD_ADC3_ADC_RAW_Average_Channel_Int(MX_UIN
FCD_ADC2_ADC_RAW_Average_Channel_Byte(MX_UI T8 NumSamples, MX_UINT8 DelayUs);
NT8 NumSamples, MX_UINT8 DelayUs); void FCD_ADC3_ADC_RAW_Disable_Channel();
MX_UINT16
FCD_ADC2_ADC_RAW_Average_Channel_Int(MX_UIN
T8 NumSamples, MX_UINT8 DelayUs);
void FCD_ADC2_ADC_RAW_Disable_Channel(); //ADC(0): //Macro implementations

//ADC(3): //Defines: void FCD_ADC0_SampleADC()


{
/**** Macro Substitutions ****
a = Unique Reference //unused
b = Which ADC Channel
c = Acquisition time }
d = Conversion Speed
e = VRef+ Option MX_UINT8 FCD_ADC0_ReadAsByte()
f = VRef Voltage x 0.01V {
******************************/
MX_UINT8 retVal;
//Common Defines
//Configure & Enable ADC Channel
#define ADC_8_MX_ADC_CHANNEL 3 FC_CAL_Enable_ADC (
#define ADC_8_MX_ADC_ACTIME 40 ADC_1_MX_ADC_CHANNEL ,
#define ADC_8_MX_ADC_CONVSP 3 ADC_1_MX_ADC_CONVSP ,
#define ADC_8_MX_ADC_VREFOP 0 ADC_1_MX_ADC_VREFOP ,
#define ADC_8_MX_ADC_VREFVOL 500 ADC_1_MX_ADC_ACTIME );

#ifndef MX_ADC_CHANNEL_3 retVal = FC_CAL_Sample_ADC( 0 );


#define MX_ADC_CHANNEL_3 //Inform CAL //Perform Sample - Return as byte
ADC channel 3 is now in use.
#endif FC_CAL_Disable_ADC ();

return (retVal);
fVperDiv = float32_mul(fVoltage, 0.00024414);
} //Convert actual voltage to voltage per division (VRef /
4096)
MX_UINT16 FCD_ADC0_ReadAsInt() #endif
{
fSample = float32_from_int32(iSample);
MX_UINT16 retVal; //Convert to floating point variable
fVoltage = float32_mul(fSample, fVperDiv);
//Configure & Enable ADC Channel //Calculate floating point voltage
FC_CAL_Enable_ADC (
ADC_1_MX_ADC_CHANNEL , return (fVoltage);
ADC_1_MX_ADC_CONVSP ,
ADC_1_MX_ADC_VREFOP , }
ADC_1_MX_ADC_ACTIME );
void FCD_ADC0_ReadAsString(MX_CHAR*
retVal = FC_CAL_Sample_ADC( 1 ); FCR_RETVAL, MX_UINT8 FCR_RETVAL_SIZE)
//Perform Sample - Return as MX_UINT16 {

FC_CAL_Disable_ADC (); MX_FLOAT fVoltage;

return (retVal); fVoltage = FCD_ADC0_ReadAsVoltage();


FCI_FLOAT_TO_STRING(fVoltage, 2,
} FCR_RETVAL, FCR_RETVAL_SIZE); //Convert to
String
MX_FLOAT FCD_ADC0_ReadAsVoltage()
{ }

MX_UINT16 iSample; void FCD_ADC0_ADC_RAW_Configure_Channel()


MX_FLOAT fSample, fVoltage, fVperDiv; {

//Configure & Enable ADC Channel //Configure & Enable ADC Channel
FC_CAL_Enable_ADC ( FC_CAL_Enable_ADC (
ADC_1_MX_ADC_CHANNEL , ADC_1_MX_ADC_CHANNEL ,
ADC_1_MX_ADC_CONVSP , ADC_1_MX_ADC_CONVSP ,
ADC_1_MX_ADC_VREFOP , ADC_1_MX_ADC_VREFOP ,
ADC_1_MX_ADC_ACTIME ); ADC_1_MX_ADC_ACTIME );

#ifdef MX_ADC_BITS_8 }
iSample = FC_CAL_Sample_ADC( 0 );
//Perform Sample - Return as byte MX_UINT8
#else FCD_ADC0_ADC_RAW_Sample_Channel_Byte()
iSample = FC_CAL_Sample_ADC( 1 ); {
//Perform Sample - Return as MX_UINT16
#endif return FC_CAL_Sample_ADC( 0 );
//Perform Sample - Return as byte
FC_CAL_Disable_ADC ();
//Switch off ADC peripheral }
fVoltage = float32_from_int32(
ADC_1_MX_ADC_VREFVOL ); //Convert MX_UINT16
reference voltage count to floating point (0 - 500 x 10mV) FCD_ADC0_ADC_RAW_Sample_Channel_Int()
fVoltage = float32_mul(fVoltage, 0.01); {
//Convert reference voltage count to actual voltage (0 - 5)
return FC_CAL_Sample_ADC( 1 );
#ifdef MX_ADC_BITS_8 //Perform Sample - Return as MX_UINT16
fVperDiv = float32_mul(fVoltage, 0.00390625);
//Convert actual voltage to voltage per division (VRef / }
256)
#endif MX_UINT8
#ifdef MX_ADC_BITS_10 FCD_ADC0_ADC_RAW_Average_Channel_Byte(MX_UI
fVperDiv = float32_mul(fVoltage, 0.000976); NT8 NumSamples, MX_UINT8 DelayUs)
//Convert actual voltage to voltage per division (VRef / {
1024)
#endif MX_UINT32 average = 0;
#ifdef MX_ADC_BITS_12 MX_UINT8 count;

for (count=0; count<NumSamples; count++)


{ FC_CAL_Enable_ADC (
average = average + FC_CAL_Sample_ADC( 0 ); ADC_2_MX_ADC_CHANNEL ,
//Perform Sample - Return as byte - add to average ADC_2_MX_ADC_CONVSP ,
ADC_2_MX_ADC_VREFOP ,
if (DelayUs) ADC_2_MX_ADC_ACTIME );
delay_us(DelayUs); //If
delay is not 0 then pause between samples retVal = FC_CAL_Sample_ADC( 0 );
} //Perform Sample - Return as byte
average = average / count;
FC_CAL_Disable_ADC ();
return (average & 0xFF);
//Return average as byte return (retVal);

} }

MX_UINT16 MX_UINT16 FCD_ADC1_ReadAsInt()


FCD_ADC0_ADC_RAW_Average_Channel_Int(MX_UIN {
T8 NumSamples, MX_UINT8 DelayUs)
{ MX_UINT16 retVal;

MX_UINT32 average = 0; //Configure & Enable ADC Channel


MX_UINT8 count; FC_CAL_Enable_ADC (
ADC_2_MX_ADC_CHANNEL ,
for (count=0; count<NumSamples; count++) ADC_2_MX_ADC_CONVSP ,
{ ADC_2_MX_ADC_VREFOP ,
average = average + FC_CAL_Sample_ADC( 1 ); ADC_2_MX_ADC_ACTIME );
//Perform Sample - Return as MX_UINT16 - add to
average retVal = FC_CAL_Sample_ADC( 1 );
//Perform Sample - Return as MX_UINT16
if (DelayUs)
delay_us(DelayUs); //If FC_CAL_Disable_ADC ();
delay is not 0 then pause between samples
} return (retVal);
average = average / count;
}
return (average & 0x1FFF);
//Return average as MX_SINT16 MX_FLOAT FCD_ADC1_ReadAsVoltage()
{
}
MX_UINT16 iSample;
void FCD_ADC0_ADC_RAW_Disable_Channel() MX_FLOAT fSample, fVoltage, fVperDiv;
{
//Configure & Enable ADC Channel
FC_CAL_Disable_ADC (); FC_CAL_Enable_ADC (
//Disable ADC Channel ADC_2_MX_ADC_CHANNEL ,
ADC_2_MX_ADC_CONVSP ,
} ADC_2_MX_ADC_VREFOP ,
ADC_2_MX_ADC_ACTIME );

#ifdef MX_ADC_BITS_8
//ADC(1): //Macro implementations iSample = FC_CAL_Sample_ADC( 0 );
//Perform Sample - Return as byte
#else
void FCD_ADC1_SampleADC() iSample = FC_CAL_Sample_ADC( 1 );
{ //Perform Sample - Return as MX_UINT16
#endif
//unused
FC_CAL_Disable_ADC ();
} //Switch off ADC peripheral
fVoltage = float32_from_int32(
MX_UINT8 FCD_ADC1_ReadAsByte() ADC_2_MX_ADC_VREFVOL ); //Convert
{ reference voltage count to floating point (0 - 500 x 10mV)
fVoltage = float32_mul(fVoltage, 0.01);
MX_UINT8 retVal; //Convert reference voltage count to actual voltage (0 - 5)

//Configure & Enable ADC Channel #ifdef MX_ADC_BITS_8


fVperDiv = float32_mul(fVoltage, 0.00390625);
//Convert actual voltage to voltage per division (VRef / MX_UINT8
256) FCD_ADC1_ADC_RAW_Average_Channel_Byte(MX_UI
#endif NT8 NumSamples, MX_UINT8 DelayUs)
#ifdef MX_ADC_BITS_10 {
fVperDiv = float32_mul(fVoltage, 0.000976);
//Convert actual voltage to voltage per division (VRef / MX_UINT32 average = 0;
1024) MX_UINT8 count;
#endif
#ifdef MX_ADC_BITS_12 for (count=0; count<NumSamples; count++)
fVperDiv = float32_mul(fVoltage, 0.00024414); {
//Convert actual voltage to voltage per division (VRef / average = average + FC_CAL_Sample_ADC( 0 );
4096) //Perform Sample - Return as byte - add to average
#endif
if (DelayUs)
fSample = float32_from_int32(iSample); delay_us(DelayUs); //If
//Convert to floating point variable delay is not 0 then pause between samples
fVoltage = float32_mul(fSample, fVperDiv); }
//Calculate floating point voltage average = average / count;

return (fVoltage); return (average & 0xFF);


//Return average as byte
}
}
void FCD_ADC1_ReadAsString(MX_CHAR*
FCR_RETVAL, MX_UINT8 FCR_RETVAL_SIZE) MX_UINT16
{ FCD_ADC1_ADC_RAW_Average_Channel_Int(MX_UIN
T8 NumSamples, MX_UINT8 DelayUs)
MX_FLOAT fVoltage; {

fVoltage = FCD_ADC1_ReadAsVoltage(); MX_UINT32 average = 0;


FCI_FLOAT_TO_STRING(fVoltage, 2, MX_UINT8 count;
FCR_RETVAL, FCR_RETVAL_SIZE); //Convert to
String for (count=0; count<NumSamples; count++)
{
} average = average + FC_CAL_Sample_ADC( 1 );
//Perform Sample - Return as MX_UINT16 - add to
void FCD_ADC1_ADC_RAW_Configure_Channel() average
{
if (DelayUs)
//Configure & Enable ADC Channel delay_us(DelayUs); //If
FC_CAL_Enable_ADC ( delay is not 0 then pause between samples
ADC_2_MX_ADC_CHANNEL , }
ADC_2_MX_ADC_CONVSP , average = average / count;
ADC_2_MX_ADC_VREFOP ,
ADC_2_MX_ADC_ACTIME ); return (average & 0x1FFF);
//Return average as MX_SINT16
}
}
MX_UINT8
FCD_ADC1_ADC_RAW_Sample_Channel_Byte() void FCD_ADC1_ADC_RAW_Disable_Channel()
{ {

return FC_CAL_Sample_ADC( 0 ); FC_CAL_Disable_ADC ();


//Perform Sample - Return as byte //Disable ADC Channel

} }

MX_UINT16
FCD_ADC1_ADC_RAW_Sample_Channel_Int()
{ //ADC(2): //Macro implementations

return FC_CAL_Sample_ADC( 1 );
//Perform Sample - Return as MX_UINT16 void FCD_ADC2_SampleADC()
{
}
//unused
FC_CAL_Disable_ADC ();
} //Switch off ADC peripheral
fVoltage = float32_from_int32(
MX_UINT8 FCD_ADC2_ReadAsByte() ADC_7_MX_ADC_VREFVOL ); //Convert
{ reference voltage count to floating point (0 - 500 x 10mV)
fVoltage = float32_mul(fVoltage, 0.01);
MX_UINT8 retVal; //Convert reference voltage count to actual voltage (0 - 5)

//Configure & Enable ADC Channel #ifdef MX_ADC_BITS_8


FC_CAL_Enable_ADC ( fVperDiv = float32_mul(fVoltage, 0.00390625);
ADC_7_MX_ADC_CHANNEL , //Convert actual voltage to voltage per division (VRef /
ADC_7_MX_ADC_CONVSP , 256)
ADC_7_MX_ADC_VREFOP , #endif
ADC_7_MX_ADC_ACTIME ); #ifdef MX_ADC_BITS_10
fVperDiv = float32_mul(fVoltage, 0.000976);
retVal = FC_CAL_Sample_ADC( 0 ); //Convert actual voltage to voltage per division (VRef /
//Perform Sample - Return as byte 1024)
#endif
FC_CAL_Disable_ADC (); #ifdef MX_ADC_BITS_12
fVperDiv = float32_mul(fVoltage, 0.00024414);
return (retVal); //Convert actual voltage to voltage per division (VRef /
4096)
} #endif

MX_UINT16 FCD_ADC2_ReadAsInt() fSample = float32_from_int32(iSample);


{ //Convert to floating point variable
fVoltage = float32_mul(fSample, fVperDiv);
MX_UINT16 retVal; //Calculate floating point voltage

//Configure & Enable ADC Channel return (fVoltage);


FC_CAL_Enable_ADC (
ADC_7_MX_ADC_CHANNEL , }
ADC_7_MX_ADC_CONVSP ,
ADC_7_MX_ADC_VREFOP , void FCD_ADC2_ReadAsString(MX_CHAR*
ADC_7_MX_ADC_ACTIME ); FCR_RETVAL, MX_UINT8 FCR_RETVAL_SIZE)
{
retVal = FC_CAL_Sample_ADC( 1 );
//Perform Sample - Return as MX_UINT16 MX_FLOAT fVoltage;

FC_CAL_Disable_ADC (); fVoltage = FCD_ADC2_ReadAsVoltage();


FCI_FLOAT_TO_STRING(fVoltage, 2,
return (retVal); FCR_RETVAL, FCR_RETVAL_SIZE); //Convert to
String
}
}
MX_FLOAT FCD_ADC2_ReadAsVoltage()
{ void FCD_ADC2_ADC_RAW_Configure_Channel()
{
MX_UINT16 iSample;
MX_FLOAT fSample, fVoltage, fVperDiv; //Configure & Enable ADC Channel
FC_CAL_Enable_ADC (
//Configure & Enable ADC Channel ADC_7_MX_ADC_CHANNEL ,
FC_CAL_Enable_ADC ( ADC_7_MX_ADC_CONVSP ,
ADC_7_MX_ADC_CHANNEL , ADC_7_MX_ADC_VREFOP ,
ADC_7_MX_ADC_CONVSP , ADC_7_MX_ADC_ACTIME );
ADC_7_MX_ADC_VREFOP ,
ADC_7_MX_ADC_ACTIME ); }

#ifdef MX_ADC_BITS_8 MX_UINT8


iSample = FC_CAL_Sample_ADC( 0 ); FCD_ADC2_ADC_RAW_Sample_Channel_Byte()
//Perform Sample - Return as byte {
#else
iSample = FC_CAL_Sample_ADC( 1 ); return FC_CAL_Sample_ADC( 0 );
//Perform Sample - Return as MX_UINT16 //Perform Sample - Return as byte
#endif
} }

MX_UINT16
FCD_ADC2_ADC_RAW_Sample_Channel_Int() //ADC(3): //Macro implementations
{

return FC_CAL_Sample_ADC( 1 ); void FCD_ADC3_SampleADC()


//Perform Sample - Return as MX_UINT16 {

} //unused

MX_UINT8 }
FCD_ADC2_ADC_RAW_Average_Channel_Byte(MX_UI
NT8 NumSamples, MX_UINT8 DelayUs) MX_UINT8 FCD_ADC3_ReadAsByte()
{ {

MX_UINT32 average = 0; MX_UINT8 retVal;


MX_UINT8 count;
//Configure & Enable ADC Channel
for (count=0; count<NumSamples; count++) FC_CAL_Enable_ADC (
{ ADC_8_MX_ADC_CHANNEL ,
average = average + FC_CAL_Sample_ADC( 0 ); ADC_8_MX_ADC_CONVSP ,
//Perform Sample - Return as byte - add to average ADC_8_MX_ADC_VREFOP ,
ADC_8_MX_ADC_ACTIME );
if (DelayUs)
delay_us(DelayUs); //If retVal = FC_CAL_Sample_ADC( 0 );
delay is not 0 then pause between samples //Perform Sample - Return as byte
}
average = average / count; FC_CAL_Disable_ADC ();

return (average & 0xFF); return (retVal);


//Return average as byte
}
}
MX_UINT16 FCD_ADC3_ReadAsInt()
MX_UINT16 {
FCD_ADC2_ADC_RAW_Average_Channel_Int(MX_UIN
T8 NumSamples, MX_UINT8 DelayUs) MX_UINT16 retVal;
{
//Configure & Enable ADC Channel
MX_UINT32 average = 0; FC_CAL_Enable_ADC (
MX_UINT8 count; ADC_8_MX_ADC_CHANNEL ,
ADC_8_MX_ADC_CONVSP ,
for (count=0; count<NumSamples; count++) ADC_8_MX_ADC_VREFOP ,
{ ADC_8_MX_ADC_ACTIME );
average = average + FC_CAL_Sample_ADC( 1 );
//Perform Sample - Return as MX_UINT16 - add to retVal = FC_CAL_Sample_ADC( 1 );
average //Perform Sample - Return as MX_UINT16

if (DelayUs) FC_CAL_Disable_ADC ();


delay_us(DelayUs); //If
delay is not 0 then pause between samples return (retVal);
}
average = average / count; }

return (average & 0x1FFF); MX_FLOAT FCD_ADC3_ReadAsVoltage()


//Return average as MX_SINT16 {

} MX_UINT16 iSample;
MX_FLOAT fSample, fVoltage, fVperDiv;
void FCD_ADC2_ADC_RAW_Disable_Channel()
{ //Configure & Enable ADC Channel
FC_CAL_Enable_ADC (
FC_CAL_Disable_ADC (); ADC_8_MX_ADC_CHANNEL ,
//Disable ADC Channel ADC_8_MX_ADC_CONVSP ,
ADC_8_MX_ADC_VREFOP ,
ADC_8_MX_ADC_ACTIME ); }

#ifdef MX_ADC_BITS_8 MX_UINT8


iSample = FC_CAL_Sample_ADC( 0 ); FCD_ADC3_ADC_RAW_Sample_Channel_Byte()
//Perform Sample - Return as byte {
#else
iSample = FC_CAL_Sample_ADC( 1 ); return FC_CAL_Sample_ADC( 0 );
//Perform Sample - Return as MX_UINT16 //Perform Sample - Return as byte
#endif
}
FC_CAL_Disable_ADC ();
//Switch off ADC peripheral MX_UINT16
fVoltage = float32_from_int32( FCD_ADC3_ADC_RAW_Sample_Channel_Int()
ADC_8_MX_ADC_VREFVOL ); //Convert {
reference voltage count to floating point (0 - 500 x 10mV)
fVoltage = float32_mul(fVoltage, 0.01); return FC_CAL_Sample_ADC( 1 );
//Convert reference voltage count to actual voltage (0 - 5) //Perform Sample - Return as MX_UINT16

#ifdef MX_ADC_BITS_8 }
fVperDiv = float32_mul(fVoltage, 0.00390625);
//Convert actual voltage to voltage per division (VRef / MX_UINT8
256) FCD_ADC3_ADC_RAW_Average_Channel_Byte(MX_UI
#endif NT8 NumSamples, MX_UINT8 DelayUs)
#ifdef MX_ADC_BITS_10 {
fVperDiv = float32_mul(fVoltage, 0.000976);
//Convert actual voltage to voltage per division (VRef / MX_UINT32 average = 0;
1024) MX_UINT8 count;
#endif
#ifdef MX_ADC_BITS_12 for (count=0; count<NumSamples; count++)
fVperDiv = float32_mul(fVoltage, 0.00024414); {
//Convert actual voltage to voltage per division (VRef / average = average + FC_CAL_Sample_ADC( 0 );
4096) //Perform Sample - Return as byte - add to average
#endif
if (DelayUs)
fSample = float32_from_int32(iSample); delay_us(DelayUs); //If
//Convert to floating point variable delay is not 0 then pause between samples
fVoltage = float32_mul(fSample, fVperDiv); }
//Calculate floating point voltage average = average / count;

return (fVoltage); return (average & 0xFF);


//Return average as byte
}
}
void FCD_ADC3_ReadAsString(MX_CHAR*
FCR_RETVAL, MX_UINT8 FCR_RETVAL_SIZE) MX_UINT16
{ FCD_ADC3_ADC_RAW_Average_Channel_Int(MX_UIN
T8 NumSamples, MX_UINT8 DelayUs)
MX_FLOAT fVoltage; {

fVoltage = FCD_ADC3_ReadAsVoltage(); MX_UINT32 average = 0;


FCI_FLOAT_TO_STRING(fVoltage, 2, MX_UINT8 count;
FCR_RETVAL, FCR_RETVAL_SIZE); //Convert to
String for (count=0; count<NumSamples; count++)
{
} average = average + FC_CAL_Sample_ADC( 1 );
//Perform Sample - Return as MX_UINT16 - add to
void FCD_ADC3_ADC_RAW_Configure_Channel() average
{
if (DelayUs)
//Configure & Enable ADC Channel delay_us(DelayUs); //If
FC_CAL_Enable_ADC ( delay is not 0 then pause between samples
ADC_8_MX_ADC_CHANNEL , }
ADC_8_MX_ADC_CONVSP , average = average / count;
ADC_8_MX_ADC_VREFOP ,
ADC_8_MX_ADC_ACTIME );
return (average & 0x1FFF);
//Return average as MX_SINT16 //Salida
//Salida: 0 -> C2
} trisc = trisc & 0xFB;
if ((0))
void FCD_ADC3_ADC_RAW_Disable_Channel() portc = (portc & 0xFB) | 0x04;
{ else
portc = portc & 0xFB;
FC_CAL_Disable_ADC ();
//Disable ADC Channel //Salida
//Salida: 1 -> C1
} trisc = trisc & 0xFD;
if ((1))
portc = (portc & 0xFD) | 0x02;
//Macro implementations else
portc = portc & 0xFD;

void main() //Demora


{ //Demora: Ton1 ms
//Inicializacin FCI_DELAYINT_MS(FCV_TON1);
adcon1 = 0x07;
//Salida
//Salida: 0 -> C1
//Cdigo de inicializacin de la interrupciun trisc = trisc & 0xFD;
option_reg = 0xC0; if ((0))
portc = (portc & 0xFD) | 0x02;
else
//Bucle portc = portc & 0xFD;
//Bucle: Mientras 1
while (1) //Demora
{ //Demora: Toff1 ms
FCI_DELAYINT_MS(FCV_TOFF1);
//Llamar a Macro de Componente
//Llamar a Macro de Componente: } else {
ADC1=LeerComoTensin()
FCV_ADC1 = FCD_ADC0_ReadAsVoltage(); //Ingreso
//Ingreso: B4 -> PAN
//Llamar a Macro de Componente trisb = trisb | 0x10;
//Llamar a Macro de Componente: FCV_PAN = ((portb & 0x10) == 0x10);
ADC2=LeerComoTensin()
FCV_ADC2 = FCD_ADC1_ReadAsVoltage(); //Decisin
//Decisin: PAN = 1?
//Ingreso if (FCV_PAN == 1)
//Ingreso: B3 -> PAP {
trisb = trisb | 0x08;
FCV_PAP = ((portb & 0x08) == 0x08); //Clculo
//Clculo:
//Decisin // Ton = fadd ((0.05),fmul (ADC1, (1999.9)))
//Decisin: PAP = 1? // Ton1 = fmul (Ton,1)
if (FCV_PAP == 1) FCV_TON = flt_add((0.05),
{ flt_mul(FCV_ADC1, (1999.9)));
FCV_TON1 = flt_toi(flt_mul(FCV_TON, 1));
//Clculo
//Clculo: //Clculo
// Ton = fadd ((0.05),fmul (ADC1, (1999.9))) //Clculo:
// Ton1 = fmul (Ton,1) // Toff = fadd (1,fmul (ADC2,8))
FCV_TON = flt_add((0.05), flt_mul(FCV_ADC1, // Toff1 = fmul (Toff,1000)
(1999.9))); FCV_TOFF = flt_add(1, flt_mul(FCV_ADC2,
FCV_TON1 = flt_toi(flt_mul(FCV_TON, 1)); 8));
FCV_TOFF1 = flt_toi(flt_mul(FCV_TOFF,
//Clculo 1000));
//Clculo:
// Toff = fadd (1,fmul (ADC2,8)) //Salida
// Toff1 = fmul (Toff,1000) //Salida: 0 -> C1
FCV_TOFF = flt_add(1, flt_mul(FCV_ADC2, 8)); trisc = trisc & 0xFD;
FCV_TOFF1 = flt_toi(flt_mul(FCV_TOFF, 1000)); if ((0))
portc = (portc & 0xFD) | 0x02; //Salida: 1 -> C1
else trisc = trisc & 0xFD;
portc = portc & 0xFD; if ((1))
portc = (portc & 0xFD) | 0x02;
//Salida else
//Salida: 1 -> C2 portc = portc & 0xFD;
trisc = trisc & 0xFB;
if ((1)) //Demora
portc = (portc & 0xFB) | 0x04; //Demora: Ton1 us
else FCI_DELAYINT_US(FCV_TON1);
portc = portc & 0xFB;
//Salida
//Demora //Salida: 0 -> C1
//Demora: Ton1 ms trisc = trisc & 0xFD;
FCI_DELAYINT_MS(FCV_TON1); if ((0))
portc = (portc & 0xFD) | 0x02;
//Salida else
//Salida: 0 -> C2 portc = portc & 0xFD;
trisc = trisc & 0xFB;
if ((0)) //Demora
portc = (portc & 0xFB) | 0x04; //Demora: Toff1 us
else FCI_DELAYINT_US(FCV_TOFF1);
portc = portc & 0xFB;
} else {
//Demora
//Demora: Toff1 ms //Ingreso
FCI_DELAYINT_MS(FCV_TOFF1); //Ingreso: B0 -> PMMN
trisb = trisb | 0x01;
} else { FCV_PMMN = ((portb & 0x01) == 0x01);

//Ingreso //Decisin
//Ingreso: B5 -> PMMP //Decisin: PMMN = 1?
trisb = trisb | 0x20; if (FCV_PMMN == 1)
FCV_PMMP = ((portb & 0x20) == 0x20); {

//Decisin //Clculo
//Decisin: PMMP = 1? //Clculo:
if (FCV_PMMP == 1) // Ton = fadd ((100),fmul (ADC1, (9800)))
{ // Ton1 = fmul (Ton,1)
FCV_TON = flt_add((100),
//Clculo flt_mul(FCV_ADC1, (9800)));
//Clculo: FCV_TON1 = flt_toi(flt_mul(FCV_TON,
// Ton = fadd ((100),fmul (ADC1, (9800))) 1));
// Ton1 = fmul (Ton,1)
FCV_TON = flt_add((100), //Clculo
flt_mul(FCV_ADC1, (9800))); //Clculo:
FCV_TON1 = flt_toi(flt_mul(FCV_TON, 1)); // Toff = fadd ((0.5),fmul (ADC2,3))
// Toff1 = fmul (Toff,10000)
//Clculo FCV_TOFF = flt_add((0.5),
//Clculo: flt_mul(FCV_ADC2, 3));
// Toff = fadd ((0.5),fmul (ADC2,3)) FCV_TOFF1 = flt_toi(flt_mul(FCV_TOFF,
// Toff1 = fmul (Toff,10000) 10000));
FCV_TOFF = flt_add((0.5),
flt_mul(FCV_ADC2, 3)); //Salida
FCV_TOFF1 = flt_toi(flt_mul(FCV_TOFF, //Salida: 0 -> C1
10000)); trisc = trisc & 0xFD;
if ((0))
//Salida portc = (portc & 0xFD) | 0x02;
//Salida: 0 -> C2 else
trisc = trisc & 0xFB; portc = portc & 0xFD;
if ((0))
portc = (portc & 0xFB) | 0x04; //Salida
else //Salida: 1 -> C2
portc = portc & 0xFB; trisc = trisc & 0xFB;
if ((1))
//Salida portc = (portc & 0xFB) | 0x04;
else FCV_TON1 = flt_toi(flt_mul(FCV_TON,
portc = portc & 0xFB; 1));

//Demora //Clculo
//Demora: Ton1 us //Clculo:
FCI_DELAYINT_US(FCV_TON1); // Toff = fadd ((0.5),fmul (ADC2,3))
// Toff1 = fmul (Toff,10000)
//Salida FCV_TOFF = flt_add((0.5),
//Salida: 0 -> C2 flt_mul(FCV_ADC2, 3));
trisc = trisc & 0xFB; FCV_TOFF1 =
if ((0)) flt_toi(flt_mul(FCV_TOFF, 10000));
portc = (portc & 0xFB) | 0x04;
else //Bucle
portc = portc & 0xFB; //Bucle: Mientras Ton21 < 0
while (1)
//Demora {
//Demora: Toff1 us
FCI_DELAYINT_US(FCV_TOFF1); //Salida
//Salida: 0 -> C2
} else { trisc = trisc & 0xFB;
if ((0))
//Ingreso portc = (portc & 0xFB) | 0x04;
//Ingreso: B1 -> TP else
trisb = trisb | 0x02; portc = portc & 0xFB;
FCV_TP = ((portb & 0x02) == 0x02);
//Salida
//Decisin //Salida: 1 -> C1
//Decisin: TP = 1? trisc = trisc & 0xFD;
if (FCV_TP == 1) if ((1))
{ portc = (portc & 0xFD) | 0x02;
else
//Llamar a Macro de Componente portc = portc & 0xFD;
//Llamar a Macro de Componente:
ADC3=LeerComoTensin() //Demora
FCV_ADC3 = //Demora: Ton1 us
FCD_ADC2_ReadAsVoltage(); FCI_DELAYINT_US(FCV_TON1);

//Clculo //Salida
//Clculo: //Salida: 0 -> C1
// Ton2 = fadd (1, (fmul (ADC3, (3.8)))) trisc = trisc & 0xFD;
// Ton21 = fmul (Ton2,1000000) if ((0))
FCV_TON2 = flt_add(1, portc = (portc & 0xFD) | 0x02;
(flt_mul(FCV_ADC3, (3.8)))); else
FCV_TON21 = portc = portc & 0xFD;
flt_toi(flt_mul(FCV_TON2, 1000000));
//Demora
//Llamar a Macro de Componente //Demora: Toff1 us
//Llamar a Macro de Componente: FCI_DELAYINT_US(FCV_TOFF1);
ADC1=LeerComoTensin()
FCV_ADC1 = //Clculo
FCD_ADC0_ReadAsVoltage(); //Clculo:
// Ton21 = (Ton21 - ((Ton1 + Toff1)))
//Llamar a Macro de Componente FCV_TON21 = (FCV_TON21 -
//Llamar a Macro de Componente: ((FCV_TON1 + FCV_TOFF1)));
ADC2=LeerComoTensin()
FCV_ADC2 =
FCD_ADC1_ReadAsVoltage(); if ((FCV_TON21 < 0) != 0) break;
}
//Clculo
//Clculo: //Llamar a Macro de Componente
// Ton = fadd ((100),fmul (ADC1, //Llamar a Macro de Componente:
(9800))) ADC4=LeerComoTensin()
// Ton1 = fmul (Ton,1) FCV_ADC4 =
FCV_TON = flt_add((100), FCD_ADC3_ReadAsVoltage();
flt_mul(FCV_ADC1, (9800)));
//Clculo
//Clculo: if ((1))
// Toff2 = fadd (1,fmul (ADC4, (7.8))) portc = (portc & 0xFB) | 0x04;
// Toff21 = fmul (Toff2,1000) else
FCV_TOFF2 = flt_add(1, portc = portc & 0xFB;
flt_mul(FCV_ADC4, (7.8)));
FCV_TOFF21 = //Demora
flt_toi(flt_mul(FCV_TOFF2, 1000)); //Demora: Ton1 ms
FCI_DELAYINT_MS(FCV_TON1);
//Demora
//Demora: Toff21 ms //Salida
FCI_DELAYINT_MS(FCV_TOFF21); //Salida: 0 -> C2
trisc = trisc & 0xFB;
} else { if ((0))
portc = (portc & 0xFB) | 0x04;
//Ingreso else
//Ingreso: B2 -> PB portc = portc & 0xFB;
trisb = trisb | 0x04;
FCV_PB = ((portb & 0x04) == 0x04); //Demora
//Demora: Toff1 ms
//Decisin FCI_DELAYINT_MS(FCV_TOFF1);
//Decisin: PB = 1?
if (FCV_PB == 1) //Clculo
{ //Clculo:
// ToffPB = fsub (Toff1,Ton1)
//Clculo FCV_TOFFPB =
//Clculo: flt_toi(flt_sub(flt_fromi(FCV_TOFF1),
// Ton = fadd ((0.05),fmul (ADC1, flt_fromi(FCV_TON1)));
(1999.9)))
// Ton1 = fmul (Ton,1) //Demora
FCV_TON = flt_add((0.05), //Demora: ToffPB ms
flt_mul(FCV_ADC1, (1999.9)));
FCV_TON1 = FCI_DELAYINT_MS(FCV_TOFFPB);
flt_toi(flt_mul(FCV_TON, 1));
// } else {
//Clculo
//Clculo: }
// Toff = fadd (1,fmul (ADC2,8))
// Toff1 = fmul (Toff,1000) }
FCV_TOFF = flt_add(1,
flt_mul(FCV_ADC2, 8));
FCV_TOFF1 = }
flt_toi(flt_mul(FCV_TOFF, 1000));

//Salida
}
//Salida: 1 -> C1
trisc = trisc & 0xFD;
if ((1))
portc = (portc & 0xFD) | 0x02; }
else
portc = portc & 0xFD;

//Demora }
//Demora: Ton1 ms
FCI_DELAYINT_MS(FCV_TON1);

//Salida
//Salida: 0 -> C1 }
trisc = trisc & 0xFD;
if ((0)) mainendloop: goto mainendloop;
portc = (portc & 0xFD) | 0x02;
else }
portc = portc & 0xFD;
void MX_INTERRUPT_MACRO(void)
//Salida
{
//Salida: 1 -> C2
trisc = trisc & 0xFB; }
CONCLUSIONES

La electroterapia es una disciplina pseudocientfica que se engloba dentro de la


medicina fsica y rehabilitacin y se define como el arte y la ciencia del tratamiento
de lesiones y enfermedades por medio de la electricidad.
Actualmente, la tecnologa ha desarrollado numerosos aparatos para la aplicacin
de la electroterapia sin correr riesgos de efectos secundarios, como los TENS o los
TEMS.
Los principales efectos de las distintas corrientes de electroterapia son:
antiinflamatorio, analgsico, mejora del trofismo, potenciacin neuro-muscular,
trmico, en el caso de electroterapia de alta frecuencia, fortalecimiento muscular,
mejora transporte de medicamentos, disminucin de edema, control de dolor,
Mejora sanacin de heridas, entre otras.
BIBLIOGRAFIA

UNAD, Modulo de instrumentacin mdica. Extrado el mes de marzo de


2016 desde http://datateca.unad.edu.co/contenidos/299016/299016.pdf
UNAD, Syllabus curso instrumentacin mdica. Extrado el mes de marzo de
2016 desde
http://datateca.unad.edu.co/contenidos/299016/299016_Syllabus_Instrumen
tacionMedica.pdf
UNAD, Gua integradora de actividades curso instrumentacin medica.
Extrado el mes de marzo desde
http://datateca.unad.edu.co/contenidos/299016/Guia_integrada_299016.pdf
UNAD, Gua momento 3 curso instrumentacin medica. Extraido el mes de
marzo desde
http://datateca.unad.edu.co/contenidos/299016/Momento_3._Diseno_de_un
_sistema_de_instrumentacion_Diagnostica.pdf