plc/PLC.H
2021-09-08 21:32:30 +02:00

258 lines
7.7 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <time.h>
// Estas macros son para los botones a cada
// boton, Make_Boton le asigna un n£mero ID
// y es mucho mas sencillo utilizar un nombre
// que un n£mero...
#define B_In0 2
#define B_In1 3
#define B_In2 4
#define B_In3 5
#define B_In4 6
#define B_In5 7
#define B_In6 8
#define B_In7 9
#define B_In8 10
#define B_In9 11
#define B_In10 12
#define B_In11 13
#define B_In12 14
#define B_In13 15
#define B_In14 16
#define B_In15 17
// Selecci¢n de canales de entrada ( 19xx Datos internos )
#define B_Ch00_In 18
#define B_Ch01_In 19
#define B_Ch02_In 20
#define B_Ch03_In 21
#define B_Ch04_In 22
#define B_Ch19_In 23
#define B_Out0 24
#define B_Out1 25
#define B_Out2 26
#define B_Out3 27
#define B_Out4 28
#define B_Out5 29
#define B_Out6 30
#define B_Out7 31
#define B_Out8 32
#define B_Out9 33
#define B_Out10 34
#define B_Out11 35
#define B_Out12 36
#define B_Out13 37
#define B_Out14 38
#define B_Out15 39
// Selecci¢n de canales de entrada ( 19xx Datos internos )
#define B_Ch00_Out 40
#define B_Ch01_Out 41
#define B_Ch02_Out 42
#define B_Ch03_Out 43
#define B_Ch04_Out 44
#define B_Ch19_Out 45
#define B_AcercaDe 1
#define B_Fun 54
#define B_Sft 53
#define B_Not 52
#define B_Run 51
#define B_And 60
#define B_Or 59
#define B_Cnt 58
#define B_Tr 57
#define B_Lr 56
#define B_Hr 55
#define B_Ld 66
#define B_Out 65
#define B_Tim 64
#define B_Dm 63
#define B_Ch 62
#define B_Cont 61
#define B_7 72
#define B_8 71
#define B_9 70
#define B_Ext 69
#define B_Chg 68
#define B_Scrh 67
#define B_4 78
#define B_5 77
#define B_6 76
#define B_Play 75
#define B_Del 74
#define B_Mont 73
#define B_1 84
#define B_2 83
#define B_3 82
#define B_Rec 81
#define B_Ins 80
#define B_Up 79
#define B_0 89
#define B_Clr 88
#define B_Ver 87
#define B_Write 86
#define B_Down 85
#define B_DebugCode 90
#define B_ResetValores 91
#define B_Configurar 50
#define B_Reset 46
#define B_Salvar 47
#define B_Cargar 48
#define B_Salir 49
///////////////// Una vez que estemos en el modo RUN
#define R_In0 1
#define R_In1 2
#define R_In2 3
#define R_In3 4
#define R_In4 5
#define R_In5 6
#define R_In6 7
#define R_In7 8
#define R_In8 9
#define R_In9 10
#define R_In10 11
#define R_In11 12
#define R_In12 13
#define R_In13 14
#define R_In14 15
#define R_In15 16
// Selecci¢n de canales de entrada ( 19xx Datos internos )
#define R_Ch00_In 17
#define R_Ch01_In 18
#define R_Ch02_In 19
#define R_Ch03_In 20
#define R_Ch04_In 21
#define R_Ch19_In 22
// Selecci¢n de canales de entrada ( 19xx Datos internos )
#define R_Ch00_Out 23
#define R_Ch01_Out 24
#define R_Ch02_Out 25
#define R_Ch03_Out 26
#define R_Ch04_Out 27
#define R_Ch19_Out 28
#define R_Stop 29
#define R_Up 30
#define R_Down 31
//
// N£mero de Entradas y Salidas
//
#define Numero_In 16
#define Numero_Out 16
#define Numero_Tim 48
#define Numero_Tmp 8
//
// Aqui estan definido los nombres de todos los comandos
// y su _ID correspondiente. El programa debe guiarse por
// estos c¢digos...
//
#define ReadNop 0 // No Opera
#define Ld 1 // Inicio de bloque
#define Or 2 // Funcion Or
#define And 3 // Funcion And
#define _Out 4 // Inicia salida
#define Tim 5 // Temporizador
#define Cnt 6 // Contador
// #define _Tr 7 // Rel Temporal (No se considera FUNCION)
#define Fun 99 // Las siguientes macros son las
// funciones dentro de FUN
#define End 101 // Final de programa
// No he tenido ocaci¢n de comprobar el funcionamiento
// de las dos siguientes instrucciones en un Automata.
// Por lo que no comprendo bien su funcionamiento l¢gico.
#define Il 102 // Instrucci¢n de condici¢n
#define Ilc 103 // Instrucci¢n fin de condici¢n
#define Sft 110 // Registro de desplazamiento
#define Keep 111 // Switch biestable ( Rel Latch )
#define DifU 113 // Activador en el flanco de subida
#define DifD 114 // Activador en el flanco de bajada
#define TimH 115 // Temporizador de alta velocidad
#define Cmp 120 // Comparador
#define Mov 121 // Move
#define Mvn 122 // Move Not
#define Add 130 // Add (Suma en BCD)
#define Sub 131 // Subtract ( Resta en BCD )
#define Stc 140 // Introduce un 1 en el flag de acarreo
#define Clc 141 // Borra el flag de acarreo
// Macros para los parametros y parametros compuestos
#define P_void 0 // Sin parametro activo
#define P_Ld 1 // Fusi¢n de bloques
#define P_Tr 2 //
#define P_Hr 3 // Reles internos
#define P_Cnt 4 //
#define P_Tim 5 // Utiliza estado del temporizador
#define P_Keep 6 // Utiliza estado del biestable ( Rel Latch )
#define P_Not 7 // Negaci¢n del dato Entrada
#define P_Not_Tr 8 // Negaci¢n del dato Rel Temporal
#define P_Not_Hr 9 // Negaci¢n del dato Rel Interno
#define P_Not_Cnt 10 // Negaci¢n del dato Contador
#define P_Not_Tim 11 // Negaci¢n del dato Temporizador
#define P_Keep_Hr 12 // Keep Guardando valores
#define P_Tim_Data 13 // Dato TIM/TIMH/CNT (inutil en vú2.0)
#define P_Out 14 // Carga una salida
int Menu_Edicion(void) ;
void Reset_Programa(void) ;
void Resetea_Memoria(void) ;
int InicializaMemoria(void) ;
int CargaEntornoGrafico(void) ;
void ReImprimeCanal_In(int Canal) ;
void ReImprimeCanal_Out(int Canal) ;
void Abandona_Programa(char *texto, long valor) ;
typedef struct {
unsigned int Bit : 1; // Bariable de tama¤o 1 bit
} Puertas;
typedef struct {
Puertas In [Numero_In] [6]; // 16 Entradas x 6 canales..
Puertas Out [Numero_Out] [6]; // 16 Salidas x 6 canales..
Puertas Hr [Numero_Out] [10]; // 16 Reles internos x 9 canales..
Puertas Ri [Numero_Out][10]; // Reles internos volatiles.......
Puertas Tr [Numero_Tmp] ; // 8 Reles temporales...............
Puertas _Ld [200]; //200 Ld's...........................
Puertas _Cnt [Numero_Tim] ; // 47 Biestable l¢gico con pulsaci¢n.
Puertas _Tim [Numero_Tim] ; // 47 Logica temporizaci¢n...........
// Puertas Bt [3]; // 3 Preestados l¢gicos de Tiempo...
clock_t Contador_de_Tiempo[3]; // 3 Cron¢metros de inicio para Bt..
int Tim_Cnt [Numero_Tim] ; // 47 Comprobadores temporizaci¢n....
Puertas Pre_Ld [9999]; // Preestados l¢gicos a los LD's....
} MemoriaRam;
typedef struct {
unsigned char Comando;
unsigned char Parametros;
unsigned int Dato;
unsigned int SubDato;
} FirmWare;
struct Colores {
char Texto;
char F_Texto;
char VisorLCD;
};
typedef struct {
struct Colores Colores;
Puertas PcOut;
Puertas TimeFlow;
Puertas Int8;
} Configuracion;
// extern int Fichero_bot(char Dinamicos_Estaticos);