Pages

RC filters and OpAmps (remember those?)

I tested a simple circuit with a low pass RC filter on a 2Hz pulse circuit.



Vout = Vin (1 - exp ^ (-t/RC))

Couldn't get simpler. The Vout was input to AnalogIn of the LPC1768 for ADC conversion. As expected, it was reading intermediate values. (ADC on the pulse was reading only zeros or 1s.) Great! For lack of a respectful oscilloscope, I made do with this test result.

Now to the drawing board.

What could change here to accomodate for a small capacitance value of the sensor (in place of the 470uF)?

1. The reactance of the capacitor is inversely proportional to the input frequency. So to bring that down, I have to increase frequency of the input pulse. 2kHz? 10MHz? Somewhere in between?

2. The capacitance is seemingly low. I ran some simulations on circuitlab (in demo mode) and unfortunately do not have the plots saved. Fortunately though, I quickly made a note of the change in output for different capacitance values.
Vin - pulse of 3.3V, 2MHz
R1 - 100Kohms
Vout max for C1 at 1pF - 2.74V
Vout max for C1 at 5pF - 1V
Vout max for C1 at 10pF - 500mV

3. At this point, since my sensor is un-calibrated, I do not know the min and max capacitance values, changed by soil moisture. In the worst case, it is smaller than 10pF, making it a bit obvious that I now need to design in voltage amplifiers.

Enter OpAmps!!!!!!

Next iteration of this design process will include 2 opamps; one for amplification and the other as voltage follower for reducing output impedance.

A full weekend into this, I am now almost ready to spend on a good simulator. Please leave your suggestions in the comments. I loved circuitlab for the duration I used it - super quick and easy to simulate - but I am not a power user and am loathe to spend that cash on it.

Update: I have bought a month's worth of circuitlab and am loving it. 

Programming Languages - which one is your favorite?

Source: http://spectrum.ieee.org/static/interactive-the-top-programming-languages
Impressive where Python has reached in terms of popularity! And C still rocks!! yayy. #2 is not too bad at all.

Talking about favorites, mine is by far C. It is fast, efficient and great for embedded systems. I know, at the cost of OOP advantages.

What I like about Python is that it is not half as esoteric as Perl and yet claimed to be very extensible. I don't know as my use of Py so far has been limited, without really testing its capabilities. 

The indenting annoys me. Really? Indented programming in the 21st century?

The best part of Python if you ask me is that it uses C for optimized code in its libraries. So there you have it, a great marriage between raw performance and useability. Notwithstanding the fact that Py also lends OOPability. I may have just created a new word - OOPability.

Okay, I relent. The winner of this beauty contest is Python.

Capacitive Sensing Irrigation

Now here's a project I have been working bits and pieces on so far.

The idea: Moisture sensors with mesh networking talk to a main sprinkler-valve controller. Familiar enough.

The twist? Home-made capsense moisture sensors. Super excited about these. Moisture sensors cost a ton. The typical hand-made sensor uses 2 galvanized nails and is resistive. Nails corrode over time and among other problems, require frequent re-calibration. Enter: capsense using a PCB. Terrific idea and most of all, I'll get to play with raw capacitive sensing!

For the test circuit, I will be hard-wiring it up. As the next step, the mesh network sounds like a great idea for sensors to talk to the controller.

For the controller, I'm using a robotics microcontroller - the NXP mbed LPC 1768. The really cool bit is that code compiles online and generates a .bin. To run this on the target, I just need to drop the .bin in its file system and reset the micro-controller. Love it!

Terminal connectivity to mbed: https://mbed.org/handbook/Terminals
For example: screen /dev/tty.usbmodem1412

So far:
  1. Controller: I ran the hello world program on mbed for blinking of LED1 and also a test of analog input
  2. Sensor: Made a 555 pulse generator of 2Hz frequency with (a different) led blinking and connected the moisture sensor to this to create high-pass filter to modulate the output pulse-width. (I will post the circuit diagram on github once it is tested and ready.)
Next step: write an adc program to read the input from the capsense. Connect these 2 (the sensor circuit and the controller) and run tests to my hearts content.

Pan and Tilt kit on its way

I just ordered a pan and tilt system from ServoCity - the SPT100. It can carry up to 10 ounces in weight, which should be sufficient for a bulb (even the smart ones) and a socket.

I intend to use this to control the direction of a light bulb, as opposed to the more typical uses such as camera or airplane. The SPT100 can be hung upside down per spec - exactly what I need!

The project will be developed in phases:
1. Start with one pan & tilt and write/test code to control it using raspberry pi with a servo controller if necessary.
2. Separately plan/design the bulb dimming and color control. Do I:
  • use a packaged solution - such as the super expensive and feature-rich Philips Hue - or 
  • design a limited version myself (good enough for a garage) with a cheaper RGBW led bulb
3. Integrate 1 and 2. If the solution so far is fully home-grown in my garage with no smart bulbs, the connections are bound to be hard-wired. Networking (zigbee, bluetooth, wifi) will happen at a later stage.

4. Scale: What if I wanted 6 bulbs in a room, all individually controlled by the pi?

5. Installation planning: Track lighting system is one possibility to explore

Light Automation

Objectives:

 

Control lighting in the room using raspberry pi. A set of bulbs must be programmable for task lighting, to mood lighting. If dance-floor effect is possible with the spot-light capability of the bulbs, synthesized light effects are a plus.

 

Must haves:

    1. RGBW dimmable LED bulbs
    2. Brightness to meet task lighting and mood
    3. Swivel control of the bulb socket
    4. Programmability of lights and swivel with python

    Research so far has dragged up:

    1. Bulbs: Philips Hue as the winner for programmable bulbs but LIFX and Belkin follow close on its heels if 16 million colors is not a criterion
      • Other options include LIFX, belkin, LG, Samsung, Lumen
    2. Robotics solution for swivel: Also called pan and tilt
      •  Uses 2 servos, one generic for pan and the other specialized for tilt
    3. Track lighting systems for mounting several bulbs
    4. Controller board for each pan-tilt assembly which talks to the pi using a wireless technology
    Found some interesting videos with low power led projects such as the led cube. Look it up on youtube.

    A note on the network technologies:

    • Bridge is on the internet using wifi
    • Hue and its friends talk to the bridge using Zigbee
    • There is no bridge zigbee API available for adding custom devices - walled garden

    Other smart bulbs connect to the link/bridge using Bluetooth LE. Bluetooth LE is a PAN technology with a span of a few meters whereas Zigbee is a LAN and covers the entire house.

    PiDoorbell: IoT Home Automation workshop @ PyCon 2014

    PiDoorbell: Automates sense-and-notify when someone arrives at the doorstep. A picture or video is sent directly to the configured phone as a text message almost instantaneously. This is an Internet of Things project created by Rupa Dachere, Founder and Executive Director of CodeChix.org.


    A Raspberry Pi, an echo sensor, a camera, a couple of resistors and wifi connectivity is all you need to build your own PiDoorbell. Well, that and some Python code.

    In April 2014, I was a TA and Instructor for a workshop on PiDoorbell at PyCon in Montreal. (A link each to the tutorial video and source code is at the bottom of the page.) The objective of the tutorial was to bring up the hardware kit provided to each participant to successfully sense an object, and click a picture or video.


    Over 20 folks were at the workshop and the TAs were on their feet helping everyone. I instructed the class on network setup on Raspbian with different ways of connecting to the network and helped bring up network connectivity via internet sharing from the laptop, via direct ethernet connection and also wifi hot spot access. To tide over the spotty wifi access, I had set up our own access point router fed from intenet sharing from my Mac, which in turn was connected to PyCon's wifi access.





    Here is the full team of TAs and Instructors:




    PiDoorbell at PyCon 2014 was a huge success! The preparation for this workshop was intense in the weeks preceding the event and it was great fun watching it unfold and consumed eagerly by participants.




















    Workshop video: https://www.youtube.com/watch?v=i62piPQkUtA
    Python source for the project: https://github.com/CodeChix-OpenSource/PiDoorbell
    CodeChix post: http://www.codechix.org/2014/05/pycon-2014-pidoorbell-tutorial/
    Rupa's blog post: http://rupadachere.blogspot.com/2014/06/recap-of-pycon-and-pidoorbell-tutorial.html
    Lyz's blog post: http://princessleia.com/journal/?p=9314

    Maker Faire 2014 update

    In the meanwhile, I was at PyCon 2014 in Montreal as a co-instructor and TA for PiDoorbell. More about it another day but today was Maker Faire. No pics in this post - I mean business. :P A quick report on my exploration follows.

    Interesting products for developers:
    1. spark core - wifi on board (but no mesh), compatible with arduino
    2. pinoccio - home automation kit of boards - one with wifi and rest with atmel's mesh
    3. ply90 - which also made my favorites list last year
    4. NASA's phonesat - an android phone, extra batteries and a couple of add-on sensors make this cubesat work
    5. electric imp - an IoT (Internet of Things) solution that boasts of - wait for it - a cloud
    6. Qfusion - a programmable invention platform currently being designed and seeking funding

    Apart from this, I saw plain old FPGA being re-branded as 'hardware you can program as opposed to software that runs sequentially line by line'.

    Among the products on exhibition were a few that caught my attention:
    1. Braigo - a braille printer using Lego Mindstorms and very little else, created by Shubham Banerjee, a 12 year old from Santa Clara
    2. inet2DVR - a home automation system built on top of a security recorder
    3. Lil Bot - a robot for kids to learn programming on, with a web interface much like Scratch's except for hardware i/o blocks

    And did I mention the robots? :) All this just in the expo hall. I did not venture into the Startup Space.

    Some observations: 3d printers were not the major attractions. Infact, I only saw a booth or two with printers on display, unlike the endless aisles of 2013. The open expo hall layout this year was far superior to last time's tiny booths. And believe it or not, I can swear I saw a bigger crowd today than before. Maker Faire's strategy of affordable family tickets for Sunday is cleary a huge success. According to this, 2013 had 44% first-time attendees and half of all attending with children.  The event is an incredible experience where tech and fun coexist in the real sense, endorsed heavily by enthusiastic participation by families with young children. How young you ask? Sitting next to me on Caltrain was a mom with a 2.5 month old, returning from the Faire. I kid you not! That's Maker Faire's true success, if you ask me.