Showing posts with label Bare engineering. Show all posts
Showing posts with label Bare engineering. Show all posts

Thursday, September 17, 2015

How to add intelligence to our homes? - Part 2

This is the long overdue update of the house project conceptualized a while back with my kids.  In this project, a model house was wired for simple lighting using LED's.
 
The USB home
Each part or room in the model house will be lit by a dedicated LED and each LED will be directly connected to the pins of the microcontroller, in this case, the Arduino Uno.
 
The Arduino Uno wired using a recycled IDE cable


The Arduino being wired
The Arduino will act as a hardware controller/driver to power up the LED's but commands will come from a PC.  This whole architecture can be ported to a real, full sized house and control is not limited to lighting only but for the purposes of demonstration, the model house should be sufficient to illustrate.
The GUI in a Windows PC



The GUI showing the check boxes and sliders as control inputs

The model home is connected to the PC via the USB port.  The Uno will function as a slave unit with the PC as the master.  If a user clicks on the GUI, the corresponding LED will light up (or toggle off) in the actual model home.  This therefore illustrates how a real USB controlled home can be made possible.

Wednesday, December 25, 2013

Line tracking truck upgraded

Well, it's Christmas and the kids and I have more time together.  We exchanged gifts and I got this gift below.  This is a collection of comics pages from newspapers!  :-)  This is probably the funniest I got so far so I can really look forward to the next year and be excited about what to expect again next.



After the gift giving part was through and the funny talk has subsided, we were back to the line tracking truck project.  After the code was tested and optimized for actual runs (considering motor speeds and sensor feedback triggering, etc), it was time for some UPGRADE.   One interesting upgrade is how to incorporate a reasonable degree of recovery in cases of overshooting the line.  Thus, a "recovery" routine must be integrated into the code so that the truck will try to "look for" the line back once an overshoot is encountered.  Several code modifications were needed to make this workable.

1.  The overshoot should be minimum.  Thus a quick stop code is to be designed to react quickly once overshooting is detected.
2.  Overshoot must be defined.  The idea is to try to recover from a turning overshoot.  If the line/tape ends in a straight line, the assumption is that the end of the line is reached and no need to "recover."  However, if the overshoot happens in a turn, the truck should try to get back into the path.
3.  There must be a limit to the recovery procedure.  If after a certain number of tries, success is still not achieved, the truck should stop trying in the end.


In this upgrade, the truck was already provided with an auto-detect function.  In the previous run, the tape was white and the floor was dark.  This time, black "tape" is used against a white floor.  The truck will auto-detect a bright or dark floor and then use that information to sense the line/tape.  If it cannot calibrate, it will flash an LED so the user will know that a calibration error occurred.  A manual reset is needed (so it can try to calibrate again)


Looking for a black tape however was not as easy as I thought.  I cannot find a black tape at home wide enough for the sensor spacing design and stores are closed for the holidays so some improvisation was required.  So finally, some scrap black strip and a laptop bag strap were used for the testing.  A bend was introduced into the path so that the truck will overshoot on purpose during the execution of the turn.  If you remember, the minimum turn radius of the truck is only 2 feet.  The bend below is definitely with a much smaller radius than the supposed smooth turn of 2 feet. 


To come up with the logic of the recovery, the assumption was that there must be first a "detected" turn event.  This will be the basis for action.  The recovery will involve a reverse move with a matching steer to the opposite direction.  (the steering for this reverse motion is currently set at 10degrees only)  The truck then will stop at an instant of tape/line detection.  This is the desired success criteria for the recovery procedure so that the truck can go back into tracking the line.  If the truck cannot find anything after a certain number of search cycles (this time it is set to 5), the failure will be acknowledged and the search will stop.


After several erroneous codes and some funny truck behavior, the serial monitor was used (and abused) to understand where the erroneous values came from.  Then it was found that the sensor values in the "recovery" routines were conflicting with the initial calibration logic and modifications were made for consistency.  The timings for the quick stop motion was also not right.  In the end, for the truck to stop, I have to introduce a reverse motion at full motor power for 500ms.  This is enough to "kill" the momentum but not enough to cause much reverse movement.


Finally, below is the video of the truck overshooting and trying to recover.  Notice how it stops and reverses in the bend, then recovering back to tracking the line.  Then, it makes a quick stop after the line ends (this time in a straight line fashion). 


Merry Christmas to all.  May God richly bless everyone and more projects to come for 2014!

Saturday, December 14, 2013

Cruise control for an old truck

Cruise control is to maintain a car's speed at a certain number during long drives.  The system is designed so that the throttle is electronically controlled to adjust and respond to the load demand.  As the car cruises along a gentle climbing road, the throttle should open up to maintain speed.  Inversely, as the road gently slopes down, cruise control will close the throttle to still maintain set speed.  The key is proportional throttle control as well as closed loop speed sensing.  

I happen to own an old truck with a manual throttle control as shown below.  For this project, this manual throttle control is the perfect candidate for automation.


To make it work:

1.  High torque servo motor drive mechanism
2.  Hall effect speed sensing
3.  Lots of speed calibration values
4.  Mechanical system to link the throttle to the control servo
5.  Stepping on the brakes to immediately disengage the system

For safety, the project will not tamper with existing electrical circuits and mechanical systems but will be a full piggy back system.  The servo mechanical drive will be fully override capable in case of abnormal behavior.  Power failure will also put all mechanisms back to manual default.

Project milestone:
Completion by end Q2, 2013

Ideas are welcome if contributed for free. :-)

Friday, December 13, 2013

Light seeking truck project

This project is a demonstration of how to create a light seeking system that is relatively low cost to make and execute. This involves an Arduino microcontroller as the heart of the whole project.  The target system is a truck that is a broken down RC, bought from a second hand store on an "as is" basis as referred to previously in the older posts. 

The building blocks:

Below is the video of the first building block of code and electronics.  It involves two light dependent resistors (LDR), a servo motor and a light source to test the responses.  As light is focused on any one of the LDR's, the servo moves accordingly.  The design thought of is that the servo movement should be relative to the difference in intensities read by the LDR's.  The bigger the delta, the greater the angular rotation.  This system will be the basis of the steering system for the truck.

 


From the above, the design was copied into the truck body itself using a prototype breadboard as seen below.  The servo motor is already installed in the steering mechanism replacing the original DC steering motor installed.  We would be interested to control the steering in incremental fashion and not only in fixed angles, left or right.  Aside from the LDR's, a 4-channel IR sensor is also being put in place to be used for another project later on (the line follower project).




This is the first prototype of the hardware and software together in the truck body.  The original electronics of the truck were removed (PCB at the tip of the screw driver) and will be disposed of.  The software was tested using an Arduino Leonardo (mini format) compatible board.  This was chosen because of the thin layout fitting the thin breadboard.  The program will be ported later on to the Arduino Uno to be installed into the truck body.



Below is the truck with the LDR's already in place.  Two placed in the front and two at the back.  All placed on the corners of the truck body.  The Arduino board is also installed as can be seen under the deck of the truck.  The power to the drive motor will be provided by the L293D H-driver IC.  All the IR sensors are placed under the front bumper for the later project.


Almost all set.  Now, it's time to close the truck, upload the software and test run the system.  Below is the first steering test.  Using a laser pointer to trigger the LDR's, the front wheels steer toward the light input.  This is our first taste of success.



For the full functional test, power must now be from batteries because we have been using the USB port to power the system yet.  The final step was to connect the Arduino to battery power as well as connect the H-driver to the battery as well.  The drive motor will be powered from the battery without going through the Arduino. 


Running the prototype:

Below is the first ever test run of the light seeking truck.  Obviously, the sensors and steering need to be optimized further but the demonstration unit is already a success story. 



Friday, December 6, 2013

What is bare engineering?

Welcome to bare engineering. This blog is about exploring possible applications of the basic sciences in everyday life with bare minimum costing as much as possible. Do visit time and again. Your suggestions and project ideas are also welcome.