(Driver controller) to drive the 2 motor using XOD

Dear Friends

I’m working on robot project platform that derived by 2 Stepper motors (2WD ROBOT)
The idea of the project is a robot to help children with Autism and help them interact with others
I’m starting with (driver controller) to drive the 2 motor using XOD
In the project Attached …I can control the motor speed direction and position using 2 rotary encoders
ROVER STEERING2.xodball (20.6 KB)

Using (AccelStepper) node
Hardware Arduino mega /DUE
ivanmason/accelstepper@0.1.2
Please I need help to control the 2 motors with:

1-Serial communication to control it (from other controller )
2-PWM RC-signals to control it (from PWM-RC RECEIVER)

Thanks a lot for help

@wayland
@nkrkv
@ivanmason
@gweimer
@evgenykochetkov
@system

please help

I don’t have any experience with stepper motors or Serial communication between boards. I would guess that RC PWM output in XOD would be a number between 0 & 1, with 0.5 being center/stop output. For steering, you would probably map that to a stepper count that translates to left/center/right steering. For drive motor, I’m not sure you would care about count for RC control. You would probably just modify update speed of the stepper motor based on RC output (0.5 = no stepping; 0 = max stepping in one direction; 1 = max stepping in the other direction).

can you please monition the pwm node ?
@gweimer

If you are trying to read PWM from an RC receiver, you MIGHT be able to use analog-read, but more likely you will have to measure the pulse length. The easiest way to do that is with pulse-in function, which has been implemented in robertspark/components — XOD as a pulse-in node for XOD. Unfortunately, I don’t have any experience with this either (or an RC receiver to test with). I’m sure you could do a web search for “arduino rc receiver” or similar to find examples of what actually needs to be done.

thanks a lot i will try to use this nod and give you feed back

cheers

@kmw
@xodballxod
please help if you can

check out my post on serial accumulation and talk-back.

once you get the communication happening, you gotta parse the strings… I’ve been fighting strings forever, and they’ve been dogging me down. The issue is that C++ isn’t like other language like VBA, for example. A lot of the C++ functionality requires KEEN understanding of pointers, addresses, memory, size of value… I’m getting it slowly, but it’s a long road.

In any case, you may be able to get examples from the actual arduino .ino examples for talking between boards, too. I’ve seen tons, and they are already in the correct syntax.

Now, the idea is that you want to parse a command from the string. The easiest is to actually just have each character be a command, and maybe have a number value after the command that has an intensity. Like, F105 for “Forward 105 steps”…

Really, as soon as you get the UART between the boards, you’ll almost be there.

here’s an example in XOD for what you want

Dear xoders
I’m able to read the PWM and map the out put number
The challenge :
I need to convert the out put number to pulses that can achieve cw-ccw (same as the encoder )

Thanks a lot for all the help and guidance


@kmw
@xodballxod
@gweimer
@wayland
@nkrkv
@ivanmason
@gweimer
@evgenykochetkov
@system

Check out this library that has the node you need… I assume it works.
https://xod.io/libs/danielterletzkiy/compact-utils/

There may be others in other libraries… Look at all the encoders you can find, if this one doesn’t work. Or use this to figure out how to build your own.
I think it works, though… I just can’t wire an encoder in 10 seconds to test it.

thanks alot @xodballxod

i already control the servo with encoder
i need to control it by pwm using AccelStepper nods
here is my progress


for now

please check my attached image

I’m not sure what you are asking for?

Maybe you want FADE?

I think what is being asked for is a way to convert the PWM output number into a timed pulse generator. The further the PWN output number is from “center”, the faster the pulse generator should run.

One option would be one of the *-wave nodes. Since you are only interested in pulses, the square-wave node probably makes the most sense. You will want to change T value to match the time between pulses. You can use a ‘map’ node to convert the PWM output to an appropriate T value, but it might take some extra math since you want faster pulses for either direction from “center”. The DUTY input won’t matter since you only care about when output changes to true (not how long it is true). You might run into problems using this solution if it is not able to pulse fast enough for you…

BTW: kind of rude to keep tagging people in your posts just because you want a bunch of people looking at your post. Most of us are probably looking at all new posts as we have time and we will see your question without you tagging us.

I apologize…i didn’t mean to be rude…sorry

Now I remember… Thanks! With stepper motors, usually you use a stepper motor driver, and the flashing true/false drives the step… I thought he was using servos, for some reason.
Your suggestion is really smart!!


analog-map-to-pulse-speed.xodball (6.8 KB)

Thank you very much for your support. I wish you all the best

I apologize…i didn’t mean to be rude…sorry

With the four wheels rotating as much as 80 times per second, that’s 2 * 4 * 80 = 640 interrupts per second. If we add two or three RC Channels we quickly approach 8000 interrupts per second.

It might sound like a lot to process, 11000 interrupts in a second…The problem is that there will be times when all of our interrupts will occur at the same time. The Arduino is only able to process one interrupt at a time and so a queue will be formed. The interrupts within the queue are processed according to a fixed priority, not the time at which they occurred.
When I input the RC signal to the controller and convert it to the position of the motor, the Arduino automatically reduces the speed of the motor.
When i cancels the input Rc signal, the motor returns to its normal speed

You said you had a drive motor and a steering motor. Why do you need to process interrupts for all 4 wheels? Even if you want to track distance travelled, you can count stepper pulses rather than read a separate encoder on each wheel, and you will send same number of pulses to all drive wheel stepper motors (unless you are using tank steering and don’t have a steering motor).

You don’t need to process every pulse from RC channels. You just need to measure the length of a single pulse for each channel, then repeat often enough there isn’t a noticable lag after changing RC signal. Sampling each channel 1 or 2 times a second would probably be sufficient in most cases. If you use a servo for steering, you can plug it directly into RC receiver and not have to sample it.

A low end Arduino might still have trouble processing fast enough, but it sounds like you are putting extra load on it that is not needed.