turnigy 9x and fire control

Discussion in 'Electrical & Radio' started by GregMcFadden, Oct 9, 2012.

  1. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    Lately I have been playing with the custom firmware simulator for the turnigy 9x (or similar clones) transmitter while waiting for the smartieparts programming board to come in. I've been working to a passable and easy to implement fire control setup via transmitter mixes using the companion9x software/firmware configuator. All debugging sofar is done in the computer simulator.
    so here goes (cross posted from the 9x forums). Aft turret elevation not implemented yet. Selecting which turret is able to fire at target is straightforward but not implemented yet in the code below (much simplified from prevoius attempts and other folks help on the 9x forum) The code below moves the turrets (desirement of a continuous rotation pot makes the brain control easier) to point where the target pot is set if the turret can physically point there. if not the turret stops at predefined stops. With a simple conditional statement, a single fire button will fire only those turrets converged on target, not those that can not train properly, although there are enough inputs to do separate firing buttons (or implement both if desired for an override)

    CH9 really needs to be CH10 or higher I believe, but for debugging its use is fine.

    this is built on the open9x firmware.
    CH1 is front azimuth, CH2 is front turret elevation: Ch5 is aft turret azimuth. Rotation is considered WRT to clockwise being positive from looking down on the hull

    CH01 +100%CH9 Curve(Curve 1)
    CH02 +100%P2 Curve (xspan>
    R +100% P1 Switch(CS6) Curve(Curve 8)
    CH05 100%P1 Curve(Curve 4)

    CH09 +113%P1

    CH16 100%P1 Curve(Curve 8)

    Curve 1: -67,-67,-45,-22,0,22,45,67,67
    Curve 4 (X,Y Pairs 9 pt custom curve): -100,0; -75,26; -33,66; -10,66; 0,0; 10,-66; 33,-66; 75,-26; 100,0
    Curve 8 (X,Y Pairs 9pt custom): -100.-100; -75,-100; -50,-100; -10,-25; 0,-25; 10,-25; 50,-100; 75,-100; 100,-10

    Custom Switches:
    "CS6 v1span>

    this gives a fairly reasonable result in simulation for azimuth and for elevation in the bow turrets... I plan to play more with it once I am satisfied with the state of the sim to see about converging the barrels...
    Convergence is doable (I think) I am planning out the math and how to implement in the transmitter. the 9x has just the right amount of channels: 3x for throttle, rudder, pump. 3x for aft azimuth, elevation, fire. 3x for forward azimuth, elevation, fire.
     
  2. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    I don't know why the forum is eating the custom switch line but lets try again... dagitthis makes no freakin sense, forum refuses to accept custom switch string
    CS6 V 1 less than V2, Pot 2, Channel 16
     
  3. tgdavies

    tgdavies Active Member

    Joined:
    Jan 7, 2012
    Posts:
    130
    Very interesting that all this can be done in a standard transmitter.

    I suppose that you could link fore and aft elevation as part of the convergence calculations?

    Are you modifying the TX to use continuous rotation pots?

    If you were using rotary controllers with discrete steps, (I know the 9x doesn't support that, it's just something I've been thinking about) how many steps per rotation do you think would be desirable, in practice?
     
  4. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    fore/aft linked by default and come from same pot. yes, I am lookin to continous rotation pots.
     
  5. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    aftermarket boards (sky9x / gruvin9x boards) enable rotary encoders....
     
  6. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    So a bit more work...
    [​IMG]
    docs.google.com/spreadsheet/ccc


    The link will open a google docs spreadsheet. if you scroll right you will see a picture with a diagram of the turret layout and angles that I am working with. Below that are surface plots of the modified outputs of the stern turret to converge with the midpoint of the fronts. the plots are in dimensionless space for length with the variable of interest being divided by the length between the front turrets to the center of the rear. angles are in radians. the three plots give the change in the aft turret angle to convergence, the corrected range, and the total aft angle off of centerlien as defined in the geometry picture.

    on the lower left of the sheet is all current mixes... (ignore ch11) there are 4 remaining fake/real channels (yes you can extend the 9x to 16 channels with a second TX/RX, but I am using 7 of the channels for mixing purposes so there would be no point for me). It remains to be seen if I can find a suitable set of mixes to approximate the equations shown... 5 curves remain unused as well. the curves take in a single input. the mixes can replace previous values, multiply or add to previous. the real gotcha may be sufficient memory on the tx itself for the program, but we will see. (I have seen reference to addon memory hacks for it too)
     
  7. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    Almost there, math sorted out, still figuring out how to implement fully. I've got the actual range equation working in the TX simulator for the aft turret. I wish I understood more coding since it looks like adding some of the necessary functions would be easy enough (much easier than doing it via the current interface), looking at the open9x source, if I understood the implications of the additional math as well as how to make it a compilation option for the firmware. So very very close.....
     
  8. buttsakauf

    buttsakauf Well-Known Member

    Joined:
    Oct 14, 2010
    Posts:
    695
    Location:
    Waycross, GA
    Greg you never cease to impress me!
     
  9. wrenow

    wrenow RIP

    Joined:
    Jul 30, 2007
    Posts:
    439
    Greg,
    To save some wheel reinvention, feel free to check out the Big Guns Yahoo archives for discussion and programs for the Fire Control Assistant (FCA) I posted, which does it all in the ship, but move the maths etc. to the TX.
    The hardwaret: Take a ~$15 Picaxe Servo controller board. Decide which turret is your fire director (say, Turret A) and your assisted turret (say Z).
    The concept: When Turret A enters the "sweet spot" where Z can converge, Z disengages from its otherwise commanded position and parallels A. Depending on the amount of depression, dialed in, the guns converge by that factor.
    The implementation: the board accepts the commanded position for A, Z, and depression, does the calculations, and then outputs the Z position (if no sweet spot, its commanded position - if sweet spot attained, converging fire). To save a channel, the Z turret could be run off of a wire harness to the rudder, so that rudder commands Z as well.
    Hope this proves helpful.
    Cheers,
     
  10. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    Unfortunately, that is not quite what I am trying to do. I had that degree of functionality working a while back where the turrets parallel one another when possible. What I am adding is the (call A master, B slave) is the following: Turret B converges to a point with A rather than paralleling, and range on turret B adjusts to be the correct range to the target rather than the same range as was commanded for A. couple that with not having extra hardware in the ship, and it is very interesting.... I will look there and see what I can learn, however, as I realized that if I want pump control I am out of channels without doing something interesting (it may be a 9 channel tx but not in PPM, although with a second module can be a 16ch tx)

    thanks
    Greg
     
  11. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    More on this in a bit, but I finally got my smartieparts board for the 9x. installation was easy and companion9x uploaded my chosen firmware strain (I use that term intentionally) to the transmitter along with model information. Unfortunately the latest version of firmware has not been released again to the automatic compilation server that companion9x calls, so off I am to find a SVN tool and winavr to compile the latest version.... good news, global variables and easier math for mixes (in my case) bad news, no simulating it on companion9x yet (although I expect to see it the next time companion9x comes out with a release).
     
  12. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    this project is on hold until the next major companion9x release (or when I finally sus out how to compile it on linux) as there is a bug in the current version that buggers up curves. bug is fixed in the source, but a precompiled version is not yet available.
     
  13. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    alright, no hold here. I've got one of three trig functions I need added to the firmware. only cost me 200 bytes and (at 50700 now and the tx has room for something on the order of 64k but I believe the practical max is 60k-ish) now a bit more to implement (unfortunately I should be working on the littorio right now, but this is interesting)
     
  14. wrenow

    wrenow RIP

    Joined:
    Jul 30, 2007
    Posts:
    439
    BTW, Greg, one of our members is also experimenting, but with the Gruvin motherboard replacement (more "oomph: in the processor, a couple of extra rotary controllers).

    One thing you may have glossed past in the FCA was that the cannons are only parallel at maximum range (infinity) if ever ot zero depression (you can set it for slight convergence even at the least depression setting). Convergence amount is dialed in by your depression amount. Long discussion and even charts on the Big Guns Yahoo list. It is not a totally precision fire control system, but more of a close-ology approach to getting more rounds in a tighter area.

    Cheers,
     
  15. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    Yep. Here is my plan to work it. The math ignoring gravity is quite easy. What I will get out of the internal mixes and inputs is 4 values. Range for bow turrets. Azimuth for bow turrets. actual Range for stern turrets, actual azimuth for stern turrets. the range output is nondimensionalized based on the spacing between bow and stern turrets (range/dist bet turret groups) (with only 8 channels you get two turret pairs).

    Now the fun. this math is the same for every single ship out there since it has been nondimensionalized. right now I am working with a max range of R* (dimensionless range) = to 2 or 4,although that can be changed. (so in the case of a battleship that ends up being a maximum range of 1-3 times its boat length given typical turret spacing). now the longer the range the poorer your close range resolution given the finite steps that the tx outputs.

    Now fot adjusting to specifics. once these 4 values are determined, you then use them directly (my plan for bow turrets) or mix them with a curve (stern turrets) to remove any errors (see gravity, mech setup, etc). this allows one set of math that is actually exact except for gravity to work generically. So the start is putting in the necessary math withtout excessive memory use. (heck I was trying to add it as a compile time option but I don't fully understand how that works and it was being fussy)

    I have not figured out in the source how to call multiple values at once so some of this will be done in the mix menu in the tx, unless I can figure that out. I had a rough approximation working with just the multipoint curves but it needed better trig amongst other things. I've been going to great pains to minimize my memory usage so the stock board can be used (for example, sine/cos come from one table, a quarter wave table where (resolution wise) x-axis is effectively unsigned 5 bit and y axis is unsigned 8 bit, getting me 8 bit resolution in x and 10 in x. if that is not enough, I can change both to >10 or more but I don't want to do that until all is working.
     
  16. Tugboat

    Tugboat Facilitator RCWC Staff Admiral (Supporter)

    Joined:
    Jan 10, 2007
    Posts:
    8,298
    Location:
    Statesboro, GA
    Joining the club. Not worried so much about the future board, as I'm playing. But one Smartieparts board is on the way to me :) It will serve as the off-board (the opposite of onboard?) brains for USS Macon (aka Big Balti). Lots of room in Macon. Had toyed with the idea of an onboard computer (like using my old netbook), but it'll be enough of a challenge to just get it on the water :)

    Also buying an 8' trailer for going to events. I'm starting to outgrow the bed of my Tacoma, even just with Fast Gun.
     
  17. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    Great news. I have figured out how to retrive the current value of any calibrated input stick or pot. I will be using the recently implemented global variables to allow menu settable input channels for range and azimuth. range and azimuth will take in the full travel from two of those inputs. these will go to two new functions available in the mix selection screen called RNG and AZM (3 character max is set on the cluster they are in). this will output a value between -100 and 100%. so how this will work is as follows. the user will set up 3 or 4 custom curves specific to their ship. 2 will take the +/- 100% range input and map it to bow and stern turrets respectively. the other two will map the range output to the mechanical geometry of the range servo on the bow and stern turrets respectively.
     
  18. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    alright... tolerable square root function finally debugged, now others can be as well. Next onto the real stern turret range function, then the converging angle function.... getting close. I have been using bow turret cluster as the primary reference and port side as the positive half for angles... with no changes, one could re-reference to stern turret with stbd side positive. that reduces some errors that show up as you do the math but is a bit less intuitive to me.... we will see how that goes.
     
  19. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    Alright, finally a good update. code re-referenced (didn't take much) so that positive is to starboard, same as how the pot turns on the tx.

    the range calculating function works properly at all tested points sofar. Now I need to add the stern turret azimuth function. halfway there and the harder of the two is done.
     
  20. GregMcFadden

    GregMcFadden Facilitator RCWC Staff

    Joined:
    Dec 6, 2006
    Posts:
    2,526
    alright, it works for both range and bearing (works currently defined as TX outputs match outputs on excel spreadsheet) ... still some last code tweaks to do but after this, the next step is to get it into a ship. Anyone who wishes to try this out (and give me some feedback) PM me and we can chat.