Developer

SAXA TESTER SERIAL

Controlador mecanico interligado a todas as funcoes do terminal Saxa, usado para simular chamadas e troca de sinais de DTMF. Foi usado um microprocessador PIC que controla 3 circuitos de entrada e saida de 14 portas totalizando 42 canais interligados a reles que fazem o contato direto no circuito do terminal SAXA.

Desenvolvido por:PauloSilva

Uso esclusivel da Brastel

Saxa tester

SAXA TESTER USB

Controlador mecanico interligado a todas as funcoes do terminal Saxa, usado para simular chamadas, checagem do estado das luzes e troca de sinais de DTMF.

Foram usados 4 microprocessadores PIC, o primeiro processador controla 48 saidas que estao ligadas a reles que controlao as teclas do terminal SAXA, o segundo controla via sensores optcos todos os leds do terminal, o terceiro controla toda a parte de reconhecimento dos sinais de DTMF, o quarto microprocessador esta encarregado de fazer a juncao dos outros treis micros e a interface USB.

Desenvolvido por:PauloSilva

Uso esclusivel da Brastel

Circuito basico

Codigo C

sbit SPExpanderRST at RC0_bit;

sbit SPExpanderCS at RC1_bit;

sbit SPExpanderRST_Direction at TRISC0_bit;

sbit SPExpanderCS_Direction at TRISC1_bit;

unsigned short rxdata[3] = {0,0,0};

unsigned short u=0;

int uart_up[8],l;

unsigned short rxcount, rxchar, i, j,k, readit;

unsigned short t[3];

char cou[10];

char *argv[100];

void interrupt() {

if (PIR1.RCIF)

{

rxchar = UART1_Read();

if (rxchar == 68)

{

j = 0;

}

else

{

t[j] = rxchar;

j ++;

if (j >=3)

{

j = 0;

}

}

PIR1.RCIF = 0;

}

for(k = 0;k <=3;k++)

{

rxdata[k] = t[k];

}

}

void sendUart(unsigned short p){

// ShortToStr((unsigned short)p,cou);

// UART1_Write_Text(p);

UART1_Write(0x41); //65

UART1_Write(p);

UART1_Write(0x42);//66

UART1_Write(0x44); //68

//Delay_ms(1);

}

//------------------------------------------------------------------------------

void Init1(){

ADCON1 = 0;

TRISB = 0;

TRISD = 0;

portd=0;

portb=0;

TRISC = 0b11111111;

SPBRG = 0b00011001;

TXSTA = 0b00100100;

INTCON.GIE = 1;

INTCON.PEIE = 1;

PIE1.RCIE = 1;

}

//------------------------------------------------------------------------------

void main() {

unsigned short k[8],ff[4],fff[4];

unsigned int q,w,h,dat;

Init1();

UART1_Init(9600);

Delay_ms(100);

SPI1_Init();

Delay_ms(100);

Expander_Init(0);

Delay_ms(100);

Expander_Init(1);

Delay_ms(100);

Expander_Init(2);

Delay_ms(100);

Expander_Init(3);

Delay_ms(100);

Expander_Set_DirectionPortAB(0,0xFFFF);

Expander_Set_DirectionPortAB(1,0xFFFF);

Expander_Set_DirectionPortAB(2,0x0000);

Expander_Set_DirectionPortAB(3,0x0000);

Expander_Set_PullUpsPortAB(0, 0xFFFF);

Expander_Set_PullUpsPortAB(1, 0xFFFF);

Expander_Set_PullUpsPortAB(2, 0xFFFF);

Expander_Set_PullUpsPortAB(3, 0xFFFF);

portb=0;

while(1){

q=80;

dat=0;

if (((rxdata[0] == 65) && (rxdata[2] == 66)) && (rxdata[1] > 0))

{

dat = rxdata[1];

rxdata[1] = 0;

rxdata[0] = 0;

rxdata[2] = 0;

rxchar = 0;

t[1] = 0;

sendUart(0);

}

for (h=0;h<4;h++)

{

if(h==0)

{

portb= Expander_Read_PortA(0);

ff[1] = portb;

}

else if(h==1)

{

portb= Expander_Read_PortB(0);

ff[2] = portb;

}

else if(h==2)

{

portb= Expander_Read_PortA(1);

ff[3] = portb;

}

else if(h==3)

{

portb= Expander_Read_PortB(1);

ff[4] = portb;

}

k[0] = PORTB.F0;

k[1] = PORTB.F1;

k[2] = PORTB.F2;

k[3] = PORTB.F3;

k[4] = PORTB.F4;

k[5] = PORTB.F5;

k[6] = PORTB.F6;

k[7] = PORTB.F7;

for (w=0;w<8;w++)

{

if(dat == q && k[w])

{

sendUart(q);

dat = 0;

}

else if(dat == q && !k[w])

{

sendUart(q + 1);

dat = 0;

}

q=q+2;

}

}

if(fff[1] != ff[1])

{

Expander_Write_PortA(2,ff[1]);

fff[1] = ff[1];

}

else if(fff[2] != ff[2])

{

Expander_Write_PortB(2,ff[2]);

fff[2] = ff[2];

}

else if(fff[3] != ff[3])

{

Expander_Write_PortA(3,ff[3]);

fff[3] = ff[3];

}

else if(fff[4] != ff[4])

{

Expander_Write_PortB(3,ff[4]);

fff[4] = ff[4];

}

Delay_ms(100);

}

}