Welcome! Log In Create A New Profile

Advanced

Magnetic Rotary Encoder - Basic Questions

Posted by snoop911 
Magnetic Rotary Encoder - Basic Questions
July 16, 2008 09:30PM
First all, I love the sound of this project! I'd like to start experimenting, and learn how to do all these wonderful things people are talking about, but I have a looooooonnnngggg way to go...

To start tinkering, I have an old canon printer that I could use for parts, but I'm not exactly sure how the Magnetic Rotary Encoder fits in to all this...

The printer has a motor that drives the paper, there is a round transparent disc with a pattern on it, and a small sensor around a portion of the disc. I'm assuming the thin disc is an optical encoder, and the sensor reads the pattern and sends it out the wires connected to the sensor.

My friend has a "PWM Motor driver" that he says I can control the motor with. But not sure how this connects to the Magnetic Rotary Encoder v1.0. Does this board read the optical input and output PMW to the motor driver? And how would I control the actual speed/position that I want the motor to move?

Seems a bit overwhelming at the moment, but I'm hoping things will start to make sense, and I can contribute to the cause of RepRap!!!

Edited 1 time(s). Last edit at 07/16/2008 09:32PM by snoop911.
Re: Magnetic Rotary Encoder - Basic Questions
July 16, 2008 09:53PM
The Magnetic Rotary Encoder will allow the computer to know the position of the motor shaft. By tracking the position over time the computer can determine the speed. The computer can then increase the power (pulse width) or decrease the power to adjust the motor to the desired speed.
Re: Magnetic Rotary Encoder - Basic Questions
July 17, 2008 12:40AM
So it would go,

PC (or Arduino) <-> Magnetic Rotary Encoder <- Sensor <- Optical Encoder Disc


with the Magnetic Rotary Encoder also connected to the Motor via:

Magnetic Rotary Encoder -> PWM Motor Driver Chip -> Motor

Is this right?
Ru
Re: Magnetic Rotary Encoder - Basic Questions
July 17, 2008 04:02AM
If you already have an optical sensor, there's no need for a magnetic one too.

The sensor (magnetic or optical) is just that; a sensor. It can't actually do anything other than tell another device about rotation. It needs to talk to a microcontroller, which can interpret its output, and drive a motor controller.

So:

Sensor -> Arduino (or whatever) -> Motor controller -> Motor
Re: Magnetic Rotary Encoder - Basic Questions
July 17, 2008 10:46AM
Its called closed loop control.

Steppers are open loop - the controller powers the coils in the new pattern and you hope there is enough torque (torque=twisting force) to move the motor to the required position before the next step. If there isnt then you miss steps and never know and will be out of position. Obviously design all the parts to be powerful enough.

Servo control is closed loop - the motor is powered until a position sensor tells the controller it is at the required position.

To close the loop - magnetic or optical sensors are used to count the shaft turns. My newish Canon printer appears to have a plastic strip behind the printhead with markings on it and an optical sensor on the moving head = direct position sensing which is better because there could be slight variations between the motor drive shaft and the printhead, even using toothed belts.

In the closed loop system you are talking about, the motor's torque is adjusted by switcing it on and off very quickly = PWM - pulse on longer than off = more torque and more movement of the load. Pulse not on at all, stationary.

As Ru says, the machine controller (Arduino) has to do the 'where am I?' and 'how do I get there?' calculations. The motor controller will just 'amplify' the Arduino's commands from tiddly little CPU pin output to monster motor power.
Re: Magnetic Rotary Encoder - Basic Questions
July 17, 2008 01:12PM
Reprap (Darwin) uses a stepper motor controlled by a PIC, so where does the Magnetic Encoder get used?

I was thinking of using my printer parts (pwm driver ic, and the optical encoder / motor), but is it perhaps better to go magnetic and buy the Magnetic Rotary Encoder board?

Just as a test, I hooked up a scope to the optical encoder output, and it toggles crazy fast when I move the disc. Not sure if decoding these signals to determine speed/position is a tall task, but I'm thinking if I use the magnetic setup, it might be easier for me to start with. Suggestions?
Re: Magnetic Rotary Encoder - Basic Questions
July 17, 2008 04:16PM
snoop911 Wrote:
-------------------------------------------------------
> Reprap (Darwin) uses a stepper motor controlled by
> a PIC, so where does the Magnetic Encoder get
> used?
>
> I was thinking of using my printer parts (pwm
> driver ic, and the optical encoder / motor), but
> is it perhaps better to go magnetic and buy the
> Magnetic Rotary Encoder board?
>
> Just as a test, I hooked up a scope to the optical
> encoder output, and it toggles crazy fast when I
> move the disc. Not sure if decoding these
> signals to determine speed/position is a tall
> task, but I'm thinking if I use the magnetic
> setup, it might be easier for me to start with.
> Suggestions?


An encoder's output is super simple to decode - it just ticks on and off a given number of times (probably listed on the housing) every revolution. I've seen encoders from 1 to 1600 ticks/revolution. Quadrature is slightly more complicated, but it's basically just two syncopated signals instead of just one, so you know which direction it's going.

I don't have much experience with magnetic encoders, but I assume it just uses a hall effect sensor or something to determine magnetic field? If so, it will probably give back an analog value that actually maps to what part of the rotation you're on, so there's no need to calibrate.

An optical encoder will work just as well in this case, because we're only going for closed-loop velocity control, not position. An optical encoder can give you velocity and relative positions, but not absolute positioning (unless you have some way of homing it, like a limit switch or index channel).
Ru
Re: Magnetic Rotary Encoder - Basic Questions
July 17, 2008 06:06PM
Quote

I was thinking of using my printer parts (pwm driver ic, and the optical encoder / motor)

The optical encoder will certainly be a useful tool. All the more so because it is already mounted to one bit of a cartesian positioning system.

Whether you can easily make the printer's servo obey your commands is another matter, but I think it might be one worth persevering with.

Quote

but is it perhaps better to go magnetic and buy the Magnetic Rotary Encoder board?

The rotary encoder is intended to aid in control of the extruder. For axis control, Darwin uses stepper motors which have no sensor feedback. They're more than sufficient for our needs, however. You don't need to buy any sensors at all for the cartesian bot.

The extruder on the other hand needs sensor feedback so we can get a good idea of how much plastic is actually being extruded, and tailor flow rate to suit the speed with which the head is moving.

So the question is: do you want to use the printer as part of a repstrap?

If yes, you don't need to buy a sensor for the printer's axis, it already has one. You'd just need to buy a sensor for the extruder.

If no, then you could try chopping the sensor off the printer and mounting it onto an extruder motor... unless its something really weird, it will be outputting simple PWM or quadrature encoded signals that you could conceivably stuff straight into an arduino with no further problems. Or buy a magnetic sensor instead.

Hope that clears things up a little winking smiley
Re: Magnetic Rotary Encoder - Basic Questions
July 17, 2008 07:06PM
So the question is: do you want to use the printer as part of a repstrap?

Definitely. I tore down the printer some more yesterday, and found another motor (its used to move the print head across the paper (width-wise)). Haven't found ITS sensor, but if its a stepper motor, I could dedicate that to the cartesian axis control portion... freeing up the the optical sensor for the extruder.

Assuming I can figure out how to read the PWM or Quadrature output (I'm not sure which it is at the moment), I'll have to modify repstrap's arduino code so that it closes the loop based on the optical sensor output, correct? I haven't looked at the code, but I'm hoping I'll be able to stumble my way thru it!

Also, maybe this is a loaded question, but what does the magnetic sensor output look like? For example, if its PWM, does the velocity AND position get encoded in the width and frequency somehow?
Re: Magnetic Rotary Encoder - Basic Questions
July 17, 2008 07:47PM
snoop911 Wrote:
-------------------------------------------------------
> So the question is: do you want to use the printer
> as part of a repstrap?
>
> Definitely. I tore down the printer some more
> yesterday, and found another motor (its used to
> move the print head across the paper
> (width-wise)). Haven't found ITS sensor, but if
> its a stepper motor, I could dedicate that to the
> cartesian axis control portion... freeing up the
> the optical sensor for the extruder.

You can tell pretty easily by looking at the number of wires coming out of it - if there are only two, it's a DC motor. If there are more, it's probably a stepper (steppers will have four or six wires generally, but sometimes more just to confuse you ;-)).

> Assuming I can figure out how to read the PWM or
> Quadrature output (I'm not sure which it is at the
> moment), I'll have to modify repstrap's arduino
> code so that it closes the loop based on the
> optical sensor output, correct? I haven't looked
> at the code, but I'm hoping I'll be able to
> stumble my way thru it!

Yep, that's the idea. Although very few optical encoders output in PWM, so it's pretty unlikely that you have one. Quadrature is a good assumption.

> Also, maybe this is a loaded question, but what
> does the magnetic sensor output look like? For
> example, if its PWM, does the velocity AND
> position get encoded in the width and frequency
> somehow?

Not sure... could be PWM, could be an analog voltage. I haven't looked into the one the RRRF has. Good question though. Anyone know?
Ru
Re: Magnetic Rotary Encoder - Basic Questions
July 18, 2008 04:51AM
Quote

Also, maybe this is a loaded question, but what does the magnetic sensor output look like? For example, if its PWM, does the velocity AND position get encoded in the width and frequency somehow?

It can do both absolute and relative encoding, I believe. With quadrature you get two waveforms so you can get direction and speed, and it is up to the controller to count pulses and work out where the motor is from there (you'll need to do calibration, and have home positions and stuff to do this properly).

In other modes, I don't know how it might work. You can always work out velocity from the rate of pulses (or change of an analogue signal).
Re: Magnetic Rotary Encoder - Basic Questions
July 18, 2008 05:27AM
If it's quadrature you might find the following useful: - [hydraraptor.blogspot.com]

It describes how to control the speed of a DC motor with a quadrature encoder, with source code examples.


[www.hydraraptor.blogspot.com]
Re: Magnetic Rotary Encoder - Basic Questions
July 18, 2008 04:13PM
Quadrature is unlikely because it is attached to a motor - and the printer knows wich way it is running the motor, just not how fast. (speed varies with load, direction (usually) dosnt)

Quadrature is only useful where the controller dosnt control the speed or direction. Like in a mouse.
Re: Magnetic Rotary Encoder - Basic Questions
July 18, 2008 05:24PM
Lampbus Wrote:
-------------------------------------------------------
> Quadrature is unlikely because it is attached to a
> motor - and the printer knows wich way it is
> running the motor, just not how fast. (speed
> varies with load, direction (usually) dosnt)
>
> Quadrature is only useful where the controller
> dosnt control the speed or direction. Like in a
> mouse.


The printer knows which way current is flowing, not which way the motor is moving - a small but important distinction. For a non-zero length of time while the printhead reverses direction, the direction that the controller says the motor ought to be going and the direction it is really going can be different. Of course, one can compensate for that by having smart software that tracks absolute velocity, and assumes that when it is at a minimum the printhead has reversed directions. However, it is generally easier to just always use quadrature, and not have to make a guess.
Re: Magnetic Rotary Encoder - Basic Questions
July 18, 2008 05:25PM
The motor that drives the paper thru, with the transparent disc and optical sensor, has quadrature outputs. It has 2 squarewave outputs (Unfortunately, I don't have 2 probes, so I can't verify they are out of phase with each other), but both are going to the main canon controller board... the motor is (was) being driven by 2 wires (DC) via PWM.

[hydraraptor.blogspot.com]

Thanks for the great link! He is also counting pulses with a quadrature encoder!

BTW, are only the hex files available for the reprap? I was hoping to look at the
PIC extruder code, but I only see the hex files!
[sourceforge.net]

(I couldn't even *find* the source link for the *axis controler!*)
Re: Magnetic Rotary Encoder - Basic Questions
July 18, 2008 06:21PM
This is an OS project, so all the source is available. Here is a link to the SVN repositories.

[reprap.org]

Edited 1 time(s). Last edit at 07/19/2008 02:09AM by nophead.


[www.hydraraptor.blogspot.com]
Re: Magnetic Rotary Encoder - Basic Questions
July 19, 2008 02:31AM
Nothing like doing the research! Looks like the RRRF encoder has a whole slew of output options. Check them out at [www.reprap.org]. I've never heard of SSI - sounds interesting.

I'm a little concerned that the EM radiation from the motor could interfere with the magnetic sensor, but I don't know... is there anyone out there with experience in this field that could give us a better opinion? Looking at the docs, the magnet is very very close to the sensor, so maybe the motor is far enough away to make it not a big deal.
Re: Magnetic Rotary Encoder - Basic Questions
July 19, 2008 02:44AM
Zach has reported that it works on a GM3 and Forrest has used similar magnetic encoders on similar small motors so I guess it is not a problem.


[www.hydraraptor.blogspot.com]
Re: Magnetic Rotary Encoder - Basic Questions
July 20, 2008 08:59PM

Nothing like doing the research! Looks like the RRRF encoder has a whole slew of output options. Check them out at [www.reprap.org]. I've never heard of SSI - sounds interesting.


The magnetic rotary encoder board does have a slew of output options, but I was wondering what does the magnetic sensor output look like that allows the AS5040 chip to decode the input and break it up into either pwm, ssi, etc.

Thanks for the source link, I can't wait to look at it and see if it can be ported to work with parts!
Sorry, only registered users may post in this forum.

Click here to login