M
myown
Guest
Código:# include "D: \ 4431.h"# BYTE QEICON = 0xFB6
# BYTE POSCNTH = 0xF67 / / Captura 2 Registro, Alto Byte / QEI de posición contra el Registro, Byte Alto
# BYTE POSCNTL = 0xF66 / / Captura 2 Registro, Baja Byte / QEI de posición contra el Registro, Baja Byte
# BYTE MAXCNTH = 0xF65 / / Capture 3 Registro, Alto Byte / QEI Max.
Límite de Registro de Cuenta, Alto Byte
# BYTE MAXCNTL = 0xF64 / / Capture 3 Registro, Baja Byte / QEI Max.
Límite de contar Registro, Baja Byte
# BYTE ANSEL0 = 0xFB8 / /
# BIT ANS2 = ANSEL0.2
# BIT ANS3 = ANSEL0.3
# BIT ANS4 = ANSEL0.4# include "QEI.h"# BYTE PWMCON0 = 0xF6F / / PWM CONTROL DE REGISTRO 0
# BYTE PTCON0 = 0XF7F / / REGISTRO DE CONTROL PWM TIMER 0
# BYTE PTCON1 = 0XF7E / / REGISTRO DE CONTROL PWM TIMER 0
# BYTE PTPERH = 0xF7A / / PWM Periodo de Registros
# BYTE PTPERL = 0xF7B / / PWM Periodo de Registros# uso fast_io (A)
# uso fast_io (B)
# uso fast_io (C)# BYTE PORTA = 0xF80
# BYTE PORTB = 0xF81
# BYTE PORTC = 0xF82# BIT RB0 = PORTB.0
# BIT RB1 = PORTB.1/ / CONECTAR AL LCD (FANUC 3000)# BIT DD1 = PORTC.0 / / XA (a) 1
# BIT DD2 = PORTC.1 / / XA (a) 2
# BIT DD4 = PORTC.2 / / XA (a) 3
# BIT DD8 = PORTC.3 / / XA (a) 4
# BIT TPM = PORTC.4 / / XA (a) 5estático sin firmar Int32 currentQEIPos, temp / / siempre debe ser firmado por la aritmética.# include "D: \ f3000.h"# int_rtcc
vacío clock_isr () / / LED de Fanuc 3000
(
select_axis (x);
data_output (currentQEIPos);
)void main ()
(
set_tris_a (0xff);
set_tris_b (0b00111100);
set_tris_c (0);
set_tris_d (0xff);
set_tris_e (0xff);
setup_adc_ports (NO_ANALOGS | VSS_VDD);
setup_adc (ADC_OFF | ADC_TAD_MUL_0 | ADC_WHEN_INT0 | ADC_INT_EVERY_OTHER);
setup_spi (FALSE);
setup_wdt (WDT_OFF);
setup_timer_0 (RTCC_INTERNAL);
setup_counters (RTCC_INTERNAL, RTCC_DIV_2);
setup_timer_1 (T1_DISABLED);
setup_timer_2 (T2_DISABLED, 0,1);setup_power_pwm_pins (PWM_COMPLEMENTARY, PWM_OFF, PWM_OFF, PWM_OFF);
/ / PPWM canales 0 y 1 son a la vez y siempre frente a los valores
setup_power_pwm (PWM_CLOCK_DIV_4 | PWM_FREE_RUN, 1,0,1023,0,1,0);
/ / tiempo muerto para añadir cargas reactivas
enable_interrupts (INT_RTCC);
enable_interrupts (GLOBAL);
/ / Setup_oscillator (falso);initQEI (4);while (TRUE)
(
currentQEIPos = getQEIPos ();
set_power_pwm0_duty (2048);
)
)
# BYTE POSCNTH = 0xF67 / / Captura 2 Registro, Alto Byte / QEI de posición contra el Registro, Byte Alto
# BYTE POSCNTL = 0xF66 / / Captura 2 Registro, Baja Byte / QEI de posición contra el Registro, Baja Byte
# BYTE MAXCNTH = 0xF65 / / Capture 3 Registro, Alto Byte / QEI Max.
Límite de Registro de Cuenta, Alto Byte
# BYTE MAXCNTL = 0xF64 / / Capture 3 Registro, Baja Byte / QEI Max.
Límite de contar Registro, Baja Byte
# BYTE ANSEL0 = 0xFB8 / /
# BIT ANS2 = ANSEL0.2
# BIT ANS3 = ANSEL0.3
# BIT ANS4 = ANSEL0.4# include "QEI.h"# BYTE PWMCON0 = 0xF6F / / PWM CONTROL DE REGISTRO 0
# BYTE PTCON0 = 0XF7F / / REGISTRO DE CONTROL PWM TIMER 0
# BYTE PTCON1 = 0XF7E / / REGISTRO DE CONTROL PWM TIMER 0
# BYTE PTPERH = 0xF7A / / PWM Periodo de Registros
# BYTE PTPERL = 0xF7B / / PWM Periodo de Registros# uso fast_io (A)
# uso fast_io (B)
# uso fast_io (C)# BYTE PORTA = 0xF80
# BYTE PORTB = 0xF81
# BYTE PORTC = 0xF82# BIT RB0 = PORTB.0
# BIT RB1 = PORTB.1/ / CONECTAR AL LCD (FANUC 3000)# BIT DD1 = PORTC.0 / / XA (a) 1
# BIT DD2 = PORTC.1 / / XA (a) 2
# BIT DD4 = PORTC.2 / / XA (a) 3
# BIT DD8 = PORTC.3 / / XA (a) 4
# BIT TPM = PORTC.4 / / XA (a) 5estático sin firmar Int32 currentQEIPos, temp / / siempre debe ser firmado por la aritmética.# include "D: \ f3000.h"# int_rtcc
vacío clock_isr () / / LED de Fanuc 3000
(
select_axis (x);
data_output (currentQEIPos);
)void main ()
(
set_tris_a (0xff);
set_tris_b (0b00111100);
set_tris_c (0);
set_tris_d (0xff);
set_tris_e (0xff);
setup_adc_ports (NO_ANALOGS | VSS_VDD);
setup_adc (ADC_OFF | ADC_TAD_MUL_0 | ADC_WHEN_INT0 | ADC_INT_EVERY_OTHER);
setup_spi (FALSE);
setup_wdt (WDT_OFF);
setup_timer_0 (RTCC_INTERNAL);
setup_counters (RTCC_INTERNAL, RTCC_DIV_2);
setup_timer_1 (T1_DISABLED);
setup_timer_2 (T2_DISABLED, 0,1);setup_power_pwm_pins (PWM_COMPLEMENTARY, PWM_OFF, PWM_OFF, PWM_OFF);
/ / PPWM canales 0 y 1 son a la vez y siempre frente a los valores
setup_power_pwm (PWM_CLOCK_DIV_4 | PWM_FREE_RUN, 1,0,1023,0,1,0);
/ / tiempo muerto para añadir cargas reactivas
enable_interrupts (INT_RTCC);
enable_interrupts (GLOBAL);
/ / Setup_oscillator (falso);initQEI (4);while (TRUE)
(
currentQEIPos = getQEIPos ();
set_power_pwm0_duty (2048);
)
)