Monday, December 5, 2016

RC SERVO ROBOT ARM: Weekend project

This is our weekend project: a simple RC servo robot arm. 

Host controller is Mac using Python scripting, while servo controller is a spare Fubarino SD.

I tried with MSP430 Launchpad, but Serial + 3 servos was over the capability of this little Mac-hated board. Fubarino is a cherry plenty of power, and the ported SoftwareServo library from ChipKit is stable and effective.
Fubarino accepts directly joint angle in ms. Python script uses a simple Inverse Kinematics (Updated versione: math credits to COŞKUN YETİM):

def ik(self, position):
l1 = self.arm1
l2 = self.arm2

x = position.x - self.home_position.x
y = position.y - self.home_position.y

dist = min(l1+l2, sqrt(x*x + y*y))
dub = sqrt(x*x + y*y) / dist
x /= dub
y /= dub

thetar = acos(x/dist)
theta1 = acos((l1*l1 + x*x + y*y - l2*l2) / (2*l1*dist)) + thetar
theta2 = pi - acos((l1*l1 + l2*l2 - (x*x + y*y))/(2*l1*l2))

self.set(180-degrees(theta1), 180-degrees(theta2))

Graphic is provided by a simple Svg to path script. The library used (svg.path) can provide point coordinates for Line, Arc, CubicBezier and QuadraticBezier without pain. All graphic may be created within Inkscape.

Overall code may be downloaded at this link.

Friday, December 2, 2016

IOT RECIPE: 02 Energy Monitor

In this post i'll cover actual sensor setup for energy monitor.

Energy monitor

To evaluate power consumption i've routed main cable coming from utility energy monitor in a new electrical panel. In this panel i've installed:
  • 3 three-phase energy meter (16 kW of maximum power)
  • 1 single-phase energy meter
This is an internal view of my setup inside an ABB electrical panel (upper part, with two of these energy monitor) after thermal-magnetic circuit breaker and surge protector.

For this duty i preferred to go with an industrial solution, because i was not confident with DIY solutions on main power side.
My solution is a products from Italian manufacturer LOVATO:
LOVATO DMED300T2 is a compact (four modules) energy meter. The main advantage is the presence of two programmable pulse output (up to 1000 pulses/1kWh or programmable threshold).
The output is an open collector, in which each pulse has a duration of 60ms: an open collector is a transistor based output that can be read by an external PLC (like arduino).

The electrical connection requires only to route an input pin of the arduino to open collector and connect the two IC grounds to have the same reference level and let current from arduino to flow once open collector is open.

There are two methods to read these output, with interrupts or with pooling.
Because i had only one external interrupt, i had to go with pooling: loop forever and check if digital input is high or low. If is high, and previous one was low, than increment a counter and go on to next input. 

First of all, in my system maximum power is 16 kW: this means each hour i can have a maximum number of pulses of 16 * 1000 = 16.000 pulses/hour equal to 4.45 pulses/second, each one of 60 ms.
If entire loop timing is less than 60ms, no pulse is missed.

Because open collector is transistor based, i found no debounce routine is needed (situation like button press may need a stabilisation in input reading).

My piece of code for pooling is:

pinMode(LOVATO1, INPUT);           // set pin to input

digitalWrite(LOVATO1, HIGH);       // turn on pullup resistors

READ1 = digitalRead(LOVATO1);

if (READ1 != LASTSTATE1) {
    if (LASTSTATE1 == 1) {
      COUNTER1 ++;

Taking into account the time delta between reading A and reading B (60s in my case), is possible to average the energy consumption during this period, and to define average power consumption during the period.
Passing via serial milliseconds and pulse numbers between loops, i can reduce the time spent communicating with host, leaving calculation on other side.

Resulting chart of 1 day power consumption average (1 tick/30 minutes):

Tuesday, November 29, 2016

IOT RECIPE: 01 Introduction - Sensor web interface

I'll start a new series of posts on IOT matter from the end.
This is the web interface running on my local area network.

Running the site is a mini flask web server running on a Raspberry PI. In the screenshot, charts are provided by and Justgage javascript library.

In this series of posts i'll cover all the ingredients of my recipe:
- Sensors overview (DHT22, Energy, Light, Barometric pressure, Pellet height)
- Raspberry Pi data acquisition with Arduino
- Launchpad Tiva CC3200 with WiFi
- Node Red Engine
- MQTT, Mosquitto, Paho
- Rrdtool, circular timeseries database
- Flask server
- Charting with javascript
- Debian unit files
- Telegram Bot Api

Sunday, November 27, 2016

OUTSIDE: Dan Gelbart, marvellous craftman

Check out a series of 18 videos on prototypes by Dan Gelbart.

With simple language and real examples Dan will capture you as nobody did before; his videos are not only about prototypes or machinery: each time i look at Dan's videos, he says to me that if you really believe in yourself, you can spend all your life doing what you like and be proud to share your achievement with others like you.

My favourite one is #5 on spot welding.

Check out Dan Gelbart Youtube channel for other videos

PEATOL/TAIG: Milling attachment 1220

Milling attachment
Part # 1220

From Taig: The milling attachment is used to hold the workpiece while the cutting tool is held in the headstock spindle. The attachment provides vertical travel of approximately 1 3/4 inches. The dial provides travel in .001 inch increments.

The cutters (end mills) are held in the spindle with collets to provide maximum rigidity. Miniature end mills come with 3/16 inch diameter shanks and various size cutting diameters. The end mills will cut all materials steel, aluminum, brass, plastic and wood.

Milling on a lathe? If you already have a mill, you will find are needed more passes and lighter cut with this attachment.
The attachment may also be used for gear cutting. Check out this video by xynudu on youtube:

Saturday, November 26, 2016

OUTSIDE: Making gears at home

Making gears at home is quite difficult and a lot of tools and machinery are needed.

At least you need a rotary attachment for a mill or lathe with a specialized tool (involute gear cutter).
Another drawback is that to cut a specific gear you need a specific size of involute gear cutter, so a complete set (normally 8 pieces, around 100 bucks) is needed.

Chet out this great video by Tubalcain:

Another option is to build a small spur gear hobber machine (project already in the wishlist) like this beautiful one by Jack Hayes:

Also in this case, only the hobber, quite difficult to find, at least requires 80 bucks.

Solution? Not for helical or spur gears, but there is a particular set of gears, called worm gears you can machine at home. 

From wikipedia: "Worm-and-gear sets are a simple and compact way to achieve a high torque, low speed gear ratio. For example, helical gears are normally limited to gear ratios of less than 10:1 while worm-and-gear sets vary from 10:1 to 500:1"
Is possible to find this set of gears in telescope aligning mechanism or in a mill 4th rotary axis. In this set the two axis are perpendicular, and only one is driving.
The drived gear can be machined easily using only a lathe, and the other one may be simply a machine screw with imperial, metric, acme or custom thread. Is only needed to have the a screw tapper.

Check out this self-explanatory video by Dalibor Farny:

Finally a link of great kinematics models. From KMODDL site: "KMODDL is a collection of mechanical models and related resources for teaching the principles of kinematics--the geometry of pure motion. The core of KMODDL is the Reuleaux Collection of Mechanisms and Machines, an important collection of 19th-century machine elements held by Cornell's Sibley School of Mechanical and Aerospace Engineering."
Digital file property of Cornell University Library. Made available under the same terms as a Creative Commons Attribution Non-commercial Share Alike License

Friday, November 25, 2016

ELECTROMAGNETIC CLOCK: Kundo (Germany) clock

A vintage Germany clock from manufacturer Kundo, around 1960's.

This particular and clever kind of clock keep time as mechanical watches do, with a swinging pendulum. But there is no mechanical winding: instead a magnetic force applied by the solenoid inside brass cylinder to the pendulum arm, gives to the pendulum a momentum maintaining pulses during time.

The solenoid is mechanically activated by a micro switch linked to the pendulum on the upper side.

Accuracy is provided by the brass bell, which is screwed on the pendulum. Each turn right raise the bell on the pendulum linkage, keeping the period shorter. On the other side, each turn left lower the bell, keeping the period longer.

I've replaced original battery (visible in the photo) with two AA size 1.5V batteries, and i've never replaced them in 4 years now.