Платформа хорошая, слов нет, только есть пара вопросов: 1 каков её вес, и в связи с этим, не проскальзывают ли колеса? 2 о мотор шилде. Где заказывали, какие моторы и сколько можно подключить к нему? 3. Как подаются команды на движение? Смотрел видео без звука, может там и сказано было.
1. Вес меньше 100 грамм, точнее надо взвешивать. 2. Шилд вот тут брал - http://iarduino.ru/shop/Expansion-payments/motor-shield-l298p.html. Работает нормально, есть управление скорость, тормоза. Шилд на два мотора, я подключил четыре т.к. не вижу смыла раздельно каждый двигатель питать. 3. Колеса не проскальзывают. 4. Команды достаточно простые, вот программа - Код (Text): /* RemoteXY select connection mode and include library */ #define REMOTEXY_MODE__SERIAL #include <RemoteXY.h> /* RemoteXY connection settings */ #define REMOTEXY_SERIAL Serial #define REMOTEXY_SERIAL_SPEED 9600 { 5,11,54,0,3,5,1,0,45,3 ,21,21,2,94,0,1,0,46,38,21 ,21,2,92,47,0,1,0,22,21,21 ,21,2,60,0,1,0,68,20,21,21 ,2,62,0,4,0,2,8,8,53,1 ,67,4,2,2,20,6,2,11 }; struct { /* input variable */ unsigned char button_1; /* =1 если РєРЅРѕРїРєР° нажата, иначе =0 */ unsigned char button_2; /* =1 если РєРЅРѕРїРєР° нажата, иначе =0 */ unsigned char button_3; /* =1 если РєРЅРѕРїРєР° нажата, иначе =0 */ unsigned char button_4; /* =1 если РєРЅРѕРїРєР° нажата, иначе =0 */ signed char slider_1; /* =0..100 положение слайдера */ /* output variable */ char text_1[11]; /* =строка оканчивающаяся нулем UNICODE */ /* other variable */ unsigned char connect_flag; /* =1 if wire connected, else =0 */ } RemoteXY; ///////////////////////////////////////////// // END RemoteXY include // ///////////////////////////////////////////// //Function Channel A Channel B //Direction Digital 12 Digital 13 //Speed (PWM) Digital 3 Digital 11 //Brake Digital 9 Digital 8 //Current Sensing Analog 0 Analog 1 /************************************************************* Motor Shield 2-Channel DC Motor Demo by Randy Sarafan For more information see: http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/ *************************************************************/ int spd1 =50; void setup() { RemoteXY_Init (); //Setup Channel A pinMode(12, OUTPUT); //Initiates Motor Channel A pin pinMode(9, OUTPUT); //Initiates Brake Channel A pin //Setup Channel B pinMode(13, OUTPUT); //Initiates Motor Channel A pin pinMode(8, OUTPUT); //Initiates Brake Channel A pin } void loop(){ RemoteXY_Init (); /* spd (100); forward (); delay (2000); back(); delay (2000); right (); delay (2000); left (); delay(2000); */ brake(); if (RemoteXY.button_1==1) forward (); if (RemoteXY.button_2==1) back (); if (RemoteXY.button_3==1) left (); if (RemoteXY.button_4==1) right (); spd1 = RemoteXY.slider_1; spd1 = map (spd1,0,100,20,255); } void forward () { //Motor A forward digitalWrite(12, HIGH); //Establishes forward direction of Channel A digitalWrite(9, LOW); //Disengage the Brake for Channel A //Motor B forward digitalWrite(13, HIGH); //Establishes backward direction of Channel B digitalWrite(8, LOW); //Disengage the Brake for Channel B } void back () { //Motor A forward digitalWrite(12, LOW); //Establishes forward direction of Channel A digitalWrite(9, LOW); //Disengage the Brake for Channel A //Motor B forward digitalWrite(13, LOW); //Establishes backward direction of Channel B digitalWrite(8, LOW); //Disengage the Brake for Channel B } void left () { //Motor A forward digitalWrite(12, HIGH); //Establishes forward direction of Channel A digitalWrite(9, LOW); //Disengage the Brake for Channel A //Motor B forward digitalWrite(13, LOW); //Establishes backward direction of Channel B digitalWrite(8, LOW); //Disengage the Brake for Channel B } void right () { //Motor A forward digitalWrite(12, LOW); //Establishes forward direction of Channel A digitalWrite(9, LOW); //Disengage the Brake for Channel A //Motor B forward digitalWrite(13, HIGH); //Establishes backward direction of Channel B digitalWrite(8, LOW); //Disengage the Brake for Channel B } void spd(int spd) { analogWrite(3, spd); //Spins the motor on Channel A at full speed analogWrite(11, spd); //Spins the motor on Channel B at half speed } void brake () { digitalWrite(9, HIGH); //Engage the Brake for Channel A digitalWrite(9, HIGH); //Engage the Brake for Channel B }
Подождите, я, конечно может не понимаю, но если вы пинами программно управляете моторами, зачем в системе мотор шилд?
Вот тут туториал неплохой - http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/step4/One-Motor/
Ага, посмотрел. Получается, управление с аналогового выхода просто уменьшением напряжения вдвое? Тогда как вы узнаете, что платформе нужно проехать 5 метров, и остановиться? Или такую задачу вы не ставили?
Можно поставить энкодер, тогда будет знать проеханное расстояние. Выбранный двигатель и колеса это позволяют сделать. Вот - http://amperka.ru/product/miniq-wheel-encoder