Automatic Pen!

"Necessity is the mother of invention!"

I was always struggling with Kanjis(Japanese characters) and thinking about a way to write things like Kanjis with an automatic pen that you just move it on the paper and it will write it for you like this scene from the "i Robot":

However, there are two problems:

(1) Locating pen's head

(2) Printing method

Obviously, the pen should know where exactly is the head, so it can activate the printer at the right time. Some smart pens use a specific coded paper that lets the tracker know where is it. It's also possible to use optics like a computer mouse. However, I want it to work on any paper! and also optics are not accurate and fast. If you move a mouse to a point and return very fast, the cursor won't end up on the first point. 

Generally, tracking things is not easy! even with the best sensors you need lots of filters (like Kalman) and predicting algorithms, especially when you need to measure on the order of millimiter. But i just wanted to test my idea, so i used the best available tracking method which is being used in printers. The shaft encoders of a printer are very accurate and can track and alighn the paper precisly. I made an arm with two joints and installed a shaft encoder on each joint:

I hooked up the shaft encoders to an Arduino which is pretty fast (around 16MHz). The sensors send a pulse for each line. By having the number of lines it's possible to calculate the angle from a reference point. The encoder resulotion is very good but to make it better i used an algorithm to interpolate between the pulses as i explained here. Then I used simple trigonometry to get the position of the head from the reference point(which is the main joint).

Now i know where the pen exactly is in real-time which takes me to the next problem: Printing method.

I thought about different methods. One method is a laser! but the distance of the laser to the paper is not constant, lasers consume a lot of power and it may burn the paper! Another one is having an ink head(like an ink-jet printer) like a real printer. But i don't have one right now and fitting an ink head into a pen is a complicated process. I just needed a pen to touch the paper on the exact moment to test my idea.

This is the tricky part! except you use a laser, any other mechanical method takes time! imagine you're moving the pen very fast and it reaches a point that should leave a mark. The Arduino sends signal to a drive, drive activated the solenoid and the pen moves toward the paper. Even if everything takes less than a second, the pen moves a little bit away from the designated point. So you never hit the right point. But with a fast computers the offset is negligible.

Most solenoids in the market are either slow or heavy. The best thing that i could use is a solenoid that moves a CD drive's laser! it's super fast and accurate:

I connected the solenoid to the Arduino with a drive and programmed it to trigger the solenoid on a one specific point. The results wasn't bad! The system leaves a mark on that point every time passes from it. But if you have lots of points loaded in the system it has to search for specified point on every position. That means every time you move the pen it has to scan the whole loaded image and check if it should leave a mark or not. That makes the thing slow!

Im thinking about a way to predict the pen location and limit the scan size to a circle around the pen. I will update this post if i found a solution!