Tuesday, April 8, 2014

Test Drive

It's done!

I have made the final touches and the car has finally been made.
What do I think about the project?
Well, to be honest, this kind of project requires a "version 2, version 3 etc..". You learn as you go alone and improve the next time you make the same project.
For example, I wish I had a battery gauge bar that will indicate the level of battery charge that is left in the battery for knowing when it's time to charge

Too many connections
To ease the development process of the car I had to separate the full PCB into four main circuit which were connected to each other via dupont connectors. this causes the interiour of the car, well, look like a mesh of spaghetti. I should have connected the boards together and created only one PCB that housed all of these four circuits. The circuits are:
1. The H-BRIDGE for the car wheels
2. The H-BRIDGE and Missile control for the rocket launcher
3. The main board which contains the main processor.
4. The voltage regulator for the IC chips.

At the end, all in all, the project is a success and lots of fun. Now to the next project.

One last thing, checkout the test drive :).


Monday, November 25, 2013

Lithium-Ion power

Yes, I have a small LAB :).

I used my storage room, which is located in the entrance of the building I live in as a LAB. I don't have too much equipment, after all I'm not a professional.

I do have the basics, an old computer PSU that was modified to a power supply (not in the picture) for 3.3V, 5V and 12V. A computer stand with a screen, keyboard and mouse. A Multimeter and a soldering iron. The software I use is all free software. For the PCB CAD software I use Fritzing and for programming the AVR chip I use the Arduino IDE with the Arduino as ISP sketch via an Arduino UNO board.

For all the boards I create I place an ICSP so I will be able to update the software in place. 

Going back to the project, I finished the main board which has three circuits on it as you can see in the following picture:
The circuit on the left is the missile control driver board. It has two H-Bridge circuits for controlling the missile Horizontal and Vertical motors as well as the missile shooting motor. The Horizontal and Vertical stop triggers are connected to the H-Bridge circuit so that once the missile turret reaches it's limit and the trigger is triggered, the motor is cut off via the driver board so it won't keep rotating in that direction to protect the motor. It seems that during my analysis of the missile launcher which I had to take apart I seem to have caused the Horizontal right sensor to stop functioning. I can fix it, but I'll keep it for later.

The top middle circuit is a 5V power regulator for the micro-controller and devices which require 5V DC to function. The devices are the PS2 joystick wireless plug, the distance Echo sensor and the microchip itself.
During my tests with the board, strange behaviors were encountered which I really have no clue on why they happened. At first the board did function, but then it worked randomly. The missile launcher didn't function, but I later discovered why, and fixed the problem. I forgot to place a 10K resistor to the Base of one of the transistors which caused huge amounts of current to flow into it (I'm using the 2N2222 BJT Transistors) which heated up to a point where it simply stopped working (burned out). I fixed it and replaced it.

In any case, the first tests where really a failure.

I had to leave the project for some time and got back to it later this weekend when I moved all my stuff back home.

I'm still puzzled on why it failed but I do have some possible candidates. The first and most likely is the power supply and it seems I may take my friend's advice and use a different power supply for the micro-controller and devices circuit and another one for powering the motors (car and missile). The second candidate has to do with software.

I'm very experienced in software so I wrote a helping library for Arduino which I call EDA (Event Driven Application). It provides a very easy way to receive events that can occur on different PINs and call a function when the trigger happens. For example, I can set a PIN to call a function once a RISE event happens which means when the PIN goes from LOW to HIGH. It also provides a debouncing functionality which is very useful. The library also provides timed events which are triggered after a certain interval.

The EDA library made my life easier for many other projects, but it was not debugged properly and I have a feeling it may be the cause.

The next thing I'm going to do is connect everything together on the Car and probably start testing to see how well it will function and go from there.

Again, for testing each progress in the Car I have my trusted testing team who likes their job of QA for this project and they do massive stress testing as well :). Here are two videos taken during their fine work. Their names are Karen (my oldest daughter) and Rani (my middle son) - I have another younger daughter named Caitlin which I didn't hire yet ;).

 

Monday, November 4, 2013

Power Supply

It's been some time now since my last post. I was a little busy with work related matters and a trip to Japan which consumed all my time. This post is rather coming a little late as most of the work in this post was done some time ago but I didn't have the chance to document it.

So, Power Supply. The car does require some powerfully power supply that has to be battery based. the motors do require significant amount of power (current) to make it role. Using regular alkaline batteries is one option, but they will get replaced frequently which can be expensive. The SmartCar has a motor for each wheel which sums up to 4 motors, the missile launcher has three motors but only two can run simultaneously, this makes it 6 motors and we are not yet done, there is the processor, echo distance sensor and the wireless Joystick.
Above you can see how I plan to construct everything together. The missile launcher will be placed in the front and the power supply on the back, in the middle the main board with main processor and the supporting circuit for the missile launcher. Currently I'm using regular batteries but I will changing the power supply to Li-Ion batteries.

For now, every attempt to power the entire car with the power supplies failed and in all cases caused either the main processor to reset or the wireless Joystick to loose sync.

Oh well, I still need more lab work to find the correct configuration and I will probably need to add a small circuit for regulating 5V from the power supply.
The first measurements I did with a 9V battery showed that a current of ~60mA was required to power the main circuit (the main processor, the Echo Sensor and the Wireless Joystick connector). the 9V I had can't really supply too much current. Connecting a Voltmeter to the circuit showed the voltage getting dropped on the battery. Adding capacitors did help, but did not solve it, it only delayed the effect.

What I really want is to power everything from only one battery source. Currently I used two power sources, the 9V battery to power the main processor and the 4x1.5V batteries (6V) to power the motors.

I'm still waiting for my Li-Ion batteries to arrive and hope it will do the job, so for now I'm on hold for the power supply - I will do some more tests to ensure that I have everything ready until I get the Li-Ion batteries.

Now to something different:
Let's move to the missile launcher. First thing is first, let's remove the guts of the missile. 
The main board had the wires of the motors soldered to it, so I took a wire cutter and snapped them loose.
I then took a ribbon cable of 16 wires. Why 16?
3x "2 wires for motor"
5x "two wires for motor trigger"  (left, right, up, down and missile launched)

I really could have used only 11 wires if I really wanted to and everything would have worked just fine. All the motor triggers can be connected in daisy chain common ground wire for one end and the other end is really the trigger. As the missile motor does not require an H-Bridge one end is connected to ground so you also save another wire.
One of the best inventions is the Hot-Glue, it simply makes your work much easier. I used the Hot-Glue to stick everything together and keep them in-place.

I made sure to label all the wires to know which goes to which.


Above is the final product. The supporting circuit has been designed but still not built. Making a prototype PCB is really time consuming. It takes me around 3 hours to create one.

I'm dumping more picture of the SmartCar just to give a sense on how it looks right now.
Above is the supporting board for the Car Wheels.


Above you see the Wireless Joystick connector

Monday, October 7, 2013

Toy Car missile launcher

I have one of these (similar) missile rocket launcher which I don't use anymore, after all how much will you use it.

It's time to recycle!

The plan is to place the missile launcher on the Smart Car and control it via the PlayStation joystick - now that will make a nice toy for my kid.

Let's dissect and see what's inside shall we?
Nothing much in the upper part of the launcher, but there are a few things to notice here. The motors are regular DC motors and not servo or stepper motors therefore controlling the angle of the head is not something predetermined. The first thing to watch out is when tilting the head of the launcher it needs to stop at a certain point so that it won't simply break the gears or burn the motors. The way they do it for this launcher is by a trigger switch which you can see in the following picture:

When the head tilts as low as it can a trigger switch will be pressed that will cause the motors to stop. This is also done for the turning of the head left and right. This is something that needs to be handled via the PCB that I need to build to make the launcher work properly and not break after a few shots.
The trigger switches for the head turning left and right (horizontal turns) are connected to the two yellow lines and the second one is connected to the two orange lines.
I have marked with RED the lines that go to the motors and in BLUE the trigger lines that indicate that the head of the missile launcher reached the end of the horizontal or vertical turn. This is important so that when triggered the motor should not be moved any more in that direction so that the missile motors and gear won't get damaged.

I disassembled the head to understand what I'm dealing with here. The missile are loaded and shot from a single motor. The motor turns the missile holder to load the next missile, then it pulls back a missile shooter which is placed on a spring and then releases it. When the missile is released, there is a trigger that is pressed when the missile is released, this is to know when to stop the motor.

This made me think a little, if the motor stops when the missile release trigger is pressed, then the next missile shooting should start when someone presses the fire button, this will require the missile launcher to load the next missile, pull back on the missile shooter and then release. This can take some time, well, 3-4 seconds.
I have a better plan for this. I'm sure I can make a piece of code that can measure how much time it took for the missile to get released and calculate the time it requires to simply load the next missile, pull back on the missile shooter, but stop just before the release making the shoot time when pressing the fire button as short as possible.
The green wire is connected to the trigger and the orange-red wire is the motor power line.

Just to give you an idea, I did the schematics for the motors and it's very similar to the first schematics which are for the wheels of the Toy Car as they both use regular DC motors. The difference here are the trigger points that must be connected to the PCB to trigger when reaching the limits of the head turning.

PlayStation Joystick Control

So I now have a Toy Car, with a basic remote that can make the car go forward backwards and turn in both directions. This is really not something new to my kid nor that of a unique toy, but I have some plans to spice it up but this will have to wait to the next post.

Let's focus on the title of the post, the PlayStation joystick. I have one laying around from the old days, it's a wireless one and also came with a dual port converter to USB.
The USB converter seems to have become broken for some reason that I care little about (I have another one). It does show signs of life as you see in the picture, but nothing much happens beyond the USB port.
Great, now lets take it apart! :).

Yeah, I really don't give a damn about the board, but I only need the connectors. The connectors can be attached to an Arduino that is programmed with the relevant software and see what happens.

I took the first connector and attached some wires to it to see if this is really any good or if it even works.

I connected the wires and uploaded the sketch taking from:
I used the picture of the connector to connect the wires.
The communication with the controller is rather simple but require some effort.
1. Send an "Attention" to the controller so that it will be ready to receive a command via the "attention" line. This is actually the "Control Select" line which is used to indicate which control is currently in use. Each controller has it's own line. The rest of the wires (lines) are shared between all controllers (sort of a bus like).
2. Send a command to the controller via the "command" line.
3. Receive the data via the "data" line.
4. should receive and ACK from the "acknowledge" line, but the library simple doesn't use it, I can understand why :).
The "clock" line, well it's a clock line what do you think it does? :).

The wires that are required for the connector to function are 4:
1. Attention (or Select)
2. Command
3. Data
4. Clock

Seems to do the job. The joystick functions rather well, let's use the other connector and make a more convenient connector to plug into whatever PCB I will make.




Although the "ACK" line is not required, I still connected it, and also maintained the coloring as described in the link above just to get a better reference when connecting the plug to the Arduino.

Monday, September 30, 2013

Remote Controlling the car

So the car can run and move, now to the fun stuff, to add a remote control to the Car.
First things first, what to use as a remote? I decided to use a Joystick BOB (break out board) module. Look at the picture, does it look familiar? It should, it's the same analogue Joystick you use in the PS/PS2/PS3 controllers. To connect it to the Arduino board it's very simple, the module has 5 pins which are (not in the correct order :)):
1. VCC
2. GND
3. X - Axis
4. Y - Axis
5. Swtich

The connections, well, the first two you know where they go. The X and Y axis goes to the analogue pins of the Arduino. The switch is optional, if you like to use it then connect it to whatever pin on the Arduino.

The X and Y axis are actually POT devices, so when tilting the joystick, the X will have a certain voltage from 0 - 5V corresponding to the tilt and the Y acts the same. 

Great, now the Joystick is connected and the Arduino can read the position of the Joystick, let's try make something run.

Still, the data needs to be sent wireless to the Toy Car. Again, cheap stuff. There are nice 433Mhz transmitter and 433Mhz receiver modules that can be used for this. These modules are really cheap, something like 1.25$ for both a transmitter and receiver.

The thing is on these cheap wireless modules is that they really don't do much.
The transmitter when the data pin goes to HIGH, starts sending a 433Mhz wave signal and that's it. When the pin goes LOW, it stops sending the wave signal.

The transmitter when receiving a wave signal on the 433Mhz band, it turns the data pin HIGH and when there is no signal, it turns it to LOW.

You can understand that these modules will not work out-of-the-box and require some software tuning code. Luckily, there is a nice Arduino library called VirtualWire that does all the fine work of CRC checks and synchronizing the transmission and receiver to a pre-configured baud rate. The library does not support multiple transmitters, or to be more clear a collision detection or avoidance mechanism (for wireless it's CA - Collision Avoidance). I'm not going to go deep into it, but I do have an idea on implementing it myself, but that will have to wait for the other 5 433Mhz module to arrive so I can do some tests.

The transmitter module and the receiver modules do not come with an antenna, so just for the purpose of the tests, I used an alligator clip as an antenna.



Great! Now let's connect everything together. The Joystick will be connected to the first Arduino board along with a transmitter module. It will read the values of the joystick and transmit them, nothing fancy.
The second Arduino will be connected to the Toy Car and the receiver module.

After a few tries from my son (my trustee QA :)) I finalized the correct calibrations, and the car worked nicely.

Here is a demo of my son testing the car:


The sound of glass braking at the end of the video was done by my daughter that dropped a glass by mistake in the kitchen, nothing serious :).

Saturday, September 14, 2013

It can move

Making the car actually move was not as smooth as I expected. When I got a well constructed circuit for an H-Bridge to control the motors on a breadboard, it took me quite sometime to debug and understand what is not ticking. After making it work on a single motor, I created the PCB.

Time to construct the car and make it run.
I connected the motors to the car body and hooked the wires to the motors:

What you see in the above picture is the bottom of the car, so the motors actually go under the car. On the other side I placed the H-Bride PCB and connected the wires:

I then placed the upper platform of the car to mount a breadboard to continue the testing and hopefully make the cat run.


I took out an Arduino board and connected the pins to the H-Bridge using a breadboard and created a small sketch that will make the car move forward, backwards, rotate left and rotate right, each for 2 seconds.

The first tests didn't make the car move at all. Now that is a bummer. At first I though it's probably the battery, so I hooked them directly to the motor and the motor ran like there was no tomorrow. Back to the drawing board.

Looking at the schematics I created, I used 100K resistors so I will have a small as possible current leakage. I found a very cool site with a JAVA applet that can do a rather well simulations, check it out (The link has also the code to the H-Bridge circuit that I created):

Just to be clear, when I indicate a leakage I mean the current that passes though the H-Bridge Circuit and does not pass though the motor.

The good solution would be to place a 3 Darlington Transistors together and not just a pair, which would have solved the problem, but this would require a new PCB and throw away the one I already made. Another solution that is not so bad is using lower resistors to allow more current to drive the Transistors and allow more current to flow to the motor. Making the resistors 10K instead of 100K should resolve the problem. This, however, will have a current leakage problem when the motors run. If the input switches, both of them are set to off state there is a very minor leakage (in the PICO rating), when one of them is turned on, there is a leakage current of ~1.3mA. Well, it's not so bad, considering other alternatives I think this is the preferred solution.
OK, got the new 10K resistors replacing the 100K and this indeed did the job.
This is the updated Schematics

Don't want to bore anyone, but I also had a problem of the Arduino getting reset when using the same power supply as the motors. I didn't debug this, but I also decided not to mess with it too much, so I hooked a 9V battery to the Arduino, connected the grounds together with the H-Bridge ground and made the motors run on a 4 AA Cell batteries.

And now for the test. The test went as expected, but I still need to test the motors when I run them with PWM to see if I can make the Car go left and right in different speeds.

The next step would be to use another Arduino board connected to a joystick and wireless transmitter to make a remote control for the car. I will also need a wireless receiver on the car as well.

On last thing, I made a video of the test I did with the car after all the adjustments, enjoy.