LinuxCNC-RIO - RealtimeIO for LinuxCNC based on FPGA (ICE40 / ECP5)

More
13 Aug 2026 07:12 - 19 Aug 2026 07:46 #348687 by viewsat

DIR/PULSE issue resolved, thank you!! (2026-08-19)

Last edit: 19 Aug 2026 07:46 by viewsat.

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

More
13 Aug 2026 07:26 - 13 Aug 2026 07:28 #348688 by meister

All my positive terminals are connected to the purple cable via a thin wire.

Dirhold isn’t the problem; it really is the voltage that’s coming through – there was a clear difference between 3.3V and 5V.

My connections are like in your image, but with EN connected.

You could use a multimeter to check what voltage is coming through your DIR pin.
 
I suspect that when the DIR signal starts acting, it might not follow the set dirhold wait time, outputting PULSE before the process is complete. When encountering a motor driver with a slow dirhold response, this results in an invalid PULSE output. It's strange that increasing the dirhold value doesn't solve the problem; this is a problem I don't understand.
 



You can check that Dirhold is working using Testbench and by monitoring it on an oscilloscope or logic analyser.
It worked for me with the default settings, but it’s certainly better to set it to the manufacturer’s specifications to be on the safe side.


(cd riocore/plugins/stepdir/ ; make)



In my tests, the problem only occurred at 3.3V;
if you Google ‘DM542 problem’, you’ll find lots of reports of the same issue.[/quote]
Attachments:
Last edit: 13 Aug 2026 07:28 by meister.
The following user(s) said Thank You: viewsat

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

More
13 Aug 2026 08:28 - 19 Aug 2026 07:47 #348690 by viewsat

All my positive terminals are connected to the purple cable via a thin wire.

Dirhold isn’t the problem; it really is the voltage that’s coming through – there was a clear difference between 3.3V and 5V.

My connections are like in your image, but with EN connected.

You could use a multimeter to check what voltage is coming through your DIR pin.
 
I suspect that when the DIR signal starts acting, it might not follow the set dirhold wait time, outputting PULSE before the process is complete. When encountering a motor driver with a slow dirhold response, this results in an invalid PULSE output. It's strange that increasing the dirhold value doesn't solve the problem; this is a problem I don't understand.
 




You can check that Dirhold is working using Testbench and by monitoring it on an oscilloscope or logic analyser.
It worked for me with the default settings, but it’s certainly better to set it to the manufacturer’s specifications to be on the safe side.


(cd riocore/plugins/stepdir/ ; make)



In my tests, the problem only occurred at 3.3V;
if you Google ‘DM542 problem’, you’ll find lots of reports of the same issue.


I apologize for asking so many questions. I always use 5V to power the 74HC245 and the driver. If there's a problem, usually adjusting the DirHold time is all that's needed. When I use a Mesa 7i92 + 74HC245 (5V) + DM542 (pulse=10, DirHold=25), everything works perfectly, and it correctly returns to the zero position. However, when I switch to a Tang Nano 9k+ + Riocore + 74HC245 (5V) + DM542 (pulse=10, DirHold=25), it fails to return to the zero position, and adjusting the DirHold time doesn't help.

 

DIR/PULSE issue resolved, thank you!! (2026-08-19)
Last edit: 19 Aug 2026 07:47 by viewsat.

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

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
13 Aug 2026 13:19 #348699 by tommylight

If I replace the DIR PC817 optocoupler with a high-speed 6N137, it can correctly return to the zero position. 

This is wrong way.
By modifying the driver, you risk damaging it and reducing its reliability.
Although the PC817 has a very low bandwidth, the correct solution is to increase the dirhold.

Tux, you have a nasty way of replying, and you have been warned once about it.
It is their choice if they want to modify something or not, that is what DIY is about and helps with learning.
You are right about PC817, but you are wrong about dirhold as it does not magically raise the level to 5V on 3.3V systems.
I understand you are trying to help, so thank you, but the way you do it sometimes comes as very offensive and demeaning.

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

More
13 Aug 2026 14:10 #348701 by meister
Sorry for my poor English – enjoy it; it’s the first and probably the last video in which I’ll try to speak English.

www.youtube.com/shorts/u9xUOXN080M

Well, yes, blue is a 3.3V level, as I measured it directly at the FPGA pin
The following user(s) said Thank You: viewsat

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

More
13 Aug 2026 16:39 #348705 by tuxcnc

I have never written anywhere that I forbid anyone to do anything.
I wrote that modifying Chinese electronics is a bad idea, which is true for several reasons.
Cheap PCBs do not tolerate re-soldering very well, the copper peels off from the substrate, even if something works well immediately after such an operation, there is no guarantee that it will work after a month or a year.
Is there any prohibition against writing about it?


PC817 is a strange chip that works in a strange way.
First of all, it is an analog circuit, not a digital one.
Secondly, the input is controlled by current, not voltage, and the output forces current, not voltage.
In addition, the frequency response strongly depends on the input current, a small current means a small propagation time, but also a small output current.
The chip can work really fast (several dozen kilohertz), but then it may not drive the next stage with a small current.
However, when driven by high current, it may have problems already at a few kHz.
There must always be some compromise, assuming that the designer knew what he was doing and did not assume that if the PC817 withstands 50 mA, 20 will be fine...
The following user(s) said Thank You: viewsat, tommylight

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

More
13 Aug 2026 18:25 #348708 by PCW
PC817 is a strange chip that works in a strange way.
First of all, it is an analog circuit, not a digital one.
Secondly, the input is controlled by current, not voltage, and the output forces current, not voltage.
In addition, the frequency response strongly depends on the input current, a small current means a small propagation time, but also a small output current.


Not really strange at all, almost all transistor/Darlington output optocouplers function this way
and this type optocoupler is by far the most common.

Logic optocouplers also typically have current inputs (since the input  of most optocouplers   is simply a bare LED)
but differ in having a voltage output.
 
The following user(s) said Thank You: viewsat, tommylight

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

More
14 Aug 2026 00:47 - 19 Aug 2026 07:47 #348714 by viewsat
DIR/PULSE issue resolved, thank you!! (2026-08-19)
I used this inexpensive DM542 only for testing RioCore, not for an actual CNC machine tool. The circuit modifications are for technical discussion only, please don't mind. I'm showing four sets of drivers in the photos, but only this inexpensive DM542 has a problem, hence this discussion. Strangely, increasing the dirhold value doesn't solve the problem; I really can't understand this. However, this inexpensive DM542, when used with the same settings on a MESA7I92, shows no positioning error. This inexpensive DM542 was taken from my existing engraving machine for testing.
 
Attachments:
Last edit: 19 Aug 2026 07:47 by viewsat.
The following user(s) said Thank You: meister

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

More
14 Aug 2026 02:01 - 19 Aug 2026 07:48 #348717 by viewsat
DIR/PULSE issue resolved, thank you!! (2026-08-19)
DIR use pc817 Error!


DIR modified 6N137 ok!!
Last edit: 19 Aug 2026 07:48 by viewsat.

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

More
14 Aug 2026 03:50 #348721 by tuxcnc

I'm showing four sets of drivers in the photos, but only this inexpensive DM542 has a problem

A long time ago, 3xTB6560 drivers were popular and I had them too.
There, PC817 supported not only dir inputs, but also step inputs. There were problems with this, but the chips were in sockets and it was easy to replace them with selected ones and it worked somehow.
So there are only two options:
1. Your driver is faulty.
2. This type of driver is poorly designed.
Either way, the cause is not to be found in riocore.

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

Time to create page: 0.449 seconds
Powered by Kunena Forum