Go Down

Topic: Convert PWM signal from rotary encoder to exactly signal for control stepper (Read 8925 times) previous topic - next topic

devahoch

Hi, I am a new in arduino, I need a some helps for my project.
I want to build a flatbed printer from Epson printer. I need to control stepper motor for move plate by ARDUINO UNO R3. As input signal to Arduino I can take a output PWM signal from rotary encoder in printer, this is a 5v signal. becouse in other project I know, Arduino have loss pulses for hight pulses from encoder, I don't want to convert this PWM signal to output pulsea for stepper, I want to use only signal as signal for  start - stop stepper motor, corect pulsea for stepper I can test and change in code for Arduino.
My diagram:
ROTARY ENCODER ---PWM signal (about 20ms ...500ms I don't now exactly)------INPUT ARDUI.----Stepper pulses for motor (in this duration 20ms...500ms: this is constant cycle)



What do you think, this diagram is realy work. Thank you

MarkT

I don't understand, a rotary encoder is likely an incremental quadrature encoder, you
count pulses, not time them.  I'd still do the standard thing of using interrupt driven
quadrature decoder, then in the main code you can do what you like with the encoder
output (detect change and turn motor on/off, implement a PID loop to turn motor into
servo motor, measure speed, whatever you like).
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

devahoch

I don't understand, a rotary encoder is likely an incremental quadrature encoder, you
count pulses, not time them.  I'd still do the standard thing of using interrupt driven
quadrature decoder, then in the main code you can do what you like with the encoder
output (detect change and turn motor on/off, implement a PID loop to turn motor into
servo motor, measure speed, whatever you like).
Thank, but in other simile project, is there big problem for read pulse from rotary encoder, pulses are lossing when encoder rotare to fast ( very hight pulses).
My project is identical with thread http://forum.arduino.cc/index.php?topic=234667.0
I readed you post there too, Try to make code for control. But I am novice in ARDUINO, need more time to understand and write code.

MarkT

If you just want on/off distinction then lost pulses aren't an issue are they?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Robin2

My project is identical with thread http://forum.arduino.cc/index.php?topic=234667.0
My impression is that the project in that Thread fizzled out because it was too complicated for the OP.

Is there a stepper motor in the printer you want to convert? Many (most?) new printers don't have stepper motors.
What specific printer do you have?

How many pulses per revolution does the encoder produce?
Can you post a photo of the encoder?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

devahoch

My impression is that the project in that Thread fizzled out because it was too complicated for the OP.

Is there a stepper motor in the printer you want to convert? Many (most?) new printers don't have stepper motors.
What specific printer do you have?

How many pulses per revolution does the encoder produce?
Can you post a photo of the encoder?

...R
All specifications are:
In Printer EPSON Photo style R1400 is Brushed DC motor 42v for move paper, Is only DC motor, no servo. In the sharf for move paper is rotary encoder with 180 pulses per revolution. Paper move with constantly cycle, no continous, and this is control by encoder.
Now I want to build a plate for flatbed print, For move this plate ( instead paper) I use stepper with linear guideways. As signal for control stepper I can use PWM from encode or voltage from DC motor (42v).
In other thread I know, pulse from PWM encoder lose for digital read on Arduino, that I want to control stepper by duration of cycle, when encoder ( res. DC motor) rotary. Digital signal from encoder or analog signal from DC motor. 

Robin2

That photo looks almost exactly like the small Canon printer I took apart. The encoder disk on my printer has the printing at a diameter of about 60mm = circumference of about 188 mm and there are so many graduations that I cannot count them. There could easily be 10 per linear mm or 1880 per revolution. Are you sure yours only has 180?

How are you measuring / counting to get 180 - can you show us the circuit that is producing the pulses. If you have used your Arduino as part of that please post the code.

I don't understand how you can describe the encoder output as PWM. Have you looked at it with an oscilloscope and if so can you post a photo of the trace from the 'scope.

You can't possibly use the motor voltage to detect anything because it would be meaningless even when the printer was complete and working.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

devahoch

Sory, encoder has 360 pulses per revolution, I haven't a osciloscope, this number is from other forum.

MorganS

I'm still not understanding how the encoder is meant to control anything.

For a normal 3D printer, laser cutter or other stepper-motor based device, there's no measurement of where the motor is. The Arduino just sends out the required number of steps and the stepper always moves that exact number of steps.

The next time I pull apart a printer, I'm definitely going to look for this encoder. It looks useful for the projects I build.
"The problem is in the code you didn't post."

Robin2

Sory, encoder has 360 pulses per revolution, I haven't a osciloscope, this number is from other forum.
Don't trust that source of information. Count them yourself.
Can you provide a link to the source of your info?

If you don't have an oscilloscope then I think it would be safest to assume that PWM has nothing to do with this.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

devahoch

Today, I have  more time to talk, how and what I want to control stepper.

1, work principle of Printer.
    When printer send command, printhead spray a ink from right to left and paper is in standing . when printhead is on left position, printer send command (turn on voltage 42V) to DC motor PF for move paper by PF Roller, on the PF roller is rotary encoder with 360 steps per revolution. Encoder read some value of steps and printer TURN OFF PF motor. Now printhead make spray ink from LEFT to RIGHT and proces move paper turn back when printhead is on RIGHT position.
- PF Roller have 8mm of diameter, one circumferential length is 25,13mm. For one cycle move paper is cc 5mm (no exactly, only estimate) is cc 1/5 circumferential length and is cc 1/5 of 360 steps=72 steps. time of one cycle is very short (cc 50 mili second), that I think, Arduino can't read make matematic for corect pulse (steps/second) as input in this short intervale.

2, For control my external stepper I must use signal from ENCODER or from DC motor for synchronize with proces spray ink of printhead.

3, My plan: I don't want to read exactly pulse, but I want to make signal START - STOP for stepper.

   a, I want to use signal from ENCODER for signal START - STOP for stepper (use digital input).
   b, Use voltage from DC motor (42V ...switch.....5v) as Signal START - STOP for stepper (use analog input)

Do you think, what is better for me, and is realy for build?
For determine of problem, I upload principle of mechanism of printer.
Thank you.


Robin2

The diagram you posted talks of a stepper motor being used for paper feed but, AFAIK your printer uses a DC motor and an encoder.

I think you are saying that you need to replace only the paper feed mechanism with a feed table that can move the cloth. The printhead movement will be unchanged.

And I think you are saying that the feed table just needs to advance one position everytime the printhead gets to the end of its travel. If that is the case it seems like all you need is some sensor (perhaps an optical device) to detect that. Then you can organize your stepper motor and its gearing to move the feed table the correct distance. Does that make sense? In this concept there would be no need for an encoder.

And thinking about it further you may have in mind that the moment the printer tries to power the feed motor could be used as a means to detect when the printhead has reached the end of its travel. I can now see some logic in that. If the printer is still working normally it should not be too difficult to use your Arduino to test that assumption by using it to flash an led when the motor power comes on and seeing if that corresponds with the location of the printhead.

Have you figured out how many mm the feed table must advance for each print row?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

devahoch

Thank you Robin!
I don't want to build sensors for position of printhead, becouse is complication for me. in true, PF DC motor work immediately when printhead is in correct position, that I can use this signal from DC motor to input of Arduino. My concept is use this signal as BUTTON input for Arduino (That when BUTTON is pressed, Stepper work - when BUTTON is release, Stepper stop). Speed of Stepper is programed in Arduino (I must to try make pulses for this).
Now I build a linear mechanism for plate, when I have done, I can try this. But earlier, I must have a correct concept of project.
I must use a encoder, becouse from this, I can use signal for DIR (is very important in project).

Riva

The paper feed roller has a fixed diameter and the encoder on the end of this shaft has a fixed number of lines so from this you can work out haw far the paper moves per division (line).
Could you not just monitor the direction the printer is trying to turn the DC motor step the stepper in the same direction and generate the encoder feedback pulse(s) to the printer. Keep doing this until the printer stops trying to drive the DC motor (It's happy with the paper position). This way the printer will not start the carriage printing until the table is in position and steady. The way you seemed to want to do it is hoping you can move the table as fast as the printer paper was fed and hope your in position before the carriage head prints.
Don't PM me for help as I will ignore it.

Robin2

PF DC motor work immediately when printhead is in correct position, that I can use this signal from DC motor to input of Arduino.

I must use a encoder, becouse from this, I can use signal for DIR (is very important in project).
You are still not explaining things clearly enough for me to see the overall picture.

I think (in Reply #11) I figured out how you are planning to use the DC motor power as a signal.

But I am completely lost as to how you plan to use the encoder. I still have my doubts that the encoder is only 360 pulses per revolution. But more importantly, if you replace the paper feed with a table driven by a stepper what will drive the encoder?

I think my bigger confusion is that I suspect you want things to work so the printer is completely unaware that you have been mucking about and your descriptions have not painted a clear picture for me of how that is to be achieved. And I don't know if my confusion arises because I don't understand exactly what mechanical changes you have in mind or whether it relates to not knowing enough about how you intend the control system to work.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up