hw cleanup

This commit is contained in:
Rene Hopf
2015-04-07 23:34:48 +02:00
parent 13fca3424c
commit e8ec969423
16 changed files with 113 additions and 63695 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -28,6 +28,15 @@ MEM(float e_sd1) = -1;
INIT(
GPIO_InitTypeDef GPIO_InitStructure;
TIM_ICInitTypeDef TIM_ICInitStructure;
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1 | TIM_Channel_2;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_BothEdge;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter = 0xF;
TIM_ICInit(ENC0_TIM, &TIM_ICInitStructure);
TIM_ICInit(ENC1_TIM, &TIM_ICInitStructure);
/***************** port 0, quadrature or step/dir *********************/
e_res0 = (int)PIN(res0);
if(e_res0 < 1){
@@ -91,6 +100,30 @@ INIT(
// enable tim
TIM_Cmd(ENC1_TIM, ENABLE);
TIM_Cmd(ENC0_TIM, DISABLE);
NVIC_DisableIRQ(EXTI9_5_IRQn);
TIM1->CR1 |= TIM_CR1_DIR;
GPIO_InitStructure.GPIO_Pin = ENC0_A_PIN | ENC0_B_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(ENC0_A_PORT, &GPIO_InitStructure);
TIM_EncoderInterfaceConfig(ENC0_TIM, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
TIM_Cmd(ENC0_TIM, ENABLE);
TIM_Cmd(ENC1_TIM, DISABLE);
//NVIC_DisableIRQ(EXTI9_5_IRQn); TODO
//TIM1->CR1 |= TIM_CR1_DIR; TODO
GPIO_InitStructure.GPIO_Pin = ENC1_A_PIN | ENC1_B_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(ENC1_A_PORT, &GPIO_InitStructure);
TIM_EncoderInterfaceConfig(ENC1_TIM, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
TIM_Cmd(ENC1_TIM, ENABLE);
);
RT(
@@ -104,55 +137,55 @@ RT(
if(e_sd0 != sd0 || e_sd1 != sd1 || e_q0 != q0 || e_q1 != q1){
if(q0 >= 0.0){ // quad 0
e_q0 = q0;
TIM_Cmd(ENC0_TIM, DISABLE);
NVIC_DisableIRQ(EXTI9_5_IRQn);
TIM1->CR1 |= TIM_CR1_DIR;
GPIO_InitStructure.GPIO_Pin = ENC0_A_PIN | ENC0_B_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(ENC0_A_PORT, &GPIO_InitStructure);
TIM_EncoderInterfaceConfig(ENC0_TIM, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
TIM_Cmd(ENC0_TIM, ENABLE);
// TIM_Cmd(ENC0_TIM, DISABLE);
// NVIC_DisableIRQ(EXTI9_5_IRQn);
// TIM1->CR1 |= TIM_CR1_DIR;
// GPIO_InitStructure.GPIO_Pin = ENC0_A_PIN | ENC0_B_PIN;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
// GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
// GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
// GPIO_Init(ENC0_A_PORT, &GPIO_InitStructure);
// TIM_EncoderInterfaceConfig(ENC0_TIM, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
// TIM_Cmd(ENC0_TIM, ENABLE);
}
/*if(q1 >= 0.0){ // quad 1
e_q1 = q1;
TIM_Cmd(ENC1_TIM, DISABLE);
//NVIC_DisableIRQ(EXTI9_5_IRQn); TODO
//TIM1->CR1 |= TIM_CR1_DIR; TODO
GPIO_InitStructure.GPIO_Pin = ENC1_A_PIN | ENC1_B_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(ENC1_A_PORT, &GPIO_InitStructure);
TIM_EncoderInterfaceConfig(ENC1_TIM, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
TIM_Cmd(ENC1_TIM, ENABLE);
if(q1 >= 0.0){ // quad 1
e_q1 = q1;
// TIM_Cmd(ENC1_TIM, DISABLE);
// //NVIC_DisableIRQ(EXTI9_5_IRQn); TODO
// //TIM1->CR1 |= TIM_CR1_DIR; TODO
// GPIO_InitStructure.GPIO_Pin = ENC1_A_PIN | ENC1_B_PIN;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
// GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
// GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
// GPIO_Init(ENC1_A_PORT, &GPIO_InitStructure);
// TIM_EncoderInterfaceConfig(ENC1_TIM, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
// TIM_Cmd(ENC1_TIM, ENABLE);
}*/
}
if(sd0 >= 0.0){ // stepdir 0
e_sd0 = sd0;
TIM_Cmd(ENC0_TIM, DISABLE);
//clk
GPIO_InitStructure.GPIO_Pin = ENC0_B_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(ENC0_B_PORT, &GPIO_InitStructure);
//dir
GPIO_InitStructure.GPIO_Pin = ENC0_A_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(ENC0_A_PORT, &GPIO_InitStructure);
TIM_ETRClockMode1Config(ENC0_TIM,TIM_ExtTRGPSC_OFF, TIM_ExtTRGPolarity_NonInverted, 0x00);
TIM_TIxExternalClockConfig(ENC0_TIM,TIM_TIxExternalCLK1Source_TI2, TIM_ICPolarity_Rising, 0x00);
NVIC_EnableIRQ(EXTI9_5_IRQn);
TIM_Cmd(ENC0_TIM, ENABLE);
// TIM_Cmd(ENC0_TIM, DISABLE);
// //clk
// GPIO_InitStructure.GPIO_Pin = ENC0_B_PIN;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
// GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
// GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
// GPIO_Init(ENC0_B_PORT, &GPIO_InitStructure);
//
// //dir
// GPIO_InitStructure.GPIO_Pin = ENC0_A_PIN;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
// GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
// GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
// GPIO_Init(ENC0_A_PORT, &GPIO_InitStructure);
// TIM_ETRClockMode1Config(ENC0_TIM,TIM_ExtTRGPSC_OFF, TIM_ExtTRGPolarity_NonInverted, 0x00);
// TIM_TIxExternalClockConfig(ENC0_TIM,TIM_TIxExternalCLK1Source_TI2, TIM_ICPolarity_Rising, 0x00);
// NVIC_EnableIRQ(EXTI9_5_IRQn);
// TIM_Cmd(ENC0_TIM, ENABLE);
}
/*if(sd1 >= 0.0){ // stepdir 1
e_sd1 = sd1;

View File

@@ -174,7 +174,7 @@ void cmd(char * s){
read_pos++;
read_pos %= TERM_BUF_SIZE;
buf[8 + 1] = 0;
buf[4 + 1] = 0;
if(UB_USB_CDC_GetStatus()==USB_CDC_CONNECTED){
UB_USB_CDC_SendString((char*)buf, NONE);

View File

@@ -379,6 +379,7 @@ void set_mitsubishi(){ // TODO
set_hal_pin("conf0.acc_p", 0.15);
set_hal_pin("conf0.acc_pi", 50.0);
set_hal_pin("conf0.cur_lp", 0.5);
set_hal_pin("encm0.enable", 1.0);
}
void set_br(){
@@ -401,3 +402,31 @@ void set_br(){
set_hal_pin("conf0.acc_pi", 50.0);
set_hal_pin("conf0.cur_lp", 0.0);
}
//linear 25 ohm
//e250 15
void set_e240(){ // TODO
set_hal_pin("conf0.pole_count", 1.0);
set_hal_pin("conf0.max_vel", RPM(8000));
set_hal_pin("conf0.max_acc", RPM(8000) / 0.002);
set_hal_pin("conf0.max_force", 4.8);
set_hal_pin("conf0.max_cur", 13.0);
set_hal_pin("conf0.fb_type", ENC1);
set_hal_pin("conf0.fb_rev", 0.0);
set_hal_pin("conf0.fb_res", 2048.0);
//set_hal_pin("conf0.r", 5.4);
//set_hal_pin("conf0.l", 0.0082);
//set_hal_pin("conf0.j", KGCM2(0.268));
//set_hal_pin("conf0.km", 0.135);
set_hal_pin("conf0.r", 25.0);
set_hal_pin("conf0.l", 0.003);
set_hal_pin("conf0.j", KGCM2(0.268));
set_hal_pin("conf0.km", 0.068);
set_hal_pin("conf0.pos_p", 45.0);
set_hal_pin("conf0.acc_p", 0.025);
set_hal_pin("conf0.acc_pi", 10.0);
set_hal_pin("conf0.cur_lp", 0.0);
set_hal_pin("cur0.magpos", 0.0);
set_hal_pin("enc0.quad_en0", 1.0);
}

View File

@@ -26,3 +26,4 @@ void set_sankyo();
void set_sanyo();
void set_mitsubishi();
void set_br();
void set_e240();

View File

@@ -216,7 +216,8 @@ int main(void)
link_pid();
set_bergerlahr();//pid2: ok
set_e240();
//set_bergerlahr();//pid2: ok
//set_mitsubishi();//pid2: ok
//set_festo();
//set_manutec();

View File

@@ -47,7 +47,7 @@ ServoFrame::ServoFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title){
leiste->Add(uhu,0,wxALIGN_LEFT|wxALL,3);
leiste->Add(stmbl,0,wxALIGN_LEFT|wxALL,3);
topsizer->Add(leiste);
drawpanel = new BasicDrawPane((wxFrame*)top,8);
drawpanel = new BasicDrawPane((wxFrame*)top,4);
topsizer->Add(drawpanel, 1,wxEXPAND,0);
wxArrayString waves;
@@ -205,7 +205,7 @@ void ServoFrame::OnTimer(wxTimerEvent& evt){
for (int i=0; i<ret; i++){
if(addr >= 0){
values[addr++] = (buf[i]-128) / 128.0;
if(addr == 8){
if(addr == 4){
drawpanel->plotvalue(values);
addr = -1;
}