Monday, December 19, 2016

My Thoughts of Building the Ultimate Robot ever

I had this passion as a kid to build the ultimate robot. But as a kid, I had no idea how to do it technically, but watching Transformers on tv, gives already an idea what is a robot, its a humalike being made of metals. I just dont know why kids like me get so fascinated by those fictions. In the real world we live in, robots may practically play important roles in our daily lives. I could just imagine if we can create robots with intelligence better than ours, daily traffic could be solved in an instant. Larger robots could be made to get important resources that our civilization needs from other planets in the solar system. And it is not a fiction that resources around our solar system is so huge, we may not need to struggle to survive anymore if we are able to get those resources.

In my own thoughts, at least where I can reach and afford, I would buy a 19 dof biped robot already assembled and working. Once I get it, I would begin developing a software that would manage the servo motors' movements. To explain briefly, i would implement an algorithim that would calculate the rotation of a series of servo motor shaft to get the tip into the desired location. I would be starting with INVERSE KINEMATICS to achieive this. I will also combine it with OpenCV to identify objects, distinguished between faces and track the objects' location. Add some more sensors and analyse data coming from these sensors using a number of data analytics algorithm that were adpoted from those being used in currency trading strategies like the bladerunner trade, daily finonacci pivot table, dual stochastic trade, etc. Those forex trading strategies are actually artificial inteligence algorithms.

Aside from inverse kinematics, my ideal robot should have gyroscope installed at each body joints where the servo is located. Gyroscope can give location of each joint in 3d space.

My conclusion, it is very much possible to create the ultimate robot to improve all of our lives.

Sunday, June 19, 2016

Small Desktop CNC is the Best for New DIY'ers like Me

I still consider my skills as beginner in DIY'ing because I am also busy with my day job as programmer which is completely not related to my favorite hobby.  I really love making new things that is why I have the Smart Watch Project, the Ibeacons, and creating stuff with the 3d printer(which I think is still defective). The small desktop cnc is just perfect for my skills because I want to explore the new frontier of creating nearly commercial version of pcb and I do mostly small pcb's so the size is just perfect. The small cnc can do more than just milling pcb's, it can be used to create more decorative stuffs or work with materials that the 3d printer can't use. So basically, the 3d Printer can compliment the cnc. These two high tech machines are must have in a small design/creative studio.

My small cnc is powered by Arduino GRBL shield and the work area is good enough to mill 4 pcb's  for my smart watch project. Most electronic modules in the market today are small and always uses smd components that is why this cnc is really perfect for most electronics design studios.

Actually I've had the cnc for quite sometime now but I am still not able to operate it to create an object but I was able to test to mill a square with success just to test its accuracy because I am busy designing the enclosure, and the dust collection attachment which are must haves and very important components of the machine and the reasons are obvious, the enclosure will protect the machine from harshness of the environment while the dust collection attachment will keep the interiors clean when using it. Too much dust inside can really harm the machine.

Here are some of the pictures of the cnc:

Sunday, May 8, 2016

My DiY Smartwatch Project: Teensy LC is the clear Winner(for now)

I have decided to use the Teensy-LC for now because of the availability of libraries, easy to use, lots of existing examples and so many ports and digital/anolog/pwm pins. I am ditching Esp-12E and I will be using ESP-01 instead as the wifi module. And it's a weekend and I had spent sometime creating a simple sketch to make the smartwatch work. And so far, I have created a sketch using the ESP-01, 1.44" tft screen and the expensive 4-wire touch panel. Below is the connection diagram I used:
I even had to prepare a development board for ESP-12 and included in the board the 1.44"tft lcd with the 4-wire touch panel attached into its surface. I was so lucky that the technician I hired did not made any mistake and the soldering is like a pro:

The sketch I created is based on the existing examples when I loaded the teensyduino into the Arduino IDE. I also used the adafrruit 4-wire touch panel library and I did not had difficulty using it.  To summarize what the sketch do, I program the whole screen as a button, so when I hard-press the screen, it will automatically activate the wifi to search for existing wifi hotspots and display them on the screen and after 5 seconds, it display the wartch face again.
here is the watchface:
And here is the sketch:
#include <stdint.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
#include "TouchScreen.h"
// Color definitions
#define    BLACK   0x0000
#define    BLUE    0x001F
#define    RED     0xF800
#define    GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0 
#define WHITE   0xFFFF
#define YP A0  // must be an analog pin, use "An" notation!
#define XM A1  // must be an analog pin, use "An" notation!
#define YM 6   // can be a digital pin
#define XP 7   // can be a digital pin
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

Teensy3.x and Arduino's
You are using 4 wire SPI here, so:
 MOSI:  11//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
 MISO:  12//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
 SCK:   13//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
 the rest of pin below:
#define __CS 10
#define __DC 9
Teensy 3.x can use: 2,6,9,10,15,20,21,22,23
Arduino's 8 bit: any
DUE: check arduino site
If you do not use reset, tie it to +3V3

TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC,8);

uint16_t ccenterx,ccentery;//center x,y of the clock
const uint16_t cradius = 63;//radius of the clock
const float scosConst = 0.0174532925;
float sx = 0, sy = 1, mx = 1, my = 0, hx = -1, hy = 0;
float sdeg=0, mdeg=0, hdeg=0;
uint16_t osx,osy,omx,omy,ohx,ohy;
uint16_t x0 = 0, x1 = 0, yy0 = 0, yy1 = 0;
uint32_t targetTime = 0;// for next 1 second timeout
uint8_t hh,mm,ss;  //containers for current time

void drawClockFace(){
  tft.fillCircle(ccenterx, ccentery, cradius, BLUE);
  tft.fillCircle(ccenterx, ccentery, cradius-4, BLACK);
  // Draw 12 lines
  for(int i = 0; i<360; i+= 30) {
    sx = cos((i-90)*scosConst);
    sy = sin((i-90)*scosConst);
    x0 = sx*(cradius-4)+ccenterx;
    yy0 = sy*(cradius-4)+ccentery;
    x1 = sx*(cradius-11)+ccenterx;
    yy1 = sy*(cradius-11)+ccentery;
    tft.drawLine(x0, yy0, x1, yy1, BLUE);

static uint8_t conv2d(const char* p) {
  uint8_t v = 0;
  if ('0' <= *p && *p <= '9') v = *p - '0';
  return 10 * v + *++p - '0';

void setup(void) {

  tft.setTextColor(WHITE, BLACK);
  ccenterx = tft.width()/2;
  ccentery = tft.height()/2;
  osx = ccenterx;
  osy = ccentery;
  omx = ccenterx;
  omy = ccentery;
  ohx = ccenterx;
  ohy = ccentery;
  drawClockFace();// Draw clock face
  //get current time from compiler
  hh = conv2d(__TIME__);
  mm = conv2d(__TIME__+3);
  ss = conv2d(__TIME__+6);
  targetTime = millis() + 1000;

void drawClockHands(uint8_t h,uint8_t m,uint8_t s){
  // Pre-compute hand degrees, x & y coords for a fast screen update
  sdeg = s * 6;                  // 0-59 -> 0-354
  mdeg = m * 6 + sdeg * 0.01666667;  // 0-59 -> 0-360 - includes seconds
  hdeg = h * 30 + mdeg * 0.0833333;  // 0-11 -> 0-360 - includes minutes and seconds
  hx = cos((hdeg-90)*scosConst);   
  hy = sin((hdeg-90)*scosConst);
  mx = cos((mdeg-90)*scosConst);   
  my = sin((mdeg-90)*scosConst);
  sx = cos((sdeg-90)*scosConst);   
  sy = sin((sdeg-90)*scosConst);

  // Erase just old hand positions
  tft.drawLine(ohx, ohy, ccenterx+1, ccentery+1, BLACK); 
  tft.drawLine(omx, omy, ccenterx+1, ccentery+1, BLACK); 
  tft.drawLine(osx, osy, ccenterx+1, ccentery+1, BLACK);
  // Draw new hand positions 
  tft.drawLine(hx*(cradius-28)+ccenterx+1, hy*(cradius-28)+ccentery+1, ccenterx+1, ccentery+1, WHITE);
  tft.drawLine(mx*(cradius-17)+ccenterx+1, my*(cradius-17)+ccentery+1, ccenterx+1, ccentery+1, WHITE);
  tft.drawLine(sx*(cradius-14)+ccenterx+1, sy*(cradius-14)+ccentery+1, ccenterx+1, ccentery+1, RED);
  tft.fillCircle(ccenterx+1, ccentery+1, 3, RED);

  // Update old x&y coords
  osx = sx*(cradius-14)+ccenterx+1;
  osy = sy*(cradius-14)+ccentery+1;
  omx = mx*(cradius-17)+ccenterx+1;
  omy = my*(cradius-17)+ccentery+1;
  ohx = hx*(cradius-28)+ccenterx+1;
  ohy = hy*(cradius-28)+ccentery+1;

void loop() {
   TSPoint p = ts.getPoint();
   if (p.x > 300 and p.y > 300 and p.z < 300) {
  tft.setCursor(0, 0);
  tft.println("CHECK WIFI NETWORKS");
    while (Serial1.available()) {
        char c =;
   tft.setTextColor(WHITE, BLACK);
  ccenterx = tft.width()/2;
  ccentery = tft.height()/2;
  osx = ccenterx;
  osy = ccentery;
  omx = ccenterx;
  omy = ccentery;
  ohx = ccenterx;
  ohy = ccentery;
  drawClockFace();// Draw clock face
  //get current time from compiler
  hh = conv2d(__TIME__);
  mm = conv2d(__TIME__+3);
  ss = conv2d(__TIME__+6);
  targetTime = millis() + 1000;
   else {
  if (targetTime < millis()) {
    targetTime = millis()+1000;
    if (ss == 60) {
      ss = 0;
      if(mm > 59) {
        mm = 0;
        if (hh > 23) hh = 0;


Thursday, May 5, 2016

ESP-12E vs Teensy-LC for my DIY Smartwatch Project

Today, my Teensy-LC and ESP-12E just arrived and I am so excited to experiment with them over the weekend. I have not decided which of the two MCU's should I use for my DIY Smartwatch Project.So I want to list down their strength and weaknesses to help me which I should choose.

1. Microcontroller(MCU) Speed
Teensy uses MKL26Z64 ARM Based Chip rated at 40Mhz while ESP-12E uses ESP8266 which is rated at 80Mhz but can be overclocked at 160Mhz. Clearly, ESP-12E is the winner.

2. Arduino Compatibility
Recently ESP-12E and its variant can already be programmed using the Arduino IDE and while Teensy-LC is already programmable in the same IDE so both are tied on this. But I still don't know if all commands in Arduino is supported by both MCU's all I know is in the case of Teensy, some are not supported.

3. Power Consumptions in Sleep Mode and Normal Mode
I am totally new to this microcontrollers so I cant compare them based on this category. Probably when I get to program them, that will be the time for me to be able to decide which one is better than the other.

4. GPIO/Ports/Availability of Libraries
Teensy has so many GPIO's(dont know exactly how many), PWM Pins, 3 Serial Ports, 1 SPI Port and No built in RTC and since it can be programmed in the Arduino IDE, I assume the SPI, I2C libraries will work, while ESP-12E has very few exposed GPIO and PWM pins, 1 SPI and 1 I2C port and I also assume that the Arduino SPI and I2C libraries will work. It seems I have a problem here because I need at least 2 SPI ports(the LCD Display and SD Card uses SPI ports) because I have not tried connecting 2 devices in 1 SPI port but I have read somewhere that it is possible for several devices to share 1 SPI port. The smartwatch does not need too much GPIO and PWM pins. I give the credit to Teensy in this category though.

In conclusion, I am still not able to decide which one is better than the other although ES-12E has built-in wifi radio and while the Teensy do needs ESP-12E.

Friday, April 29, 2016

MAX30102 Heartbeat Sensor and Oximeter

A very common but most likely the most important feature of smartwatches that should make them useful and separates them from ordinary watches is the inclusion of sensors that measure rate of heart beat and blood oxygen level. I am not a health professional but as an ordinary folk, the data could be important. For example I could use the data make the color of the watch's screen respond to changes in my heartbeat patterns.

And again, while I was searching for simple circuits that I can use for my DiY Smartwatch, I was able to find the MAX30102 Heartbeat Sensor and Oximeter which I believe some of its variants were used in Samsung latest flagship smartphones. Below is its sample schematic diagram:

This can be a premium alternative to the one I found on ebay, a sparkfun clone product but very cost effective and working:
And with the schematic at hand, I could use thinner pcb and integrate other watch stuff like the rtc in one pcb which could make the watch thinner. The downside is since it will be developed from scratch, prototyping will be more difficult.

Thursday, April 28, 2016

Update on my DiY Smartwatch Project

Recently, I had been slowly researching for new add-ons for my SmartWatch Project. And here are the things I have in possession for the project:

1. I have 3d Printed the watch bezel and the result is very promising see picture below:

2. 6DOF MPU-6050 Module 3 Axis Gyroscope+Accelerometer,  Heart beat sensor and ESP-03 wifi module has arrived:

3. The 1.44" touch panel has arrived as well:
The hunt for touch panel was not an easy task. I have searched all over Metro Manila and I could not find this precious component, I have searched ebay, and nobody sells this item, so I tried alibaba there were some who sells similar product but too expensive and so I decided to buy a 1.44" lcd with touch panel and luckily, I was able to buy 7pcs at $10/pc + $30 shipping and $20 customs duties. I have chosen the 4-wire touch panel because Adafruit already has an existing arduino library so it would be easy to implement.

I also currently ask a pcb designer to do the rtc pcb design and currently, I have asked them to use 0201 packaging for all resistors and capacitors so that the whole module would fit into 8mmx8mm pcb and the initial design is here:
So far the rtc pcb design project cost is $35. I would have to order all parts from abroad including the pcb fabrication and the prototyping may cost over $100+ because if I order from digikey, shipping cost is pegged at $40 minimum.

see related article: Hacking the 1.44" TFT LCD for my Smart Watch Project

Wednesday, April 20, 2016

CynBet EnerchipRTC is a Great Product for the DIYers

Space is so precious when designing an electronic gadget. Electronics Designers always looking for small components that would perform a whole task if not the major task. Another advantage of being small is that it consumes less energy.

I for one is constantly looking for small electronic components for my numerous DIY personal project and recently, I found the Cymbet Enerchip RTC which is a rtc(real time clock), battery, power management circuit packaged in 5mm x 5mm integrated chip(qfn) package. By the way, Cymbet is the supplier of Google Glass' battery requirements.

Although it is very small, I wonder why they did not included a 32kHz crystal, but having a builtin battery is more than enough to catch my attention. The chip came in 3 variant but personally, I prefer the CBC34803 because it uses I2C communication protocol and lasts up to 120hrs. Here is a typical circuit diagram of this chip:
Another nice feature of this system on chip is that if you are designing your own chip, the company also sells some of their products in wafer form, so like if you want to create your own arduino with builtin power supply can be possible, well who knows, maybe? LOL!

Sunday, January 3, 2016

Using Android Devices in Machine to Machine Communication

Would it be great to make your android device do something even when you are away from it? Or may be let it ring to let you find it with the use of another phone? This process is somewhat or maybe it is a full machine-to-machine communication application which is widely used in so many industrial applications today. 

Just recently, a lot of parents are very much concern with the whereabouts of their kids so they are forced to buy another security device to let them achieve this but these devices are often expensive and requires extra contract with the telcos to ensure reliability.

Nowadays, a lot of inexpensive android smartphones equipped with the latest OS and hardware but the only thing missing is a reliable app that would make these smartphones high tech device. So I thought I should create a simple app that screens incoming sms messages. If this app is able to receive a certain code which in this case is "Hello", it will automatically launch the camera app to take picture and display the thumb nail on the screen. This is just a demo program just to test whether my idea of making the android device do something even when you are away from it.

And I would suggest that this app can be enhanced further by adding Bluetooth communication with HM10 to control other devices in the house with so much ease. You may check my previous post here: More Fun with HM 10

You may download the source of the app here:

If I will have the time, I may combine the 2 apps.