Controlling AL5A Arm

Hi All,

We have a Tri-Track and AL5A Arm which both use the same Bot-Board II, and we’re trying to control it using Bluetooth. So far, the Bluetooth part of the code (using HSERIN to get commands) has been written and we can use this to drive the Tri-Track’s motors. Another member in my group has been working on using the same program to control the arm and unfortunately he can’t get it to work.

I’ll post some code below that should rotate the base servo to the right by approximately 10 degrees every time the command is received, however, we all that happens when the command is received is that the base servo jumps a bit to the right (presumably about 10 degrees, I’m not entirely sure as I’ve not actually seen it myself). We know that the arm works because he tested it with the PS2 controller. Could someone take a look at his code please? I shan’t post the Bluetooth stuff as that is definitely working.

Here is the sub-routine to turn the servo to the right:

[code]base_right
Base_Offset = (Base_Offset + base_angle*10) MAX 900 MIN -900

pulsout 2,(Base_Offset) 'turn base <base_angle> degrees right

GOTO main[/code]

Thanks,

Ern

[code]base_right
Base_Offset = ((Base_Offset + base_angle)*10) MAX 4000 MIN 2000

pulsout 2,(Base_Offset) 'turn base <base_angle> degrees right
pause 20

GOTO main[/code]

Thanks for that Jim, I’ll get him to test it soon.

Ern

Hi, I’m the person writing the code mentioned above. Just an update and some more questions.

The solution you suggested had no effect. I’ve done several tests and I’m getting some strange results. Basically when a character is received the base should turn (D for left, E for right) based on the code,

base_left
Base_Offset = (Base_Offset - 100) MIN 2000 MAX 4000
pulsout 2, (Base_Offset)'turn base <base_angle> degrees left
GOTO main

I updated the servo limits as you mentioned and (just for ease of testing) I have removed the base_angle variable and replaced it with a number. The problem i’m having is that, regardless of +/-, the base always turns to the left, and the angle of the turn seems completely unaffected by the value. I’m really not sure what it is i’m doing wrong and any help really would be appreciated.

I’ve just noticed you also added a pause, though i’m assuming that won’t change the problem i’m having.

As a side note, before I removed the base_angle variable I did test it the way you suggested and was having the exact same problems, I removed the variable to see if that would help.

Thanks, Daniel.

The pause is important. This entire thread is chock full of nothing… I want to see more of the code, images of your wiring, and a short video. I suspect code and power issues.

Power/wiring shouldn’t be an issue, controlling the arm using the PS2 controller is absolutely fine. The rest of the code controls the motors of the tri-track robot and again, is working without any issues. Once I get the base working properly I’ll expand it to also control the rest of the arm servos but for now I just want somewhere to start.

I’ll give it a try with the pause when I get home and update this thread on how it goes, with more code if necessary. Apologies for the vagueness, I’m right in the middle of a bunch of exams and haven’t got the time (or a camera) to take a video of the problem. As I said, when the character is put into the console the arm just twitches to the left, regardless of the value(s) being sent, thats the best description I can do for now.

Thanks, Daniel.

Ok, I have now tried the code with the PAUSE but to no avail. Still having the exact same problem as before.

I have attatched the full code for you to take a look at. Ignore everything below the base_left and base_right subs, I plan on updating those once I get this part working.

Cheers, Daniel.
testcode.bas (4.1 KB)

As I mentioned above, I have no camera to take the video/photos besides my phone, which I cannot use without a memory card (Which I lost and am yet to replace). I’ll see if I can borrow one tomorrow but I have about 30 minutes of free time between my exam and work so its more likely to be Friday before I can get anything uploaded.

In the mean time, could you please take a look at the code and see if you can offer any advice? I’m fairly certain the wiring is not an issue due to the fact that controlling it with the PS2 controller presented no problems at all and, besides code, nothing has been changed since I tested it with that.

Thanks, Daniel.

I’ve looked at the code. It will not work. When doing inline servo pulses (pulsout) you must repeat the pulses every 20mS. All of the sound commands are taking too long and the pulses are too far apart. You are using gosubs with goto main at the end instead of return. Also when waiting for serial data the processor is not doing anything, ie creating servo pulses… so essentially you are creating a single servo pulse every time you press a button. There are probably other issues as well.

Hint. Use hardware rather than software for either receiving data or creating the servo pulses.
HSERVO, HSERIN

Thanks for the reponse, I know a lot of it may seem obvious (It does to me now, anyway) but this is my first attempt at writing BASIC code and i’m mostly learning it as I go along.

I did look at using HSERVO, however I’m struggling to understand how it works. The only examples I can find are in the BRAT code and a lot of that I found pretty confusing. I was also under the impression that HSERVO only works for pins 14 and 15? Is there anywhere I can get more information on using this command? (Besides the manual, I tried there and it didn’t get me very far)

I’ve attatched the updated version, hopefully I’ve understood what you were saying and most of the issues have been resolved.

I need to get to bed now since I have an exam tomorrow, but i’ll be testing this code tomorrow night after work.
testcode.bas (3.91 KB)

A quick update. The code does seem to be working now, however there are a couple of issues

Firstly, I am unable to move the servos in increments and only have success when sending a series of commands at once to cause a longer movement. I think this is down to the joints on the arm being too loose though (as the servos cannot hold the weight alone), and am hoping to resolve it tomorrow when I get hold of some tools. Once that is done I should be able to make some changes to servo constraints and then the code will be in working order. (Almost).

Second, every command I send causes a each servo in the arm to twitch. Presumably this is because of the pulsout commands in the main loop, however the value being pulsed should not change unless certain characters are received so I’m unsure as to why it is causing this reaction. I’m thinking of seperating the arm commands into another loop so that the servos will not be active until the arm is needed, though I doubt this will resolve the twitching problem, only limit it to one mode of operation.

If you have any suggestions for resolving this i’d appreciate it greatly,

Thanks, Daniel.

The code is still not right. Do all of the servo pulses in one place, and the pause 20 can be changed to a lower value if needed. Putting them in one place will allow you to generate the pulses on every pass of the routine. You still have the issue of no pulses generated when no command is received…

I’m assuming you are using the same code as you posted on the 13th.

Oh, I do actually have them all in that single loop, not sure why I uploaded it before moving them all. Yes, effectively the same code except I’ve modified the rest of the subroutines to simply update variables and moved all pulsout commands into the main loop. I’ve been quite busy recently and until I can tighten the joints I can’t configure the servo limits properly, and the positioning is constantly off since the variable will increase whilst the servo is unable to actually move.

I’m not really sure what to do about this, is there a command to execute when no character is received?

Cheers

You’re going to need to post your updated code. We can’t give incredibly specific advice if we don’t know exactly what you’ve changed.

Here’s the updated code. The MAX/MIN values don’t mean a lot right now, I’ll work them out once I get the arm tightened up.
testcode.bas (3.66 KB)