This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| et:projects:tudengid11:kaugjuhitav2 [2011/04/07 23:15] – mihhail smirnov | et: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:// |
| + | |||
| + | Picture 2 Block diagram | ||
| + | |||
| + | ====6.2. Spider concept and parts.==== | ||
| {{http:// | {{http:// | ||
| - | Picture | + | Picture |
| Line 121: | Line 126: | ||
| ^Total | ^Total | ||
| - | ====6.2. Algorithm and programming.==== | + | ====6.3. Algorithm and programming.==== |
| {{http:// | {{http:// | ||
| - | Picture | + | Picture |
| 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:// | ||
| + | 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 < | #include < | ||
| - | #include < | + | #include < |
| - | // COM connector | + | #include < |
| - | usart in_port = USART(0); | + | #include < |
| - | // 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, | ||
| + | int pos[sizeof(init_pos)/ | ||
| + | for(i=0; i< | ||
| + | pos[i]=init_pos[i]; | ||
| + | } | ||
| + | |||
| // | // | ||
| 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, | usart_try_read_char(in_port, | ||
| - | if(c=="move forward" | + | if(c==' |
| - | // Left top leg | + | // Initial positionв |
| - | usart_send_string(out_port, | + | usart_send_string(out_port, |
| - | usart_send_string(out_port, | + | "# |
| - | hw_delay_ms(300); | + | for(i=0; i<sizeof(pos)/sizeof(int); i++){ |
| - | usart_send_string(out_port, | + | pos[i]=init_pos[i]; |
| - | hw_delay_ms(300); | + | } |
| - | usart_send_string(out_port, | + | |
| - | // Right bottom leg | + | |
| - | usart_send_string(out_port, | + | |
| - | usart_send_string(out_port, | + | |
| - | hw_delay_ms(300); | + | |
| - | usart_send_string(out_port, | + | |
| - | hw_delay_ms(300); | + | |
| - | usart_send_string(out_port, | + | |
| - | // Right top leg | + | |
| - | usart_send_string(out_port, | + | |
| - | usart_send_string(out_port, | + | |
| - | hw_delay_ms(300); | + | |
| - | usart_send_string(out_port, "#4 P1500 S1000\n" | + | |
| - | hw_delay_ms(300); | + | |
| - | usart_send_string(out_port, | + | |
| - | // Left bottom leg | + | |
| - | usart_send_string(out_port, "#6 P1800 S1000\n" | + | |
| - | usart_send_string(out_port, | + | |
| - | hw_delay_ms(300); | + | |
| - | usart_send_string(out_port, | + | |
| - | hw_delay_ms(300); | + | |
| - | usart_send_string(out_port, | + | |
| } | } | ||
| - | else if(c=="turn left"){ | + | // Left upper leg |
| - | // Left top leg | + | else if(c==' |
| - | usart_send_string(out_port, | + | /* |
| - | usart_send_string(out_port, | + | Left bottom |
| + | */ | ||
| + | usart_send_string(out_port, | ||
| hw_delay_ms(300); | hw_delay_ms(300); | ||
| - | usart_send_string(out_port, | + | usart_send_string(out_port, |
| hw_delay_ms(300); | hw_delay_ms(300); | ||
| - | // Right top leg | + | usart_send_string(out_port, |
| - | usart_send_string(out_port, | + | |
| - | usart_send_string(out_port, | + | |
| hw_delay_ms(300); | hw_delay_ms(300); | ||
| - | usart_send_string(out_port, | + | /* |
| + | Right bottom leg | ||
| + | */ | ||
| + | usart_send_string(out_port, | ||
| hw_delay_ms(300); | hw_delay_ms(300); | ||
| - | // Right bottom leg | + | usart_send_string(out_port, |
| - | usart_send_string(out_port, | + | |
| - | usart_send_string(out_port, | + | |
| hw_delay_ms(300); | hw_delay_ms(300); | ||
| - | usart_send_string(out_port, | + | usart_send_string(out_port, |
| hw_delay_ms(300); | hw_delay_ms(300); | ||
| - | // Left bottom | + | /* |
| - | usart_send_string(out_port, | + | Right upper leg |
| - | usart_send_string(out_port, | + | */ |
| + | usart_send_string(out_port, | ||
| hw_delay_ms(300); | hw_delay_ms(300); | ||
| - | usart_send_string(out_port, | + | usart_send_string(out_port, |
| hw_delay_ms(300); | hw_delay_ms(300); | ||
| - | usart_send_string(out_port, | + | usart_send_string(out_port, |
| - | usart_send_string(out_port, | + | |
| - | usart_send_string(out_port, | + | |
| - | usart_send_string(out_port, | + | |
| hw_delay_ms(300); | hw_delay_ms(300); | ||
| - | else if(c==" | + | /* |
| - | // Left top leg | + | Left upper leg |
| - | usart_send_string(out_port, | + | */ |
| - | usart_send_string(out_port, | + | usart_send_string(out_port, |
| hw_delay_ms(300); | hw_delay_ms(300); | ||
| - | usart_send_string(out_port, | + | usart_send_string(out_port, |
| hw_delay_ms(300); | hw_delay_ms(300); | ||
| - | // Right top leg | + | usart_send_string(out_port, |
| - | usart_send_string(out_port, | + | |
| - | usart_send_string(out_port, | + | |
| - | hw_delay_ms(300); | + | |
| - | usart_send_string(out_port, | + | |
| - | hw_delay_ms(300); | + | |
| - | // Right bottom leg | + | |
| - | usart_send_string(out_port, | + | |
| - | usart_send_string(out_port, | + | |
| - | hw_delay_ms(300); | + | |
| - | usart_send_string(out_port, | + | |
| - | hw_delay_ms(300); | + | |
| - | // Left bottom leg | + | |
| - | usart_send_string(out_port, | + | |
| - | usart_send_string(out_port, | + | |
| - | hw_delay_ms(300); | + | |
| - | usart_send_string(out_port, | + | |
| - | hw_delay_ms(300); | + | |
| - | usart_send_string(out_port, | + | |
| - | usart_send_string(out_port, | + | |
| - | usart_send_string(out_port, | + | |
| - | usart_send_string(out_port, | + | |
| hw_delay_ms(300); | hw_delay_ms(300); | ||
| + | // | ||
| + | usart_send_string(out_port, | ||
| + | hw_delay_ms(1000); | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[0]+=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[0]-=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[1]-=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[1]+=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | |||
| + | // Right upper leg | ||
| + | else if(c==' | ||
| + | pos[2]-=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[2]+=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[3]+=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[3]-=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | |||
| + | // Left bottom leg | ||
| + | else if(c==' | ||
| + | pos[4]-=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[4]+=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[5]+=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[5]-=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | |||
| + | // Right bottom leg | ||
| + | else if(c==' | ||
| + | pos[6]+=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[6]-=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[7]-=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | } | ||
| + | else if(c==' | ||
| + | pos[7]+=inc; | ||
| + | sprintf(str, | ||
| + | usart_send_string(out_port, | ||
| + | c=' | ||
| } | } | ||
| } | } | ||
| - | | + | } |
| + | </ | ||
| + | |||
| + | The source for personal computer: | ||
| + | |||
| + | <code c> | ||
| + | #include < | ||
| + | #include " | ||
| + | |||
| + | int main(int argc, char *argv[]) | ||
| + | { | ||
| + | QApplication a(argc, argv); | ||
| + | MainWindow w; | ||
| + | // w.setFixedSize(650, | ||
| + | w.show(); | ||
| + | return a.exec(); | ||
| + | } | ||
| </ | </ | ||
| + | <code c> | ||
| + | #include " | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| - | ====6.3. Construction.==== | + | MainWindow:: |
| + | : 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 | ||
| + | << ' | ||
| + | << ' | ||
| + | << ' | ||
| + | << ' | ||
| + | |||
| + | // Commands: movements | ||
| + | list_char_commands_movements | ||
| + | << ' | ||
| + | << ' | ||
| + | << ' | ||
| + | << ' | ||
| + | |||
| + | // Labels: legs | ||
| + | list_label_legs.append(new QLabel(" | ||
| + | list_label_legs.append(new QLabel(" | ||
| + | list_label_legs.append(new QLabel(" | ||
| + | list_label_legs.append(new QLabel(" | ||
| + | |||
| + | // Buttons: legs | ||
| + | for(int i=0; i<4; i++){ | ||
| + | list_button_legs.append(new QPushButton(" | ||
| + | list_button_legs.append(new QPushButton(" | ||
| + | list_button_legs.append(new QPushButton(" | ||
| + | list_button_legs.append(new QPushButton(" | ||
| + | } | ||
| + | |||
| + | // Buttons: movements | ||
| + | list_button_movements.append(new QPushButton(" | ||
| + | list_button_movements.append(new QPushButton(" | ||
| + | list_button_movements.append(new QPushButton(" | ||
| + | list_button_movements.append(new QPushButton(" | ||
| + | |||
| + | // Horizontal layout: movements' | ||
| + | // Fixed size: movements' | ||
| + | // Connection: movements' | ||
| + | for(int i=0; i< | ||
| + | h_layout_buttons-> | ||
| + | list_button_movements.at(i)-> | ||
| + | connect(list_button_movements.at(i), | ||
| + | } | ||
| + | |||
| + | // Connection: legs' buttons and legs_buttons_push() | ||
| + | for(int i=0; i< | ||
| + | connect(list_button_legs.at(i), | ||
| + | } | ||
| + | |||
| + | // 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)-> | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // Open serial ports | ||
| + | // Horizontal layoyt: ports | ||
| + | int usb_ports=16; | ||
| + | for(int i=0; i<4; i++){ | ||
| + | if(OpenComport(usb_ports, | ||
| + | QString str; | ||
| + | str.sprintf(" | ||
| + | list_radio_button_ports.append(new QRadioButton(str)); | ||
| + | h_layout_ports-> | ||
| + | usb_ports++; | ||
| + | } | ||
| + | else break; | ||
| + | } | ||
| + | |||
| + | // Grid layout | ||
| + | g_layout-> | ||
| + | g_layout-> | ||
| + | for(int i=0; i< | ||
| + | g_layout-> | ||
| + | g_layout-> | ||
| + | } | ||
| + | g_layout-> | ||
| + | |||
| + | // Set layout of main window | ||
| + | setLayout(g_layout); | ||
| + | } | ||
| + | |||
| + | MainWindow:: | ||
| + | { | ||
| + | |||
| + | } | ||
| + | void MainWindow:: | ||
| + | for(int i=0; i< | ||
| + | if(list_button_legs.at(i)-> | ||
| + | for(int k=0; k< | ||
| + | if(list_radio_button_ports.at(k)-> | ||
| + | SendByte(16+k, | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | else{ | ||
| + | for(int k=0; k< | ||
| + | if(list_radio_button_ports.at(k)-> | ||
| + | SendByte(16+k, | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | void MainWindow:: | ||
| + | for(int i=0; i< | ||
| + | if(list_button_movements.at(i)-> | ||
| + | for(int k=0; k< | ||
| + | if(list_radio_button_ports.at(k)-> | ||
| + | SendByte(16+k, | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | <code c> | ||
| + | #ifndef MAINWINDOW_H | ||
| + | #define MAINWINDOW_H | ||
| + | |||
| + | #include < | ||
| + | |||
| + | 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, | ||
| + | QList< | ||
| + | QList< | ||
| + | QList< | ||
| + | QList< | ||
| + | QList< | ||
| + | QList< | ||
| + | QTextEdit *textEdit_log; | ||
| + | }; | ||
| + | |||
| + | #endif // MAINWINDOW_H | ||
| + | </ | ||
| + | |||
| + | *{{http:// | ||
| + | |||
| + | *{{http:// | ||
| + | |||
| + | *{{http:// | ||
| + | |||
| + | *{{http:// | ||
| + | |||
| + | ====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, | 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, | ||
| 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:// | ||
| + | {{http:// | ||
| + | |||
| + | Picture 6 Detail drawings | ||
| {{http:// | {{http:// | ||
| - | Picture | + | Picture |
| {{http:// | {{http:// | ||
| {{http:// | {{http:// | ||
| - | Picture | + | Picture |