In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Wrenow wrote: What I would like to do is: Take input from 8 pots and perhaps a couple of switches, do a little logic and calculation, and output the information in a 20ms pulse frame compatible with standard hobby r/c. This is the format generated by the encoder in the radios. The purpose is a customized buddy-box. Basically, this is a replacement for the common NE5044 chip used in hobby radios. Most of the pot inputs are just read and the level passed through (or reversed, or limited, or mixed, then passed through) in the encoded format. So far, a hobby RC radio can already do this. What I want to do with a few of the channels, a hobby radio generally cannot do. Plus, with this encoder, you can turn a basic, inexpensive, 4 channel hobby radio into a powerhouse 8 channel computer controlled unit. Explanation follows at various levels of detail, and I am enclosing drawings for clarification: The basic constraints: Does the SX have the clock speed speed or oomph to handle all this (8 - 10 pot reads, 3-4 if-then-elses, a little calculation, and output 9 precise pulses on one pin based on that information every 20 ms)? I am thinking it will need to do the reads/calculations/timekeeping/etc. in the dead space of the frame, which could be as little as 4 ms. 30,000 ft. view: I am involved in R/C model Warship Combat (see www.ntxbg.org). The object is to get more shots on target. Using the following, grossly simplified, assumptions: The ship has 2 turrets, one in the bow, one in the stern (1 and 2, or A and D, respectively) Each turret has about a 270 degree field of fire. For clarification A (or 1) being 135 degrees either side of the centerline of the ship going forward, 0 being the CCW end of motion or stop, with 45 degrees from the 0 position being 90 degrees from the centerline of the ship on the left, or port side, 135 degrees being dead ahead, 225 degrees of rotation being 90 degrees to the right (starboard) of the centerline, and 270 degrees of rotatin being the tull stop on the right. D (or 2) being the same as A, but rotated 180 degrees (center, or 135 degrees of rotation, is dead astern). Both turrets are controlled by 270 degree pots on a 1:1 basis. So far, so good, my RC radio can do this. Note, however, that the fields of fire have an overlap of about 90 degrees on each side - 0-90 on A overlaps with 180-270 degrees on D, and 180-270 degrees on A overlaps with 0-90 degrees on D. The guns use a third pot to dial in depression for close-in targets. Several other controls are used in the ship, but those are relatively straightforward, pretty much 1:1 just like a simple RC hobby radio (EPA is the most complicated adjustment necessary), so let's focus on the 3 channels that need fudging for now. What I would like to have happen: When you flip a switch to enable master/slave mode, D goes to parallel with A if it can, and ignores its own control. If it cannot, it goes to wherever its control is set. Better yet, adding more depression closes the angle of D relative to A so that the barrels tend to converge on a single spot. Considering an 8 bit representation of 0-255 being 0 to 270 degrees, what I have come up with so far: syntax: pot1 is the value at pot1, tur1 is the value to be output to control the turret. 1=A, 2=D, 3=depression (range fudge factor) tur1 = pot1 IF pot1 < 86 THEN tur2 = pot1 + 170 ELSEIF pot1 > 170 THEN tur2 = pot1 - 170 ELSE tur2 = pot2 ENDIF This should give you a parallel fire with A as the master, D as the slave, when A is in the sweet spot. Of course the "convergence" tweak, in the same format, is: dep=pot3 tur1 = pot1 IF pot1 < 86 THEN tur2 = pot1 + 170 + (pot3 / 10) ELSEIF pot1 > 170 THEN tur2 = pot1 - 170 - (pot3 / 10) ELSE tur2 = pot2 ENDIF The results will need to be limited to 0-255, of course. What I am thinking is to build this into a controller box of choice, and then plug it into the radio as the pulse stream commonly encoded in RC prior to the RF stage, which is accessible through the buddy-box port. Does this sound easy, difficult, impossible? Especially for a newbie? Has something similar already been done that you can point me to? If it helps to do so, picture that I am wanting to build as a custom "BuddyBox" trainer system. They do the same thing (without the smarts), just take the baseband ppm signal from the encoder of the trainee's radio and feed it through the buddy box port of the trainer's radio to the RF stage as long as the trainer holds the switch closed. Release the switch, and he seizes control back to his encoder stage. There is a pretty good explanation of the structure of the output signal required at [url]http://www.geocities.com/BourbonStreet/3220/servotx.html[/url] Hardware recommendations and programming suggestions are certainly appreciated. Thanks, Wreno ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=106994 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)