Thursday, December 19, 2013

Created my first 3D printer design. An external RFID case.

I am planning on playing around with RFID to open the door to my house.  The RFID board I am using is just a circuit board, so I needed something to mount and protect it outside the door. I didn't see anything on Thingiverse, and I had just looked at an openscad tutorial, so I went through step by step and made an enclosure I thought would work for me.

Downloadable from here:

http://www.thingiverse.com/thing:207213


Building a framework to manage Hackmaster character sheet management

I'm working on a project with a friend to manage the Hackmaster RPG character sheets on the web.

We are working to set up a basic framework for the site.  We want a single page to be updated dynamically with no reloads at all.

Our thought is to use MongoDB using Perl on the web server back-end as the presistant data store.  Then use jquery to pass data to and from the server to the web page.  Finally Use knockoutjs to update the data elements in the page.

How to install mongodb on Ubuntu:  http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

How to install knockoutjs: http://knockoutjs.com/downloads/index.html

Testing if mongodb works:

> Mongo
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
    http://docs.mongodb.org/
Questions? Try the support group
    http://groups.google.com/group/mongodb-user
Server has startup warnings:
Mon Sep  2 22:30:58.039 [initandlisten]
Mon Sep  2 22:30:58.039 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Mon Sep  2 22:30:58.040 [initandlisten] **       32 bit builds are limited to less than 2GB of data (or less with --journal).
Mon Sep  2 22:30:58.040 [initandlisten] **       Note that journaling defaults to off for 32 bit and is currently off.
Mon Sep  2 22:30:58.040 [initandlisten] **       See http://dochub.mongodb.org/core/32bit
Mon Sep  2 22:30:58.040 [initandlisten]
> db.test.save( { a: 1 } )
> db.test.find()
{ "_id" : ObjectId("52254b79b578d8dc54e545ac"), "a" : 1 }
> quit
function quit() { [native code] }
> quit()
Next thing I need to do is to write a little perl cgi script to act as a gateway between the web page and mongo. 

How to redesign the future.

One of the major problems in people's lives is that too much stuff we use is not designed to work together. The people who design the different systems in our houses (heaters, dishwashers, clothes washers, dryers, fridges, freezers), our cars, our phones, and our computers are all work independently, with no concept of managing the houses power.  This inefficiency in design makes the modern house nearly impossible to convert to alternative energy systems.

If I were running a huge high tech company,  I would take in 100 random families from every area in the country, 2 per state, and build them 10 different  styles of housing, ecologically sound and sustainable, something that reuses a lot things we think of us as waste today.  The initial building should be engineered to last 100 years. I would design these houses so that even if they were torn down, everything that went in them could be used again in another house.

The houses should each be independent, off the grid and not connected to any utilities. They should have sufficient solar panels and wind generators to power the house and to recharge the electrical vehicles and electric mowers, and electric power tools.

I would roll out 10 versions, to 10 families each, of a complete set of technologies, and create a single environment that spans from smart phones, to pad computers, to TVs, to laptops, to desktop machines. An environment that would make it impossible to lose data, that securely shared info anywhere in the world, proof even against the best intelligence agency/corporate spying.  That could scale up temporarily using shared cloud processors to inexpensively perform massive calculations in the blink of an eye.

This environment would span all the house systems, including the appliances, heating, cooling, and hot water generation.  By centrally managing when each system is drawing their highest amount of power so that they take turns you could reduce the maximum amount of amps needed to run a home by a factor of 10.  Just by taking turns, not running the the washer up in a spin cycle when the freezer compressor is running, you can massively reduce the maximum level of required amps. By using LED lighting, and light pipes to bring in ambient sunlight you could reduce the power required for lighting to about 1/4 of that required for florescent lights. Half the energy used in a house goes to heating water. By using solar water heaters you could make the cost of generating hot water essentially free.

Such a house could easily be powered by a many fewer solar panels and a much smaller set of lead acid batteries than a standard house that does not intelligently manage its power requirements.  This makes the return on investment of the solar and wind power generation system pay back in just a few years instead of in decades.

I would combine the best features and requests of all these different groups of people, fix any problems they run into, and finally roll out a complete solution to living, that uses tech as a tool to make people's lives better and more complete.  The reuse and recycling of common waste items would create entire new sectors of our economy. I would radically redesign everything from scratch, creating a house that can be build and maintained for much less than anything mass produced today.

Finally I would redo how houses are built. I would manage the way houses are build centrally, for economies of scale. Think car manufacture, not house contractor for the model I would use to roll out these new methods of living. But the houses would be designed online by the customer, then the blueprints generated would be approved by an engineer and an architect, working with the customer to quickly nail down any issues, any custom construction built in a large building and shipped to the customer site where a uniformed professional work crew that makes a living wage would assemble the homes.

Thursday, August 1, 2013

Today's Sensor is the Joy Stick!

I am slowly going through all 37 of the modules in the Sunfounder lab kit, one a day. 

Tonight I wired up the joystick, and tried out the sketch from the documentation.  The markings on the board were good, and with the help of the sketch I was quickly reading the analog values, but the digital button seemed to not work.  I remembered that there is a built in 20K ohm resistor inside the Arduino.  This means that the pin will normally be high, and then go low when you press the button.



Save this file as Joystick.ino inside a Joystick directory in your Arduino folder.
int jX = 0; // Analog pins for X and Y axis.
int jY = 1;
int jZ = 7; // Digital pin on Z axis.

void setup ()
{
  pinMode (jX, INPUT);
  pinMode (jY, INPUT);
  pinMode (jZ, INPUT);
  digitalWrite(jZ, HIGH);  // This was missing.
  // The above line sets the pin high
  // and engages an internal resistor.
  Serial.begin (9600);
}

void loop ()
{
  int x, y, z;
  static int px, py, pz;
  x = analogRead (jX) / 10.24 - 50;
  y = analogRead (jY) / 10.24 - 50;
  z = digitalRead (jZ) ;
 
  if ( px!=x || py!=y || pz!=z ){
    Serial.print (x, DEC);
    Serial.print (",");
    Serial.print (y, DEC);
    Serial.print (",");
    Serial.println (z, DEC);
  
    px=x;
    py=y;
    pz=z;
  }
 
  delay (200);
}



I added in some logic to only report when there is a change, the static keyword only allocates the variables once, and then stores the old value. I also scaled the range from 0 to 99 on the x and y axis, and then subtracted 50 so that center scale is zero.

The pin out markings were good on this one.

Wednesday, July 31, 2013

37 sensor kit from Sunfounder lab

So, I saw this kit on Amazon.  It seemed too good too be true.  The kit was priced right, it was less than 2 dollars for each board.  Of course many of the boards are not sensors, some of the 37 are emitters of various frequencies of light and sound.

The package arrived in just a few days.  It was small enough to have been left by my mail carrier in my mail box.  I opened the medium sized padded envelope  and pulled out a nice plastic case that firmly latched shut.  Opening the case revealed the 37 modules each in little plastic bags.  None of them were labelled and there was no documentation.  Each module seemed to be well made and I didn't see any badly soldiered joints. 

Freshly unpacked.


Everything came mounted on tiny boards.  These easily plugged into a breadboard and I was able to connect several different modules to an Arduino board.   I sorted the various modules 2 or three into a single small bag.  I used the picture from the Amazon web page to identify each item.  This got rid of more than half the bags and organized the modules by function.

The list of modules from Amazon:

1.Passive Buzzer Module
2.common-cathode RED&GREEN LED Module
3.Knock sensor module
4.Shock-switch sensor Module
5.Photo resistor sensor Module
6.Push button Module
7.tilt-switch Module
8.RGB LED Module
9.infrared-transmit Module
10.RGB LED Module
11.hydrargyrum-switch sensor Module
12.two-color commoncathode LED Module
13.Active buzzer Module
14.Analog-temperature sensor Module
15.Colorful Auto-flash Module
16.Magnet-ring sensor Module
17.Hall sensor Module
18.Infrared-receive sensor Module
19.Analogy-Hall sensor Module
20.Magic-ring Module
21.Rotate-encode Module
22.Light break sensor Module
23.Finger-Pulse sensor Module
24.Magnetic spring Module
25.Obstacle avoidance sensor Module
26.Tracking sensor Module
27.Microphone sensor Module
28.Laser-transmit Module
29.Relay Module
30.18b20 temperature sensor Module
31.Digital-Temperature sensor Module
32.Linear-Hall Sensor Module
33.Flame sensor Module
34.High-sensitive voice sensor Module
35.Humidity sensor Module
36.Joystick PS2 Module
37.touch sensor Module


There was also a download link that had more information about how to use the various modules. 

The download is kind of a mess.  The manual reads like it was machine translated from another language.  I need to work on cleaning this up and uploading it to github so that people can just drop in the library and have examples for all the modules, and modules that show how to wire everything up.

It was also not clear to me how to wire these modules up to an Arduino board.


Oh look, it is a DHT11 !  Ignore the G N D V, that is just gibberish.


Looking down from the top, brown wire is ground, red is 3.3-5v power, and orange is signal.


Conclusion

Overall the hardware is nice.  Everything I have spent the time figuring out I have been able to get working.  Many of these boards would be several dollars individually by themselves.  The humidity sensor itself is 5 or 6 dollars if bought by itself.  IR receiver's are $2 as a bare component.  Having the bare component mounted on small boards makes it much easier to breadboard up examples, and the components are much tougher mounted in the modules than they would be otherwise.  Especially for me, since as I get older my hands get more and more apelike.

The only possible thing that one might consider bad is that many of these boards are near duplicates... there are 4 modules that sense temperature, 3 hall effect modules, a couple RGB lights, and so on. A little less duplication and a little more variety might be good.  But this might also be seen by some as a good thing.  Maybe you want to explore how variations on these components all work. 

Unfortunately, if you are currently looking for something you can just buy and get working in a day, you must look elsewhere.  The sole negative, but it is a giant negative, is that the Arduino sketches and instructions on how to wire up these modules is fairly difficult to do.  I've been spending a couple of hours getting each sensor to work in an evening.  I like doing this, so no big deal to me, but this might be a deal breaker for someone else.

Another thing that would be nice would be to throw in a few 3 wire, 4 wire, and one 5 wire female to male connectors so that you can easily wire the components right up to the pins on an Arduino board.  I bought this wiring kit for the variety of wiring options it gave me for Arduino, breadboard, and Raspi.

Thursday, July 18, 2013

Update on my Raspbmc media player project.

The Infrared Remote control is working great now.  This means that I can just reuse a free old remote control and move the $20 wireless USB keyboard onto another project.    This also means that the player draws even less power now, the IR Receivers are amazingly low power.  I am re-using the old remote control from the media player that Netgear deactivated as soon as I hooked it up to the Internet. 

I got an IR receiver from Lady Ada's site here:  http://www.adafruit.com/products/157 for just a couple of dollars.  Plus shipping, so buy a lot of other stuff there too. *L*

I also bought the cable and bread board connector for the Raspi here:  http://www.adafruit.com/products/914 Since this is  reusable for many projects I consider it a tool and am not adding it to the cost of this single project.

If you want they sell a remote control with a configuration file all figured out for you already.  If you want to reuse and old remote, that is easy to do too.

I followed the directions on Ada Fruit as well and programmed my remote control in just a few minutes.

http://learn.adafruit.com/using-an-ir-remote-with-a-raspberry-pi-media-center

I had to type in the commands from a screen shot, here is something you can copy and paste from:

sudo modprobe lirc_rpi
sudo kill $(pidof lircd)

mode2 -d /dev/lirc0
irrecord -d /dev/lirc0 ~/lircd.conf
 

A lot of remote controls have been programmed already, and the config files shared at this site: http://lirc.sourceforge.net/remotes/

This receiver is so much more sensitive than any I have ever used before.  I can literally point the remote control 180 degrees away from the chip and it still reads the button presses.  The old media player would sometimes not get a button press pointing right at it.

I have three more of the chips and 3 more Raspi boards, so I will be adding a wire harness to each of these 4 chips and wiring up every Raspi I own with inexpensive IR. 

The Raspi's can also send IR so I will be working on that next. 

Monday, July 15, 2013

Reply from my Senator regarding illegal NSA data collection.


Dear Mr. [Name Redacted]:
 
Thank you for sharing your concerns regarding the recent revelations of data sharing between Verizon and the National Security Agency (NSA).
 
According to documents released in the press, the Federal Bureau of Investigation (FBI) sought permission to collect data on cell phone use of Verizon customers as part of a classified program aimed at preventing acts of terror in the United States. The Foreign Intelligence Surveillance Court (FISC), which oversees requests for classified electronic surveillance for foreign intelligence gathering, approved at least one request that Verizon provide the FBI and National Security Agency (NSA) with select call log data for Verizon customers. The FBI claims the data collected and shared includes routing information such as originating and receiving phone numbers, individual mobile subscriber numbers, calling card numbers, and the time and duration of each call. It does not include content of the call, or the personal location or identification information of customers.
 
The FISC was created in 1978, and is composed of 11 federal judges. Its authority to grant access to business records was established under the USA PATRIOT Act and was extended in 2008 and 2012.
 
Thank you also for sharing your concerns regarding the National Security Agency’s (NSA) data collection program “PRISM.”
 
The Director of National Intelligence (DNI) recently confirmed reports that the NSA has used a classified computer system known as PRISM to collect foreign intelligence information. The system contains communications of foreign citizens located abroad that have been collected by internet service providers and delivered to the NSA for analysis. The DNI also released a public fact sheet about the program. It is available at: http://1.usa.gov/1bhNPkX.
 
PRISM’s information gathering falls under procedures that were passed in the FISA Amendments Act of 2008 (FAA) and extended by the FISA Amendments Act Reauthorization Act of 2012. While the internet service providers subject to information requests have not been confirmed, the DNI stated that all information was provided after the law enforcement and intelligence agencies’ requests were approved by the FISC.
 
I fully support efforts to protect our nation, but such efforts must not compromise the very foundation that makes our country great; our civil liberties and Constitutional rights. Many questions, including the breadth of the information gathering, the extent of information about U.S. citizens that was gathered, and the length of time that the information was kept on file, must be addressed.
 
It's critical that we find a balance between security and freedom. Protecting our national security is critically important, and we still need to learn more, but any sort of overbroad surveillance is cause for serious concern. I voted against the Patriot Act in 2001, the FISA amendments in 2008, and the extension of Patriot Act provisions in 2011. I will continue to support measures that protect our nation from terrorism while also reforming the most dangerous parts of this law to protect our civil liberties and constitutional rights.
 
I will continue to closely monitor this situation as additional details about both incidents come to light. Should any legislation related to intelligence gathering and our civil liberties come before the Senate, I will keep your views in mind. Thank you again for getting in touch with me.
 
                         Sincerely,
              
                         Sherrod Brown
                         United States Senator
 
 

Wednesday, July 10, 2013

Flexible, Low Power, Yet Powerful Computing System.

What I would like to have is a computer with many programmable circuits so that the system can reconfigure and rewire itself on the fly. 

When you want a music player or a video player, or a video encoder, or whaterever, it loads the codexs onto very low power circuits and the main CPU idles as it only does enough to keep data fed between the memory, disk, screen, and the circuits.  Imagine a computer that could play 1080P video while encoding the video at the same time in real time and only draw a few watts of power.   Imagine being able to convert a half dozen videos at the same time, in less time than your most powerful computer can do it now, and still draw less than 10 watts. 

A few dozen common protocols and functions could be permanently loaded into ASICs so that they are always ready to go without any setup time.

The computer could be upgraded by just replacing the ASICs with newer ones, or stacking more

Tuesday, July 2, 2013

Makerbot Replicator 2 has an Extruder Feed Problem.

But the community already had a fix before I even got my printer.  The symptoms are varied.  Prints won't stick to the platform no matter how carefully you adjust the table.  You might just get a missed layer here or there, which really weakens a print.  Or you might get the dreaded air print, when you leave a job that is going to run for 12 hours and you come back to find it only printed half the job and is now just merrily printing nothing into the air.

The problem is the design that came from the original reprap and is a common design issue with many of the modern printers that derive from this venerable ancestor.  There is a hard plastic nub that presses the filament against the extruder drive gear.  The nub is positioned with a hex screw whose position is behind a fan and some wires.  I had issues each time I adjusted the tension on the nub because I would move the wires and the heater would lose power and not maintain temperature until I pressed the wires back into the connector.  The only tension on the nub is from a tiny rubber o-ring, but any more than minor fluctuations in filament diameter would cause the filament to stop feeding.


The problem part, from it's location in the top of the printer, to it's placement on the stepper motor, to where it is in the plastic housing.

Driver stepper motor in place on extruder head from center to right.
Motor and drive gear removed from extruder head.

The assembly that guides the filament and presses the filament into the drive gear.

The solution to the problem is to print an upgrade part from Thingiverse that fixes the problem.  This can be found here:  http://www.thingiverse.com/thing:42250


This is my fix in place before I put the fan cover back in place:


One problem that I had with this upgrade was the high cost of shipping for just a single part, or having to buy far in excess of what I needed for this one project.  Another was the time to get the parts.  I foolishly orded


So what I am proposing to do is to offer the 9 kits that I made up for sale, either just the hardware or the hardware with the plastic piece, just in case you waited too long and your printer can no longer print.

The kit with the plastic parts printed and fit together looks like this:

Kit assembled and printed in Yellow plastic, red and green are also available.
Update May 2013

It looks like Makerbot finally recognized their problem and are having a batch of replacement parts made to update their machines in the field.  I paid $9 for the "free" upgrade, which they claim is for shipping and handling, but that was months ago and I have yet to get the parts to do the repair.  I suggest still doing this fix until you get the mass produced replacement parts.

Dec 2013
I got the replacement part a couple of months ago, finally.  Was too busy in college to upgrade the printer at the time.  Going to tear into the printer at the beginning of the year to finally fix this issue.

Friday, June 7, 2013

Added an OPDS library book server to my media server.

I had no real concept about what software was available to share a library onto a network.  I knew that it was possible because I saw the option in fbreader.  Fbreader is some great software that I have been using for years.  

I did a google search and stumbled across this site by luck:  http://blog.slucas.fr/en/oss/calibre-opds-php-server

What this person did was to use a database and directory created in Calibre as the basis of his library, and then write software to put that library onto the network using the OPDS protocol so that it was accessible to any compatible book reader.    His philosophy is that Calibre is a great product, but way too large a foot print and too many dependencies to use for an embedded file sharing system, like I built last weekend.
 
Getting the service running was a breeze. I just followed the 5 step directions on the site where I downloaded the web app. The only snag I hit was having a space in the directory name of the path to the book folder. Once I got rid of the space it just worked. The error page I got was very clear and pointed me right at the problem.


I pointed fbreader on my pad computer at the library by clicking back, open network library, add catalog and putting in the path to where the software lives on my web server.   

This web service works amazingly well. I am using fbreader on my pad computer and am able to browse the directory of books about 100 times faster than browsing the same directories on a local sd card on the pad computer itself.   The memory consumption and required processing power to share the library is minimal as well.

Great job Sebastien Lucas!  He is the author of this great web service.

Now I just need to load everything I own into that Calibre library and I will be set.

This is the view of the web service running in a web browser.


--

I ran into one issue with minidlna needing too much memory if I had it include my image and music folders.  I only have 256MB of RAM on the server, but plan on buying a 1GB memory card next week when I make a trip to the big city. This should allow me to index and share my music and images using minidlna.

Every American with a phone is being monitored by the NSA.

This blog is not just about technology, it is also a blog about freedom and rights. Because if you are not free then you are not free to use technology in the ways you want.  In a totalitarian regime it is illegal to communicate freely, so you can't share cool hacks with each other.  It becomes illegal to use encryption, or to program micro-controllers, except under the watchful eye of a political officer.

We are finally finding out just how far down the rabbit hole we have fallen. Last month we found out how many reporters were being electronically surveilled. https://pressfreedomfoundation.org/blog/2013/05/virtually-everything-government-did-wikileaks-now-being-done-mainstream-us-reporters  This month we get to find out exactly how many American Citizens are being monitored daily, and it appears that anyone with a phone is being tracked.  The EFF organization has a great write up regarding this entire issue which arrived in my inbox tonight.  The subject line begins  with two words.  "Stunned. Angry."

https://supporters.eff.org/civicrm/mailing/view?reset=1&id=427

This is not a Republican issue, or a Democrat issue, since the same thing has now happened under two different administrations, one of each party. This is an American issue that we should all care about.

I doubt very much that the Feds would just make Verizon hand over all their records everyday, so this must be happening with every telecom company in America. It appears that every phone call in the USA; local, state, interstate, and international, is being illegally tracked without a warrant. How many of those calls are also being listened to, authorized by a judge that will rubber stamp literally anything that crosses his desk, is anyone's guess. 

If they track who you are calling then they have a list of your friends, family, and business associates. For what purpose they need lists like this I have no idea, but the purposes that such lists have been used historically is sickening.

Thursday, June 6, 2013

Low cost electric boosted covered seated bike.

Gas prices getting you down?  

I am working on an electric boosted, covered, one person seated bike.  Basically take a tandem frame style bike with a shell and add an electric motor.  Cover the bike for aerodynamics, safety, and to allow the bike to run in bad weather.

Design specification

Take one person, a book bag, and a couple of bags of groceries from home, to school, and then back home again.  Keep the person driving the bike from getting too hot or too cold, keep them dry, and be safe.  A 10 mile trip should take about a half an hour.

Aerodynamic

It is important that a design like this needs to be aerodynamic so that it will slip through the air with as little effort as possible, this allows you to use much smaller batteries and motors to maintain the speed you want. Design will have to incorporate a light weight carbon fiber shell that covers every part of the vehicle.  This shell would have to be very light weight, mostly just a single layer of carbon fiber, but with reinforcements in critical areas, and large enough windows to allow the person in the bike a clear field of view.

Insulated

About a half an inch inside the shell I would like to have a layer of silver bubble paper to reflect summer heat away from the person in the seat.  This stuff is very light weight and is great at reflecting heat.

Ventilation

There will have to be air vents that allow external air to flow through the compartment on hot days, these vents would have to be adjustable so that on colder days you can close the vents to keep the compartment warm.  The compartment has to be sealed tight enough so that the shell reinforces the frame, but enough air has to come in to keep the driver from suffocating.

Power

A small electric motor and small battery pack will supplement pedal power, not replace it.  Shouldn't even require a license plate, electric bikes that can only go 20mph don't need to be licensed.  You state laws will vary.  As you accelerate or go uphill the motor will boost the person pedalling to make it easier.  When you decelerate or go down hill the motor will brake the bike and recharge the battery.

If possible put a thin solar panel on top of the bike to recharge the battery as long as the sun is shining.  We will also be able to hook a small fan to force air through the cockpit to keep the person cool, and power that fan directly from the solar panel. The more intense the sun shine, the harder the fan will blow. 

No heater

A lightweight design with thin tires would just not be safe in the winter anyway.

Frame

The frame would have to also be a light weight welded aluminium with a heavy duty light weight floor that can handle a lot of abuse. Maybe put a thin wooden panel over the aluminium frame using construction adhesive, and then vacuum seal a carbon fiber layer on both sides of the frame, sandwiching the floor panel and frame inside a carbon fiber and epoxy shell. 

Phone Dock

Use power from the battery to recharge the phone and run a low power amp running a couple of speakers so you can listen to music or audio-blog as you ride around.  

Security

Because this bike is light enough to carry away then there has to be an external strong point to lock it to the end of a bike rack.  The compartment should also lock at a strong point.

Started programming the Google Reader Replacement.

I wrote about why I am working on this project

There is going to be a server side and a web client side of things.

On the server side I need to:

  1. Query the database for the next feed to read and when.
  2. Schedule the read.
  3. Read the feed.
  4. Store the feed so that there are no duplicates.  (what to do with updated records?)
  5. Update the record to show when the feed was read.
  6. Repeat.

On the web client side I need to:

  • Create a login system to keep people's feeds separate. 
  • Create a form that allows people to manage (add, remove, and organize) what feeds they are subscribed to.
  • Create a form that allows people to view their feeds. (I'll add marking records as read later.)

One of the beautiful things about this system is that if there are a million people all subscribed to the same feed then you only have to download that feed once and store it once.  The server side will scale pretty easily.

The client side is a different story.  With each person having a different set of unread records, the more users, the more power is going to be needed to track everything.

Today, on the server side I am looking at the basics of doing the server side actions:

Using libcurl to read an rss file. 

Example code here: http://curl.haxx.se/libcurl/c/simple.html
More examples here: http://curl.haxx.se/libcurl/c/example.html

Using libxml2 to parse the xml in the rss file.

The web site is here: http://www.xmlsoft.org/
Example code is here: http://www.xmlsoft.org/examples/index.html

Store the records in mysql.

Example code is here:  http://zetcode.com/db/mysqlc/


Sunday, June 2, 2013

Building a Media Center to work with Raspbmc hooked to TV.

Now that I have a proper media center using UPnP to play videos from a laptop computer, I want to free up that laptop again and create a much more robust solution that uses much less power and is dedicated to just sharing files on my network.

My hardware I choose to use is a now ancient Mini-ITX board by Via, called the EPIA-M.  I had bought this board 8 or 9 years ago, added a 12v powered DC-DC power block, and then threw it in a box and ignored it for all these years.  It only draws 10 watts, and has no fan or moving parts to wear out.   It has 256MB or RAM, but I am going to expand this out to 1GB.

I ran into one hold up, the built in networking had been turned off which made me pass on FreeNAS without giving it a shot at first, but when I began to install Debian, it also could not see the built in networking on the motherboard, so I knew it was a problem and was able to reboot again, change the setting and try out FreeNAS.

FreeNAS

I gave this a shot.  I had known of the system for many years and was interested in checking it out.

Pros:
  • Very powerful.
  • Can do just about anything and is extendable using plugins.
  • Looks like once it is set up it would work for even large divisions.
  • Beautiful web interface gives you access to everything.
Cons:
  • Very complicated and has a steep learning curve
  • Even something as simple as installing plugins is not pre-setup for the user.
  • Takes a higher end system with a lot of RAM

If FreeNAS wants me as a user they need to make a version that is meant to be used on low end devices with just a little RAM.  I am a home user that just wants to serve files that are on external usb hard drives, things should just work and transmission and dnla should be built-in.

When I plug in a drive things should "just work".  The drive should be shared to the network as a windows file share and the media file tree it contains should be indexed and shared using UPnP.  Plus, the system kept crashing because evidently I need a base 6GB of RAM, plus 1 GB of RAM for each TB I wanted to serve.   I couldn't install the plug-in jail system properly and after I messed it up I couldn't modify the settings anymore.

OpenFiler

Failed to load, needed a newer motherboard than I had.

Debian

That's right, I fell back to Debian 7.0 and I got it all working in just a few hours.  Even though in some ways this is harder than just learning FreeNAS, because I already am comfortable using Debian and UNIX in general on the command line this was easy for me to get everything installed and working. 

I had to do a base install, then modify the apt-repository list to stop looking at the usb drive for packages, and added in the main Debian repository, then apt-get a bunch of packages to give me samba, minidlna, and other services I wanted to run on the box.  I just googled for help with each part in turn.  These are all just normal Debian things, and you can find a lot of info on every step.

One thing that I had always wondered how to do was to mount disks by label.

http://debian-resources.org/node/9/

And how to assign the label to a DOS disk in Debian?  Mtools!

http://www.linuxquestions.org/questions/linux-general-1/how-to-change-volume-label-of-the-usb-drives-594875/

Work left to do?  Add all the USB drives so they auto mount to the right place.  Configure Samba to share all the directories read/write.

I went with mounting the drives by UUID, here is the relevant section I added to the end of /etc/fstab:

UUID=58212b6a-dc48-45e7-8e9f-1f360d765985 /media/SciFi  auto rw,user,auto 0 2
UUID=beb927ca-4da4-4fc9-b222-be343c4fec38 /media/Text   auto rw,user,auto 0 2
UUID=c7980548-7182-404b-b32d-02c5accd8963 /media/3D     auto rw,user,auto 0 0
UUID=f25eaad0-5896-499c-b476-f57ed12bd49c /media/Comedy auto rw,user,auto 0 2
At boot up this mounts 4 usb drives that are configured with either ext3 or ext4 to the same place each time.

I shared my media directory, where all the drives are mounted with the following section in /etc/samba/smb.conf :

[media] ; user="root"
   force user = root
   comment = Media Directory
   read only = no
   locking = no
   path = /media
   guest ok = yes
   public = yes
This gives full read/write access to all the drives I mounted under the media directory.  I know, I know, "oh you gave root access to these directories" but I am the only one that has access to these folders on my local network and the machine never executes anything from these folders, so no problem.

UPnP Remote Control

I found an application called BubbleUPnP that runs on my android Pad over Wifi and sits between what they call a library and a renderer.    You can even play things locally.  But the amazing thing happens when I selected the new NAS I just built as the librar and Raspbmc as the renderer, and a second later my TV was playing what I had told it to play on my pad computer. As the media plays you have full control of the player, able to pause, fast forward, change the volume and you can read the title and see where you are in the media timewise. All in all a truly amazing thing.  I did have to check a single box on the XBMC settings to advertise my Raspi as a rendering device. So now I can almost get by without having a direct link to XBMC at all.

I noticed another app that can do everything my wireless keyboard/mouse can do, which is also interesting, will have to give that a try.

3D Printed Case

Right now I am trying to find a case I can print that will fit the mini-ITX motherboard with a nice big 120mm fan for cooling of the mother board and the usb drives I plan to place on top of the case.  If I can't find one I will work on designing one that will work for me.  The board is about 17×17 cm (or 6.7×6.7 inches) wide and deep and about 3 inches tall.   Unfortunately the build place on my Replicator 2 is just 6.3 inches deep, so I am short .4 inches.  Will have to figure out how to make something work.

Physical Setup

Current setup on bookshelf until I can get it in a case.




I had to buy an extension cord and a set of orange extenders to allow me to plug in the 6 power bricks.  This is all plugged into a backup power supply.   Then I wired up the power and the usb connections to a 7 port powered hub that I was using on the laptop machine.    The beauty of this is that I can easily shut this system down and test a Raspi model A computer I am working on to act as a NAS and file sharer as well.  I am not sure how good the power supply is going to be for the mini-itx board.

Tuesday, May 21, 2013

Finally got a Raspberry PI to try out.

I know, I know, everyone else has had at least one of these for years now.  But I am a poor college student and couldn't afford even the $25 cost, plus the cost of a power supply, case, fast SD card, and everything else that goes into  a new computer system.  I finally got a bit of a break and was able to pick one up on Amazon.  I paid a little more than $35 for the 512MB RAM Raspi with built-in Networking, but the shipping was free, so it all evened out in the end.  And got it in less than a week.  I have not been this excited about a computer in many many years.


When it showed up I looked at the mini USB power supply and saw that it was not going to fit.  It was entirely my own fault, I saw micro USB and read it as mini USB.  I was able to pick up a 1.5 amp power supply at a local Radio Shack with the right connector to fit my Raspi.   If I could recommend a single change to make this device more standard, please change to mini usb in a future revision. So now I have to buy a few micro USB cables from monoprice.com before I buy more Raspis.

Below is the $20 wireless USB mouse/keyboard/laser pointer with illuminated keys that recharges from a normal USB mini plug. I am using this tiny keyboard to interact with the raspi and it is working surprisingly well.




I put the Raspi into a plastic case I printed in January and mounted it to the back of the monitor.






Why the Raspi?

Inexpensive to buy.
Super low power.
Easy to configure.

The drawbacks.

All external access runs through USB.
Micro usb port is not common.
A little too complex.

Inexpensive.

The $25 version will run just about anything the $35 version will run, just a little slower. Since most people already have an HDMI TV, then this device can be added for the cost of itself, a keyboard, mouse and

Raspbmc Distribution

The first distribution I tried out turns the Raspi into a media player.  It is called Raspbmc.  I have been looking for a new media player for a half a year now, since the company that I bought the last player from nuked the device with an update and then told me to buy a new one.  I blogged several times about that hideous disappointment.

Looks like the raspxbmc media player release updates itself to the very latest version from the Internet, and then compiles the latest and greatest the first time it boots. I suppose after the first boot not much will need to be updated on a weekly basis. But it sure does not lend itself to immediately playing a video and achieving satisfaction. *L*   Oh! As I am typing this, after about an hour the xbmc interface came up and it is running perfectly. 

Watching an HD episode of Doctor Who right now and it is playing full screen without any problems.  The Raspi is flawlessly playing video at 1080p. It can even play my day turns into night video in apple .mov format at 1920x1080, which has twinkling little stars in the sky that show perfectly. The only files I am having trouble playing are H.264 files in an mp4 container, which are supposed to just work. Very strange.   [ I figured out that this was my fault.  I had tried to get the MP4's  to be transcoded for my old media player.  Once I turned off transcoding in the Mediatomb config file this just started working.  Trying to figure out why flv files won't play over the network next.]

I am getting more and more impressed with this Raspbmc release. I was able to adjust the corners of the screen image to match the monitor corners, and how square a box appears on the screen to perfectly fit the image to the monitor. I have never used a media player that had this detail of customization. And you can keep watching a movie as you configure the device. Astounding.

Playing movies from the local network is perfect. Ted Talks plugin allows perfect playback. Internet movie Archive plugin has mixed results, some things play great, others just silently fail. The Apple trailer plugin just doesn't work, the videos just lag and freeze constantly.


PiMame Distro

The last distro I looked at was  the Pimame release, a game emulator release that could be the basis of a mame cabinet or the like.  It did not like the first SD card I tried, so trying another card now. Seems that the machine doesn't like some SD cards.  Need to get a few more large compatible SD cards for all the large

I got pimame, an emulator for old arcade and other gaming systems working on that Raspi.  The ROMs I have did not work using advanced Mame, but they worked fine using  Mame4All.

That tiny keyboard is not going to work for this, need to hack together a real arcade controller, perhaps hooked up wirelessly to the data pins on the Raspi. :D


Raspberry Pi Chameleon

http://www.stefanopaganini.com/raspberry-pi-chameleon-overview-and-tutorial/
http://betanews.com/2013/01/18/turn-a-raspberry-pi-into-the-ultimate-emulator/





This distro looks like it has all the old 8 bit machines emulated and includes the Mame emulator as well.  Going to give this a try tomorrow.

Other distros.

The raspi debian release feels like it is almost up to the level of puppy Linux distro in usability. I understand there are a lot more packages that can be downloaded and installed to configure it the way you want.

I want to try out the Plan 9 release as well. Have always wanted to take a look at that OS.


I always want to see what is involved in trying out the digital pins that are exposed in a big header on the board, turn on an led, maybe detect a push button closing.  


 Future plans


OK, step two is to get another Raspi and setup a server that all it does is torrent, backup, and share files with a web server, media server, and a samba file share. :D 

Thursday, May 16, 2013

Got my old backpack functional again.

I have always been a fan of external frame backpacks.  This modern insistence on tiny internal frame packs is just a fad, I tell you.  I found a back pack I used when I was a teenager in my mom's garage.  Someone had removed the waist strap, rendering the pack useless, because the reason these packs work is by transferring all the weight directly to your hips and legs and supporting your back.  

New Army Surplus Waist Strap Replacement.

I found a new surplus army waist strap on Amazon for cheap, and it cinched in place with nylon webbing like it was made for that frame.  The new waist belt is much better than the original one.  Maybe next I will upgrade the shoulder straps next. :) 

Every zipper works on this pack, after being the main pack for three of us boys in our formative years.  No holes, no tears, no rips.  The aluminum tube frame was welded at each joint and it is unbowed and unbent after carrying literally tons of stuff over the years.  Amazing quality built to last.

Thursday, May 2, 2013

Google Reader going away is a wake up call.

Google reader is how I have come to rely on reading web pages on the Internet.  It was my single portal page to the entire web.  I stopped "browsing the web" years ago because I could just add a bunch of news and tech sites to Google reader and then easily keep up to date on everything that was happening.  There is only three ways I get to an article on the Internet, primarily through google reader, secondly through google search and once I am on a page I might follow a link from that page. 

Do I need to worry that Google search is going to be dropped?  That Google Mail is going to return to sender?  That Google drive will just cruise on down the turnpike?  Maybe instead of just replacing Google Reader, that this is a wake up call that we need to replace Google.  Maybe this is going to motivate a large group of people to actually get something done.

The open source community needs to step up and create something that is a game changer.  Imagine a single app that brings in all your web pages, social media feeds, email, event logs on servers, essentially anything that can generate a stream of messages or events, and then filters that fire hose of information down to a manageable level, getting rid of everything you don't care to read about.  Let what you do care about the most to be easily shareable, not just on the reader service itself, but back out to all the social media sites and to groups you have created in email as well.

Configure it so that it can use many different feed readers, or just use a built in P2P model to share feeds, so that we don't have to depend on something like Google feeds again.   Store the data locally so that it is yours all the time.  I can only imagine all the plugins that people could write to do amazing things.

 I know that I am planning on working this summer on a small web app and back end RSS aggregator  that will run on my local machine to at least bring me back up to where Reader was at without the sharing part.   I'll share the progress I make on it here with you all.

Friday, April 12, 2013

Installing elgg onto Amazon EC2 server instance

Log into your AWS instance. This is covered in previous articles.

Edit the httpd.conf file

sudo vi /etc/httpd/conf/httpd.conf

What I looked for here is not the first <Directory> directive, but the second one, that begins:

<Directory "/var/www/html">

The first one is a default section to remove all default rights from everythings. The second one grants back the rights we want to the document pointed to by the path.

Inside this section change:

AllowOverride None

To:

AllowOverride All

This allows us to then put a .htaccess file into /var/www/html/ during the next step to control rewriting for the web server.

Enter the following to prevent an error and satisfy dependencies for the install:

sudo yum install php-xml
sudo yum install php-gd
sudo yum install php-mysql
sudo yum install php-mbstring

Restart your web server:

sudo /etc/init.d/httpd restart




 

Installing and configuring Elgg:

Use wget to download the Elgg tar ball.

wget http://path to the download

that you can see by hovering over the link on the elgg download page. Right click and copy link to put the url into your paste butter.

unzip this and copy the contents of the zip directory into /var/www/http


Change permissions and create a data directory



cd /var/www/http

sudo mkdir data

sudo chown -R apache:apache .

sudo mv data ..

sudo cp htaccess_dist .htaccess


Create the database:

mysql -u root -p
CREATE DATABASE elgg;
CREATE USER elgguser IDENTIFIED BY 'elgguserpassword';
GRANT ALL ON elgg.* to elgguser;

Of course you should change at least the password to something secure.
Run the elgg install script 

In your browser go to:
http://yourhostname/

And it automatically brings up the installer.

Follow the prompts.

The database stuff is what you entered when you created the table just above this.

The data directory is /var/www/data

After the install, rename the install.php file so that it can no longer be accessed by placing a large number of random characters after the user name.

Wednesday, April 10, 2013

The virtues and leading a good life.

The ancient Greeks believed that there were virtues, or habits, that one could learn that would lead, if fate allowed, to a happier life

It was recognized that we humans are a mass of swarming desires, and that  trying to control all these desires, each wanting to go in its own direction, was a lot like herding cats.  Each of these desires seemed to have two contradictory extremes, going too far in one direction or the other. They saw the attempt to totally eliminate a desire as bad for someone as if they gave in totally to that desire.  As if a desire were a wolf that you were starving, eventually it will break free and be totally out of control until it is satiated.   It was noted that people who allow their desires to lead them to one extreme or the other are the most miserable people alive, and appear to have no control over what happens in their lives.

A virtue is the habit of seeking a balance between two extremes of a desire, such as hunger balanced between starvation and gluttony, or love balanced between madness and the total lack thereof, the desire to drink and go to parties should balance between being out of control and staying in every night.  Given anything with two extremes one should always seek the middle path, one should seek balance.  Moderation in all things, abstinence only in those things that would instantly poison your reason or your body.

The Greeks saw that we should seek balance among all the virtues, our job should balance perfectly against  family obligations,  finances balanced against the desire for more stuff, and so on.  By consistently choosing the middle path using the rational mind, not starving or overfeeding any one desire at the expense of all the others, we would build up the habits that would lead to success in every area of  life and allow us to seek fulfilment.  Over time our desires will become used to the caring concern that your rational mind tends to them all, and fall into line, not raging to be in control all the time, and not withered away and starving.


Thursday, March 28, 2013

Calculating a series on the computer.

In calculus we have started a new section on series in 10.3 on convergent and divergent series.  I decided to calculate out these series on a computer and see for myself if the series converges or diverges.   I know that pure mathematicians frown upon using numeric methods to calculate these things.  But I find that you can often see patterns that you would miss without using numeric tools to calculate huge numbers of results and

The program I wrote calculates all the results through an absurdly large maximum value.  Because of the huge number of results I decided to take a sample at regular intervals of the powers of 10.  

I stopped the programs after about 5 minutes because the interval between results became too long.  Each value that they produce takes 10 times longer than the value before it did, upto about 100,000,000 the computer is absurdly fast, but after that it slowly grinds to a halt.  It would be interesting to break these sums up into threads and calculate out huge values

This first program calculates the sum of 1/n

#include <stdio.h>
 
void main (){
 
long double i=1;
long double j;

long double result = 0 ;
long double inter = 0; 
 printf("\n");

    for (j = 1; j<10000000000000; j*=10) {

 for (; i<j; i++){
     inter = 1.0/ i;
     result =  result + inter;
 }

 printf("1.0 / %.0Lf = %.20Lf", i, inter);
 printf("  += %.20Lf\n", result);
    }
}





1.0 / 1 = 0.00000000000000000000  += 0.00000000000000000000
1.0 / 10 = 0.11111111111111111111  += 2.82896825396825396851
1.0 / 100 = 0.01010101010101010101  += 5.17737751763962026144
1.0 / 1000 = 0.00100100100100100100  += 7.48447086055034491430
1.0 / 10000 = 0.00010001000100010001  += 9.78750603604438229946
1.0 / 100000 = 0.00001000010000100001  += 12.09013612986342790703
1.0 / 1000000 = 0.00000100000100000100  += 14.39272572286572335516
1.0 / 10000000 = 0.00000010000001000000  += 16.69531126585985137713
1.0 / 100000000 = 0.00000001000000010000  += 18.99789640385390624040
1.0 / 1000000000 = 0.00000000100000000100  += 21.30048150134794616301
1.0 / 10000000000 = 0.00000000010000000001  += 23.60306659479200872866

This series diverges, as can be seen by the ever increasing sum, but I noticed that,  if you looked at the second order difference between sums, the output of this series converged to ln(10) .  I have no clue what this means at this point.

-->
1 0
10 2.828968254 2.828968254
100 5.1773775176 2.3484092637
1000 7.4844708606 2.3070933429
10000 9.787506036 2.3030351755
100000 12.0901361299 2.3026300938
1000000 14.3927257229 2.302589593
10000000 16.6953112659 2.302585543
100000000 18.9978964039 2.302585138
1000000000 21.3004815013 2.3025850975
10000000000 23.6030665948 2.3025850934

-----------

The second program is same as the first, except it is i*i instead of just i for the intermediate result in inter.  This represents the sum of 1/(n^2), which does converge to the value pi^2/6  You wouldn't thing that something so innocent looking as 1/n^2 would hold the value of pi inside itself.

1.0 / 1 = 0.00000000000000000000  += 0.00000000000000000000
1.0 / 10 = 0.01234567901234567901  += 1.53976773116654069027
1.0 / 100 = 0.00010203040506070809  += 1.63488390018489286538
1.0 / 1000 = 0.00000100200300400501  += 1.64393356668155980261
1.0 / 10000 = 0.00000001000200030004  += 1.64483406184805976450
1.0 / 100000 = 0.00000000010000200003  += 1.64492406679822627375
1.0 / 1000000 = 0.00000000000100000200  += 1.64493306684772645277
1.0 / 10000000 = 0.00000000000001000000  += 1.64493396684822148644
1.0 / 100000000 = 0.00000000000000010000  += 1.64493405684822654295
1.0 / 1000000000 = 0.00000000000000000100  += 1.64493406584812120830
1.0 / 10000000000 = 0.00000000000000000001  += 1.64493406664905016438



Thursday, February 21, 2013

Setting up Android Development under Ubuntu 12.04 - Howto.


Getting Eclipse to run:

Surprisingly Eclipse does not work "out of the box" with Ubuntu 12.04.  At least it did not on my own box.  This sort of thing is kind of bad, a hurdle like this right at the start could prevent some people from figuring out the rest of the process of making their own mobile apps on a Linux distro.

When I tried to run Eclipse I just got an error message.  I uninstalled eclipse and reinstalled it and got the same error.  Eclipse is broken out of the box on Ubuntu.

I installed the java 7 from oracle, but not sure if that had anything to do with the fix.  http://thedaneshproject.com/posts/how-to-install-java-7-on-ubuntu-12-04-lts/

So I looked up the error from the log file it told me about and found this info: http://stackoverflow.com/questions/10970754/cant-open-eclipse-in-ubuntu-12-04-java-lang-unsatisfiedlinkerror-could-not-l

Specifically this command:
  • 64 Bits System: ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64/
  • 32 Bits System: ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86/

Installing ADT 

Once I finally got Eclipse running I installed Android Development Tools (ADT) using these directions: http://developer.android.com/sdk/installing/installing-adt.html

It was tricky on the small screen of my netbook to see the selection to click.  I had to hold down on the alt key while I clicked on the window to pull it down, then grab the top of the window to make it bigger, then the selection came into view and I could click it, and finally use the alt key to move the window up so I could click on the next button.

After ADT is installed, allow it to restart Eclipse, then it asks which Android SDKs to install, and I opted for both 2.2 and the latest.  You can use some option to install different ones at any later time.

Creating a Test App:

After all this I created a test android application under the File->New menu option.  By default the app just says hello world.   I made the font a little bigger so it would show up on screen shots and photos better.

Create an AVD so you can run the emulator.

I created an Android virtual device (AVD) using the AVD manager button. The first time I did it I didn't have enough free space and it failed, but it didn't give an error message, it just sat at a screen that had "A N D R O I D _" with the underscore blinking and then did nothing else.   I cleared out some drive space, deleted the first AVD I created, cleared the project, and created a new AVD with more memory and sd card space.

The emulator is so slow and bad that it might be faster to  transfer the app to the hardware device using http each time I want to run it.



Exporting the App and serving it to the mobile device.

The process of getting the app to the device is non-obvious.  You have to export the project to a file, using a keyfile to sign the project.  I created a new key for my projects, filling out the forms as best I could.  Finally I exported the project to a directory and then placed the FirstTest.apk file onto a local web server.  http://stackoverflow.com/questions/4600891/how-to-build-apk-file/4600933#4600933

Downloading and installing the app on the mobile device.

On my mobile device I went into settings->security and enabled unknown sources.  Then I started the internet browser on the device, went the URL where the file was located on the web server, downloaded the file, went into the download area and installed the file, then opened my application.  Whereupon I was presented with "Hello World!" in glorious black and white.



Conclusion.

So that is the process of
  1. Installing Eclipse on Ubuntu 12.04
  2. Adding the ADT to Eclipse
  3. Creating a Hello World project.
  4. Getting the emulator to run the app.
  5. Sending the app to the mobile device.
  6. Running the app on the moblie device.  

Where do we go Next?

Now that we have a development environment and work flow that we know works, we can start designing applications that actually do something useful.

Final piece for the setup. 

Because the emulator was so bad  and it was so awkward to install apps, I figured out how to connect up the device directly to Eclipse using these directions: http://developer.android.com/tools/device.html#setting-up

After following the directions on that page and configuring the Tab to allow usb debugging under settings->Developer->Debugging  Allow USB debugging by checking the box.  It looks like we can even debug the apps through Eclipse directly on the hardware device, which is handy.  Now I can almost instantly start and run an app directly on the Tab itself, right from inside Eclipse rather than deal with the emulator. 

MIT App inventor.

I am also checking out app inventor here: http://gigaom.com/2012/03/05/with-this-tool-even-you-can-write-android-apps/  This promises to be a no fuss way to develop simple apps.  Might even be a method to quickly flesh out an app, then transfer it to an Eclipse project to finish/extend full functionality.