top of page

About Arnie

Arnie is a little (but not too little ;)) robotic arm, printed on 3D printer and controlled by smartphone with Android OS via WiFI. At this moment, it can be controlled in three modes:

  • Simple Control - seek bars represent angular position of all robot's motors. Each of them can be set to any value from 0 to 180 degrees. Data is sent to the robot every time when value has been changed, what gives us real time position preview

  • Sequence Programming - User can build an actions (squences) and then, perform it by just clicking Start button. Building sequence is very intuitive. User can add, delete or change moves at any time with real time preview.

  • Joysticks - User can control whole robot with use of two special joysticks. It gives less accuracy, but better dynamic of controlling robot, becuase all motors can be easily controlled at the same time

Arnie.jpg

Microcontroller

Whole driver of the robot is handled by ATmega8 with internal 8MHz oscilator. It is probably the most popular and one of the cheapest uC today. In my opinion, microcontrollers like ATmega8 are good enough for simple one-task drivers, but using it for multi-task applications, even if possible, is very awkward.

In project, two modules were needed:

  • software PWM signals (ATmega8 has only two 16-bit PWMs)

  • wifi communication

Each of them is easy to implement separately, but major assumption was to achieve good stability of servo-motors (good quality of software PWMs). The problem is that in microcontroller we have only one thread (main function). If PWM driver and handling communication would be on the same thread, WiFi could took too much processor's time and affect motors. First attempt to solve the problem was to give PWM driver higher priority than communication and implement generating signals in interrupts. Unfortunately, 8MHz is too little to handle controlling servos on software timer. ATmega8 could generate interrupt every 50us with still stable working (not affecting communication too much). PWM signal for servo-motors has period of 20ms, where pulse width vary from 0.7ms to 2.2ms (total 1.5ms). It gives us:

 

software_timer_freq = 1s / timer_interrupt_period = 1s / 50us = 20000Hz

 

Our software timer will increment 20000 times per second. We need to overflow it with frequence of 50Hz (PWM frequence):

 

20000Hz / 50Hz = 400

 

Counter should be reset every 400 ticks. That means, software PWM has 0.05ms resolution (20ms = 400 ticks).

 

400 * (1.5ms / 20ms) = 30

180* / 30 = 6*

 

Servo motor driver has 6 degrees resolution. This is terrible resolution for robot. It is very stable and communication do not affect motors, but they can't move smoothly. Solution will be explained in software section.

Software

Software is divided into four layers:

  • main program

    • ESP module

      • USART (WiFi) communication

    • Software PWM

USART (WiFi) module

We can say that receiving data from USART is equal to receiving raw data from network sockets that ESP packed into special frames. USART module is responsible just for receiving this raw data into ringbuffer, without any process steps. It is necessary for performing fast, non-blocking data receiving in next layer.

ESP module

Here, data from USART module is parsed. Because we have already data in memory, we can check if whole frame has been received without waiting for bytes (and blocking thread). This module gives us decoded data that has been sent from the controller. It has also timeout parameter that allows optimize handling packets. If new frame has been detected, module will wait for all data to be received or time has passed.

Software PWM

This is very simple module that generates PWM signal with use of one 16-bit timer. Every time when servoUpdate() function is called, PWM output pins are updated. It allows also to set destination angular position of each motor and uses equation based on simple discrete transmitance to reach smooth move characteristics.

Main program

When we have all above modules, main function becomes pretty simple, but uses smart trick to create two virtual threads and maximize performance. Controlling servo motors with PWM needs 50Hz signal with impulse lasting up to 1.5ms. That means, high signal lasts maximum 1.5ms and low signal lasts at least 20ms-1.5ms=18.5ms. 18.5ms of generating... nothing. I decided to use the time while PWM module has nothing to do, to handle WiFi packets. For PWM module important is only the moment when signal becomes high or low. To reach the best quality of signal, PWM module takes all the processor's power for a 5ms to generate 0.7-1.5ms high signal. After this time, for next 15ms signal is low and program is switched to handle wifi packets.

Driver

Arnie is drived by ATmega8 and ESP-01 module (with ESP8266 chip). Microcontroller is responsible for controlling servomechanisms and communicate with WiFi module. Communication with ESP-01 is done by AT commands sent through USART interface.

 

Three LED diodes has been added to inform user about actual status of connection (ESP8266 initialized, server ready), but also for debug purpose while testing new software.

 

Servomotors and power suply are connected with use of goldpins. There are also goldpins connected to the programming pins of ATmega8 (MISO, MOSI, SCK, RESET).

738427ncPkgs6z.jpg

Arm model

Mechanical parts was definitely Achilles heel of this project, because there was no person with knowledge of mechanical aspects. Of course it seemed to be easy design the easiest robotic arm, but every developer know that if something seems to be easy, he just did not see the hardest parts. Few options has been considered:

  • handmade wooden model

  • simple metal model

  • model for 3D printer 

First option is very confortable. Everything is cheap and can be made independently, but result would be pretty bad. Second option is better in view of quality, but it would need spending time for designing metal model, learning tools, searching someone who would produce it. The last option is a great choice for indie developers nowadays. Many people, schools or student groups have their own 3D printer. A lot of models can be found in internet, but even if someone want to design its own model, it is very simple with 3D editors. That is why model for this project has been printed on 3D printer. Result is suprisly good.

 

Model of the robot has been found in internet (https://www.thingiverse.com/thing:1454048). It is very nicely designed. Its mechanical construction keeps the orientation of the last part of the arm (e.g. gripper) to be always parallel to the ground. All parts fit perfectly even when printed on one of the cheapest 3D printer. There was only needed to drill the holes and correct some surfaces to minimize resistance. Author also has made instructable of assembling the robot and the list of non-printed parts. Model is designed for TowerPro MG-994/MG-946 and TowerPro SG-90 (for gripper) motors.

bottom of page