Wednesday, 17 February 2016

DIY Mini Drill Controller

Scene-1: The Cause

I was using a small MiniCraft drill machine for drilling holes into my home made PCBs and also for some cutting activity with some attachments. The problem that I had was that when I bought the drill it didn't come with any sort of controller. I used to use it with direct connection to battery.

It was difficult to every time remove the drill once it got stuck, because there was no way to reverse.

Scene-2: The Idea

So one fine Sunday I thought of building this drill controller.

The basic concept was that I have to build a controller circuit for :

  1. Speed Control; so that if there is any delicate job to be done then I can start slowly and increase the speed as and when reuired.
  2. Direction Control; for when the drill would get stuck/jammed I could reverse easily by the push of button.
  3. It should have a Power ON-OFF control.
  4. And finally everything should fit into a Compact box and all the controls should be user friendly and easily accessible. (don't want any tricky controls when you are handling a high speed sharp tool right :D )

Scene-3: Component Selection

To achieve this I thought of a simple idea which is to use motor-driver IC for reversing the direction and controlling the speed and a microcontroller to control the motor-driver.

I initially thought of using relays to control the direction, but then it could have become bulky and speed control would anyhow raise the need of some linear components.

Finally I ended up with L293D, which has 4 individual PUSH-PULL driver and every two of them can be paired to form a H-Bridge channel. It has a current capacity of 600mA per channel with in SOA (Safe Operating Area), beyond which it would require a heatsink (which I don't intend to provide, lack of space).


So I coupled 2 channels which would effectively double the current capacity now to 1.2A. 

The goal was to control the direction of the motor by Input signals of L293D  and speed by providing PWM to L293D input. Both of which would be from a simple low cost microcontroller, and nowadays we can pick up a cheap arduino-pro mini clone for around 200 INR, which is relatively cheap.

The advantage of using a pro-mini kind of board is that all the essential circuity for the microcontroller like clock, power are already present on board and it is quite sleek to fit into my box, and why not go for a pro-micro-328p board for 200 INR when a DIP atmega328p would cost 150 INR.

For speed control I used a 10k POT generally available in market.

I also used two tactile switches:
  1. For toggling direction.
  2. For turning it ON or OFF.
Other components used are a couple of leds, resistors, a plastic knob for POT and a DC barrel Jack.

Scene-4: Realization and Testing

The schematic of the circuit is shown below:


I have added a mechanism to detect Over-current, by which I can prevent L293D from Over-heating, if the motor really gets jammed.

Since it is a brushed motor if the rotor gets stuck then current starts continuously flowing from the same part of the coil which eventually heats-up the armature and reduces its life, and also the Motor-driver can get damaged because of high-current flow, remember the peak limit is 1.2A even when both channels are combined.

So for that I used a shunt resistor of 0.08Ohm and used to measure the voltage drop across it using ADC of atmega328p. So when voltage across it reaches 96mV (1.2A x 0.08Ohm) then we should disable the L293D in the program.

I also added a functionality to prevent transients which is called Soft-start (mostly used for powering high-current loads), which is basically slowly increasing speed (using PWM) during POWER-UP instead of instantly supplying full power.

All these and other features are present in the program.

Click the link below to get the design files (schematic) and program for it.
Code and Schematic

I have written the program using Atmel Studio, however it can be easily adapted for use with Arduino.

The programming is almost complete however there are a few glitches which I am not getting time to resolve (documented in the Readme file). Feel free to make any changes and customize according to your needs.

Scene-END: Result

Below is the result of what I built :)



The demo can be seen in the video below :



CAUTION: DO NOT PLAY WITH HIGH-VOLTAGE AND CURRENT. USE EXTREME CAUTION WHILE HANDLING POWER TOOLS.

DISCLAIMER: ALL THE INFORMATION PROVIDED IN HERE IS AS IS, WITHOUT ANY WARRANTY. THE AUTHOR IS NOT LIABLE FOR ANY LOSS WHAT SO EVER ARISING FROM THE USE OF THIS INFORMATION. USE AT YOUR OWN RISK.

Thursday, 8 January 2015

Full featured FTDI-FT232RL Usb to UART breakout board

FTDI's FT232RL is the most popular USB to UART converter chip and is used by many hobbyists. 

It is very popular because it is easy to use and is reliable and also requires very less components to build a full featured UART interface from it.

For example when compared with others like PL2303 it doesn't require a crystal oscillator externally.

And one other advantage over Pl2303 is that it doesn't hang. Sometimes if the PL2303's internal FIFO buffer overflows then it will hang the driver as a result it won't work until computer is restarted and also since the driver is hung it will not respond to OS kill messages sent during Shutdown, so you will have to FORCE shutdown your computer.

Ok so the FT232R is available on breakout boards from many stores like sparkfun, adafruit etc and also on ebay. But many breakout boards just provided connections for the basic RX, TX , VCC and GND pins only.

If you ever try to use an FTDI serial-bridge as a arduino programmer (via bootloading), then you will know that we also require the DTR pin of the FT232R.

Another thing is that there is IO voltage selection pin on FT232R which can be used to switch the IO levels between 3.3v and 5v, this is also not broken out.

So keeping in mind all these extra features i designed a simple but fully loaded PCB design for the FT232RL, it contains all the features i talk above like IO voltage selection, broken out DTR, RTS and CTS pins and also multiple GND pins and 5v and 3.3v supply output.

Here is the schematic below:




And below is board layout (warning! not to scale use the pdf from repository for printing).

For soldering the components you can take help of this image.

If you observe my design you will find that i have included two USB connectors one USB-A type board mount plug and another micro-USB Connector. That is more of something like an experimental thing i was doing. But you don't need to bother with that micro-USB just use the USB-A type connector.

Two jumpers will be required to connect the Blue lines(bottom side of board) in the above image.

For printing the board layout use ftdi.pdf file from the repo.

You can find all the Eagle Design files from here https://github.com/neutronstriker/FTDI_BREAKOUT.

After building the final product will look like this, at least thats what mine looks like :D



So thats all and thanks for reading, if you have any queries or ideas just leave a comment.

Wednesday, 7 January 2015

Simple Hexapod

Now most of you reading this article might have seen robots or remote controlled vehicles that move using wheels because people generally build robots that run on wheels.

But sometimes the flexibility and agility achieved by having a few pair of legs on your robot really outweighs the simplicity of wheels.

So i finally decided to build a Hexapod. I had built some wheel based robots before, but building a hexapod was really a quite interesting job.

I was inspired to build this after i saw a video of Polulu Simple Hexapod walker, which i felt was like one of the quite simplest hexapods to built.

Below are some images of my little Hexapod.




   
My build structure and technique is nearly same as Pololu walker. A few differences are that:-

I used cycle spokes to build its legs instead of large size paper clips, because cycle spokes are undoubtedly more stronger in enduring the load before they bend and also easily available. 




And i used an Atmega8 micro-controller instead of the Pololu micro maestro to control the 3 servo motors to move its legs.


But Gait is same as that of Pololu walker. However i didn't get the time to develop the lateral movements i only wrote the code for Front and Back movements.

The connections are quite simple just simply choose any 3 IO pins as your servo control pins and connect the servo channels directly to those. 

To build it i just placed the servos together in position and glued (using hot-melt glue) and taped everything just to be sure. Then glued the legs (made by bending cycle spokes) to the servo attachment and then fixed it with the Servos.

I have written a software based servo control driver program for Atmega8 which can be adapted to build a Soft-Servo library for AVR micro-controllers. It just requires one 8-bit timer-interrupt. https://github.com/neutronstriker/TinyHexapod is the link to the code.

Here is my hexapod in action. 


So if you have any questions or ideas just leave a comment.

Do it Yourself Power-Bank Part-3

So the previous part(part-2) was completely about working and construction of Control Circuit

Since we have built the Control circuit and also adjusted and connected the Booster circuit to Usb socket, now its time to connect the dots and complete the Puzzle.
See below to understand how to connect all the parts that we have gathered or built so far.


Now after you gathered all parts and connected them together as shown above, all you need is a decent housing (plastic case ) for your Powerbank. 

What i generally do is get a plastic box from the General store and make necessary holes or modifications in it and use it, but it is upto you for what type of housing you would like to use.

Here are some images of mine below:






So if you have built it successfully then congrats you have made yourself a Powerbank that you can use when your mobile battery is out of power or to power other electronic portable devices that are generally powered by computer USB port(5v).

But if you are stuck somewhere in the build process then you can just leave a comment and i will try to help you out.

And finally a demo video of it in action:



Some extra stuff:

The batteries that i have used here are from one of my old laptop battery pack. I had said that in 1st part of this series that i will explain how to use old laptop batteries. 

I took 3 cells and connected them in parallel ( i.e. positive to positive and negative to negative). So since each cell was of 4.2v and 2600mAh then my total rating is 4.2v 7800mAh.

Most laptop battery-packs internal contain these 18650 size Li-ion batteries in parallel sets of 3 or 4 Cells in series.

If your laptop battery is of 10.8v or 11.1v then it will contain generally 3 cells in series and 1 or more sets in parallel. If it is 14.4v then it will contain 4 cells in series and the rest is same.

The capacity generally written on battery as 4400mAh or 5600mAh or 2600mAh is defined by the battery material concentration itself and the number of battery sets in parallel.



The above image has 3 cells in series and 2 such sets in parallel. Each cell was of 2600mAh so the total capacity rating would be 10.8v 5200mAh.

When the laptop informs us the laptop battery is damaged or the capacity has depleted to very low. Most of the time it happens so that the actual cells still have 80% of juice in them.

But the battery gauge (a chip which calculates battery capacity and wear) gives wrong information. Unfortunately it is not possible most of the times to reset or override this and bring back the battery to life. Because the battery gauge chip communicates all information on a one way like traffic from battery to motherboard(from the computer we cannot send data to the battery) and even if you get your hands dirty and open up the battery to directly reprogram the chip it sometimes it stores most of its calculation info deep down locked in its protected memory.

Most battery gauge chips nowadays come with advanced security features such that if we try to tamper with their data then it will lock itself and show the battery as dead when inserted in computer.

As you can see in the above picture the battery-packs are not manufactured to be refurbished or dis-assembled and re-assembled again. Because the top and base covers which are made up of plastic are fused together. So once you try to open them it will definitely break some part of the cover.



If you are lucky enough then you may be able to open it up without breaking the cover. However we don't need the cover. What we need to do is the remove the battery connection from the circuit safely by proper desoldering.

Then disconnect the batteries in series and divide them into individual pieces and then check each cell's voltage using a multimeter.

Now those cells which have a voltage of 2.8v (strictly) or more can be used rest are to be disposed of safely or sent for recycling. If you try to charge a battery which has less than 2.8v it could pose dangerous threats like explosion. So you are at your OWN RISK.

And before finally using it you should like charge it at 4v to 4.2v maximum constant voltage and monitor if the battery temperature starts increasing then get rid of it. I would recommend you to charge at 4v only because it is safe(float charging) as at 4v you can leave the battery connected to the charger for like ever and it won't harm the battery. But this method of charging is slower and charges a Li-ion to 80% of its full capacity only.

Its normal for most used cells to decrease voltage quickly when loaded but you can do a quick calculation and find out its real capacity by giving a constant load that shouldn't exceed current draw by 70% of the maximum rating of the battery.

So this was a quick intro regarding  re-usage of laptop battery cells in Robotics or electronic projects. If you have any doubts you can post a comment.

DISCLAIMER: ALL INFO PROVIDED IN HERE IS GIVEN "AS IS" WITHOUT ANY WARRANTIES AND SUITABILITY OR FITNESS FOR ANY PARTICULAR TASK ARE DISCLAIMED. THE AUTHOR IS NOT LIABLE FOR ANY LOSS ARISING DIRECTLY OR INDIRECTLY DUE TO USAGE OF GIVEN INFORMATION. THE AUTHOR IS NOT RESPONSIBLE FOR WHATEVER PURPOSE THE GIVEN INFORMATION IS USED FOR AND THE CONSEQUENCES ARISING DUE TO IT.

!! USE IT AT YOUR OWN RISK. !!

Tuesday, 30 December 2014

Do it Yourself Power-Bank Part-2

This is the 2nd Part of the DIY Powerbank Tutorial. Link to the first part is here

So far we have covered the basic working principle of the Powerbank. List of Parts required and description of some parts.

Now we will work on the part called "Control circuit". This will work as the Brain of the Powerbank. Let me just give you a brief idea of the functions the control circuit will deal with.

  • It will show you the battery level of the Powerbank.
  • Provide a soft turn-on and turn-off mechanism. It is necessary to turn-off the device when not in use otherwise a lot of power will be wasted by the boost converter.
  • Provide indication of charging while the powerbank is charging.
  • Turn-off the boost converter when the internal battery is very low, otherwise the powerbank battery will be so depleted that it can't be charged anymore.
Well to say precisely it is control circuit that can be used for any battery operated device. Because any device that operates on rechargeable batteries requires those above mentioned functions to be carried out by some circuit.


So in the picture the control circuit in the center is shown, on the right is Step-up/boost converter and below it is the Usb socket mounted on a DOT-PCB.

You can see that the circuit is not clean because while designing the circuit i selected a component which was not available in the market and realised the mistake after fabricating the circuit. So i had to fork my way around by cutting traces and using jumpers.

But now i have corrected that error and redesigned the circuit completely. So that anyone can easily fabricate it.

The major components in this circuit are ATTINY45 microcontroller, 74HCT595 shift-register, and BSO119N03S a N-channel Power E-MOSFET, which drops minimum voltage and has very low leakage.

Below is the schematic of the Control circuit.

 However you can download the schematic and board layout files designed in EAGLE from https://github.com/neutronstriker/Powerbank_EC.

And this is the layout

This version is little different than what mine looks like because my actually prototype had some problems. 

Mind that the above image is not according to scale so just download Powerbank_EC.pdf and print in on paper without any scaling then you will get the correct size, or you could download the whole repository from link above and download the eagle files and print them.



After you have fabricated the board you can solder the components on to it by taking help from the above image.

Now the Working:

So i will just briefly explain the working of the circuit. 

The attiny45 is loaded with a program which continuously monitors the battery level of the Powerbank using ADC and Voltage divider configuration. When it falls below the programmed minimum value it will display warning, but when battery falls below reserve threshold the Control Circuit turns of the powerbank automatically.

While the device is off the attiny45 is in powerdown(sleep) mode and boost converter is off because of the MOSFET. 

The switch is connected to INT0 and when the powerbank is off and we press the switch for 3 seconds then it turns on. If i press the switch for 3 seconds when the device is ON it turns off.

When the device is ON and if press the switch for only 1 second then it displays battery level.

The charging socket is connected to PCINT0 and when external charger is connected the Powerbank starts charging and the battery animation is shown.

In this circuit 6 leds are connected to a 74hc595 shift-register which takes input from Attiny45 to drive the leds. But data is sent to 74HC595 using only 1 pin instead of 3 requied(SH_CP, ST_CP, DATA) it has been possible because i am using a modified version of Shift1 technique. You should read more about shift1 it is really very useful tool to multiplex your output pins when you have less number of IO pins.

Even if you don't understand the working now don't worry you can understand it clearly if you read the whole program source code. I have explained the working of the code and its relation and effect on the circuit in the code itself.

So below is the code just read through it and you will be able to understand how it works as i have explained what the code does where ever required.


https://github.com/neutronstriker/Powerbank_TINY  is the link to the source and hex files. It was written using AVR Studio 4 and Winavr. 

Note that in the fusebit settings of ATTINY45, the clock was set to internal 8Mhz RC oscillator, brown out(BOD) was disabled, CKDIV was UNPROGRAMMED and SUT was set to default.

Thats it for now in the next part will be final assembly and demo of its working.

Click here to goto Part-3 of this project.

Do it Yourself Power-Bank Part-1

Almost everyone nowadays owns a smart-phone. Obviously the merits of having a small computer(smart-phone) in your pocket is not necessary to explain.

But as we know every coin has two sides, this heavy computation power, packed with awe features like stunning graphics, high-speed data connectivity and great multimedia abilities require a great sacrifice of battery power. 

So many smart-phone users spend much of their device usage time connected to the wall-outlet charger.

But while on the run when a wall-outlet was not available came to our save our Great Hero :D the Power-Bank.

So nowadays power-banks are a usual gadget for most users and you can usually get a good bargain for quite a decent capacity power-bank in market.

But i wanted to build one on my own, just for fun and also because that technically i had most of the stuff required to build it lying around my workbench.

And this is what mine looks like :



So lets begin....

I will start by listing out first what parts are required and explaining what role do they play in our project on a need to know basis.

The list:
  • A couple of 18650 batteries. 
  • LM2577 Step-Up or Boost converter.
  • A USB-A Type Socket/receptacle.
  • A control Circuit.(We need to build this one).
  • A piece of Dot-PCB or veroboard for Prototyping.
  • Needless to say a soldering iron, and accessories like solder flux and solder wire.
  • Some general DIY tools.
  • And finally the housing, a box in which we will fit our parts and circuits.
The explanation:-

The working principle of our Power-bank is very simple and is shown in the diagram below.





Now the 5v DC supply available via the USB socket can be used to charge your mobile phone using your data cable. Almost all mobile phones require 5v DC input to charge-up but the current required varies from device to device. 

However most mobile phones chargers provide somewhere around 1A and thats our target too.

And when you are not using your power-bank you can charge its internal battery with your usual mobile charger only.

The Battery:

Now lets focus on the voltage part. It obvious that we are going to take power from those batteries i listed above. 18650 as battery size standard. It is the type of battery that most power-banks in the market contain. It is a lithium-ion rechargeable battery and even most laptop battery-packs contain these 18650 cells internally.

!!Caution!!:- DO NOT EVER TRY TO SHORT-CIRCUIT THESE BATTERIES. IT  CAN LEAD TO EXPLOSIONS AND DON'T USE LEAKY OR SWELLED OR FUMING BATTERIES. 

IF BECAUSE OF ANY REASON THE BATTERIES HEAT-UP, REMOVE ALL CONNECTIONS IMMEDIATELY AND DISPOSE THEM OFF PROPERLY.

DON'T PLAY WITH STUFF YOU DON'T KNOW ABOUT. Read usage and safety information about these batteries in the datasheets if the manufacturer provides any or else the generic ones at here or here, before proceeding any further.


These lithium-ion batteries generally have a full charged voltage of 4.2 - 4.3v max at no load. But when you load them it may decrease to about 3.7v to 4v. So lets assume that the moderate working voltage would between 3.3v to 4v.

You can get a variety of these batteries on ebay or other sites of various capacities and brands at various prices. So choosing the right one would be difficult. 

Most batteries come at standard 2600mAH capacity.

Now the more batteries you connect in parallel more is the total capacity of your battery-pack. Suppose you get 4 x 2600mAH batteries and connect them in parallel, then their voltage will stay the same but their charge capacity will add up, so the total capacity will be 10400mAH.

Capacity of battery-pack directly translates to the number of times you can charge your mobile phone battery. Now some people might have a misconception that "my mobile battery is of 2000mAH and 10400/2000 = 5, so i will be able to charge my mobile battery 5 times" . 

NO thats wrong actually.

How many times you can charge your mobile battery depends on many other factors too.

First of all nearly 10-15 % of the battery energy is wasted as heat during conversion from 3.8v to 5v.

Now we provide 5v to the phone but the phone's internal charging circuitry also wastes some 5 to 10% power.

When we say 2600mAH, we mean the total charge of the battery when used from full charge to full depletion. But if you deplete a rechargeable battery completely then you can't charge it any more, because a irreversible chemical reaction will occur in it . So we can use it until the battery voltage stays above 3v.

So that translates to roughly 70-80% of the total battery energy that is directly going into your mobile battery.

You would be surprised to know that many of us could get these batteries from used up old laptop battery-packs, and actually i built mine from used laptop battery only, but there are some quirks related to using cells from a depleted laptop battery-pack.  So i will explain it in the last post of this series.

OKAY now i think we have enough info regarding batteries, lets proceed to the next part in the list. 

Step-Up Converter:

The LM2577 Step-up(boost) converter. It is a DC-DC conversion circuit which takes any DC input voltage between 2.5 to 27 volts and can provide a constant regulated output anywhere between 3v to 30v, provided that the input voltage doesn't exceed the set output voltage.

If the input voltage exceeds adjusted output voltage then output will start directly following input and no conversion or regulation will take place.




To set the output properly first connect the battery at the input pins keeping in mind the correct polarity and then connect a multimeter across the output and keep turning the trim-pot until you get 5.0v on your multimeter.

Just take look at the video below for further clarification..



Once the output is adjusted, the step-up converter tuning part is complete.

Now just take a piece of dot-pcb (prototyping PCB) and mount the USB socket/receptacle on it and solder its legs firmly, then solder the output pads(O+, O-) of the LM2577 step-up circuits to two wires and solder the other ends to USB socket mounted on the PCB.




So now you have setup the output portion of our project successfully.

We will look into building the Control Circuit in the next part of this blog.

Click here to proceed to the next part in this series. 

Sunday, 28 December 2014

AVR 28-pin Development Board with USB support

So i made a development board for the 28-pin AVR micro-controllers like the ATMEGA 8, 168p, 328p etc. some time ago.

I made my design after i found the Metaboard

The metaboard design fascinated me in that it was a AVR development with built-in programmer(i.e. Usbasploader support)  and also we could upload code from Arduino directly and we can also use the USB interface on-board with the V-USB library.




But i had some extra requirements like a 3.3v regulated supply on-board. Also i did not want to sacrifice 2 pins for the USB connection so added a dip switch to disconnect them whenever necessary and some other changes as mentioned below:-

  1. Added an led which was connected to a digital I/O as well as PWM pin.
  2. Added an extra 47uF capacitor close to VCC and GND pins.(Required to compensate ground bounce when driving motors using L293D or any other motor drivers using the same supply that powers the dev board)
  3. Extra regulation filter capacitor added for power supply stability.
  4. Added a 10uH inductor for AVCC as specified by Atmel Docs for cleaner ADC.
  5. And finally as you can notice in the picture above every I/O pin has dual sockets(both male and female, you will understand the advantage only when you face the need).
You can say that my design is a bit overloaded design with whatever i could possibly add of whatever features i required.

Best of all i have tried to keep the PCB still a Single-sided one so that most people can still build it at home using toner-transfer method and common etching techniques.

Here is the layout (Warning! its not to scale, use pdf from github design files link given below)and :


and this is the schematic :


You can get the board design files from here https://github.com/neutronstriker/Metaboard_mine/tree/master. It was made using Eagle Cad software. You are welcome to make any modifications if you like.