roboforum.ru

Технический форум по робототехнике.

Pololu Trex Dual Motor Controller Dmc01

ARM7, ARM9, ARM11 etc.

Pololu Trex Dual Motor Controller Dmc01

Сообщение Artemmm » 22 апр 2014, 07:14

Здравствуйте, подскажите пожалуйста, имеется STM32F4Discovery и вот этот драйвер http://www.pololu.com/product/777, на Discovery настроил порты, задержка, флаги, USART, отправка команд идет через sprintf, когда запускаю просто светодиод мигает, но двигатели не хотят работать, не могу никак разобраться как довести его до ума
Artemmm
 
Сообщения: 5
Зарегистрирован: 22 апр 2014, 07:10

Re: Pololu Trex Dual Motor Controller Dmc01

Сообщение Angel71 » 22 апр 2014, 09:46

а вы вон те куски кода перепишите и всё заработает.
Аватара пользователя
Angel71
 
Сообщения: 10668
Зарегистрирован: 18 апр 2009, 22:18
Предупреждения: -1

Re: Pololu Trex Dual Motor Controller Dmc01

Сообщение AndreiSk » 22 апр 2014, 10:15

рассказывайте как соединяли, какие перемычки оставляли,
что посылаете, на какой скорости и т.д.
А пока это вопль потерпевшего ниочем :D
Аватара пользователя
AndreiSk
 
Сообщения: 2639
Зарегистрирован: 23 апр 2009, 17:03
Откуда: Москва, Самара
прог. языки: C#

Re: Pololu Trex Dual Motor Controller Dmc01

Сообщение Artemmm » 22 апр 2014, 11:28

#include "stm32f4xx.h"
#include <stdio.h>

void USART2_ini(void);
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_Init_Usa;
GPIO_InitTypeDef GPIO_Init_Button;
void Button_ini(void);

uint16_t delya_count=0;
void SysTick_Handler(void)
{
if (delya_count>0)
{
delya_count--;
}
}

void delay_ms(uint16_t delya_temp)
{
delya_count = delya_temp;
while(delya_count){}
}

void SendStrtoPC(char* str_p, uint16_t count)
{
uint16_t i=0;
if (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0)==1)
{
while(i< count)
{
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE)==RESET){}
USART_SendData ( USART2, str_p[i]);
i++;
}
}
}

int main (void)
{
char str[30];
SysTick_Config(SystemCoreClock/1000);
USART2_ini();
Button_ini();
sprintf(str, "0xC2,1023");

while(1)
{
delay_ms(500);
SendStrtoPC(str, 30);
}
}



void USART2_ini(void)
{
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_USART2);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_USART2);
}

{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
USART_Init_Usa.USART_BaudRate = 9600;
USART_Init_Usa.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init_Usa.USART_Mode = USART_Mode_Tx|USART_Mode_Rx;
USART_Init_Usa.USART_Parity = USART_Parity_No;
USART_Init_Usa.USART_StopBits = USART_StopBits_1;
USART_Init_Usa.USART_WordLength = USART_WordLength_8b;
USART_Init(USART2, &USART_Init_Usa);
USART_Cmd(USART2, ENABLE);
}
}
void Button_ini(void)
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
GPIO_Init_Button.GPIO_Pin = GPIO_Pin_0;
GPIO_Init_Button.GPIO_Mode = GPIO_Mode_IN;
GPIO_Init_Button.GPIO_OType = GPIO_OType_PP;
GPIO_Init_Button.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init_Button.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_Init_Button);
GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0);

}

на драйвере имеется СОМ порт (RX TX GND), соответственно PORTA3 на TX, PORTA2 на RX, GND на GND. Скорость передачи 9600.

Посылаются команды вот часть из них:

0xC8 – 0xCB: set motor 2
This command takes one data byte and returns nothing. It immediately sets the speed of the
specified motor equal to the data byte and the motor direction based on the two least significant
bits of the command byte. The direction bits work as follows:
00 = brake low (command 0xC0/0xC8)
01 = reverse (command 0xC1/0xC9)
10 = forward (command 0xC2/0xCA)
11 = brake low (command 0xC3/0xCB)

0xC4 – 0xC7: accelerate motor 1
0xCC – 0xCF: accelerate motor 2
This command takes one data byte and returns nothing. It sets the target speed of of the
specified motor equal to the data byte and the target motor direction based on the two least
significant bits of the command byte. The direction bits work as follows:

00 = brake low (command 0xC4/0xCC)
01 = reverse (command 0xC5/0xCD)
10 = forward (command 0xC6/0xCE)
11 = brake low (command 0xC7/0xCF)

Motor speed is updated 100 times per second. If it is below its target speed and if its current
direction is the same as its target direction, each update will adjust the speed by increasing it by
a tenth of its acceleration parameter. If it is above its target speed and its direction is in the
target direction, the update will merely set its speed equal to the target value (i.e. there is no
deceleration). Every 10ms, the following acceleration logic is performed:
if motor speed < target speed, motor speed = motor speed + acceleration/10
if motor speed > target speed, motor speed = target speed
If the target direction differs from the current direction, the first update will brake the motor at
100% duty cycle for the amount of time specified by the its brake duration parameter. It will
then set the motor speed to zero and accelerate from there to the target speed in the target
direction.
If you intend to use the current-limiting feature of the TReX, you should use acceleration
commands to control your motor speed. This is because acceleration commands schedule
motor updates to happen as part of a fixed update cycle that also takes care of the current-
limiting logic. “Set motor” commands set the motor speed the instant they're received and will,
at least temporarily, override any current-limiting actions the TReX is taking. If you want to
limit your current but you don't want acceleration, set the acceleration parameter to zero; this
essentially requests infinite acceleration.
Note: acceleration does not apply to braking or to a speed decrease that does not also result in a
change of direction. Motor speed can also be influenced by current-limit settings, which add
additional considerations to the logic detailed in this section. Please see the current limit
section of the parameter documentation for more details.
Artemmm
 
Сообщения: 5
Зарегистрирован: 22 апр 2014, 07:10

Re: Pololu Trex Dual Motor Controller Dmc01

Сообщение AndreiSk » 22 апр 2014, 13:29

Попробуйте понять, живой ли драйвер вообще,
и правильно ли соединения, см. post297916.html#p297916
Аватара пользователя
AndreiSk
 
Сообщения: 2639
Зарегистрирован: 23 апр 2009, 17:03
Откуда: Москва, Самара
прог. языки: C#

Re: Pololu Trex Dual Motor Controller Dmc01

Сообщение Artemmm » 22 апр 2014, 18:57

конечно живой, через терминал на полную работает

Добавлено спустя 2 минуты 57 секунд:
так как и через конфигуратор

Добавлено спустя 1 час 2 минуты 2 секунды:
приложение от Popolu ( конфигуратор) ну и переходник USB USART
Artemmm
 
Сообщения: 5
Зарегистрирован: 22 апр 2014, 07:10

Re: Pololu Trex Dual Motor Controller Dmc01

Сообщение AndreiSk » 22 апр 2014, 19:13

могу предположить, что скорость порта 19200
не выставлена на стороне STM
Ну в смысле вы выставили 9600, а надо (возможно) 19200,
но у меня DMC-2, может у вас по другому
Аватара пользователя
AndreiSk
 
Сообщения: 2639
Зарегистрирован: 23 апр 2009, 17:03
Откуда: Москва, Самара
прог. языки: C#

Re: Pololu Trex Dual Motor Controller Dmc01

Сообщение Artemmm » 23 апр 2014, 09:12

так оно и есть, baud rate 9600 стоит, хотя на драйвере стандартно идет 19200, но если я ставлю 19200 на STM, то при отправке драйвер вообще никак не реагирует, а так хотя бы диод мигает))
Artemmm
 
Сообщения: 5
Зарегистрирован: 22 апр 2014, 07:10

Re: Pololu Trex Dual Motor Controller Dmc01

Сообщение AndreiSk » 23 апр 2014, 12:24

Как то это необычно. Может в STM прошивке неправильно указаны частоты
кварца? Подергайте точно ножкой и через анализатор поглядите правильной ли длины
импульс... :o
Аватара пользователя
AndreiSk
 
Сообщения: 2639
Зарегистрирован: 23 апр 2009, 17:03
Откуда: Москва, Самара
прог. языки: C#

Re: Pololu Trex Dual Motor Controller Dmc01

Сообщение avr123.nm.ru » 23 апр 2014, 13:11

Artemmm писал(а): живой, через терминал на полную работает
тогда подайте команды на терминал и убедитесь то они верны.

Может ему 5 вольт логику надо?
Читайте !
Аватара пользователя
avr123.nm.ru
отсылающий читать курс
 
Сообщения: 14195
Зарегистрирован: 06 ноя 2005, 04:18
Откуда: Москва
Предупреждения: -8

Re: Pololu Trex Dual Motor Controller Dmc01

Сообщение Artemmm » 26 апр 2014, 15:02

а есть разница, я настроил USART на передачу строки?))

Добавлено спустя 7 минут 21 секунду:
ну т.е. отправка "hellow world"
Artemmm
 
Сообщения: 5
Зарегистрирован: 22 апр 2014, 07:10


Вернуться в ARM

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 0

cron