Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
et:projects:tudengid11:kaugjuhitav2 [2011/04/07 23:15] mihhail smirnovet:projects:tudengid11:kaugjuhitav2 [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 71: Line 71:
    
 =====6.Development.===== =====6.Development.=====
 +====6.1. Electronics ====
  
-====6.1. Spider concept and parts.====+{{http://static1.fotoalbum.ee/fotoalbum/332/152/08307627979975.jpg?600}} 
 + 
 +Picture 2 Block diagram 
 + 
 +====6.2. Spider concept and parts.====
  
 {{http://static1.fotoalbum.ee/fotoalbum/328/281/08214077581ce3.jpg?400}}  {{http://static1.fotoalbum.ee/fotoalbum/328/281/08214077581ce3.jpg?400}} 
  
-Picture Spider concept+Picture Spider concept
  
  
Line 121: Line 126:
 ^Total                      |||$263.95| ^Total                      |||$263.95|
    
-====6.2. Algorithm and programming.====+====6.3. Algorithm and programming.====
    
 {{http://static1.fotoalbum.ee/fotoalbum/330/78/0825392675dc5c.jpg?600}} {{http://static1.fotoalbum.ee/fotoalbum/330/78/0825392675dc5c.jpg?600}}
  
-Picture Movement Algorithm+Picture Movement Algorithm
    
 Movement algorithm (Picture 3 Movement Algorithm) description: Movement algorithm (Picture 3 Movement Algorithm) description:
Line 157: Line 162:
 If the algorithm reaches the “End” point the joint and the base servos are returned to the default position.  If the algorithm reaches the “End” point the joint and the base servos are returned to the default position. 
  
 +{{http://home.fill.ee/~rda/meh_proekt_gui/mehProekt_pcProgram_screenshot/meh_proekt_pc_prog.jpg}}
  
 +Picture 5 Menu control of a robot.
 +
 +1) Shows all ports that have any devices connected to them.
 +
 +2) These buttons make robot to move forward, turn left or right and to stop the current command and take standart position
 +
 +3) These buttons controls the movements of a single leg of the robot
 +
 +Source for the microcontroller:
  
 <code c> <code c>
 #include <homelab/usart.h> #include <homelab/usart.h>
-#include <homelab/delay.h>  +#include <homelab/delay.h> 
- // COM connector  +#include <string.h> 
- usart in_port = USART(0); +#include <stdio.h> 
- // pinhead GND/RX/TX + 
- usart out_port = USART(1); +// COM connector 
- int main(void) +usart in_port = USART(0); 
- {+ 
 +// pinhead GND/RX/TX 
 +usart out_port = USART(1); 
 + 
 +int main(void) 
 +{ 
 + unsigned char i;
  char c;  char c;
- unsigned char row 1;+ int str[40]; 
 + int inc=50; 
 + int init_pos[]={600, 1100, 2000, 1300, 2200, 1300, 100, 1300}; 
 + int pos[sizeof(init_pos)/sizeof(int)]; 
 + for(i=0; i<sizeof(init_pos)/sizeof(int); i++){ 
 + pos[i]=init_pos[i]; 
 +
 + 
  // USART   // USART 
  usart_init_async(in_port,  usart_init_async(in_port,
Line 175: Line 203:
  USART_STOPBITS_ONE,  USART_STOPBITS_ONE,
  USART_PARITY_NONE,  USART_PARITY_NONE,
- USART_BAUDRATE_ASYNC(115200));+ USART_BAUDRATE_ASYNC(9600)); 
 + 
 + // TX RX
  usart_init_async(out_port,  usart_init_async(out_port,
  USART_DATABITS_8,  USART_DATABITS_8,
Line 181: Line 211:
  USART_PARITY_NONE,  USART_PARITY_NONE,
  USART_BAUDRATE_ASYNC(115200));  USART_BAUDRATE_ASYNC(115200));
 +
  // Loop  // Loop
  while (true)  while (true)
  {  {
  usart_try_read_char(in_port, &c);  usart_try_read_char(in_port, &c);
- if(c=="move forward"){ + if(c=='f'){ 
- // Left top leg + // Initial positionв 
- usart_send_string(out_port, "#0 P1800 S1000\n"); + usart_send_string(out_port,  
- usart_send_string(out_port, "#1 P2200 S1000\n"); + "#P600 #3 P1100 #12 P1300 #15 P1150 #16 P2000 #19 P1300 #28 P1300 #31 P1850 \r"); 
- hw_delay_ms(300); + for(i=0i<sizeof(pos)/sizeof(int); i++){ 
- usart_send_string(out_port, "#P1500 S1000\n"); + pos[i]=init_pos[i]
- hw_delay_ms(300); + }
- usart_send_string(out_port, "#1 P1500 S300\n"+
- // Right bottom leg +
- usart_send_string(out_port, "#2 P1800 S1000\n"); +
- usart_send_string(out_port, "#3 P2200 S1000\n"); +
- hw_delay_ms(300); +
- usart_send_string(out_port, "#2 P1500 S1000\n"); +
- hw_delay_ms(300); +
- usart_send_string(out_port, "#3 P1500 S300\n"+
- // Right top leg +
- usart_send_string(out_port, "#4 P1800 S1000\n"); +
- usart_send_string(out_port, "#5 P2200 S1000\n"); +
- hw_delay_ms(300); +
- usart_send_string(out_port, "#4 P1500 S1000\n")+
- hw_delay_ms(300); +
- usart_send_string(out_port, "#5 P1500 S300\n"+
- // Left bottom leg +
- usart_send_string(out_port, "#6 P1800 S1000\n"); +
- usart_send_string(out_port, "#7 P2200 S1000\n"); +
- hw_delay_ms(300)+
- usart_send_string(out_port, "#6 P1500 S1000\n"); +
- hw_delay_ms(300); +
- usart_send_string(out_port, "#7 P1500 S300\n")+
  }  }
- else if(c=="turn left"){ + // Left upper leg 
- // Left top leg + else if(c=='a'){ 
- usart_send_string(out_port, "#0 P1800 S1000\n"); + /
- usart_send_string(out_port, "#1 P1300 S1000\n");+ Left bottom leg 
 + */ 
 + usart_send_string(out_port, "#15 P1200\r");
  hw_delay_ms(300);  hw_delay_ms(300);
- usart_send_string(out_port, "#0 P1500 S1000\n");+ usart_send_string(out_port, "#12 P900\r");
  hw_delay_ms(300);  hw_delay_ms(300);
- // Right top leg + usart_send_string(out_port, "#15 P1100\r");
- usart_send_string(out_port, "#4 P1800 S1000\n"); +
- usart_send_string(out_port, "#5 P1800 S1000\n");+
  hw_delay_ms(300);  hw_delay_ms(300);
- usart_send_string(out_port, "#4 P1500 S1000\n");+ /* 
 + Right bottom leg 
 + */ 
 + usart_send_string(out_port, "#31 P1750\r");
  hw_delay_ms(300);  hw_delay_ms(300);
- // Right bottom leg + usart_send_string(out_port, "#28 P1800\r");
- usart_send_string(out_port, "#P1800 S1000\n"); +
- usart_send_string(out_port, "#3 P1800 S1000\n");+
  hw_delay_ms(300);  hw_delay_ms(300);
- usart_send_string(out_port, "#2 P1500 S1000\n");+ usart_send_string(out_port, "#31 P1850\r");
  hw_delay_ms(300);  hw_delay_ms(300);
- // Left bottom leg + /
- usart_send_string(out_port, "#6 P1800 S1000\n"); + Right upper leg 
- usart_send_string(out_port, "#7 P1800 S1000\n");+ */ 
 + usart_send_string(out_port, "#16 P1950\r");
  hw_delay_ms(300);  hw_delay_ms(300);
- usart_send_string(out_port, "#6 P1500 S1000\n");+ usart_send_string(out_port, "#19 P1100\r");
  hw_delay_ms(300);  hw_delay_ms(300);
- usart_send_string(out_port, "#0 P1500 S1000\n"); + usart_send_string(out_port, "#16 P2050\r");
- usart_send_string(out_port, "#2 P1500 S1000\n"); +
- usart_send_string(out_port, "#4 P1500 S1000\n"); +
- usart_send_string(out_port, "#6 P1500 S1000\n");+
  hw_delay_ms(300);  hw_delay_ms(300);
- else if(c=="turn right"){ + /* 
- // Left top leg + Left upper leg 
- usart_send_string(out_port, "#0 P1800 S1000\n"); + */ 
- usart_send_string(out_port, "#1 P1800 S1000\n");+ usart_send_string(out_port, "#0 P750\r");
  hw_delay_ms(300);  hw_delay_ms(300);
- usart_send_string(out_port, "#0 P1500 S1000\n");+ usart_send_string(out_port, "#3 P1200\r");
  hw_delay_ms(300);  hw_delay_ms(300);
- // Right top leg + usart_send_string(out_port, "#P550\r");
- usart_send_string(out_port, "#4 P1800 S1000\n"); +
- usart_send_string(out_port, "#5 P1300 S1000\n"); +
- hw_delay_ms(300); +
- usart_send_string(out_port, "#4 P1500 S1000\n"); +
- hw_delay_ms(300); +
- // Right bottom leg +
- usart_send_string(out_port, "#2 P1800 S1000\n"); +
- usart_send_string(out_port, "#3 P1300 S1000\n"); +
- hw_delay_ms(300); +
- usart_send_string(out_port, "#2 P1500 S1000\n"); +
- hw_delay_ms(300); +
- // Left bottom leg +
- usart_send_string(out_port, "#6 P1800 S1000\n"); +
- usart_send_string(out_port, "#7 P1300 S1000\n"); +
- hw_delay_ms(300); +
- usart_send_string(out_port, "#6 P1500 S1000\n"); +
- hw_delay_ms(300); +
- usart_send_string(out_port, "#P1500 S1000\n"); +
- usart_send_string(out_port, "#2 P1500 S1000\n"); +
- usart_send_string(out_port, "#4 P1500 S1000\n"); +
- usart_send_string(out_port, "#6 P1500 S1000\n");+
  hw_delay_ms(300);  hw_delay_ms(300);
 +// 
 + usart_send_string(out_port, "#12 P1100 #28 P1600 #19 P900 #3 P1400 T500\r");
 + hw_delay_ms(1000);
 + }
 + else if(c=='q'){
 + pos[0]+=inc;
 + sprintf(str, "#0 P%i \r", pos[0]);
 + usart_send_string(out_port, str);
 + }
 + else if(c=='w'){
 + pos[0]-=inc;
 + sprintf(str, "#0 P%i \r", pos[0]);
 + usart_send_string(out_port, str);
 + }
 + else if(c=='e'){
 + pos[1]-=inc;
 + sprintf(str, "#3 P%i \r", pos[1]);
 + usart_send_string(out_port, str);
 + }
 + else if(c=='r'){
 + pos[1]+=inc;
 + sprintf(str, "#3 P%i \r", pos[1]);
 + usart_send_string(out_port, str);
 + }
 +
 + // Right upper leg
 + else if(c=='t'){
 + pos[2]-=inc;
 + sprintf(str, "#16 P%i \r", pos[2]);
 + usart_send_string(out_port, str);
 + }
 + else if(c=='y'){
 + pos[2]+=inc;
 + sprintf(str, "#16 P%i \r", pos[2]);
 + usart_send_string(out_port, str);
 + }
 + else if(c=='u'){
 + pos[3]+=inc;
 + sprintf(str, "#19 P%i \r", pos[3]);
 + usart_send_string(out_port, str);
 + }
 + else if(c=='i'){
 + pos[3]-=inc;
 + sprintf(str, "#19 P%i \r", pos[3]);
 + usart_send_string(out_port, str);
 + }
 +
 + // Left bottom leg
 + else if(c=='o'){
 + pos[4]-=inc;
 + sprintf(str, "#31 P%i \r", pos[4]);
 + usart_send_string(out_port, str);
 + }
 + else if(c=='p'){
 + pos[4]+=inc;
 + sprintf(str, "#31 P%i \r", pos[4]);
 + usart_send_string(out_port, str);
 + }
 + else if(c=='['){
 + pos[5]+=inc;
 + sprintf(str, "#28 P%i \r", pos[5]);
 + usart_send_string(out_port, str);
 + }
 + else if(c==']'){
 + pos[5]-=inc;
 + sprintf(str, "#28 P%i \r", pos[5]);
 + usart_send_string(out_port, str);
 + }
 +
 + // Right bottom leg
 + else if(c=='g'){
 + pos[6]+=inc;
 + sprintf(str, "#15 P%i \r", pos[6]);
 + usart_send_string(out_port, str);
 + }
 + else if(c=='h'){
 + pos[6]-=inc;
 + sprintf(str, "#15 P%i \r", pos[6]);
 + usart_send_string(out_port, str);
 + }
 + else if(c=='j'){
 + pos[7]-=inc;
 + sprintf(str, "#12 P%i \r", pos[7]);
 + usart_send_string(out_port, str);
 + }
 + else if(c=='k'){
 + pos[7]+=inc;
 + sprintf(str, "#12 P%i \r", pos[7]);
 + usart_send_string(out_port, str);
 + c='.';
  }  }
  }  }
-  }+} 
 +</code> 
 + 
 +The source for personal computer: 
 + 
 +<code c> 
 +#include <QtGui/QApplication> 
 +#include "mainwindow.h" 
 + 
 +int main(int argc, char *argv[]) 
 +
 +    QApplication a(argc, argv); 
 +    MainWindow w; 
 +//    w.setFixedSize(650, 380); 
 +    w.show();
  
 +    return a.exec();
 +}
 </code> </code>
 +<code c>
 +#include "mainwindow.h"
 +#include <rs232/rs232.c>
 +#include <stdio.h>
 +#include <iostream>
 +#include <string>
  
-====6.3. Construction.====+MainWindow::MainWindow(QWidget *parent) 
 +    : QWidget(parent) 
 +
 +    h_layout_ports=new QHBoxLayout; 
 +    h_layout_buttons=new QHBoxLayout; 
 +    g_layout=new QGridLayout; 
 +    textEdit_log=new QTextEdit; 
 + 
 +    //  Commands: legs 
 +    list_char_commands_legs 
 +            << 'q' << 'w' << 'e' << 'r' //  Left upper leg 
 +            << 't' << 'y' << 'u' << 'i' //  Right upper leg 
 +            << 'o' << 'p' << '[' << ']' //  Left bottom leg 
 +            << 'g' << 'h' << 'j' << 'k'; // Right bottom leg 
 + 
 +    //  Commands: movements 
 +    list_char_commands_movements 
 +            << 'a'  //  Move forward 
 +            << 's'  //  Tern left 
 +            << 'd' //   Tern right 
 +            << 'f'; //  Stop 
 + 
 +    // Labels: legs 
 +    list_label_legs.append(new QLabel("Left upper leg")); 
 +    list_label_legs.append(new QLabel("Right upper leg")); 
 +    list_label_legs.append(new QLabel("Right bottom leg")); 
 +    list_label_legs.append(new QLabel("Left bottom leg")); 
 + 
 +    //  Buttons: legs 
 +    for(int i=0; i<4; i++){ 
 +        list_button_legs.append(new QPushButton("Up")); 
 +        list_button_legs.append(new QPushButton("Down")); 
 +        list_button_legs.append(new QPushButton("Forward")); 
 +        list_button_legs.append(new QPushButton("Backward")); 
 +    } 
 + 
 +    //  Buttons: movements 
 +    list_button_movements.append(new QPushButton("Move\nForward")); 
 +    list_button_movements.append(new QPushButton("Turn\nLeft")); 
 +    list_button_movements.append(new QPushButton("Turn\nRight")); 
 +    list_button_movements.append(new QPushButton("Stop")); 
 + 
 +    //  Horizontal layout: movements' buttons 
 +    //  Fixed size: movements' buttons 
 +    //  Connection: movements' buttons and movement_buttons_push() 
 +    for(int i=0; i<list_button_movements.size(); i++){ 
 +        h_layout_buttons->addWidget(list_button_movements.at(i)); 
 +        list_button_movements.at(i)->setFixedSize(100, 50); 
 +        connect(list_button_movements.at(i), SIGNAL(pressed()), this, SLOT(movement_buttons_push())); 
 +    } 
 + 
 +    // Connection: legs' buttons and legs_buttons_push() 
 +    for(int i=0; i<list_button_legs.size(); i++){ 
 +        connect(list_button_legs.at(i), SIGNAL(pressed()), this, SLOT(legs_buttons_push())); 
 +    } 
 + 
 +    //  Horizontal layouts: legs' buttons 
 +    for(int i=0; i<4; i++){ 
 +        list_hLayout_buttons.append(new QHBoxLayout); 
 +        for(int k=i*4; k<4*i+4; k++){ 
 +            list_hLayout_buttons.at(i)->addWidget(list_button_legs.at(k)); 
 +        } 
 +    } 
 + 
 +    //  Open serial ports 
 +    //  Horizontal layoyt: ports 
 +    int usb_ports=16; 
 +    for(int i=0; i<4; i++){ 
 +        if(OpenComport(usb_ports, 9600)==0){ 
 +            QString str; 
 +            str.sprintf("Port %i", i); 
 +            list_radio_button_ports.append(new QRadioButton(str)); 
 +            h_layout_ports->addWidget(list_radio_button_ports.at(i)); 
 +            usb_ports++; 
 +        } 
 +        else break; 
 +    } 
 + 
 +    //  Grid layout 
 +    g_layout->addLayout(h_layout_ports, 0, 0); 
 +    g_layout->addLayout(h_layout_buttons, 1, 0); 
 +    for(int i=0; i<list_hLayout_buttons.size(); i++){ 
 +        g_layout->addWidget(list_label_legs.at(i), (i+2)*2, 0); 
 +        g_layout->addLayout(list_hLayout_buttons.at(i), (i+2)*2+1, 0); 
 +    } 
 +    g_layout->addWidget(textEdit_log, 12, 0); 
 + 
 +    //  Set layout of main window 
 +    setLayout(g_layout); 
 +
 + 
 +MainWindow::~MainWindow() 
 +
 + 
 +
 +void MainWindow::legs_buttons_push(){ 
 +    for(int i=0; i<list_button_legs.size(); i++){ 
 +        if(list_button_legs.at(i)->isDown()){ 
 +            for(int k=0; k<list_radio_button_ports.size(); k++){ 
 +                if(list_radio_button_ports.at(k)->isChecked()){ 
 +                    SendByte(16+k, list_char_commands_legs.at(i)); 
 +                } 
 +            } 
 +        } 
 +        else{ 
 +            for(int k=0; k<list_radio_button_ports.size(); k++){ 
 +                if(list_radio_button_ports.at(k)->isChecked()){ 
 +                    SendByte(16+k, '.'); 
 +                } 
 +            } 
 +        } 
 +    } 
 +
 +void MainWindow::movement_buttons_push(){ 
 +    for(int i=0; i<list_button_movements.size(); i++){ 
 +        if(list_button_movements.at(i)->isDown()){ 
 +            for(int k=0; k<list_radio_button_ports.size(); k++){ 
 +                if(list_radio_button_ports.at(k)->isChecked()){ 
 +                    SendByte(16+k, list_char_commands_movements.at(i)); 
 +                } 
 +            } 
 +        } 
 +    } 
 +
 +</code> 
 +<code c> 
 +#ifndef MAINWINDOW_H 
 +#define MAINWINDOW_H 
 + 
 +#include <QtGui> 
 + 
 +class MainWindow : public QWidget 
 +
 +    Q_OBJECT 
 + 
 +public: 
 +    MainWindow(QWidget *parent = 0); 
 +    ~MainWindow(); 
 +public slots: 
 +    void movement_buttons_push(); 
 +    void legs_buttons_push(); 
 +private: 
 +    QGridLayout *g_layout; 
 +    QHBoxLayout *h_layout_ports, *h_layout_buttons; 
 +    QList<QRadioButton *> list_radio_button_ports; 
 +    QList<QLabel *> list_label_legs; 
 +    QList<QPushButton *> list_button_legs; 
 +    QList<QPushButton *> list_button_movements; 
 +    QList<QHBoxLayout *> list_hLayout_buttons; 
 +    QList<char> list_char_commands_legs, list_char_commands_movements; 
 +    QTextEdit *textEdit_log; 
 +}; 
 + 
 +#endif // MAINWINDOW_H 
 +</code> 
 + 
 +  *{{http://home.fill.ee/~rda/meh_proekt_gui/mehProekt_kaugjuhitavSpy_mc.c}} 
 + 
 +  *{{http://home.fill.ee/~rda/meh_proekt_gui/main.cpp}} 
 + 
 +  *{{http://home.fill.ee/~rda/meh_proekt_gui/mainwindow.cpp}} 
 + 
 +  *{{http://home.fill.ee/~rda/meh_proekt_gui/mainwindow.h}} 
 + 
 +====6.4. Construction.====
  
 During the last part of the development we were given access to tools to make parts for our robot. At first we decided it would be best to make the robot out of aluminium for its good characteristics, but after we tried to make the first leg it was decided that plastic would suit best with its lighter possibilities for remodelling and sculpting. During the last part of the development we were given access to tools to make parts for our robot. At first we decided it would be best to make the robot out of aluminium for its good characteristics, but after we tried to make the first leg it was decided that plastic would suit best with its lighter possibilities for remodelling and sculpting.
 The Picture 4 Spider leg  shows a built leg of our robot. The horizontal part is referred to as “base part” the second half of the leg is referred to as “joint part”.  The Picture 4 Spider leg  shows a built leg of our robot. The horizontal part is referred to as “base part” the second half of the leg is referred to as “joint part”. 
 In both joint and base part a holes of 2,5 mm were made for attachment of servo motors. In the base part is also a cut was made to fit and attach a servo motor. A similar cut were made in the platform to fit the four servos that move the base parts. There are four 3mm holes that attach the servo motor in its place on the base and on the platform. The platform is fit with 4 holes of 4mm on the axes to hold an upper platform for controller and driver mounting. In both joint and base part a holes of 2,5 mm were made for attachment of servo motors. In the base part is also a cut was made to fit and attach a servo motor. A similar cut were made in the platform to fit the four servos that move the base parts. There are four 3mm holes that attach the servo motor in its place on the base and on the platform. The platform is fit with 4 holes of 4mm on the axes to hold an upper platform for controller and driver mounting.
 +
 +{{http://static1.fotoalbum.ee/fotoalbum/332/152/083076275dfe38.jpg}}
 +{{http://static1.fotoalbum.ee/fotoalbum/332/152/0830762777f11d.jpg}}
 +
 +Picture 6 Detail drawings
  
 {{http://static1.fotoalbum.ee/fotoalbum/330/77/0825386775fd16.jpg?400}}  {{http://static1.fotoalbum.ee/fotoalbum/330/77/0825386775fd16.jpg?400}} 
  
-Picture Spider leg+Picture Spider leg
  
 {{http://static1.fotoalbum.ee/fotoalbum/332/77/08303862927a00.jpg?400}} {{http://static1.fotoalbum.ee/fotoalbum/332/77/08303862927a00.jpg?400}}
 {{http://static1.fotoalbum.ee/fotoalbum/332/77/08303863122f24.jpg?400}} {{http://static1.fotoalbum.ee/fotoalbum/332/77/08303863122f24.jpg?400}}
  
-Picture Assembled spider+Picture Assembled spider
  
    
et/projects/tudengid11/kaugjuhitav2.1302218132.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0