Jump to content
mikep

RC Autopilot Project for PIC

Recommended Posts

I finally got around to installing a web viewer for cvs and put up the autopilot files in it. Hopefully some of you will like to take the code, schematics and pcb files and will add to it.

If you do please send me the modified files and I will send them up to the cvs server so we can benefit from each others work and keep making it better.

The URL is: http://www2.rconline.ca/horde/chora/

Let's see if opensource can get this thing moving!

Cheers,

Mike

Share this post


Link to post
Share on other sites

Hi Mike.

I looked at your pcb layout and software design. I have not analyzed it thoroughly but on a brief look, it looks good.

The requirement of a FMA co-pilot might not be written in stone. By designing the airframe properly, no FMA co-pilot would be required. If rudder throw is limited to a degree suited for the airframe, it should work anyway.

I have indeed tested the FMA co-pilot with good results but it is not a requirement for level flight after all. Old principles in aircraft stabilization still applies.

Dihedral and properly selected airfoil makes the airframe dynamically stable anyway.

I know about the theoretical difficulties in stabilizing aircrafts relative to earth plane. It is not easy to find a simple perfect method to relate the aircraft orientation relative to earth. Laser gyros of a modern fighter (full size) is not a perfect sollution either...Annoying drift will be present anyway, at least in long term.

Dead reckoning is bad I think.

Anyway your ideas looks good and I think I will give it a try by building it and trying it.

It is so great with people willing to share ideas like you do.

Thanks for sharing your ideas.

Best Regards,

Bosse

Share this post


Link to post
Share on other sites

I agree with you about the co-pilot, however on these extremely light trainers, the wind can also play against the principals of a well balanced aircraft. So I think it is much safer to use it.

Please let us know how you do with the code. The Altitude one only really works for reading in the sensor. I never bothered actually adding the correction etc although many of the code parts are there for it. The heading stuff is fully functional.

Basically you just need to copy over the same stuff from the heading code to the altitude code.

I might get to it at one point but right now I have too many projects. I was hoping someone would have finished the PCB layout for both heading and altitude and then I was going to continue with the coding.

There was someone on the list that was supposedly doing it but I haven't heard from him since august so I guess he got busy with other things as well.

By the way, if anyone wants the black case that I have up there, they cost very little. I pick them up at a surplus place near me. I think they are 5$ CDN ea.

They are made of aliminum and are quite sturdy and already have the 232 slot cut out of them. It will make for a very clean installation.

Cheers,

Mike

Edited by mikep

Share this post


Link to post
Share on other sites

You are right about the wind, or as I think of it, the turbulence.

Best Regards,

Bosse

Share this post


Link to post
Share on other sites

I, too, have been reading this thread with interest. I'm having a hard time obtaining a PDC10 and hope the circuit MikeP has generously offered to share with us will suffice.

My purpose is to build a "come home" circuit initially and work towards more advanced UAV/Autopilot functions as I learn the tricks of the trade. You've already discussed the possibility of eliminating the Copilot. I'm wondering, is the altitude hold portion really necessary and can it be eliminated instead of the Copilot? Can it also be removed without requiring serious mods to the GPS half of the circuit? The Copilot has elevator correction as part of its stability functions, would this not be adequate? True, the plane, depending on design, might gain or lose a bit of altitude with each turn but not more than 50 ft or so per 360 degrees assuming adequate wing loading, relatively calm conditions, and an even hand on the throttle. A poorly built plane can climb or descend in a level attitude if the thrust line is too high or low, or any plane if it flies through thermals/downdrafts (Copilot wouldn't know the difference), but a trued up and well balanced plane should fly at the same level regardless of thrust as long as there's enough of it to keep the airframe airborne through the turns. Is this not true?

Also, MikeP, can you tell me how to obtain the hex files for the PICs? I'm not keen on spending $249 on the MELAB software if I don't absolutely need it.

Has anyone designed a PCB layout yet?

Thanks,

Bruce

Share this post


Link to post
Share on other sites

Yes you can use the AutoPilot without the Altitude hold. Simply make the turns gentle which is easy to do. On the version I made there are three settings you can adjust; max servo travel, gain and direction.

As for providing you with a HEX file that is not a problem. I will put it up on the CVS server. The only thing I really need to do for that is re-assign some of the pins. Basically when designing the PCB I needed to reassign some of them to get the thing to fit together.

As for the PCB design, here's what I will do. Basically the design that is there works, I will complete it this week (AutoPilot only wo/Altitude) if you promise me you will build it. I simply need to go over the schematic again with the PCB to make sure everything is there and in the right place. I did notice I was missing one cap.

That goes for anyone. I'm very willing to work on it, make changes, add enhancements etc., as long as someone builds it and gives me some feedback at the same time.

If you are going to do so, step one is ordering the parts and to get it done on a Breadboard.

It's simply that I'm not really motivated if no one will use it.

Also I was hoping of having a bit more of a community of people working on it, (even if that is only giving me feedback) than continuing alone.

I was getting back into it late this summer when someone said they were working on the PCB, but I haven't heard from them since.

Cheers,

Mike

Edited by mikep

Share this post


Link to post
Share on other sites

Mike,

Have you considered using the $GPGGA sentence to get the altitude position from the GPS, or is this less dependable than the barometric altimeter? It looks like many of the Garmins such as etrex do support altitude output. Yesterday I built a PC board and got the PicBasic Pro compiler, but I will probably wait until next week to give it a good test. Hey Bruce, we can send you the code in assembly if you don't have a Basic compiler.

John

Share this post


Link to post
Share on other sites

I basically had this discussion at one point on the Yahoo list. And basically what was said was that the altitude reading from the GPS was not precise enough to be used.

I tested out both a digital and analog pressure sensor to be used with the altitude hold. Although personally I was leaning towards the digital one, the complication in obtain it and the price made me go with the analog one (Motorola).

Like I said before the altitude part is basically done. One good days work and I will complete it.

I made a few changes in the code today. Nothing serious but you should use the latest version. It has the pin assigments correted to fit the PCB and Schematic. I also changed the schematic and PCB (PCB will be up by tomorrow I think). I wish you told me you had done one. I could have saved some time today. What software did you use to design it? The one I did today is made to fit in a 2"x4" project case. I could get it quite a bit smaller, but I felt this was satisfactory for now.

I also sent up a HEX file for those that don't have the compiler.

I basically did a lot of cleaning in everything at the same time and the project should be easier to follow.

All parts at least now have the same assignments in the BOM, Schematic and PCB. :-) Also added Digi-Key part numbers to most of the parts for the AutoPilot.

Cheers,

Mike

Share this post


Link to post
Share on other sites

Excellent news, thanks Mike for all your help. I do not have a Basic Compiler so a hex file will be most welcome.

I do intend to build the circuit because I'm barred from purchasing a PDC10 from Unav due to their export restrictions. I am also, however, trying to get CCNA certified and that's forced me to put off numerous other projects until it is completed. In a month or two I hope to have something built and tested, however.

I have the transfer paper and chemicals to etch my own circuit boards but not the software to go from schematic to layout. This is the primary reason why I don't build more circuit boards. I'm sure there's an easy way to do this but I don't know what it is. If there's a layout (etch pattern) already made that I can print full-sized on my inkjet then that will save me a lot of time.

When the time comes I will also have to learn how to burn PICs, though I don't think this is terribly difficult. I acquired a simple programmer kit recently from Poptronics that should help. Hopefully the Multi-chip Programmer they use will program the 16F87X in the schematic. Anybody know otherwise?

Thanks,

Bruce

Share this post


Link to post
Share on other sites
Mike,

Have you considered using the $GPGGA sentence to get the altitude position from the GPS, or is this less dependable than the barometric altimeter? It looks like many of the Garmins such as etrex do support altitude output.

My Garmin Geko 201 supports altitude measurement with the same accuracy it has for distance, that is, less than 49 feet, as long as four satellites are being received. Less with differential corrections in operation. I typically get 15-27 feet here in Japan (don't think WAAS has hit these shores yet). That has to be better than a Copilot, no?

Bruce.

Share this post


Link to post
Share on other sites

The co-pilot doesn't really consider what the altitude is. It simply keeps the plane level at any height. For instance if you do not have enough throttle the plane will stay level but could be loosing altitude quite quickly. It's actually how they teach you to land with the co-pilot.

With the Motorola MPX4115AP I believe we came to less than 10 feet accuracy using a 12-bit ADC. I would have to go look at my notes again to be exact but it was very good. The accuracy could be increased by using a 14 or 16-bit ADC and some good algorythms but the price for the finer ADCs were getting expensive.

Also the MPX4115 is about 17$ and the ADC is about 5$. So not a great increase in cost.

I did a lot more cleaning in the files today. Split up the altitude hold and autopilot into 2 seperate projects.

I made a B&W TIFF of the PCB and also shrunk it down to fit inside one of those sexy Ice Blue Hammond cases.

So basically everything is up on the CVS server to make the autopilot and it's much simpler and clearer now than it was before.

http://www2.rconline.ca/horde/chora/

Cheers,

Mike

Share this post


Link to post
Share on other sites

Bruce,

It looks like the poptronics multi-chip programmer only has a socket to fit the 16f84. The only hardware difference for a 16F87x programmer is a few pin connections moved around, and the IC-Prog software is likely compatible with the 16f87x series. If you can get ahold of a big 28-pin socket (or stick smaller ones end-to end) and then solder 5 wires (MCLR, Data, Clock, Vdd, Vss) to the new socket according to the 16f87x pinouts it should work.

Best Regards,

John

Share this post


Link to post
Share on other sites

Argh.... I'm having a **** of a time getting the PCB to fit into that case.

So, back to the drawing board. This time I drew my keepout layer to match the case. A more logical way of working!

Anyways, as I was playing the roll of taxi driver to my daughter earlier, I started thinking, if someone want to use the code and modify it for GPS altitude, it would be quite easy to do.

I could branch out the altitude project into 2 branches. One for GPS and one for Pressure sensor.

Just a thought!

I should have the new PCB layout which will make it less of a pain to get into the cases later on tonight. I really want to get the boards into the sink tonight and I can only do them at night due to lack of a darkroom.

Cheers,

Mike

Share this post


Link to post
Share on other sites

Well here it is. What I'm hoping will be the final layout for the PCB. This one really should fit perfectly into that little blue box (Yeah, I know... I said that before).

I made 3 boards tonight and will drill them tomorrow as well as start laying out the components. If all goes well sometime this week I will do some tests. Unfortunately I don't think air tests will be possible for a bit. Montreal weather kind of sucks lately and it probably won't get much better soon. But I will keep the trainer ready to go in case we get a break.

In the mean time I will have to test it out on the good 'ol R/C truck. I'll see if it can make it around the block all on it's on. It's always good for a few stares from the neighbours as well as a cocked head from the occasional passing dog.

The B&W art is up on the site as well.

Cheers,

Mike

post-6-1067216737_thumb.jpg

Edited by mikep

Share this post


Link to post
Share on other sites

Is there a link to a place that tells more about the project (in vast detail)? The mentioned URL only has basic info. I am interested in the various features and how the device is used.

Share this post


Link to post
Share on other sites

Yes that's what I need. A good HTML page.

OK coming up shortly!

I'm more use to working with developpers. Basically a good CVS copy and a maillist is usually all we have.

But I will try and put something together similar to your project pages that I find really well made.

Mike

Share this post


Link to post
Share on other sites

Mike, thanks for the circuit mods and writeup. They will make fabricating a board much easier. I'm having some trouble printing the tiff of the etch pattern, however. My printer gives a 4.5% scale down error. I will need to figure out how to scale up the image to get rid of this error. This'll take some experimenting but hopefully won't take too long. Are there any secrets to this?

John, thanks for pointing out the pinout differences between my programmer and the 16F87X PIC. I was afraid I'd have a problem like this. Nothing's ever easy, is it. I will have to make an adapter to go from the 18 pin programmer to a 28 pin ZIF socket. So long as those 5 pins are the only ones that need to be changed it shouldn't be too difficult.

Bruce

Share this post


Link to post
Share on other sites

My pleasure Bruce.

Basically it builds quite well. Getting the DB9 to fit in the case is a bit of a hassle and I will move it back on the PCB 1mm or so. I will also squeeze in the 2 pots a few mils. however it still assembles quite well as is.

I will update the web site with some more info, the PCB changes and images later this week.

In the mean time here is a completed RCAP v1.0.0

Cheers,

Mike

post-6-1067293818_thumb.jpg

Share this post


Link to post
Share on other sites

nice pics, mike. The translucent blue case is really neat! I just finished the code for the satellite altitude hold and elevator servo routines. It doesn't have pots for adjusting the gain, travel and direction of the elevator servo yet, and the cruise altitude is set in software for now (I live in florida, no worries). I am also considering adding a satellite signal failsafe that reads the number of satellites and/or HDOP precision (in meters) to provide for a safe altitude gain in case of poor signal reception conditions. Also replaced the Max232 IC with a transistor that inverts the voltage of the data line from the gps. If anyone want the source code, just email me. Mike, I enjoyed reading your webpage on the autopilot. Do you have any test results on it yet?

Thanks,

John

Share this post


Link to post
Share on other sites

I haven't tested it out in the air yet. But I've been playing with it on my desk.

That's one of the nice thing about the my old Garmin GPS 12 Map. It has a simulation feature. Just like being outside. You can set your course, speed etc. Altitude is set for you however so that would be more difficult to play with.

When I was working on the alitude module I had a piece of tubing connected to the pressure sensor that I would suck on to simulate altitude!

My first issue today was I noticed I had the wrong gender DB-9 on the board. So I had to go to the store to get the right one, then change it.

But my biggest problem was that I blew my last 20Mhz Ceramic Resonator today. I've been moving it from project to project and must have killed it.

So I decided to try and run RCAP on a 10Mz OSC and noticed that did not work at all. The main problem was the PulseIn function. The scale is different depending on the OSC used.

(I just remembered someone last year trying it at a slower OSC and he was never able to get it to work, now I know why!) Ooops!

So I went into the code and changed that to take into account different OSCs (4, 8, 10, 20 or [40 not on 16F876] will work) and it now factors that for the PulseIn functions.

So than I got to play with it finally when I noticed my servo was jittery.

So after some debugging time I figured out it was the PulseIn comand that no longer had the same resolution that it had at 20Mhz so the servo PW would jump in pass-thru mode.

So I just placed a Digi-Key order for the same OSC I mention it the BOM. I should try them out anyways before putting them in there!

That should arrive tomorrow afternoon and then I will continue my testing.

Although a bit windy and cool. I could have actually flown today.

I'm also thinking about adding a feature that allows you to set waypoints while you are in the air. The only problem with that is that it will make the project Garmin dependant and I'm not sure I want to do that. But I think it would be a pretty neat feature. I know the times I tried to use my RPV as a "plane down" search and rescue type of a deal, It was actually very hard to determine where I was exactly. So even if I did spot the plane I would have a hard time returning to it. This would allow me to hit a switch on the radio and create a waypoint. I think I *MIGHT* also be able to make it the active GOTO so you could also set where the plane comes back to with the autopilot activated. I have that spare input/output on the board and made the MAX232 bi-directional.

As for killing the MAX232A, I thought of doing something similar but wanted to stay as standard as possible. I would consider adding a resistor as well to keep things at TTL level.

As for your code... yes please send it to me. Maybe there's something in there that I might want to add to RCAP.

Cheers,

Mike

P.S. Code changes are on the CVS server but I will not update the zip file on the web page just yet.

Share this post


Link to post
Share on other sites

Hi Everyone,

New to this forum and just recently discovered RC-CAM while surfing. I am very much interested in the latest developments. Hopefully, I can contribute or help this project along. I have a website, http://www.embeddedtronics.com/

This will give you a clue of what I'm capable of. I've been soaking up as much info as I can from this forum and have been working on my own ideas. I think an autopilot project for the pic would be great to make. Is it still a works in progress or are there people actually test flying the unit.

Sincerely,

Kin Fong

Share this post


Link to post
Share on other sites

Hi Kin,

There are 2 projects going on. One is the RCAP. It is a work in progress but just about done. Right now I am testing it on the ground to begin with. Todays test revealed some problems with the gain. Basically the GPS is taking to much time to figure out it's new course it is on during a correction and it get's pretty mixed up.

It either keeps going in circles, or it snakes back and forth towards the waypoint.

I will either lower the gain amounts (preffered method) or instead of having it stay in a correction until it is on course, perhaps simply make a small correction, return to neutral and wait for a new GPS update.

The code is updated regularly on the CVS server, and I give regular updates on a Yahoo mailing list at: http://groups.yahoo.com/group/rcpilot/

If you want to build it that would be great, one of the things I need the most is feedback.

The other project is the R/C Pilot Project.

This project is in its infancy and right now I'm actively recruiting people to work on it. The first part is to define the specs. Currently I'm looking into different networking options for the PIC. Specifically CAN at the moment. I really like the features of CAN but I'm somewhat hesitant about the complexity.

There is another thread in this forum where I wrote some stuff about it.

I also give updates regularly on the Yahoo rcpilot group maillist for this project.

If you want to offer some code, suggestion, feedback whatever in either project please feel free to just jump in!

Regards,

Mike

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×