Optical encoders with DC motors
- cptX
- Offline
- Junior Member
- Posts: 24
- Thank you received: 2
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.
- cptX
- Offline
- Junior Member
- Posts: 24
- Thank you received: 2
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.
- tommylight
- Offline
- Moderator
- Posts: 19474
- Thank you received: 6524
www.forum.linuxcnc.org/show-your-stuff/3...2-euros-for-2-motors
Please Log in or Create an account to join the conversation.
- cptX
- Offline
- Junior Member
- Posts: 24
- Thank you received: 2
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?
Please Log in or Create an account to join the conversation.
- tommylight
- Offline
- Moderator
- Posts: 19474
- Thank you received: 6524
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.
- cptX
- Offline
- Junior Member
- Posts: 24
- Thank you received: 2
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.
- Mike_Eitel
- Offline
- Platinum Member
- Posts: 1128
- Thank you received: 184
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.
- cptX
- Offline
- Junior Member
- Posts: 24
- Thank you received: 2
Two axes in closed loop with a single chip and a PC. Amazing!
Please Log in or Create an account to join the conversation.
- cptX
- Offline
- Junior Member
- Posts: 24
- Thank you received: 2
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!
Please Log in or Create an account to join the conversation.
- Mike_Eitel
- Offline
- Platinum Member
- Posts: 1128
- Thank you received: 184
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.