Optical encoders with DC motors

More
28 Mar 2018 18:25 #108047 by cptX
Hi to all,
lately I am playing with optical encoders and DC motors, all taken from old printers.
With arduino I have full control over them. I also implemented a digital PID to control their position.
Now I would like to use them with LinuxCNC.
As I have read here LinuxCNC has the capability to work with encoders (see linuxcnc.org/docs/ja/html/man/man9/encoder.9.html)
but I don't understand some things at this point:

1. What hardware do I need to feed the input signals of the encoders to the parallel port and ouput suitable signals for the H-Bridges to control the DC motors (1 PWM and 1 Direction signal per motor).
2. How to configure the software to run these motors. Should I trim the PIDs inside LinuxCNC for each axis/motor?
3. Is there a way to use my hardware measured position (from arduino) and feed this info to LinuxCNC?
4. Can I use arduino as a form of servo motor and send position commands to it through LinuxCNC? I know by this way is not actually a complete closed loop system as LinuxCNC will not have the primary feedback of the position.

Any help would much appreciated

Please Log in or Create an account to join the conversation.

More
28 Mar 2018 22:56 #108052 by cptX
Answering my own question, I found the following related infos:

www.forum.linuxcnc.org/27-driver-boards/...ncoders-and-h-bridge
emergent.unpythonic.net/projects/01142347802
www.forum.linuxcnc.org/49-basic-configur...tch-servo-for-3-axis

So looks like it is possible for 2 and maybe even 3 axes.

Please Log in or Create an account to join the conversation.

More
29 Mar 2018 01:19 #108053 by tommylight

Please Log in or Create an account to join the conversation.

More
29 Mar 2018 08:13 - 29 Mar 2018 08:35 #108061 by cptX
Hi tommylight, this is exactly what I want to do. I also found this board in ebay and considering buying it.
How did you produce the PWM and DIR signals from LinuxCNC? Do you have any code you could share with us?
Have you tried any modifications to introduce a 3rd axis or you spent all the I/O of the parallel port?
Have you connected the optical encoders directly to the parallel port? If so how, through simple resistors or through optocouplers?
Why not use this board instead of yours www.ebay.com/itm/Double-BTS7960B-DC-43A-...6:g:vgYAAOSwWyRarJJa, is this only for one motor?
Last edit: 29 Mar 2018 08:35 by cptX.

Please Log in or Create an account to join the conversation.

More
30 Mar 2018 02:36 #108092 by tommylight
Linuxcnc can output PWM to parallel port easily. The complete config with PyVCP panel as shown on the video is attached at the end of that post.
You can do 4 axis on a single parallel port in mode X, but there will be no more I/O left aside for a single input.
Yes encoders are connected directly to PP. Beware that some encoders will not work on mode X inputs doe to weak outputs.
You can also use that board with the same config, but i do not like it due to very low motor voltage. The ones i have i can change MosFets at will with more powerful or ones that can withstand much higher voltages. It should be for 2 motors, that is what it says in the link you posted.

Please Log in or Create an account to join the conversation.

More
31 Mar 2018 05:05 #108163 by cptX
Hi guys, yesterday I had a huge progress!
Using the etch servo example and a single L293D chip on a breadboard connected to the parallel port I managed to control the head of a printer successfully (normal dc motor with linear optical encoder). Trimming the PID was the most difficult part of the story, but yeah it works!!
LinuxCNC is amazing, it can do everything!!
Now I need to research if I could make 3 axes instead of normal two ones described in the example...

@tommylight thanks for the tip for "mode X". I didn't know it was existing. Right now I have configured BIOS to "EPP" but I checked and there is "Bi-Directional" mode which I suppose is the "mode X".

Theoretically to make a 3 axes cnc I need 9 inputs and at least 6 outputs:
2 Inputs per channel for optical encoders, 1 Input per channel for Home switch and 2 Outputs per channel (one for direction and one for pwm).
The current "etch servo" requires 3 outputs per channel to drive the L293D (or the L298) so I will need extra HW logic to convert the signal to two per channel. Right now etch-servo requires 9 outputs and "mode X" gives only 8 outputs...

Please Log in or Create an account to join the conversation.

More
31 Mar 2018 10:01 #108168 by Mike_Eitel
In mini 3 axis you can connect all
3 motor enable signals together.= -2 outputs.
3 home switches together when homing one axis after another. = - 2 inputs.

Please Log in or Create an account to join the conversation.

More
31 Mar 2018 11:05 #108173 by cptX
And here is a video of my implementation.
Two axes in closed loop with a single chip and a PC. Amazing!

Please Log in or Create an account to join the conversation.

More
31 Mar 2018 11:12 - 31 Mar 2018 11:13 #108174 by cptX

In mini 3 axis you can connect all
3 motor enable signals together.= -2 outputs.
3 home switches together when homing one axis after another. = - 2 inputs.


What do you mean "mini".
Enable signals are usually needed for PWM control. I don't think we can connect them together.
If we put the home switches in series (if I understood correctly your idea) then until the last axis is homed there will be force on the rest axes, something not good!
Last edit: 31 Mar 2018 11:13 by cptX.

Please Log in or Create an account to join the conversation.

More
31 Mar 2018 12:00 #108175 by Mike_Eitel
3axis is a small machine (xyz). Up to 9 are possible.

If you want to stay on position, your motors must stay under power as long as you want to do something soon = enable on. All my drivers (3 machines) are always connected to the same output. ( Enable, step, dir).

Lcnc is easy to setup having several home switches in series or parralel to make sequential homing. Well documented in the html...

Please Log in or Create an account to join the conversation.

Time to create page: 0.098 seconds
Powered by Kunena Forum