Archives for posts with tag: agilent

Hi guys,

As I wrote in the last post, here we are with the implementation of the motor controller that uses the encoder feedback.

I suggest you to read the previous post so to catch up with the point.Here there is the link https://cuverita.wordpress.com/2013/06/30/how-to-master-an-hp-printer-optical-encoder-carriage/

We will see how to set the proper speed and direction of the motor that moves the carriage considering the position coming from the optical incremental encoder.In fact it could be an easy way to make some practise with a PID controller.

In order to do that, we need a MCU.This time I chose a PIC18F2523 that is programmed using the PicKit2 while the coding is done with MpLab X IDE and XC8 compiler.

The parts to develop are:

1)How to understand out position using the channels of the encoder

2)How to set a particular speed and direction to the motor that moves the carriage

3)How to use a PID algorithm to control the system.

Ok….let’s proceed with order and, as always , the divide et impera method will help us to make the things straight forward.

I suggest you some web page to read so that the things will be more clear before starting:

1)

http://mechatronics.mech.northwestern.edu/design_ref/sensors/encoders.html

http://www.pengurobotics.com/projects/avr_hp_encoder

2)

http://www.mikroe.com/chapters/view/6/

http://www.pyroelectro.com/tutorials/h_bridge_4_transistor/

http://workshops.ist.utl.pt/arduino-lessons/lesson-ii-3-inductive-load-control/

3)

http://courses.csail.mit.edu/6.141/spring2011/pub/lectures/Lec03-MotorControl.pdf

http://ww1.microchip.com/downloads/en/AppNotes/00964A.pdf

As you can see from the resources I chose for you,I want to take and easy and applicative approach.

I remember the long course I had at the university about robust controller.The professor started with theoric stuff like: phase margin,bandwith in open loop,overshoot,rise time,settlement period etc…

For you I will skip all this shit and we will go straight with the last part of the course.In fact after almost 3 moths of explaination we came up with the standard industrial controllers better known as ProportionalIntegralDerivative controller.

The most of the closed loop controls are possible because of it and sometimes PIDs are used even if are not the proper way to rule the system.Ok,we are engineers and the time is money,so…why don’t if it works!

Well,we are going to control this motor that works at a nominal voltage of 18Volts.Considering that I have a power supplier of 14V,we will provide only this voltage to it,through an H-bridge.

p1040882

Moreover I glued a limit switch that is used to reset the count of the steps of the encoder,during the initialization.

limit

Here we have the schematic of the project

encoder

As always an image explains better than thousand words.Anyway a short commend doesn’t cost that much:

Here you have the complete source code in XC8. Some parts are inspired by the reference I gave you above.For instance the finite state machine that provides the position from the encoder output is from the third link.I swear that the rest of the code is brand new:

http://rapidshare.com/files/2444778370/encoder_pid.zip

(the password of the zip file is:”cuverita”)

For the sake of keeping the reference position, I implemented a PI controller(no derivative) in this strange way:

int pi_controller (int ref,int now){
static int integ=0;
int err=0;
int out=0;
err=ref-pos;
out=shift_number(err,KP_SHIFT);
integ=integ+shift_number(err,KI_SHIFT);

//anti wind-up code
if(err<0)
err=-1*err;
if(err<EPS){
out=out+integ;//use it if near settlement
}else
integ=0;//clear the accumulated

return out;
}

In fact I wanted to have a Kp and Ki much smaller than one.The most efficient way to divide a number is to shift it right with a bitwise operation(>>) .It saves computational time so to control the system quickly when needed.

Eventually a clip of the carriage moving.You can see an initialization that uses tha limit switch,then a change of reference position given by the pression on the switch.

The reference position is taken activelly with a proportional action,the more I push and the more the displacemente increases.This cause an error=reference-position that is compensated by an higher voltage to the motor(PWM duty cycle).

I’m available for any question…

Stay tuned!

Hei guys!

I’m back in Italy for the summer and considering I don’t know how to spend my time I decided to start some hack.

It was 34 celsius and I decided to soffer the terrible hot temperature of my my room/lab starting opening a pretty old printer that a friend gave me.This is a HP PSC 1510 AllInOne that ended his life just because of a new HP knocked at the door.

After I removed the screws I saw a nice carriage with DC motor and optical encoder.That’s cool because you can do many interesting things with one of these carriage.

I’m sure I’m not the first in the world to do that but I think it could be interesting to sum up what was the research on internet and the coding I needed to do.It could be an easier start for some other guy who finds the same situation.

First step:Who knows something about this printer?Let’s try to google that…

The best resources for it are:

1)http://www.pengurobotics.com/projects/avr_hp_encoder

2)http://reprap.org/wiki/Optical_encoders_01

I’d like to comment these two resources:

1)It seems that guy managed good the task.In this case he uses a comparator because the output of the encoder is a sinusoidal shape signal that must be compared with the half of its amplitute to become a squared shape signal. In that case he needed to arrange the threshold so to have an logic high if over half of the power supply voltage.

2)Great!There are some picture of the pinout of several optical encoder produced by Agilent. There is even the Agilent 9981 that I need

In fact one of the pictures from the second link http://reprap.org/wiki/File:FD_opto_sensor_pinout_02.JPG has the pinout of the Agilent sensor mounted on the printer carriage.Moreover after some further research I have found this http://pdf.datasheetcatalog.com/datasheet2/a/0a46za47kk0rg2x0izood71i9apy.pdf

The AEDS-962x have the same pinout and the same electronics of the Agilent 9981

There is a built-in comparator with pull-up(2.5K) so that in this case the ouptut signal has a squared shape ready to be used with a common I/O port without the use of MCU’s comparators.

Perfect…let’s see how to use the stuff we have.For sure we want to keep the perfect mechanics that works around the encoder so we must access the sensor without welding it out from the board.

hp1

An easy way to do that is welding some wire from the strip connector that acts as interface.Using the multimeter in ‘diode’ mode we can figure out to which pin the power supply and the two channels go.

As you can see from the picture there is some uggly welding coming out from the sides of the connector.The pin out in in the picture too.

hp4hp3

There is a 60 Ohm resistance between the anode of the led and Gnd.In this way the current flowing in it is limited to about 30mA

Quod erat demonstrandum once powered up the sensor(3V) the output of the channels are 0V or almost 3V for both channels.

I implemented already some code for the PIC18F2523 mcu with XC8 in order to determine the position of the carriage from the encoder.This will be the topic for the next post.

I hope that my explaination, apart the latin, was clear and that this post could help you to take some Hp printer out form the garbage 😉

That’s it for today!I’m working on the c code for the MCU so to implement a robust control of the movement.

Stay tuned!