Asked — Edited
Resolved Resolved by Rich!

Its All In The Script. Its A Control Thing You Know

I finally got a joystick (game controller). It works well linked up to the Sabertooth H bridge control to control the G=Bots two drive motors but -due to the weight and high cg of the G-Bot - I'm going to need much precise and variable control.

Can anyone point to a tutorial that may give suggestions (script, other controls, or a combination) that will allow me to achieve this?

Also, the axis of the joystick control is 90 degrees off what I want. Is there an easy what to change that?

What about custom assigning other buttons for other functions? I've gotten the soil sampler to deploy with a joystick button using Rich's E switch and I've experimented with using some other simple script to try and achieve control of the torso rotation control motor using joystick 2 (using a diverse electronincs H bridge) but, again, I need much better control (variable speed and direction ramping, etc). When I tried to add another H bridge control to control the torso rotation with joystick two, ARC won't allow more that ONE Movement Panel at a time? What's up with that? E Switch

Is there anything like a primer on how this all works? (specifically: what is scripting? Is it a language? , how does serial motor control work?, advantages of using PWM vs serial with available premade controls?)

I know I have much to learn to get the G-Bot where I want him by Halloween and I'm not even really sure where to start.

Any help ans suggestion much appreciated as usual.

Thanks


ARC Pro

Upgrade to ARC Pro

ARC Pro is your passport to a world of endless possibilities in robot programming, waiting for you to explore.

United Kingdom
#1  

Movement panels are for moving the robot around, like walking or driving. Not for moving motors.

I wrote a pretty in depth tutorial on the L298n H-Bridge which explains how they are controlled and how to use more than one H-Bridge on a robot. I'll find the link later if you can't but it's one of my topics and I have only started a handful of topics so it should be easy to find.

A joystick control will update variables for joystick position. You can use these in scripts and set PWM for ports based on the variables. This will give speed control based on analogue joysticks and also allow you to customise the directions of the joystick too.

I could show you an Example Project (and will if you really need it) but I like people to figure it out themselves after a gentle shove in the right direction so hopefully the above is that gentle shove.

PRO
Synthiam
#3  

Are you using the Sabertooth in HBridge mode with PWM inputs?

If so, the HBridge (PWM) control will allow you to have precise movements with the analog joystick

#4  

Rich, Thanks, I will be sure to read all your topics and tutorials in their entirety. Its probably just what I'm looking for.

D.J. I'm not even really sure what to ask here. I'm using the Sabertooth in simple serial mode because it was suggested to me and I really didn't know any better. Its connected to my EZB on D0 and I'm using the sabertooth control and the joystick control together in ARC to make it go. I didn't know an H bridge could be in anything OTHER than H bridge mode... Hmm... I connected it on the first digital port because serial is digital.

Is PWM analog (or 'simulated' analog)? If I wanted to experiment with the sabertooth in 'H bridge mode' would that be using PWM? Would I need to use more that one signal wire and would I need to change the dip switch settings (now 1,3 and 6 are up)? Would I need to connect it to the EZB on an analog port? Are there any advantages to using it this way? Can EZB control one H bridge digitally and another using analog? Would I want to (I guess one might have to depending on what hardware was available to them)? I saw in one tutorial something about simulating analog using digital pulses using scripting. Why would I want to do that vs using analog? Would mixing and ramping be easier using either method? I have looked at a few of the tutorials but I have precious few references in my head for all the new stuff I'm trying to absorb very quickly so please bear with me. I really appreciate all the help. The only reason I even tried to do this is that I had heard the support on this forum and platform was so awesome. :)

As I mentioned, I also want to use another H bridge to control torso rotation ideally with joystick 2 on the controller. I have a Diverse Electronics H bridge I purchased a few years ago that I want to use but I'm not sure if it needs digital or analog input. I can't find the documentation that came with it or online. I can't seem to find the company online either. They seem to have disappeared. I used that controller a couple years ago with my Futaba RC unit. At that time I had connected it to RC receiver on channels 1 and 2 and the joystick on the transmitter mixed them and drove the G-bot perfectly. I've included a picture of a board just like my DE H bridge EXCEPT mine has an additional, smaller board attached to it on the right side that has 4 places to connect wires to it. They are labeled ground, ch1, ch2 and power. Right now I have it connected to EZB port D1 using the signal wire from EZB to the ch1 connection with ground to ground and power applied to the power connection. I wasn't sure if I needed 1 wire from 1 port or 2 wires from 2 ports or if it will accept digital OR analog input. I did notice that - the way I have it connected now - when the DE controller is connected and robot power is applied the EZB will stay powered even if I pull its power connector. I'm assuming the EZB is getting power back fed through the DE board from the torso rotation motor power source connected at the other end. (I have power to that board in two places. Left and right since I wasn't sure if I needed.) Hasn't seemed to produce any magic blue smoke yet so... maybe I don't need power connected to the DE controller on the same sife as the ch1 and ch2 signal inputs? (Maybe?)

I was also able to assign one of the game controller buttons to operate an E switch using the keyboard control by using 'SET(D2, ON)' for the down button command and 'SET(D2, OFF)' for the up button command. The soil sampler unit is designed to cycle through one full deployment and simulate taking a soil sample. It has limit switches physically built into it that limit it to one cycle if power is applied to it momentarily (long enough for it to move off its first switch) so holding down the 's' key now applies power as long as its held down.

So here's what I'd like to achieve for now hopefully before Halloween:

Joystick 1 controls drive (via sabertooth) with ramping, reversing and smooth mixing. Push joystick 1 forward, robot gradually accelerates forward. Pull joystick 1 toward me robot slows down the gradually reverses with smooth mixing and differential steering (right now that joystick is 90 degrees off where I'd like)

Joystick 2 controls torso rotation. Stick left, torso rotates left. Stick right, torso right.

Left and right buttons on the front of the controller (no idea what number buttons these are in ARC) will control arm extension. (Next year's upgrade will be to add arm articulation and control)

Two more buttons to control claw open/close.

Eventually I'd like to be able to have him patrol back and forth, stop once in a while, turn and say something (Halt! Who goes there? Maybe) and also be able to interact remotely.

I haven't even gotten to the torso section yet. I'm sure I'll have lots of questions about using sounds and scripting when I get to it...

Thanks again in advance.

Gwen

OMG, my brain is toast... lol

User-inserted image

United Kingdom
#5  

Quote:

Is PWM analog (or 'simulated' analog)?

You could kind of look at it like that. PWM is pulse width modulation. Usually the device(s) connected to a PWM controlled port will act analogue like. A H-Bridge (specifically the L298n based H-Bridge but others too) will use a PWM on the enable ports (EnA and EnB - usually these come with a jumper connected to +5v from the factory) to vary the speed of the motor. The higher the PWM the faster the motor.

Wiring of a L298n H-Bridge uses 4, 5 or 6 digital ports on the EZ-B depending on the functions you want.

4 ports will require the enable pins (EnA and EnB) to be connected to a +5v supply. These are usually next to the EnA and EnB pins and connected via jumpers. I replaced the black jumpers for red in this photo so that they stand out (your H-Bridge may look slightly different).

User-inserted image

This will not give speed control.

5 ports is what is needed if you share a speed control between both channels (both motors). This involves making (or buying) a Y cable and connecting both the EnA and EnB pins to one digital port. This allows a PWM to vary the speed of both motors at the same time.

User-inserted image

User-inserted image

While my photos don't show it the two white wires from the H-Bridge join together forming a Y cable, the other end connects to one digital port.

6 ports is what you need for independent speed control of each motor. This allows 2 PWM controls (or the Movement Panel with PWM) to control the speed of each motor independently. EnA would connect to one digital port and EnB would connect to another digital port;

User-inserted image

User-inserted image

Your post was too long for me so I'll leave it at just tackling the H-Bridge and PWM for now (I need to get to bed, it's late over this side of the pond). Once you've had a chance to get your head around the above and the L298n H-Bridge Tutorial I'll go over how to use a joystick and multiple H-Bridges.

#6  

I'll take a stab at one or two of the other questions while Rich gets some sleep:)

Simplest one first.

Quote:

I didn't know an H bridge could be in anything OTHER than H bridge mode

Most can't, but the Sabertooth and Roboclaw both have multiple modes, and the Parallax HB25 acts like a big modified servo.

Sabertooth and Roboclaw have an R/C mode that also is supposed to look like a big modified servo, but so far no one here has gotten it to work well that way (of course, we were all trying with a V3, might work in a V4).

Rich's instructions were for the L298N that is sold here and is fairly common for an H-Bridge, but requires more connections than a Sabertooth in Serial mode, which only requires one digital port for serial commands. I don't know how to wire it for PWM how many additional ports it needs. I'll know in a couple of months when I start working with mine, but that will be too late for you. However, someone else may chime in here with more details.

Alan

United Kingdom
#7  

Before I sleep... The sabertooth speed control is based on the serial data sent to it. I don't have the actual numbers in front of me but I am pretty sure that if you send 1 it is fastest in reverse, 127 is slowest in reverse, 128 is stop, 129 is slowest forward and 255 is fastest forward.

There is a post somewhere with a simple (and crude) script I wrote to vary the speed of a sabertooth with a joystick using a variable and EZ-Script. The forum search should find it.

#8  

I appreciate all the help everyone. Keep the suggestions coming...

I have much to assimilate...:)

On a lighter note, I got a chance to load test the G-Bot this afternoon.. Halloween is going to be fun!

G-Bot Load Test

#9  

Thanks for the help again guys...

#10  

Gwen, love the load test! Makes me wish I was a toddler again and had you around with your leg section. Maybe in a few years down the road when I have trouble getting around I'll turn my leg section into a really cool old guys cart. cool