AXE024 servo board for Model Tank turret rotation - help please

jensmith25

Senior Member
Hi all,

I have a customer who would like to convert a Warhammer tank so that the turret can turn from side to side. (This is the tank in question: http://www.forgeworld.co.uk/The_Horus_Heresy/Legiones_Astartes/Legion_Vehicles/LEGION_SICARAN_BATTLE_TANK.html)

I have used the Picaxe boards to control LED lighting effects but I've not yet used a servo so this is a new area for me. I've done some research on servos and found a post on here with a decent tutorial but I have a few questions.

the tank itself doesn't have a huge amount of space inside so my biggest concerns are battery size and servo size. The interior width is about the length of an AAA battery.

The Warhammer tanks are a plastic/resin cast shell so the turret won't be very heavy.

questions:

1) If you use the AXE024 PICAXE-08 Servo Driver do you need a separate battery for the servo? The instructions tell you about the battery for the board but nothing is mentioned about the servo. I don't think there will be room for two lots of batteries.

2) On searching the net there are many servos available. Which of the 3 Picaxe sell be most suitable? I am assuming these are all compatible with the AXE024 They have a tiny 9g servo up to a Futaba S3003. http://www.picaxestore.com/index.php/en_gb/electronic-components/servos.html

3) Does the servo have to directly attach to the turret?

Thanks for any help / advice on this.
 

AllyCat

Senior Member
Hi,

Firstly, I must say that I am not a model-maker so this reply is only from an electronics/hardware design perspective.

1) No, you do not need a separate battery, but the battery should be chosen for the servo's requirments. You can then add-on the PICaxe using additional supply filtering or regulation, if required.

2) A servo might be a suitable solution (and any should be compatible with PICaxe commands), but IMHO you should also consider a geared stepper motor. A stepper requires more PICaxe pins (2 - 4) and more code, but I can look for a suitable link (ebay from China, at a ridiculously low price) if you wish. A stepper may give a more natural (slow) effect; bear in mind that a servo (driven from the PICaxe Basic servo command) can only resolve about 100 directions (i.e. each step is more than a degree of shaft rotation) so might look a little "jerky".

3) No, it's up to you to work out any suitable "mechanical linkage", how many degrees of rotation in total are required? But see 2); IMHO one degree of rotation is clearly visible to the human eye with any moderately-sized "arm" (read gun turret).

Cheers, Alan.
 

jensmith25

Senior Member
2) A servo might be a suitable solution (and any should be compatible with PICaxe commands), but IMHO you should also consider a geared stepper motor. A stepper requires more PICaxe pins (2 - 4) and more code, but I can look for a suitable link (ebay from China, at a ridiculously low price) if you wish. A stepper may give a more natural (slow) effect; bear in mind that a servo (driven from the PICaxe Basic servo command) can only resolve about 100 directions (i.e. each step is more than a degree of shaft rotation) so might look a little "jerky".
Hi Alan,

Thank very much for your reply. The chap is looking for up to 90 degrees rotation from left to right and back.

I've had a quick look around about stepper motors and there's no clear option direct from Picaxe for a board / motor combination like there is for the servo. What picaxe board would I need for a stepper motor? The stepper motor they do have is 12v which seems high for both the picaxe chips and being powered by battery. I'd prefer something much lower voltage.

EDIT: Reading manual 3 from Picaxe with the interfacing circuits it looks as though you can use the Darlington driver, I'm assuming with a picaxe chip. I have the 14m2 project board that has the darlington driver so would this do the job? How do you supply the 12v for the motor though without damaging the IC chip?

EDIT: - The only problem with China is the shipping time. I might need it a bit quicker than that.

Thanks very much, Jennifer,
 
Last edited:

Buzby

Senior Member
I agree with Alan, a stepper motor will give a better result.

However, I do hope you try all options before hacking into that Sicarian battle Tank - they're £72 each !.
 

Buzby

Senior Member
A further thought, how is the rotation going to be controlled ?.

Radio, IR, hardwired, or what ?
 

jensmith25

Senior Member
A further thought, how is the rotation going to be controlled ?.

Radio, IR, hardwired, or what ?
I might be completely wrong here but I assumed I could run a programme for a set number of movements and it could be switched on & off with an on/off switch on the model?
 

Buzby

Senior Member
IR remote control is really easy. Just wire up the IR sensor to the PICAXE, then use the 'irin' command to receive a number as each button on the remote is pressed.
 

The bear

Senior Member
@jensmith25,
Why not use a small DC motor? Give a few seconds to turn one way, same treatment for the other way.
An old CD player will have two small motors, you only require one.
Good luck.
Regards, Bear..
 

AllyCat

Senior Member
Hi Jennifer,

Sorry for the late reply, there's been a major broadband outage. :(

This is the exact stepper that I've bought and used (it's been discussed on this forum a few times) but you're correct that it will probably take a month to arrive from China. However, if you put "28BYJ-48" into ebay.co.uk and select "UK only" there are various UK sellers (with or without the driver board) from about £4. We can probably give you exact dimensions, etc. if you need them (note the offset shaft due, to the internal gearbox). There are many other sources and types of stepper motor but most will need gearing (e.g. using a "leadscrew") as their output shafts have relatively few (stable) angular positions for each revolution.

However, I'm not 100% certain that it's "best" for your application (even if it fits). The gearing is very high so you might find the turret movement is too slow. It requires 4 PICaxe pins (maybe 3 with a little modification) and suitable (but well documented) software to drive them. There are no "endstops" to the movement as such, you must count the steps that you send to the motor (in the appropriate direction) and then it can be returned to the original position.

In more critical applications, an "endstop" (or reference position) microswitch (or photosensor or magnetic reed switch, etc.) can allow the software to "calibrate" its position after a power-down (if the "last" position was not backed-up in the PICaxe's EEPROM). But IMHO, still more suitable than a normal dc motor which is always likely to need a gearbox and position sensor(s), such as a potentiometer or limit switches.

In principle, a servo is very easy to control, but I think it may need to be geared (by a factor of about 2) to improve the available torque (which may still be rather low for the turret) and to improve the positional resolution. However, in practice, the servo will potentially move much too fast, so probably more sophisticated sofware will be needed to give a natural movement. Alternatively, using PULSOUT can give greater positional control, but again needs more software control (it becomes a "foreground" rather than a "background" software task).

It really all depends on the degree of "reality" that is required and the amount of hardware and software complexity that is acceptable.

Cheers, Alan.

EDIT: Yes, the 14M2 project board with Darlington driver chip should be fine, Perhaps use 3 x AA (Alkaline) or 4 x AA{A} (NiMH) cells, but that stepper is so high geared I've had plenty of torque with only two cells.
 
Last edited:

jensmith25

Senior Member
This is the interior of the kit, photos supplied by the customer. I don't have the kit.

DSC_0339_sm.jpg DSC_0347_sm.jpg

The stepper motor looks fairly small. It's dimensions are listed as 28mm dia which should be ok. How high is it?

Got to fit batteries, board and motor into the space. I think the 14m2 board (Axe117) is only just going to fit length wise. I assume you couldn't use the smaller servo board with a stepper motor?

I presume the board provided with the linked stepper motor isn't necessary if using the Picaxe?

I am completely new to this as I've never used stepper motors before or written the code to control one. I've only done very basic commands to light an LED in sequence for traffic lights.

How slow is slow? I'm guessing it doesn't have to be 'fast' as such, or incredibly realistic but a smooth turn would be necessary I think. I would think a return to centre would be required on power down so the tank can be stored.

Given my experience I would want it to be as simple as possible.
 

eclectic

Moderator
I'm playing with one of these stepper kits at the moment,
for one of my own projects.

Might I suggest that you buy one of the British-sourced kits,
for about £4 and have a play?

Even if you don't use it for this project, it will be a useful
learning experience.
e
 

AllyCat

Senior Member
Hi Jen,

A few quick answers before I go out to cut down a tree (or at least part of it). :)

Height of the stepper motor is about 20 mm with the shaft protruding another 10 mm.

I think it's about 4,000 steps (pulses) for a full revolution. With a PICaxe you might get 100 pulses/sec, but raising the clock frequency might get higher.

No, the interface board is not required if the PICaxe board has the (Darlington) driver chip. Actually only 4 small transistors are needed (with a few resistors) and even might be better because they drop less volts than a Darlington.

To be honest, the servo is probably an easier programming task, but I have concerns about getting sufficient torque from a small servo. If you (he) actually want + and - 90 degrees (from centre) then it really can't be geared at all. A servo will require a 4.5 - 6 volt supply; I think you might get away with 2 or 3 (even AAA) cells for the stepper.

You might get more useful information (torque, size, etc.) about servos from the HobbyKing website (note they have a UK warehouse) : http://www.hobbyking.com/hobbyking/store/index.asp. And I agree with e.

Cheers, Alan.
 

jensmith25

Senior Member
Thanks Alan and e. I have bought a couple of the stepper motors and will give it a try with my existing 14m2 board. If I can power one with 2-3 AAA cells then that will fit ok. AA's will be too big according to my customer. They're nice and cheap for just the motor.

I've had a quick search on the forum and see the motors used with a couple of little robots so don't seem too bad speed wise so just have to try it and see.
 

Hemi345

Senior Member
Hi Jen,

A few quick answers before I go out to cut down a tree (or at least part of it). :)

Height of the stepper motor is about 20 mm with the shaft protruding another 10 mm.

I think it's about 4,000 steps (pulses) for a full revolution. With a PICaxe you might get 100 pulses/sec, but raising the clock frequency might get higher.

No, the interface board is not required if the PICaxe board has the (Darlington) driver chip. Actually only 4 small transistors are needed (with a few resistors) and even might be better because they drop less volts than a Darlington.

To be honest, the servo is probably an easier programming task, but I have concerns about getting sufficient torque from a small servo. If you (he) actually want + and - 90 degrees (from centre) then it really can't be geared at all. A servo will require a 4.5 - 6 volt supply; I think you might get away with 2 or 3 (even AAA) cells for the stepper.

You might get more useful information (torque, size, etc.) about servos from the HobbyKing website (note they have a UK warehouse) : http://www.hobbyking.com/hobbyking/store/index.asp. And I agree with e.

Cheers, Alan.
Hi Alan, could you tell me what the shaft diameter of that stepper is? Thanks.
 

erco

Senior Member
Jen: IMO you had it right to begin with, asking about a servo. A 9-gram servo is smaller, more efficient, more powerful, and easier to control than that Ebay stepper. The Hobby King HXT900 is among the best and an incredible value at $2.69.

I have used those Ebay steppers: http://www.picaxeforum.co.uk/showthread.php?26090-Stepper-Motor-Demo They have tiny plastic gears that strip, and even when new have significant backlash. I would not recommend them for anything except learning about steppers. Your customer will be much happier with a servo.

Not to mention that size is important in this application. In addition to a the Picaxe controller, a ULN2x03 or other hardware is required for the stepper motor. The Picaxe servo controller or even a bare Picaxe can drive a servo directly, no extra driver hardware required. A tiny 08M2 can drive a servo and read an IR sensor and have several extra I/O pins left over for other functions, like LED firing lights. That same 08M2 is barely up to the task of driving a stepper motor, which takes all 4 output pins.
 
Last edited:

jensmith25

Senior Member
Hi Erco - I saw that video in my search earlier. It sounded like you were happy with them there. Did they fail later on?

If I were to go down the servo route and add an IR sensor, what bits do I need to add to the servo driver board to get the IR to work?

I am actually interested in the IR function for other projects in terms of remote control lighting that I've been asked about.
 

JimPerry

Senior Member
I disagree with comments about stepper reliability - I have had one on my desk stepping clockwise/anticlockwise at a variable speed for 18 months - as an ornament - I have several and can post you one if you PM your address :cool:
 

jensmith25

Senior Member
I disagree with comments about stepper reliability - I have had one on my desk stepping clockwise/anticlockwise at a variable speed for 18 months - as an ornament - I have several and can post you one if you PM your address :cool:
Hi Jim, Is it the 5V 28BYJ-48 one?
It's very kind of you but I already ordered 2 earlier today if it's the same one.
 

AllyCat

Senior Member
Hi Hemi,

Hi Alan, could you tell me what the shaft diameter of that stepper is? Thanks.
@ Hemi: The (brass) shaft is 4.9 mm in diameter and extends 9 mm from the body of the stepper. Two flats (6.25 mm long) are cut from the end the shaft, with the Across Flats dimension being 3.0 mm.

@ Jen: I think most of us have suggested that you should compare the two types of motor as they each have strengths and weaknesses (not just literally). Sadly the HXT900 appears to be on Backorder from the UK warehouse. When testing, I suggest you attach a "pointer" at least as long as the "gun barrel" to check the stability, resolution and "holding torque", etc. of the system. Note that a Servo normally drains some power all the time it is connected to the battery; a stepper only loads the battery when driven (by a pulse) from the PICaxe. But nearly all these "issues" have solutions, we're (hopefully) just trying to help you know what factors you (may) need to consider.

Cheers, Alan.
 

CLUELESS1

Senior Member
I have been using thease steppers for a long time for pcb board camera pan & tilt. I was going to put microswitch limiting on their rotational travel. however I just use mechanical endstops. I have momentary pushbuttons to control the motors, and works just fine. I use the pcb's that come with the motors and just put the picaxe outputs into the pcb's. The only problems were finding something to put on the shaft to mechanically connect with, ended up drilling out meccano bits, Ended up spending more money than the motor to connect.
 

Hemi345

Senior Member
Hi Hemi,
@ Hemi: The (brass) shaft is 4.9 mm in diameter and extends 9 mm from the body of the stepper. Two flats (6.25 mm long) are cut from the end the shaft, with the Across Flats dimension being 3.0 mm.
Thank you Alan.

Ended up spending more money than the motor to connect.
That's what I'm finding with my current project. The couplings are almost (or are) more than the motor itself. I just ordered one of these to adapt the 5V 28BYJ-48 stepper to a 1/4" shaft.

Was trying to adapt a standard size servo, and the cheapest couplings I could find for that were $5/ea and $6 shipping with no ebay source. :eek:
 

jensmith25

Senior Member
@ Jen: I think most of us have suggested that you should compare the two types of motor as they each have strengths and weaknesses (not just literally). Sadly the HXT900 appears to be on Backorder from the UK warehouse. When testing, I suggest you attach a "pointer" at least as long as the "gun barrel" to check the stability, resolution and "holding torque", etc. of the system. Note that a Servo normally drains some power all the time it is connected to the battery; a stepper only loads the battery when driven (by a pulse) from the PICaxe. But nearly all these "issues" have solutions, we're (hopefully) just trying to help you know what factors you (may) need to consider.

Cheers, Alan.
Thanks Alan and Clueless1,

Ok, well I will try both and see how it goes. I found the HXT900 on Ebay with stated genuine parts and 100% feedback so went with that. To some extent it will depend on size and what will fit in the space with the batteries.
 

CLUELESS1

Senior Member
Thanks Hemi345, I ended up drilling out these Meccano cranks.

http://www.meccanoandcomp.com/userimages/procart11.htm

Being of brass they drill easily. Only problem is they deserve a drill stand, and care not to loosen the brass part from the plate.

Another part was costing £6 which I dropped using

Picture below shows a board camera (black box, lense cover fitted) which is mechanically driven by a smaller stepper (tilt mode) which then will connect to the stepper we are talking about for panning mode. This camera is being fitted in a half lantern was light (in top section) with a dummy bulb below so it looks like a wall light. In the picture you can see the round aluminium shaft connectors which were £6 pair. As the item holes are either 3,4,5 mm they needed drilling to correct shaft fit.

That's my two pence worth.

STEPPER.jpg
 

CLUELESS1

Senior Member
Many thanks for the offer Bear, fortunately my last camera on the house was my half lantern wall light giving 180 degree viewing, Picaxe at the helm. Thanks Steve thats useful for all. Regards
 

jensmith25

Senior Member
I have got the servo and AXE024 servo board up and running and have programmed it to do a simple swipe from side to side. It seems to be working pretty nicely but I need to slow down the movement as it's quite fast and not very tank turret like.

How do I control the speed of the servo? I did see some code but didn't understand it - looked like you need a servo-delay but wasn't sure how this worked in order for me to control it.

This is the code so far:

servo 1, 150 ; start servo on pin one and move to center

main:
pause 1000 ; wait a second
servopos 1, 200 ; move servo clockwise
pause 1000 ; wait a second
servopos 1, 150 ; move servo to center
pause 1000 ; wait a second
servopos 1, 100 ; move servo counter-clockwise
pause 1000 ; wait a second
servopos 1, 150 ; move servo to center

goto main ; return to main program loop

Sorry, I don't know how to put the code in one of the scroll boxes.

Any tips appreciated.
 

hippy

Technical Support
Staff member
As soon as you issue a SERVOPOS command the servo will jump to that position as fast as it can, so simply move smaller distances. For example to more slowly move from 200 to 150 ...

Code:
For b0 = 200 To 150 Step -1
  ServoPos 1, b0
  Pause 10
Next
 

jensmith25

Senior Member
Thanks very much hippy.

So I can understand what I'm doing, why is it b0 and not b1 for example? What does the number relate to?

I assume therefore that to go from 150 to 200 it would then be Step +1?

I've got it going slow to step 200 but then it jumps back to 150 rather than going slowly back.

Code:
main:	servo 1, 120	; Set the servo to its starting position 
pause 2000			; Stay at the start position for a while 
for b0 = 120 to 200	; Move the servo from position 120 to 200 
servopos 1, b0	; Set the new position 
pause 10	; Wait a while 
next b0	; Continue until at position desired 

pause 2000		;pause for 2 seconds
for b0 = 200 to 120 	
	servoPos 1, b0
	pause 10
next b0
goto main	; Repeat from start position
 
Last edited:

AllyCat

Senior Member
Hi Jen,

b0 is just a "default" variable name, you can use any from b0 to b27, or w0 to w13 (words) for larger numbers (greater than 255).

It's common (but not essential) to declare "meaningful" variable names such as symbol TURRETPOSITION = b0 and then for TURRETPOSITION = 120 to 200 etc..

step 1 is the default (implied) value, so the code line: for b0 = 120 to 200 is actually interpreted as for b0 = 120 to 200 step 1 . So for b0 = 200 to 120 is not really a "sensible" command. It only executes once (with b0 = 200) , then steps b0 up to 201 (because the default is step +1) and then terminates at the next (because 201 is greater than 120). Your "jump back" is because the code then goes to main: and sets the servo to 120 again.

Try this code in the simulator and then change a few of the numbers:
Code:
for b1 = 5 to 10
	sertxd(#b1," ")
next b1
	sertxd(cr,lf)
for b1 = 5 to 10 step 1
	sertxd(#b1," ")
next b1
	sertxd(cr,lf)
for b1 = 10 to 5
	sertxd(#b1," ")
next b1
	sertxd(cr,lf)	
for b1 = 10 to 5 step -1
	sertxd(#b1," ")
next b1
Cheers, Alan.
 

jensmith25

Senior Member
Thanks very much Alan. I'll have another go and see how I get on.

I can't see the simulator in the MacAXEpad software. Can you do it in that or do I need the Windows programming editor?
 

AllyCat

Senior Member
Hi Jen,

Yes I think you need the Windows Editor (PE5 or PE6) to run a simulation. However, you should be able to run the same test code on a "real" PICaxe using the Terminal Emulator (PICAXE : Terminal ; or f8), but I only know the Windows version of Axepad, not if the Mac version is different.

A real chip will run much faster than the simulator, so you might want to put a Pause (e.g. 100) with each sertxd... command, although it won't affect the final appearance of the characters on the screen.

Cheers, Alan.
 

jensmith25

Senior Member
Try this code in the simulator and then change a few of the numbers:
Code:
for b1 = 5 to 10
	sertxd(#b1," ")
next b1
	sertxd(cr,lf)
for b1 = 5 to 10 step 1
	sertxd(#b1," ")
next b1
	sertxd(cr,lf)
for b1 = 10 to 5
	sertxd(#b1," ")
next b1
	sertxd(cr,lf)	
for b1 = 10 to 5 step -1
	sertxd(#b1," ")
next b1
Cheers, Alan.
Hi Alan,

I've installed the software on my windows 7 laptop and run the code and it counts up from 5 to 10 or whatever numbers you enter and then counts down again.

I eventually figured out what you meant - to add a step -1 to the reverse motion and it now works although it is having the occasional stutter after a few minutes.

What does 'sertxd' do? Sorry, my knowledge of this stuff is basic.
 
Last edited:
Top