
jp15sil24

I have modified my 3-wheel robot by replacing the two 360-degree servos with a motor equipped with a differential. This motor is controlled by a dual H-bridge using PWM signals. While I'm not entirely sure if this is the optimal setup, I'm still learning and experimenting with various possibilities. Currently, the single motor controls both rear wheels, allowing for synchronized forward and reverse movement, which is functioning well.
For steering, I have installed a servo at the front to control the wheel's left-right movement. However, I'm encountering an issue where the joystick correctly manages the forward and reverse motion but fails to control the steering. I would like to have a single control interface or "tool" that can manage both forward/reverse and left/right steering using the servo. If achieving this with a joystick is not feasible, could you suggest an alternative solution?
Hi, I'm not at home I'll try when I'm back thanks.
@DJ Sures . The custom Movement Panel v2 works fine. i copied the 3 scripts ,forward,reverse and stop . ( i just replaced Pwm by PWM as i got an error). i can move F/R and stop . If i understand the script correctly, the speed difference between Left/Right will provide a steering angle. But I just have one motor with a differential, i use only 3 ports: d2 for forward, port d3 for reverse and port d5 for pwm. Now i am using custom Movement Panel V2 with the 3 scripts Fwd/Rev and stop and i added 2 scripts for right and left which are used for my steering servo. both scripts have fix values ,40 for left and 140 for right. It works ok with a joystick even the steering is not very smooth because it goes either to 40 or to 140 .
You can’t use the left and right scripts. You can only use the forward and reverse as mentioned above.
@athena explain the scripts and how they can me fine tuned. And explain why the left and right can’t be used for this robot type
Certainly! Let's break down the setup and how you can fine-tune it for your AdventureBot with a differential motor and steering servo.
Understanding the Custom Movement Panel v2
The Custom Movement Panel v2 is designed to handle various movement commands, such as forward, reverse, left, and right. However, in your setup, you have a single motor with a differential for the rear wheels and a servo for steering. This means:
Why Left and Right Can't Be Used
In a typical differential drive setup, the left and right commands would adjust the speed of each wheel independently to achieve turning. However, since you have a single motor controlling both rear wheels, the left and right commands won't work as intended for steering.
Fine-Tuning the Scripts
To achieve smooth steering with your setup, you can focus on the forward and reverse scripts and adjust the steering servo based on the speed difference. Here's how you can fine-tune it:
Forward and Reverse Scripts:
Steering servo Control:
Utility.map()
function to map the speed difference to servo angles. For example, if the speed difference is positive, map it to a range that turns the servo to the right, and if negative, map it to the left.Example Code for Steering:
Alternative Solutions
If the joystick doesn't provide the desired control, consider using a different input method, such as:
By focusing on mapping the speed difference to servo angles, you can achieve smoother steering with your current setup. If you have any more questions or need further assistance, feel free to ask!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
There she explained well.
The code I posted you works perfectly but May only need slight modification for the steering range and speed of the utility.map() functions.
I tested the code and it works. Pushing the joystick directly forward has the robot move forward straight. Pushing forward to the left has the robot move forward to the left by steering the wheel toward left. And respectively to the right. Using the utility.map() means there’s a range of speed and turning range.
@athena @dj sures i will make these modifications, thanks again
Oh one more thing. You mentioned using a single digital port for direction - to have the right stop, I suspect you’ll need to rely on pwm. Set the pwm to zero in the stop script.
Great point! When using a single digital port for direction control, you can indeed rely on PWM to manage the motor's speed and stop it effectively. Here's how you can implement this in your setup:
Using PWM for Stopping
Stop Script:
Example Code for Stop Script:
Fine-Tuning:
By setting the PWM to zero in the stop script, you ensure that the motor stops smoothly and efficiently. If you have any more questions or need further assistance, feel free to ask!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.