Model Boat Mayhem - Forum

Please login or register.

Login with username, password and session length.
Pages: 1 [2]   Go Down

Author Topic: Turret Rotation  (Read 2826 times)

g6swj

  • Full Mayhemer
  • *****
  • Offline Offline
  • Posts: 318
  • Short Wave Jammer! -.-
  • Location: Northamptonshire, UK
Re: Turret Rotation
« Reply #25 on: January 19, 2017, 05:00:50 PM »

Clever piece of kit - unless using sail servos you still have the 180 degree limitation.

From what I can make out it (MatchBox Servo Matching/Power System) allows 4 servo's all on the same channel and for each of the 4 servos you can configure:
  • direction of rotation (reverse the RX signal)
  • set end points - limit rotation
Clever piece of kit but not what is being proposed for the Andy (dreadnought72) /C-3PO solutions
Regards
Jonathan
Logged

dreadnought72

  • Full Mayhemer
  • *****
  • Offline Offline
  • Posts: 1,661
  • Wood butcher with ten thumbs
  • Location: Airdrie, Scotland
Re: Turret Rotation
« Reply #26 on: January 22, 2017, 08:50:27 PM »

Horrible restyling of post by forum software. Sorry
Logged
Enjoying every minute spent building Racundra.

Bob K

  • Bob K
  • Full Mayhemer
  • *****
  • Offline Offline
  • Posts: 3,175
  • Location: Windsor
Re: Turret Rotation
« Reply #27 on: January 22, 2017, 09:00:44 PM »

    [/list]Clever piece of kit - unless using sail servos you still have the 180 degree limitation.

    270 degree servos are commonly available, other values too.  Its just the "standard" ones that only go 90 degrees
    Logged
    HMS Skirmisher (1905), HMS Amazon (1906), HMS K9 (1915), Type 212A (2002), HMS Polyphemus (1881), Descartes (1897), Iggle Piggle boat (CBBC), HMS Royal Marine (1943), HMS Agincourt (1912)

    dreadnought72

    • Full Mayhemer
    • *****
    • Offline Offline
    • Posts: 1,661
    • Wood butcher with ten thumbs
    • Location: Airdrie, Scotland
    Re: Turret Rotation
    « Reply #28 on: January 22, 2017, 10:00:34 PM »

    Martin, an hour of editing and tweaking later, I'm told that the 'edit' time for a post has expiredl My post is lost!!  {:-{


    I was trying to publish software, using the code key, and it's all gone. Is there a handy list of 'do not use' particular [] commands anywhere, 'cos I need to use 'em?


    Andy, deeply frustrated.
    Logged
    Enjoying every minute spent building Racundra.

    dreadnought72

    • Full Mayhemer
    • *****
    • Offline Offline
    • Posts: 1,661
    • Wood butcher with ten thumbs
    • Location: Airdrie, Scotland
    Re: Turret Rotation
    « Reply #29 on: January 22, 2017, 10:48:33 PM »

    Oooo! Maybe a save!  ;)  File saved from the depths of copy-&-paste!!!  O0


    A Dip Into Programming!


    My previous flowchart contained a box asking "is targetBearing within turret training range?". There should be an image of this simple question below.


    Hmmm. Well, that's an easy question for us, eyeballing a solution, but in programming terms it needs to be defined more completely. There's a flowchart below which details precisely how to answer this question, producing the results which are either "not in range" or "in range", for any turret. How cool is that? (Answer, not very: all questions and queries in a flowchart should result in 'answerable', logical questions.)


    Off to the basics. I'm measuring all angles from the bow, clockwise (if you want to think in degrees, that's fine - though the program will gulp up stepper counts instead, still measured from zero).


    What's (vaguely) interesting here is that the second flowchart doesn't care what units are being used, it's only interested in the relationship between numbers, where these numbers are measured from the bow, clockwise.


    The anticlockwise limit to a training arc is defined as a variable. I'm using (the cunningly named) turretMin[ x ] for this, where 'x' is the turret number (for programmers, you'll notice that the turretMin variable is actually an array: "what's an array, Andy?" Ok. Think of a horizontal row of pigeon holes, one box for each turret, where each one is numbered by another variable called 'x'). That means turretMin[ 2 ], for example, will be the leftmost position allowed by the turret numbered 2 in our initial declaration of these variables. (Incidentally, good programming practice dictates that turret 2 will be the third turret, since we can - and should - number arrays from 0 upwards.)


    Similarly, turretMax[ x ] is the clockwise limit. This is ('I see the square brackets!') another array. Finally, targetBearing is the singular angle, measured from the bow, of the target we wish to point at.


    So what's happening in the expanded flowchart?


    Turrets, any turrets, have two mathematical formats. Type one have a training arc which crosses the '0 degrees' boundary. That is, the left limit (turretMin) might be 220 degrees, while the right limit (turretMax) might be 140 degrees. This is the situation for turret A in the Dreadnought, and (maybe different limits, but same result) for turrets A & B in Warspite, for example.


    Type two turrets have training arcs which do not cross the '0 degrees' boundary. Think of turrets P, Q, X & Y in Dreadnought. X & Y in Warspite. P, Q and X in Invincible. Their training arcs are completely outwith the 0 degrees boundary...incidentally, we can include Dreadnought's P turret as a type two, if we set a turretMax of 360 degrees.


    The flowchart, in its first query, differentiates between these two formats.


    Type two is forced to the right, one is to the left.


    On the right side of this flowchart, we first ask "is targetBearing >= turretMin[ x ]?" and then asks "is targetBearing <= turretMax[ x ]?". If (and only if!) the answer to both these questions is 'yes', then the targetBearing lies within the training arc: it's "in range". Simple! It's a question of "Are you bigger than that AND less than that?"


    To the left, the answer's a little more devious. "is targetBearing >= turretMin[ x ]?" will scope any bearing angles "above" the minimum angle to 360 degrees, and then (should this fail) will ask a further question "well then, is targetBearing <= turretMax[ x ]?", to fill in the other options. Our question now is "Are you bigger than that OR less than that?"


    If (and only if!) the answer to either these last two questions is 'yes', then the targetBearing lies within the training arc: we once again get the result "in range".


    The good news - while it's easy to pick our slow wetware through a flowchart, step-by-step, it actually makes it more complicated than the program. Here's how we could write the above for an Arduino, which uses a (close!) dialect of the language known as C.


    targetOpportunity = FALSE;           // we set a targetOpportunity variable = FALSE
    if(turretMax[ x }>turretMin[ x ]){   // this is first query in flowchart
    if(targetBearing>=turretMin[ x ]{   // this is the right-side 'YES' route
      if(targetBearing<=turretMax[ x ]{  //
       targetOpportunity = TRUE;         // if 'YES' AND 'YES', therefore the target is in arc
      }
    }
    } else {                             // a 'NO' to first query in flowchart: we'll go down the left-side     
    if(targetBearing>=turretMin[ x ]{   //
      targetOpportunity = TRUE;          // Above minimum? Good!
    } else {           
      if(targetBearing<=turretMax[ x ]{
       targetOpportunity = TRUE;         // OR below maximum? Just as good.
      }
    }
    }


    The outcome is a TRUE of FALSE flag set for any turret.


    Incidentally, "//" marks the start of any comment, and is disregarded by the microprocessor.


    The above works really well, and extremely quickly.


    But we could even speed it up. (... Can you see how? (Advanced Question Paper! Not obligatory!))


    More soon!


    Andy

    Logged
    Enjoying every minute spent building Racundra.

    ballastanksian

    • Full Mayhemer
    • *****
    • Offline Offline
    • Posts: 4,371
    • Model Boat Mayhem inspires me!
    • Location: Crewkerne
    Re: Turret Rotation
    « Reply #30 on: January 22, 2017, 11:00:36 PM »

    I have not the first clue Andy but I will be interested to see the answer. The simplicity of what is written as code above belies the amount of work you and C3PO have done on this in your own zones.

    A couple of future projects are very suitable for this type of technology and the cost is not prohibitive either  :-))
    Logged
    Pond weed is your enemy

    Bob K

    • Bob K
    • Full Mayhemer
    • *****
    • Offline Offline
    • Posts: 3,175
    • Location: Windsor
    Re: Turret Rotation
    « Reply #31 on: January 23, 2017, 07:54:50 AM »

    Reducing a complex logic problem to a simple sequence of Boolean (yes/no) filters is producing a very elegant set of instructions.  Although I have not used "C" I appreciate how it works, avoiding spurious 'break outs' (IF/THEN/GOTO) which could confuse the logic under certain conditions.

    PS:  I always write my replies in MS Word, then copy / paste into the Reply box. That way if anything goes wrong I still have my saved copy to start again with.
    Logged
    HMS Skirmisher (1905), HMS Amazon (1906), HMS K9 (1915), Type 212A (2002), HMS Polyphemus (1881), Descartes (1897), Iggle Piggle boat (CBBC), HMS Royal Marine (1943), HMS Agincourt (1912)

    dreadnought72

    • Full Mayhemer
    • *****
    • Offline Offline
    • Posts: 1,661
    • Wood butcher with ten thumbs
    • Location: Airdrie, Scotland
    Re: Turret Rotation
    « Reply #32 on: January 26, 2017, 09:52:38 PM »

    Finished soldering today - six steppers now attached to thecompass, LCD, LEDs, and my input devices. The next few days? Getting it all to talk to each other.


    This IS going to work: personal status? Quietly confident.


    Testing and video demos to follow  :-))


    Software afterwards.


    Andy, still aiming for the end of January.
    Logged
    Enjoying every minute spent building Racundra.

    Capricorn

    • Shipmate
    • *
    • Offline Offline
    • Posts: 4
    • Model Boat Mayhem is Great!
    • Location: Minnetonka, Minnesota USA
    Re: Turret Rotation
    « Reply #33 on: September 13, 2017, 01:59:49 AM »

    Hi Andy, and all.  It's been quite a while since I've been on this forum.  I recall your project the dreadnaught, very interesting.  I thought you might be interested in my latest turret control, it's pretty basic, but I finally got it running.  Uses the same 5v geared steppers you are using.  An UNO and ULN2003/2803, and an LSM303 compass.  It certainly doesn't have ranging etc or the other fail safes you have.  Once I got the kinks out I was able to keep the steppers all synced.  Cap

    Here's video, hope the link works:
     
    https://www.youtube.com/watch?v=mgtidK7LFhA
    Logged

    Capricorn

    • Shipmate
    • *
    • Offline Offline
    • Posts: 4
    • Model Boat Mayhem is Great!
    • Location: Minnetonka, Minnesota USA
    Re: Turret Rotation
    « Reply #34 on: September 13, 2017, 04:54:08 AM »

    I thought I'd mention a couple more things, I looked through your thread some more and Bob K Agincourt, all very interesting.

    You might have a look at the Customstepper.h library, it has one feature that I think really allowed me to get it to work the way I wanted.  It's the stepper.isDone() boolean check.  If you put all your stepper movements in loops that first check that the steppers are done rotating (ie the arduino finished sending each step pulse it needed to complete the last command), the new movement won't begin, so your motors complete their movements before the new movement command.  They don't loose count of where they were, although that can be done other ways, I just found it to work quite well.  Also, I have read people having problems running several steppers with Customstepper.h but it works, some bug in their sketch.

    I also have the primary pointing device (director) run the turrets, the director turns the full 360 or multiples, it runs off degrees 0 deadahead gotten from subtracting the current compass heading from the initial.  The way it's set up, when activated, it trains on dead ahead (but that could be 90, 270, whatever, or could be input).  It can be activated by a single radio channel.

    The LSM303 compass module breakout works really well in my opinion, has the calibration example and the heading example with the library.  It's tilt compensated, ie has magnetometer and triple axis acclerometer, it gives stable heading with random variation of usually 1 deg, up to just under 3, not too bad.

    For development purposes you might try biting off a smaller amount at first, then adding the other features.  All my steppers are stuck down with sculpting wax, and the turrets are stuck to the motor shafts with the same.  Makes retrials after errors much faster.  Of course the turrets will at some point need to be fixed and zeroed.  On my larger model from a while back I had set screws on the shafts with a hole in the turret for hex driver.  If small enough I'd probalby use a piece of tight fitting silicon tubing so if they get out of alignment you simply twist them back.  Once you get one turret to follow the director and not exceed its field it's easy to add more, 7 not a problem.

    Note that the director turrets in the video I  posted has three seperate stepper circuits, the director,  turrets 1 and 2 are wired directly to the same circuit, as are 3 and 4.  So that requires 4x3 digital outputs that's getting close to max for an UNO.  The Mega has plenty, good choice for 7 turrets :-))

    I'd be happy to share how it runs if anyones interested.   Cap
    Logged

    Mr.R.Duino

    • Shipmate
    • *
    • Offline Offline
    • Posts: 8
    • Model Boat Mayhem is Great!
    • Location: Duino Land
    Re: Turret Rotation
    « Reply #35 on: September 14, 2017, 09:00:00 AM »

    Hi Capricorn,

    Nice video - looks like you have a pretty neat solution.

    Not sure if you have seen it but checkout this thread - http://www.modelboatmayhem.co.uk/forum/index.php/topic,56800.0.html

    And also https://login.proboards.com/login/6696601/1

    Do you have any plans to add other functionality?

    Logged

    Capricorn

    • Shipmate
    • *
    • Offline Offline
    • Posts: 4
    • Model Boat Mayhem is Great!
    • Location: Minnetonka, Minnesota USA
    Re: Turret Rotation
    « Reply #36 on: September 14, 2017, 09:48:44 PM »

    I did see the t.a.r.g.e.t. thread, I was a member on this site years ago when I was working on a 1:35 scale DD, that has functioning turrets, I conversed with Andy and some others on his dreadnaught project, probably they don't recall.  But Andy was the one that suggested the compass module to me.  I take rather long breaks (years) from working on my model ship, I only just got back into it a couple months ago on RCGroups, and this realy just a mini version of what I had before, with the compass added.  The 1:35 scale DD has guns that elevate also via steppers.

    Once I had it working well I posted the video and I searched around various sites to see what others may have similar.  I saw Andys post here, seems to have stalled a while back, I can understand that, thought I'd add some new life to it.

    I don't plan any additional features at the moment, not until I get a model to put it in.  I was contemplating a 1/200 scale BB plastic kit, probably the Bismarck, but that is a lot of work, not sure I want to commit.  What features did you have in mind, or suggest?  Cap

    PS what year was 1984 written, because I've googled it and I can't get past the cypher question.
    Logged

    AlexC

    • Full Mayhemer
    • *****
    • Offline Offline
    • Posts: 133
    • Location: West Coast Scotland
    Re: Turret Rotation
    « Reply #37 on: September 14, 2017, 11:56:14 PM »


    PS what year was 1984 written, because I've googled it and I can't get past the cypher question.

    A very ill (TB) George Orwell finally completed the manuscript for 1984 in December of 1948 on the Scottish Island of 'Jura' (inner Hebrides) the book was first published on 8th June 1949 in the UK.

    Hope this helps.

    Alex.
    Logged

    Capricorn

    • Shipmate
    • *
    • Offline Offline
    • Posts: 4
    • Model Boat Mayhem is Great!
    • Location: Minnetonka, Minnesota USA
    Re: Turret Rotation
    « Reply #38 on: September 15, 2017, 01:16:36 AM »

    Thanks Alex, I misread the question, finally figured it out; "about what year was novel 1984 written?", duh, 1984....
    Logged

    Bob K

    • Bob K
    • Full Mayhemer
    • *****
    • Offline Offline
    • Posts: 3,175
    • Location: Windsor
    Re: Turret Rotation
    « Reply #39 on: September 15, 2017, 10:51:31 AM »

    I believe this thread should be merged with . . .
    http://www.modelboatmayhem.co.uk/forum/index.php/topic,56800.0.html

    Progress is being made towards a working system.
    Logged
    HMS Skirmisher (1905), HMS Amazon (1906), HMS K9 (1915), Type 212A (2002), HMS Polyphemus (1881), Descartes (1897), Iggle Piggle boat (CBBC), HMS Royal Marine (1943), HMS Agincourt (1912)
    Pages: 1 [2]   Go Up