Saturday, January 25, 2014

Robot makers: a funny head for your bot





We start this new section of our blog building a funny head for our future bot. As usual, we try to spend the less money we can and to have a nice final result. The idea is to build the head on top of a 2-DOF bracket as the one in the following figure that you can easily found on the market for a few bucks.


The material
Here is the list of the material you need for this instructable. All of them can easily be found either on your waste basket or in your pencil case.

Some construction paper. I used the paper box of cakes that you can
see in this figure.

A pair of scissors.

A pencil (and probably an eraser ;-) ). A ruler with millimeters scale will
also be of great help.
And the HC-SR04, your preferred ultrasonic sensor.

A 2-DOF pan-tilt bracket on which we will mount the head of our bot.

And some female-to-male cables (at least four to connect the HC-SR04 sensor).

First step
Draw on the construction paper the following diagram and cut it along the thick lines. Remark that according to the thickness of your paper you should adjust dimensions so that global dimensions are respected.

Second step
Draw on the hard paper the following diagram and cut it along the thick lines.

Friday, January 17, 2014

SG90: a mini-servo motor





This is a a very handy and cheap servo motor with nice performances. It is suitable for many lightweight applications. We will use it to motorize a 2-DOF Tilt-Pan on which we will mount our preferred ultrasonic sonar sensor, namely the HC-SR04. Before proceeding let us review the main specs. 


Basics
Brand:             Tower Pro
Modulation:     Analog
Torque:           1.8 Kg.cm (at 4.8V)
Speed:             0.12 s/60° (at 4.8V)
Motor type:      3 poles
Gear type:        Plastic (Nylon)
Rot./Support:    Bushing
Supply voltage: 3V-6V

Pinout
Red wire:      +Vcc
Brown wire:  GND
Orange wire: Signal

Physical dimensions
Length: 23mm
Width:  12mm
Height:  29mm
Weight: 9g


Additional infos
Pulse width: 500-2400 μs
Rotational range: 180° (nominal)
Operation
The servo is controlled by sending pulses of width between 500 and 2400 μs. At each pulse the servo will rotate of 1°. Then, you should wait for 20ms for the servo to reach the position before sending the next pulse.


Programming
In order to experiment with the servo, you can use the Servo library at Arduino.cc. You can also follow this small tutorial/example.
Caveats
Remark that a servo is power consuming and that the Arduino can drive limited current (up to 40mA) per pin. Moreover, the total current output is 200mA. Therefore, it is not a good idea to drive directly more than two SG90, otherwise you risk to damage your Arduino.

Sunday, January 5, 2014

HC-SR04: beats phenomenon?





In this post we argued that the beats phenomenon takes place when using the HC-SR04 sensor. We start from the initial experiments and we plot the measures obtained from the sensor against their occurrence time (see Figure 1 below). 


Figure 1. Recollecting data from the previous experiments.
What we remark from the figure is that for the first about 1700 time units the measured value oscillates between the value 982 and 984 (with very few errors). After 1700 time units, the sensor starts oscillating mainly between values 1002  and 1003 in most cases (remark that there are still many oscillations between 982 and 984).

So we have two thing to explain:
  1. why the measures oscillate (mainly) between two values?
  2. is there a truly beats phenomenon for explaining the oscillations after time 1700? Or is it simply due to some characteristics of the sensor ? Or is due to some interference with Arduino, for example with IRQ service?
Answering the first question is easy. Indeed, according to Arduino specs, the precision is up to 3us. Answering the second question is more complicated and requires a series of experiments. We start from the very last one since it is the easiest one. We just restart our main experiment (see this post) disabling interrupts.

Figure 2 below illustrates the results of this second batch of experiments.


Figure 2. The second batch of experiments.
And here is the surprise! We only remark oscillations between the value 984 (the correct value) and 982 with practically negligible exceptions!

Conclusions.
There is no beats phenomenon going on. The second oscillation observed in early experiments (see Figure 1) is due to the interaction between IRQ service and the HC-SR04 sensor. The oscillations between value 984 and 982 (see Figure 2) are compatible with the approximation error in Arduino specs.

What's next
We are going to test the US-020 ultrasonic sensor. So, as usual, stay tuned!


See also