Tuesday, June 26, 2012

Making Beirut v1.0


I was always frustrated of how the hardware and the DIY community is still small in Lebanon. This keeps reminding me of how we are brought up into thinking that we are not made for it. It is just not meant to be: we are too busy with our social, political and economic  problems that for some reason we forgot a big problem- we just don't make stuff anymore we consume.

Obviously the community is there, it just need the right environment to grow. "Making Beirut v1.0" is the first actual gathering for the hardware maker community in Lebanon. In my opinion, Beirut is not ready for a Maker Fair <yet>, however, and as the name of the exhibition suggests, we would like to promote the maker culture, spread the knowledge and gather the community so that v2.0 will be closer to the full deal.

During four days many items will be exhibited. I, myself will be exhibiting a couple of items that can be found on my blog and elsewhere. And I can ensure the people attending the exhibition that they will also be an active part of the exhibition where they can play with robots, interact with tables, experiment with photography, and even play with electronics!

So get your geeky spirit ready, and join the makers at karaj and learn how you can promote and meet a community that is hacking its way into the city as they want to see it.


Tuesday, June 5, 2012

The ShakerBOT: Snakeboard inspired robot

When one thinks about robot locomotion, the first thing that comes to mind are bipedal robots or mobile wheeled robots. This is not the case with Sevag Babikian. As part of a research done by the Mechanical Engineering department at the American University of Beirut, Sevag built a wheeled robot which motion is inspired from the snakeboard. He called it the ShakerBot.




What is the ShakerBot made of? 

As we can see above, the Shakerbot is made up of the following components:
- A plexiglass laser cut chassis
- A central DC motor connected to a 2kg metallic flywheel
- A couple of DC motors (steering motors) on the front and back. These motors are called steering motors and they are connected to an axle which in turn is connected to friction wheels to guide the robot.
- A couple of castor wheels on both sides of the robot to support its weight.

All the motors are connected to quadrature encoders to compute their instantaneous position and speed.  Each motor is driven using an L298 based motor driver circuit, capable of driving up to 4A continuously.The brain of the Shakerbot is an Arduino Mega board. The Arduino Mega communicates wirelessly via bluetooth (ARF32 module) to a PC for teleoperation.

So, how is motion generated on this ShakerBot? 

 

Have you ever seen a snakeboard? Or have you ever felt the urge to kneel on a rotating chair and start turning in order to experience the effects of inertia, or those of dizziness? Well, ShakerBot operates on the same principle. The flywheel generates momentum which drives the robot around. Steering motors, as well as the flywheel, move in a sinusoidal fashion. The motion pattern of the flywheel and of the steering motors are what generate the different robot motions (forward, backward, rotation, parallel park etc.). The mathematics are quite complicated and can be fully understood in this publication by Lewis A. et al (1993).

The following video explains the mechanism better


The Arduino Mega board does all the complex mathematical and trigonometric equating and controls the DC motors accordingly.

How does the ShakerBot communicate with the PC? 

 

As mentioned above, the computing is done on the Arduino Mega board. However, it is required to have a wireless connection with a PC in order to teleoperate the ShakerBOT and tell it where to go. A couple of months ago I received a bluetooth module from Farnell electronics. It is the low cost ARF7044A based on the ARF32 bluetooth module manufactured by Adeunis (you can find it on the Farnell Electronics website). I decided to help Sevag out in implementing the bluetooth communication on the ShakerBot using this board. For 23£ I can tell you that this chip worked like a charm. We were able to achieve instantaneously a wireless communication, simply by wiring it to the serial Tx and Rx of the Arduino Mega and by connecting it to our laptop's bluetooth.
The ARF7044 connected to the arduino shield
I will be using more of this ARF7044 in the future and I will post whatever I find. 
  
On another note, for all the electronics makers, geeks and hackers out there, I discovered lately a website with a large  community powered by Farnell electronics that you should check out. It is called element14

Sevag and his ShakerBOT

Concluding thoughts

 

The easiest mechanism for robot locomotion is the differential drive mechanism. However if we look at humans we see that we use bipedalism very efficiently. We can walk, run and even climb with minimal energy consumption. This is because we make use of gravity to ease up the locomotion. Up until now, every attempt to mimic human bipedalism on humanoid robot has been very inefficient. This might change as technology as we learn how to fully harbor the physics and dynamics of the system. Same thing can be thought about this ShakerBOT. Humans use snakeboard efficiently, they harbor the momentum generated by their bodies in order to propel. Maybe this ShakerBOT and after plenty of modifications and improvements will turn out to be an efficient locomotion method after all.

Finally, I am very excited to see the maker movement growing fast in Lebanon. First Mounir and his Octocopter and now Sevag and his ShakerBOT. I can ensure you that there many more creative people just waiting to expose their work!

Monday, April 16, 2012

Lebanese OCTO Copter built by Mounir Zoorob

A few days ago, I bumped into Mounir Zoorob's OCTO copter project. It is a very impressive flying monster that Mounir designed entirely by himself. It is 1m in diameter and it has a 3 axis camera Gimbal, all designed from scratch. Apparently he has spent over 4 months very hard at work to finish it on time. I must say he did a pretty amazing job. So I invited Mounir on DepotBassam to write a small review of his OCTO copter flying machine, and here is his post:

Before starting, I would like to mention that the materials used are not the best choice. However, since there was nothing available in this part of the world and shipping carbon fiber parts was not possible I had to go with aluminum and Plexi glass instead. (on that subject, review DepotBassam's post on Lebanese electronics shops for more info)
I used 2cm * 2cm * 1 mm aluminum square tubes and the motors are from DIY drones with 35cm wires 2836/9. Each engine has a thrust of 1300g approximately.


I'm using Ardumega from DIY Drones as the main controller with magnetometer + sonar. So far it has proven to be the best thing I have ever bought for this hobby. i enjoyed it so much i bought it as a kit and soldered everything together


I designed and laser cut the case from a 3mm black plexiglass to hold both the Ardumega and the receiver.


As for the motor controllers, I bought 8 25AMP Turnigy ESC's from HobbyKing.
I am currently using 11*4.7 props but will go with the 12 later on down the road. All well balanced


Ardumega will be responsible for the compensation on the roll/pitch axis at the moment. Later on, I will upgrade it to control all three axis.

This is my camera gimbal. It currently has 2 active axis , but later on I will upgrade it to 3 axis. Currently I'm working on finalizing roll and pitch, but I am still waiting for the right parts to arrive.   
Wires were also taken into consideration during the design phase :) very neat :) 
Wires from the ESC's  to main power source are all well soldered and added heat shrink.
Here's the OCTO almost ready for a test flight :)

Here is the OCTO after couple of flights. I modified the design of the Gimbal and I integrated a new landing gear design on it
I promise the next design will be more elegant. With the cash at hand and the time this is the best I was able to come up with.

Here is a sample picture from the video I'm taking from the OCTO


Here is the first video from the OCTO, of course it looks better now but this is just a sample.



For those who love beer, here's one for you :) Note: I got rid of that beard
Feel free to ask me anything, your feedback is important to me. It better be a good one though!

Saturday, April 14, 2012

Wall Mounted Double Pendulum for Experimental Photography

(or how we went to outer space shot some galaxies and came back)
Through the lens of Abir Ghattas

My first interest in chaotic behavior can be traced back to this post. This time however, instead of simply developing a simulator I decided to build a real double pendulum. Watching a double pendulum dance erratically was worth a million simulation. If you are follower of this blog you will realize instantly that I could never let this opportunity pass without transforming it into some sort of a crazy experiment (-mostly photographic-).
 
The first step in the process was the design of the pendulum. The dimensions were chosen such as to maximize the chaotic behavior. Click here to download the AutoCAD .dwg file.

All dimensions are in cm
The material was chosen to be transparent 2mm thick plexiglass (4mm would have been ideal-but it was not available). The reason I chose to use a transparent material was so that the light can pass through in photography. I would definitely choose another material if I was using the pendulum for decorative purposes.

As for the components needed:
- 6mm ball bearings x4
- 6mm Hex Screw with nuts and washers  x2
- 3mm wall mounting screws and screw anchors x2

The following slideshow displays the assembly process


Here's a video of the double pendulum in action


After the assembly, Abir Ghattas and Patrick Abi Salloum came over for the photoshoot. We used LEDs of different colors connected to 3V coin batteries and we took long exposure pictures in the dark.
Left to Right: (1) Abir painting the pictures with LEDs (2)focusing (3) Patrick vs. Abu Ali
Courtesy of Patrick Abi Salloum

"Angel of Death" courtesy of Patrick Abi Salloum
For the result check Abir's website: http://abirghattas.com/double-pendulum-experimental-shoot/
and Patrick's flickr: http://www.flickr.com/photos/patrickas/7072749767/in/photostream

Monday, March 26, 2012

The Bathroom Illusion

Last month we moved to a new workshop. The new space used to be a storage house, so you can imagine the mess. It is old and required lots of renovation work. Now you might think that the renovation work was boring... well... not for me.

One particular issue that needed urgent attention was the bathroom door. It had a fully transparent window.



One day my friend was having a piss..
I snapped a picture..

I developed the picture..
And sticked it to the window
And now my friend is always having a piss


Thursday, March 1, 2012

Class B Push-Pull Amplifier Design for DC Motor Analog Drive

I am currently involved in a project that requires analog speed control of a DC motor. One very popular method to achieve control of DC motors requires the use of a PWM signal along with an Hbridge circuit. Modular circuit website  provides a great resource for the Hbridge circuit and explains thoroughly different PWM driving techniques like Sign-Magnitude and Lock Anti-Phase Drive methods. However, and after doing a basic online search, I barely found any good resources on analog DC motor drives. There are many reasons for this mainly because switching drive methods are generally much more efficient than their analog counterparts and PWM signals are easily generated using microcontrollers as compared to the use of DAC for analog control. This does not mean that analog drive is obsolete as it is still the preferred method in some applications such as motor frequency response, continuous time control, and applications that are sensitive to the electromagnetic interference (EMI) that can be generated by a PWM switching circuit.

A famous method for transforming an analog signal into switching PWM signal is done using a class-D amplifier (switching amplifier). However such an amplifier design is complicated and requires lots of components. On the other hand, there are some commercially available power amplifiers such as the LM675, L165. Such ICs are a bit expensive and not widely available for the hobbyist to use.
In this post I will be reviewing DIY analog circuit designs to drive DC motors using BJT power transistors. This requires good knowledge of BJT transistors. If the terms base, collector, emitter, npn, pnp, cut-off, active and saturation regions do not mean anything to you, then maybe you should consider doing a BJT transistor research before continuing to read here.

I will be using a TIP31 npn transistor which has the following characteristics:
- Current gain: hfe=β= 50
- Collector-Emitter saturation voltage : Vce(sat)=1.2V
- Cut-off voltage Vbe(on) = 1.8V [according to the context-this will be called Vbe from now on]
I will be using also TIP32 which is the complimentary pnp transistor of the TIP31.

Common Emitter Configuration 

In this configuration we can achieve current control for the motor. Since for a DC motor the torque is proportional to current (T=K*ic where K is a constant that depends on the motor's winding configuration), torque control can be achieve using this circuit. While in active mode, the equation relating ic to Vin can be found (note Vbe = Vbe(on))


Let us understand this model intuitively:
  • For Vin<Vbe  transistor is in cut-off region and motor is off.
  • For Vin>Vbe and Vce>Vce(sat) transistor is in active region, motor torque T is proportional to Vin.
  • As we increase Vin, ib increases which means ic increases and Vce decreases. 
  • For Vin>>Vbe and Vce=Vce(sat):saturation region, motor reaches its maximum torque/speed capacity.
If we follow the DC motor's mechanical model developed in the following Carnegie Melon tutorial and assuming the only torque applied on the motor shaft is that of shaft inertia (Jm) and damping (B) we can compute the transfer function of the speed (w) versus ΔV=Vin-Vbe

According to the transfer function the steady state relationship between speed and voltage in the case of no load condition is
According to this result, decreasing Rb would cause the speed to go higher. Of course this method has its pros and cons:
  • pro: Assuming β is constant we can achieve linear current (torque) control of DC motor
  • con: The model is highly dependent on the current gain β (hfe) which varies alot specially for high power BJT (in the case of TIP31 it varies between 10 and 100). Hence the model is non linear!
Common Collector Configuration (also called Emitter-Follower)

In order to cancel the effect of β on the system we connect the motor in a common collector configuration. In this configuration, the motor is connected to the emitter of the BJT as shown in the following figure. This configuration is called emitter follower because the voltage on the emitter will always be following that of the input with a voltage drop of Vbe. So the gain of this configuration is a bit less than 1.


Again, and to evaluate the circuit, we need to find the transfer function ω/ΔV where ΔV=Vin-Vbe.
In this configuration when the transistor is turned on, Ve=Vb-Vbe. Knowing that ΔV=Vin-Vbe, the relation between the motor current, motor voltage and Vin can be found:

According to the mechanical model of the motor we know that the motor torque is equal to


Since T=K*ie and performing the Laplace transform we obtain


Equating the two equations we get the following relation:


The electrical model of the motor gives

Where R and L are the internal resistance and inductance of the motor coils. We are assuming in here that the motor is ideal and the generated EMF constant (K) is equal to that of the torque/current proportionality constant. Combining the electrical model with the previous equations of Ve and ie we obtain the following transfer function

From this transfer function we notice that if we choose Rb = 0 the effect of β on the motor is canceled. The transfer function then becomes


This is exactly the transfer function of a DC motor. However we haven't considered yet the rotation of the motor in both directions (Clockwise CW and counterclockwise CCW)

Class B Push-Pull Amplifier
In order to be able to rotate the motor in both clockwise and counterclockwise directions we should be capable of providing a negative current to the motor. This can be achieved using a push-pull amplifier. A push pull amplifier is a Class B type of amplifier that either drives a positive or a negative current into a load. It consist of a pair of complimentary transistors, in our case NPN and PNP BJT transistors, connected in common collector configuration.


When +Vcc>Vin>Vbe the upper transistor (NPN) is in active region and the lower transistor (PNP) would be in cutoff region. When -Vcc<Vin<-Vbe the lower transisor (PNP) will be in active region and the upper one will be in cutoff. The same theory developed in the previous section can be applied in here.
In order to be able to drive the transistors from a high output impedance source (potentiometer - DAC etc.) we need an impedance matching device. This can be achieved using a UA741 op-amp. The feedback for the op-amp needs to be implemented depending on the gain needed. In our case unity gain is required.

In order to test the class B push-pull amplifier I devised a setup consisting of a DC motor of maximum speed 30RPM connected to a quadrature encoder to measure speed. The data acquisition is accomplished using a dspic30F4012 microcontroller. Running at 120Mhz and 30MIPS this dspic computes the instantaneous velocity and communicates serially with a Matlab code in order to display in real time this velocity. I connected a potentiometer to the input of the amplifier. I would set the pot at a certain voltage and then wait for steady state condition to measure the velocity of the motor.

The amplifier/DC motor/encoder/acquisition setup used for the experimentation
The following plot shows the RPM vs voltage (Vin) curve for the Class B push pull amplifier design shown above.



We notice from this plot that there is a dead zone around 0V. This dead zone is called "crossover distortion" in the literature. This is obviously due to base-emitter voltage necessary for the NPN transistor to be in the active region (in the case of positive Vin) and for the PNP transistor to be in the active region (in the case of negative Vin). In the case of TIP31 and TIP32 this crossover distortion is of about 2Vbe=2*1.8=3.6volts. This  is not desirable at all since it provides non-linearity that will cause the frequency response analysis or the closed loop control to fail.

In the following allaboutcircuits.com article a solution for this crossover distortion was suggested which consists of connecting the op-amp with the negative feedback in the following manner


Without any loss of generality and in order to understand better this circuit we are going to analyze the NPN half of it. A is the gain of the amplifier.

Assuming Vin=ε is the voltage  responsible for switching the transistor from the cut-off region to the active region. Considering the case when the transistor is about to switch to the active region, then Vbe=1.8V while Ve is still 0V, hence according to the previous formula

Since the opamp has a very large gain A (about 200000 for ua741), this shows that ε is infinitesimal and very close to zero.
The following plot shows the RPM vs voltage (Vin) curve for the improved Class B push pull amplifier design with opamp feedback as compared to  the previous case


We notice from the plot that the crossover distortion has been reduced from a value of 3.6 volts to a value of 0.5v with the improved feedback design. We know from the theory that the new crossover distortion is supposed to be infinitesimally small, however in practice, this turned out not to be true. The reason for this is unknown to me but most probably it has to do with the imperfections in the opamp. If you have an idea about the reason please don't hesitate to comment.

I do realize that this design might need improvements and maybe the implementation of a class AB amplifier would have provide a better response, however for my current analog control of a DC motor application the Class B push-pull amplifier turned out to be very useful as it provided an almost linear relation between RPM and voltage. If you have any suggestions or improvements please comment on this post.

References and suggested readings:

Monday, January 16, 2012

DIY smartphone headphone adapter (with MIC & control button)



  • Do you happen to own a very expensive and personal set of headphones?
  • Do you have a special connection with your personal headphones such that you cannot listen to music without them?
  • Do you wish your personal headphones have the feature of the remote control (buttons) and MIC that smartphone earphones usually have? 
  • Do you have an AUX line in your car's radio and you like to listen to your smartphone's music in your car?
  • Are you bothered when you receive a phone call while driving because you'll have to unhook your phone from the AUX input to answer, which can get you into an accident?
  • Are you like me and you prefer not paying tens of dollars for something that you can build yourself and will only cost you time (and a few dollars). There is nothing more rewarding then DIY!  
Ja3far had the same problems mentioned above and in the video below he will show you the solution he came up with. (This is my first time shooting a DIY video, and I think I am a bad illustrator, so excuse my sloppy technique)



In the video, Ja3far decided to make an adapter which he can hook up to his expensive headphones (or any other earphone/headphone). This connector has a microphone and a button. Ja3far can use the button to play/pause/move to the next track/answer phone calls (the features of the button depends really on the operating system of your smartphone). And the MIC is obviously used to communicate during a phone call without having to bother (very useful while driving).

This project requires little knowledge of electronics and soldering. You just need the following items:
1- Solder and Soldering Iron
2- Wires*
3- Electret MIC*
4- Push Button*
5- TRRS (Tip-Ring-Ring-Sleeve) audio Jack*
6- Multimeter (not necessary, but it is good to be able to perform continuity testing to follow the connections of the Jack)

*total cost is about 2$
All these items can be found at your local electronics shop.
The TRRS jack goes into the smartphone audio input, while it is important to note that regular earphones and headphones have a TRS type of jack as shown below:
A TRRS audio jack

Headphones TRS jack
For a headphone jack: TIP is connected to Left channel, RING is connected to the Right channel, and Sleeve is connected to the Ground.
Oh and this is a final image of the adapter.

I know it doesn't look great but hey it does the job, and trust me wearing your headphones with this geeky looking gadget will definitely make you stand out.
So I leave the aesthetics for the aesthetic minded.