myown
Member level 1
i=poscnth;
driver - under ir2184 and 4 irfp250
motor - Brushed(48V) with 500 pulse encoder
while my PWM duty = 2048 that is 50% PWM -> motor not turning
PWM < 2048 -> left turnig
PWM > 2048 -> right turnig
I must set position target, and target must be = currentQEIPOS
How I can do it (with or without PID, better with PID)
HELP!!!
maybe anybody have link for comlete code PID motion?
Code:
#include "D:\4431.h"
#BYTE QEICON=0xFB6
#BYTE POSCNTH=0xF67 //Capture 2 Register, High Byte / QEI Position Counter Register, High Byte
#BYTE POSCNTL=0xF66 //Capture 2 Register, Low Byte / QEI Position Counter Register, Low Byte
#BYTE MAXCNTH=0xF65 //Capture 3 Register, High Byte / QEI Max. Count Limit Register, High Byte
#BYTE MAXCNTL=0xF64 //Capture 3 Register, Low Byte / QEI Max. Count Limit Register, Low Byte
#BYTE ANSEL0=0xFB8 //
#BIT ANS2=ANSEL0.2
#BIT ANS3=ANSEL0.3
#BIT ANS4=ANSEL0.4
#include "QEI.h"
#BYTE PWMCON0=0xF6F // PWM CONTROL REGISTER 0
#BYTE PTCON0=0XF7F // PWM TIMER CONTROL REGISTER 0
#BYTE PTCON1=0XF7E // PWM TIMER CONTROL REGISTER 0
#BYTE PTPERH=0xF7A // PWM Period Registers
#BYTE PTPERL=0xF7B // PWM Period Registers
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#BYTE PORTA=0xF80
#BYTE PORTB=0xF81
#BYTE PORTC=0xF82
#BIT RB0=PORTB.0
#BIT RB1=PORTB.1
//CONNECT TO 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 DWT=PORTC.4 // XA (a) 5
static unsigned int32 currentQEIPos,temp; //must be signed long because of arithmetic.
#include "D:\f3000.h"
#int_rtcc
void clock_isr() //LED display from 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 channels 0 and 1 are both on and always opposite values
setup_power_pwm(PWM_CLOCK_DIV_4|PWM_FREE_RUN,1,0,1023,0,1,0);
//add dead time for reactive loads
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
// setup_oscillator(False);
initQEI(4);
while(TRUE)
{
currentQEIPos = getQEIPos();
set_power_pwm0_duty(2048);
}
}
driver - under ir2184 and 4 irfp250
motor - Brushed(48V) with 500 pulse encoder
while my PWM duty = 2048 that is 50% PWM -> motor not turning
PWM < 2048 -> left turnig
PWM > 2048 -> right turnig
I must set position target, and target must be = currentQEIPOS
How I can do it (with or without PID, better with PID)
HELP!!!
maybe anybody have link for comlete code PID motion?