fernandodiaz
Junior Member
Offline
Posts: 73
Thank You
-Given: 1
-Receive: 18
|
|
« on: October 21, 2007, 01:12:18 01:12 » |
|
Hi here i make one interpreter to mitutoyo SPC interface (calipers micrometers rules etc) only conect pic direct to instument 3 pin wires and send serial rs232 readout very short code each 200ms update and send made in Mexico. enjoy .......
'include "proton_4.inc" ' MITUTOYO 'DEVICE 16F877 device 16f84A DIM TEMP AS BYTE ' var del loop ' total de lineas de codigo 77 DIM TEMP1 AS BYTE DIM SIGNO AS BIT ' SIGNO DE LA MEDIDA dim D5Y6 as byte ' digitos dim D3Y4 as byte ' digitos dim D1Y2 as byte ' digitos DIM PUNTO AS BYTE ' POSICION DEL PUNTO Y UNIDADES MM 0 INCH INPUT PORTA.0 ' Request INPUT PORTB.7 ' clock pin INPUT PORTB.6 ' data pin OUTPUT PORTA.1 ' SERIAL OUTPUT OPTION_REG.7 = 0 ' PULLUP ENABLE pullup da 160ua x: '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ low portA.0 SIGNO = 0 ' PONER A 0 TODAS D5Y6 = 0 D3Y4 = 0 D1Y2 = 0 PUNTO = 0 '______________________________INICIO_____________________ 'request on pin to 2.5v a 0v dc resistencia de 100k FOR TEMP = 1 TO 19 'EN TOTAL 19 CLOCKS IGNORADOS-1 INTERRUP TOTAL DE INTERRUP = 52 CLOCKS @ BTFSC 06,7 ; BRINCA SI 0 @ GOTO $-1 @ BTFSS 06,7 ; BRINCA SI 1 @ GOTO $-1 NEXT TEMP gosub checarelojL ' 1 0 1 ret CHECA SI ES POS O NEGATVO BIT 20 @ BTFSC 06,6 ; BRINCA SI VALE 0 DATA @ BSF SIGNO ; PONE EN 1 VAR TIPO BIT gosub checarelojh gosub ddr '______ ____ _____ D5Y6 = TEMP1 gosub ddr D3Y4 = TEMP1 gosub ddr D1Y2 = TEMP1 gosub ddr PUNTO = TEMP1 input portA.0 '______________________TERMINA______________________________ TEMP = D1Y2 GOSUB CONVIERTE D1Y2 = TEMP TEMP = D3Y4 GOSUB CONVIERTE D3Y4 = TEMP TEMP = D5Y6 GOSUB CONVIERTE D5Y6 = TEMP
TEMP = PUNTO ' FLOTATE POS Y UIDADES MM INCH GOSUB CONVIERTE PUNTO = TEMP 'rsout dec signo," ",dec D5Y6," ",DEC D3Y4," ",DEC D1Y2 ' ," ",dec punto
SEROUT PORTA.1,16468,[dec signo," ",dec2 D5Y6,"",DEC2 D3Y4,"",DEC2 D1Y2,13] '" ",DEC2 PUNTO, 13] '84 o 16468 - 9600 BAUD
delayms 200 GOTO X end
CHECARELOJL: ' subrutina para checado de reloj @ BTFSC 06,7 ; BRINCA SI 0 @ GOTO $-1 return CHECARELOJH: ' subrutina para checado de reloj @ BTFSS 06,7 ; BRINCA SI 1 @ GOTO $-1 return
CONVIERTE: TEMP = ((TEMP & %1111) * 10) + (TEMP >> 4) 'COVIERTE bcd Binary Coded Decimal A digitos RETURN DDR: FOR TEMP = 1 TO 7 gosub checarelojL @ BTFSC 06,6 ; BRINCA SI VALE 0 DATA @ BSF TEMP1,7 ; PONE EN 1 VAR @ RRF TEMP1 gosub checarelojh NEXT TEMP gosub checarelojL ' el octavo bit @ BTFSC 06,6 ; octabo bit @ BSF TEMP1,7 ; PONE EN 1 VAR gosub checarelojh return
|