Sunday, May 26, 2013

Connecting Huanyang HY01D523B VFD speed controller to Mach3

Huanyang HY01D523B VFD
Few months ago I purchased Huanyang HY01D523B VFD and 1.5 KW water cooled spindle motor from eBay for my CNC router.  Recently I completed mechanical part and started final part, electrical. First of all I googled on the how to control spindle from software. Luckily there is a way not only to turn spindle on/off from Mach3, but control RPM and read actual PRM count back. This part a bit tricky as Huanyang VFDs aren’t implementing standard ModBus protocol, but uses their own, so is not directly supported by Mach3. But I found special plug-in which solves this issue, and I’ll back to software part later.

Connecting power lines

HY01D523B VFD could be powered from single on three-phase 220V/50Hz. I use single-phase power line, so I connected phase wire to R terminal of VFD, and null line to T; PE goes to E terminal.
Spindle is three-phase, and is connected to U, V, W terminals. If your spindle runs in wrong direction, just swap any two wires of the motor. For details please refer to VFD manual.

Hardware interface

To connect VFD to PC, you will need RS-485 adapter.

Sunday, November 4, 2012

DIY fume extractor for soldering

Impressed by the price tags on soldering fume extractors and tired by inhaling crap I decided to build something of this kind by myself. Result you may see on photos below. It is is made of:

  • 3 mm polystyrene sheet;
  • two 80 mm coolers from dead ATX PSUs;
  • aquarium activated carbon filter sheets from eBay;
  • rocker switch;
  • barrel jack receptacle;
  • some wires and foam insulation strips.

Polystyrene was bent without heating, only two grooves were carved to help bending. All parts were hot-glued, bottom lid mounted on double-sided adhesive tape.

Device is powered from 12V/1A wall PSU.

Total construction time – less than 2 hours.

DIY fume extractor

DIY fume extractor - filter in place

DIY fume extractor - ready to go

Saturday, March 10, 2012

My first bookmarklet: Flickr photo page by photo ID

Tired of direct links to Flickr photos, when I’m unable to find the author, I decided to create my first (and really simple) bookmarklet for purpose of translating of Flickr photo ID into URL of photo page.

Here is the result, just click of drag to your favorites the following link: Flickr photo by ID

When clicked, bookmarklet will ask you photo ID. Just put it there and click OK – you’ll be redirected to Flickr photo page.

Here is few examples what is photo id (photo id is in bold):

Code of bookmarklet for your convenience:

<a href="javascript:var photo_id=prompt('Please enter flickr photo ID',''); if (!photo_id) return(false); window.location='' + photo_id;return(false);">Flickr photo by ID</a>

Sunday, October 30, 2011

DIY outdoor all-weather 3G/Wi-Fi router

My father lives in the village where no broadband connection is available. To access Internet he used creepy and hell expensive GPRS connection. Once tired by absence of normal connection and impossibility to show him some video on youtube I decided to make something to resolve this nonsense. At that time I was aware few neighbors of him are using 3G USB modems with Yagi antenna attached. After small research USB modem was bought to do the same. Unfortunately first attempts to connect to the network using solely internal antenna was complete failure. But when I was outside house and connected 1/4-wavelength long piece of copper wire into modem’s antenna socket, I was able to connect to the network.

Due to impossibility to make connection from the house, first more or less working solution included wireless router with USB port (at the time one of the cheapest TP-Link TL-MR3220) that was located in attic and this fascinating wire antenna:

It's how broadband looks far away from the city

Surely I was able to connect modem directly to PC using only external antenna and USB extension cable, but I have reasons to go wireless. To name a few:

  • I and my nephew have wi-fi enabled devices (phones, laptops, ipods, etc.) we would like to use them anywhere in the premises. So this hotspot will serve not only standalone desktop PC, but any wireless device in range.
  • I didn't wanted use PC as a router as it often turned off because is a little loudly and located in the living room.
  • While drilling in the attic was OK, inside cabling will be a pain. Wireless access from desktop is a real saving and relief.

Few weeks after installation I visited father again and found that:

Monday, February 7, 2011

Debugging firmware without debugger

My thermocouple sensor stuck for a while on firmware development stage until my Logic Sniffer is arrived.

This is because I faced a problem with I2C communication:

  1. When I communicating my firmware based on Atmel’s AVR302 application note source code, it works as expected;
  2. When I poll LM75A I2C thermometer it also working fine, but after I read value from it strange side effect appears: my firmware stops responding with address acknowledge when I trying to address it;
  3. After few (rather random) polls to LM75A my firmware are able to process commands until thermometer part is polled again.

There are many wait loops in firmware source code originated from app note like following:

sbis PINB,PINB2 ; wait for SCL high rjmp whi_dac wlo_dac:
sbic PINB,PINB2 ; wait for SCL low rjmp wlo_dac

It seems to me that because of incorrect handling of a bus states firmware hangs on one of these loops.

I ordered logic analyzer to examine bus traffic but because it seems that the package delayed somewhere due to Chinese New Year I want to try today one approach that come to my mind during last week how to debug firmware inside ATTiny13 without hawing hardware debugger. Idea is pretty simple:

  • ATTiny13 has 8 pins;
  • 3 is pre-occupied (RESET, VCC, GND);
  • On 2 pins (PB2(T0) as SCL and PB1(INT0) as SDA) sits I2C bus;
  • Thus 3 pins (PB0, PB3, PB4) are free and could be used for debug purposes.

Idea is to use LEDs connected to free 3 pins as indicators of key points in source code. 23 gives us 8 possible combinations. All that I need is to set PB0, PB3, PB4 to HIGH/LOW state according to key point number in binary format.

Sunday, December 12, 2010

K-Type thermocouple sensor I2C interface board

Today I finished with board preparation and soldering:
K-Type thermocouple sensor I2C interface board
Most important part is firmware to turn ATTiny13 into I2C ADC which is not ready yet. Will continue with this task on next week.

Friday, December 10, 2010

K-Type thermocouple measuring

I'm designing the circuit to measure high temperatures (up to 600 °C) with at least 1 degree resolution with TWI (I2C) interface.

Literature on thermocouples:

Circuit design will include LM75 TWI temperature sensor for cold junction compensation, LM358 dual operational amplifier for two-stage amplification and ATTiny13 microcontroller for ADC and TWI interfacing (software slave).

Board layout supposed to be as narrower as possible to be insulated with heatshrink tube. Thermocouple will be connected using 3.5 mm screw terminal. For MCU communication and power supply 4-pin JST connector will be used (2.5 mm step). TWI address of LM75 will be configured using solder jumpers, ATTiny address will be set using TWI protocol and default address and then stored to EEPROM.

Device will support 3.3V and 5V supply.

Dual stage Non-inverting amplifier calculation is the following:

As I need 600 degrees upper level, voltage could be aplified up to 125 times to be below 3.3V for normal operation with this supply voltage as about 25mV corresponds to 602° on k-type probe.


1st stage: R2=10K, R1=1K, Gain=11

2nd stage: R2=10K, R1=1K, Gain=11

Total gain = 11*11 = 121

Total gain of 121 is good for us as it gives 25mV*121=3.025V at 602 °C (25 mV reading).

Measurement resolution considering 10-bit ADC will be:

At 3.3V 3.025/(3.3/1024)=938 steps, about 0.64 °C per step.

At 5V 3.025/(5/1024)=619 steps, about 0.97 °C per step.

I will work on proof of concept today; let's see the results.

Thursday, July 8, 2010

Digital Soldering Station Concept

Haven't written some time due to my work and ongoing projects I will explain later.

My pumping station is on hold for a while as it is not urgently required till first frosts. Actually all electronics is complete and working perfectly. The only thing is to pack it into cases and make good water insulation for immersed parts. This part I hate most because I have no suitable tools and place to do the hardware work.

Now I'm working on digital soldering station to replace my old 40W 220AC iron with tool more suitable for lead-free soldering. Features I'm going to implement:

  • PID controlled heating of 24V iron (I'm going to use SL-ICMC 24V/48W iron with ceramic heater that normally used with CMC series of Solomon stations with K-type sensor)
  • 3-digit numerical display for temperature reading and setting
  • Two-button 100 to 450 °C temperature setting
  • Calibration using external thermometer
  • Replaceable circuit for thermocouple or thermistor sensor support
  • EEPROM to store temperature settings when station is switched off

I have bought switching PSU 24V/2.7A, iron and metal case for this project and now working on electronic part. Hope to come soon with first results.

Monday, March 8, 2010


Finally I got it working yesterday! The problem with TWI was not in MCU nor in software TWI Master implementation, but in differences in addressing.

In LM75A datasheet said that 7-bit addressing used for the device. MSB bits are always set to 1001, and value of 3 lower bits depends on logic level on pins A0:A2. As A0:A2 pins I have connected to Vcc, address of my sensor is b01001111 (8-bit binary) = 0x4F (hexadecimal). I have successfully used this address with Arduino and all was working as expected.

But when I started with ATTiny13 running software TWI nothing were working. As I haven’t full-functional digital oscilloscope, I had tried to make some “poor man’s logic analyzer” using codes from here. Got it working, but results were strange to me because SCL signal on TWI bus wasn’t like a strobe but more likely signal. So I decided to make more research over the net.

Fortunately I have found topic on forum where somebody discussed interaction with different LMxx sensor, and I noticed strange addressing in code. Address of device were 0x90 that corresponds to b10010000. I have maid guess that address should be not left-padded as I used it with Arduino, but right-padded. I put b10011110 (0x9E hex comparing to 0x4F I've used before) as address and now everything is working just fine!

Sunday, March 7, 2010

LM75A setup

I made serious mistake during design of pumping station thinking LM75A has non-volatile memory for configuration parameters. Actually this IC haven’t such ability as store configuration between power-ups.

Fortunately I have connection to TWI pins on both sensor board and wiring, so decided to create some “hardware config file” basing on ATTiny13. I have created Arduino sketch to test approach and it is working just fine, but tiny13 has no hardware TWI implementation comparing to ATMega168. After some research over the net I found nice implementation of AVR-300 (Software TWI) by Peter Fleury: 

Here are 2 PCBs, one is test board for LM75 sensor, second is ATTiny13 for software implementation of TWI:

Homebrew PCBs for LM75A digital thermometer and ATTiny13 based board to configure sensor

My configuration board is still not working despite simplicity of the library. I haven’t found why, but my guess is that internal RC oscillator is not suitable for this. Will try to run with external crystal today.

Update: I had made it working!