Help with custom motor node for Elegoo Robot Car

I’m new to XOD. So far it looks fantastic.

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.

Any insight is appreciated.

Main - works

Elegoo Motor - seems to work

Base Motor - seems to work

Move Forward - does not work

hi, try this

image

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:

Since I’m sending a 0 to the speed inputs when the delay ends, it should stop, but does not.

use continuous-pausable instead of true-pulse, eliminate gate

image

cesars, I tried your first suggestion and could not figure out how to send a pulse via the if-else node.

Then I tried this suggestion (using continuous-pausable) and it is back to doing nothing at all. ;-( (But I do appreciate your help!)

I thought that the ideal would be continuous-pausable
here if-else

image

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.

I have tried continuous-pausable and it works well for me

I understood that in the last update it was already generic, what is its version? (I have it modified)

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.

SUCCESS!!

Thank you cesars & gweimer!!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.