Robotarakan Petya pour dix dollars

Rencontrez Petya, le servo Ă  trois pattes Ă  six pattes


Je continue de publier des articles de la série Arduino Brain. Petya est un hexapode très bon marché (une dizaine de dollars). Ce peut être un merveilleux projet pour un jour de congé pluvieux, qui divertira les adultes et les enfants. Puisque nous parlons de divertissement, voici une vidéo avec Petya dansant sur de la musique funk:



Bien sûr, je n'ai fait aucune analyse sonore, j'ai simplement programmé Petya pour danser à un certain rythme. Voici une autre vidéo dans laquelle Petya montre son mépris pour jongler avec des balles:



Dans sa forme actuelle, Petya ne peut que marcher, mais en même temps, il peut voir (mesurer la distance) des obstacles à proximité. Son cerveau, cependant, est suffisamment productif pour pouvoir digérer les données de nombreux autres capteurs, envoyez vos suggestions!


Comment cloner Petya


Liste de courses


3 , / . , :



, , . (, ), . . — . , ;)


NB: 9g , . . , , , SketchUp . , , , .




, 3 , hardware/body/. - ::



1, . - :



3 . , . :





. hardware/motherboard/. :



ATMega8 , . :



, , , . :



N.B. , ATMega8A 2.7-5.5, 6. — NiMH 1.2V . (6.4 ), , . , , !


( ):




, . ; . , , . , , , :



:



; , Q3 Q4 "" Vcc, , . :



, , , R6. 47 55 , ( ). , , (910 )!


( ). , CR2032, . ( , [] , , )
, , Q3 Q4 . , , , , , .


, . , . 2n3904, , , . , , .


, , , , :



.


, , :


  • isf471 2n3904.
  • Sharp GP2Y0A21YK0F:
  • LM393:


, , , ATMega8. :


  • -

-


50 ; 1 (0 ), 2 (90 ). , 16 (timer1), (timer2). , Servo.h , , fast PWM.


8 , timer1 1 ( 8).
ICR1 TOP (20000), , 20 , 50 . OCR1A OCR1B ( ) .


. timer2, , , ICR1, , . , 50 , , - :


  • timer2 128, , 4.096 ms = 256 * 128/(8 * 10^6).
  • timer2, , .
  • capture interrupt timer1 timer2 ( ).

4 2 , , 20 . , (1.5 ), :


OCR1A = 1500;    // left servo
OCR1B = 1500;    // right servo
OCR2  = 1500/16; // center servo


-, :


const uint8_t  zero[3] = {45, 50, 40};     // zero position of the servo (degrees)
const uint8_t range[3] = {25, 25, 20};     // the servos are allowed to move in the zero[i] +- range[i] interval

zero[3] , (. ). , 45° ( ), 45° , . , range[3] . , i zero[i]-range[i] zero[i]+range[i].



( , 0°-90°) uint8_t pos[3]. update_servo_timers() - . pos[i]=zero[i]+range[i] i=0,1,2.


. pos_beg[3], pos_end[3], time_start[3] duration[3]. , . :


  • pos[0] pos_beg[0], , ;
  • pos_end[0] (- );
  • time_start[0] (, );
  • , , duration[0] ( ). , (pos_end[0]-pos_beg[0])/duration[0] /.

movement_planner(), pos[] , update_servo_timers(), - pos[].



, , , ( ) . , . , . , :


  • 1: {zero[0]-range[0], zero[1]-range[1], zero[2]+range[2]}
  • 2: {zero[0]-range[0], zero[1]-range[1], zero[2]-range[2]}
  • 3: {zero[0]+range[0], zero[1]+range[1], zero[2]-range[2]}
  • 4: {zero[0]+range[0], zero[1]+range[1], zero[2]+range[2]}

2 ( ):


const int8_t advance_sequence[4][3] = {{-1, -1,  1}, {-1, -1, -1}, { 1,  1, -1}, { 1,  1,  1}};

, i step zero[i] + range[i]*advance_sequence[step][i].
:


    uint8_t step = steps_per_sequence-1; // at the initialization stage the (previous) movement is considered to be complete, thus the next movement will be planned starting from the step 0
    while (1) {
        if (is_movement_finished()) {
            step = (step + 1) % 4; // if previous movement is complete, then perform the next step; this variable loops as 0,1,2,3.
            plan_next_movement(step, advance_sequence); // execute next movement
        }
        movement_planner(); // update the servos position according to the planning
        _delay_ms(1);
    }


, , 4 5 . , ( , ), adc_left_eye adc_right_eye , :


        adc_left_eye  = adc_left_eye *.99 + adc_read(5)*.01; // low-pass filter on the ADC readings
        adc_right_eye = adc_right_eye*.99 + adc_read(4)*.01;

_delay_ms() , .99 1-.99 .


:


        uint8_t lobst = adc_left_eye  < distance_threshold; // obstacle on the left?
        uint8_t robst = adc_right_eye < distance_threshold; // obstacle on the right?

(, ) :


        if (is_movement_finished()) {
            if (!lobst && !robst) {
                sequence = advance_sequence; // no obstacles => go forward
            } else if (lobst && robst) {
                sequence = retreat_sequence; // obstacles left and right => go backwards
            } else if (lobst && !robst) {
                sequence = turn_right_sequence; // obstacle on the left => turn right
            } else if (!lobst && robst) {
                sequence = turn_left_sequence; // obstacle on the right => turn left
            }
            step = (step + 1) % steps_per_sequence; // if previous movement is complete, then perform the next step
            plan_next_movement(step, sequence); // execute next movement
        }

, !



! , , :


:


  • "", . , , . , ?
  • ( !) , , .
  • , , avr-gcc . , - .

:


, V2 , ! , // :


  • — , ;
  • , RC- ;
  • ;
  • R6 ;
  • ( ) ;
  • — . — , ;
  • DĂ©placez lĂ©gèrement l'Ă©lectrolyte. J'ai dĂ» l'incliner, car sinon, la jambe centrale gauche lui fait mal;
  • Ajoutez des sites de test avec un accès facile Ă  eux avec un oscilloscope;
  • Ajoutez une paire de LED de dĂ©bogage pour le dĂ©bogage sans oscilloscope;
  • Ajoutez des plots de soudure pour toutes les jambes de microprocesseur inutilisĂ©es pour le dĂ©bogage et l'expansion du robot.

Conclusion


Petya est terriblement amusant!



All Articles