Encoders

I have been doing some testing on my robot, in particular the wheels. I noticed, as expected, that the wheels do not turn at the same speed even when given the same command. This is a common problem and means that the robot does not drive in a straight line. The problem is even more evident when the robot is driving on carpet, as the rear castor takes a while to straighten up, meaning the robot drives on a curved trajectory. The solution to this issue is to add wheel encoders.  I have designed and built encoders in the past so I had a pretty good idea of what was required. I once designed an encoder that fits inside a servo housing, replacing the original electronics. The servos motor could be driven via a motor controller, as you would a normal motor, and the encoder would give feedback of the speed, allowing closed loop control. This design used an infra-red reflective sensor shining onto one of the gears inside the servo which had alternating black and white stripes painted onto it. When combined with a schmitt trigger, this set-up gave a series of pulses, the frequency of which was proportional to the speed of the motor. I didn’t want to use this exact design on my humanoid robot. I didn’t want to modify the servo to run as a normal motor as more hardware would be needed in the form of a motor controller. I decided to use a variation of the design but with the encoder external of the servo, shining onto the wheel itself.  The resolution of the encoder would not be as good doing it this way but it was a sacrifice I was willing to make.

I decided to use the QRD1114 sensor. This is a popular sensor and is used for line following robots quite a lot. It can detect the difference between black and white surfaces, due to the way the IR light reflects or is absorbed by the surface. I wanted to incorporate a schmitt trigger into the design to ensure the output of the encoder is a clean, square wave. I have designed and build these in the past using a comparator and a bunch of resistors. However, after some research I found a buffer chip that will do the job without any external components. The part number is SN74LVC1G17DBVR. It’s a tiny, surface mount chip, perfect for the job. The circuit schematic for the encoder is shown below.

Encoder schematic

Encoder schematic

I designed the board for the encoders and fabricated them. For the wheel I needed a disk with alternate black and white stripes printed onto it. I designed the pattern, using  Inkscape and printed it on a laser printer. I cut out the design and glued it to the wheel. I mounted the encoder so that the IR sensor was shining onto the striped pattern. I cut slotted holes to mount the encoder to allow for adjustment. The pictures below show the encoder mounted on the robot.

Side view of encoder mounted to robot

Side view of encoder mounted to robot

Encoder aligned with the wheel

Encoder aligned with the wheel

This set-up gives around 40 pulses per revolution of the wheel. I have connected the signal from the encoders to an external interrupt on the Arduino and set it up so that an interrupt occurs on a change of state. This means the count is incremented every time the encoders sees a change from black to white or vice versa.

I am happy with these encoders. The resolution is not brilliant but is more than sufficient to keep the robot driving in a straight line. I have written a control loop for each wheel, just proportional control at the moment, to keep the wheels spinning at a constant speed.

Advertisements

Battery powered Pi and servo switch

This post will outline the details of a couple of circuits I designed and built for my robot. The first is a regulator to supply my Raspberry Pi with power from a 7.2V battery. Although a simple circuit, it has some features that make it very easy to use to power the pi. Below is the schematic for the circuit, designed using Eagle.

Regulator circuit for Raspberry Pi battery supply

Regulator circuit for Raspberry Pi battery supply

The regulator is a 3A, 5V low drop out regulator (part no MIC29300-5.0WT) even though the schematic shows a different regulator. I realise that using a regulator like this is not the most efficient way of dropping voltage. As the current draw is relatively low (measured at around 0.7-0.8A with everything plugged in and running) and not a huge voltage drop is needed (8V for a fully charged battery dropped to 5V) then this approach is sufficient and quite cost effective. A good heat sink is required for the regulator, which I found out after making the circuit and not leaving enough room for a large heat sink. The regulator has been performing well with just a small heat sink for the moment but gets quite hot. I’m going to see how this goes and maybe redesign the PCB to allow for a bigger heat sink at some point. The feature I included in this design was having the 5V output connected to a USB socket, and also to some screw terminals. This means a standard  cable can be used to connect power to the Raspberry Pi’s USB power connector. The screw terminals allow power to also be connected to my USB hub. The picture below shows the circuit built and mounted to my robot.

Regulator built and mounted to robot

Regulator built and mounted to robot

The second circuit designed and built for my humanoid robot is a switch to turn the servo supply on and off. Let me explain why this is useful. At the moment, the Raspberry Pi on my robot is running headless and I am using a laptop to connect to the Pi via SSH. I can run my python GUI and control the robot from the laptop. I wanted a way to switch the servo power on when I run the GUI and off again when the program is closed. This will help the batteries last longer by cutting the power when I’m playing around with code and saves my legs walking over to the robot to power up the servos when its time to test said code. Anyway, below is the schematic for the circuit.

Servo switch schematic

Servo switch schematic

The relay used has a 6V coil and I’m using the supply voltage for the servos to switch the relay. A 2N2222 transistor is used to switch voltage to the coil with an output from the Arduino switching the transistor. A resistor to limit current, and another to pull the transistor gate low when the output from the Arduino is low or not present are required. Also a diode across the relay coil is recommended. I have built and tested this circuit and mounted it to the robot. I works great and does exactly what I intended it to do. The picture below shows the circuit in all its glory.

Servo power switch

Servo power switch

With the addition of these two circuits and some fully charged batteries, my robot can now roam around untethered. I really need to work on some code now to take advantage of this. Another task on my to-do list is to design and build some optical encoders for the wheels. I’ll be sure to keep you informed of any progress I make.

Touchy feely…

I’ve finished the improved potentiometer mounts on my humanoid robot and they are working well and much sturdier than the previous design. I’ve been working on an improvement to the robot that I’ve been planning for a while. As the title of this post may have given away, I am giving my robot a sense of touch. I have been toying with the idea for a few months now and I have found some time to start work on it. I wanted the robot to be able to sense when its hand has touched something, ideally from any angle. I tried a design that involved a spring mounted to the end of the robots arm, with a bolt passing through the middle of the spring. A ball mounted on the end of the spring was to be the robots new hand. The idea was that the spring would deflect when the hand touched something and make contact with the bolt. This would act as a switch and be connected to a digital input of the Arduino. I fabricated a prototype of this arrangement and whilst it worked reasonably well, the spring had to be quite stiff, to avoid false triggering as the arm moved about. This meant that the hand would have to push objects quite hard before the switch would trigger. What I really wanted was a switch that would trigger at the slightest touch and this design didn’t really meet the requirements.

I went back to the drawing board and revisited the idea I had initially for a sense of touch. This was simply to use tactile switches mounted to the hand that switched when they hit something. I have made a couple of quick circuits on strip-board that are simply a tactile switch and a connector. I have mounted these circuits to two sides of the robots hand. I already had connections on my interface board for switches so connecting these up was easy. Have a look at the picture below to see how these look mounted to the robot hand. As an experiment I have glued a bit of a cable tie to the tactile switch to extend the range of the switch and make it trigger a bit easier. This helps the switch trigger no matter what angle the hand hits an object. Seems to work really well!

Hand switches

I have connected the switches to the Arduino and modified the Arduino software to read the switches and added a switch status byte to the data packet being sent to the pc. I have also added to my Python code to graphically display the switch status on the screen.

I added a sense of touch to my robot in readiness for automating the robots movements. The robot needs to know when the hand has come into contact with something so the arm can be stopped and appropriate action be taken. I’m sure that the design of the hand switches will change and evolve as I do more testing but I’m happy that these switches will do the job for a while. Just a couple more switches for the other hand to make now!

Interface board

I’ve been quite busy today.  I redesigned the interface board that allows the arduino to be connected to the plethora of servos and sensors that will comprise my new robot.  I designed the circuit using Eagle and used the toner transfer method to transfer the design onto copper clad board and used ferric chloride to etch the board.  I’ve made quite a lot of home-made circuit boards now and I’ve developed a technique that works almost every time and gives nice, clean traces.  The interface board breaks out all of the PWM pins, all of the analogue input pins and eight of the digital i/o pins with pull-up resistors for connecting to switches.  I’ve also attached the battery and wired up a switch for the servo power which my previous robot lacked.  The interface board is attached to the robot and wired to the arduino, although I need to change some of the wiring and shorten some connections to keep everything looking tidy.  Next job is to start work on the servo brackets and mounts for the potentiometers.

excitingtechnology.net

Facts and Thoughts on Technological Progress

Turing's Radiator

Pleasantly Warm Topics in Computational Philosophy

Mind the Leap

One small step for the brain. One giant leap for the mind.

Steve Grand's Blog

Artificial Life in real life

jimsickstee

Hi, I'm Jim. Read what I write and I'll write more to read.