I bought an Elegoo Robot car and successfully made it move forward, back, etc using the gweimer/h-bridge-2dir. I decided to make a custom patch that defaulted to the pinouts for the Elegoo so I could easily insert it into other projects without having to remember the pinouts. As I was doing so I noticed that the gweimer/h-bridge is based on deprecated components. So, I thought, “great learning experience. I can update it using the newer components suggested by the help information.” I did that and it works for a “simple connection.” But, when I try to use a delay node to start and stop it, it is not working. When I activate my Move Forward patch, it simply does nothing. I assume I am doing something stupid, but I’ve worked on this for the last day and can’t figure out what is wrong.
I suspect the problem is with my activation of the motor in the Move Forward patch (using a pulse on change node connected to the delay node).
Attached are screen shot images of my main patch (with the simple setup that does work), my Elegoo Motor patch, the “base motor” patch where I made the “upgrade” to the gweimer/h-bridge-2dir, and finally the Move Forward patch, which does not work.
Thanks cesars - partial success! Now the car does respond and move forward (it did nothing before), but it does not stop after the time has expired. Here is the new main patch and the new move forward patch with your suggested modification:
Unfortunately, cesars, that connection causes this error:
Transpiling…
Specialization patch not found Cannot find specialization if-else(pulse) for abstract xod/core/if-else. Try creating the missing patch in your project or install a library which provides such one.
I’m wondering if it might have something to do with my implementation of the “motor upgrade” where I initialize three nodes (pwm-write and 2 digital-writes) all at the same time. When I originally made that I put in a defer node because it seemed to me that the digital writes needed to occur before the pwm-write, but I could not get that version to work.
cesars, the fact that continuous-pausable works for you suggests that my earlier observation might be correct, namely that the problem is not with my forward patch, but it is with a synchronization issue in my motor patch.
continuous-pausable works for me with other components. It just does not solve the problem with my move forward patch.
I’m not sure what version you are asking for. My version of XOD is Version 0.29.1 (0.29.1.7630).
Sounds like motor node is getting pulse before if-else updates. Adding a defer miss between timer and motor should fix that. You also need another pulse to read the stop speed, so you need to also feed the delay-DONE to the motor SET pin. Use an any node to join the DONE and ACT pins, feed that to defer, then to motor SET.