View Full Version : Mini-HowTo DIY Servo Signal (PWM) to PPM Converter
rich smith
Feb 12, 2009, 11:52 AM
As promised here's a chip that combines 4 PWM servo signals into a PPM stream. It was originally developed for a wireless buddy box but also for FMA and Paparazzi autopilots so they don't have to use special receivers or hack into a regular one to get PPM. It only costs a couple bucks and can be built in minutes.
The conversion routine is only 20 something instructions long. Originally written for Tiny12(11) but tested on my Tiny13 failsafe and Mega8 autopilot platforms. Also works with Tiny25/45/85, Mega8515, Tiny26, 2313, and similar AVR chips w/o modification. 3-5 volt power can be obtained from a receiver, ESC, USB port, PC drive cable, or batteries (1 lipo or 3-4 NiMh).
The diagram shows Tiny13 pinout for a servo connector and Corona 410 RX. It works with 6, 8, and more channels but must be at least 4. Let me know if you see any typos or have questions.
SRVPPM12.HEX (fuseh=ef fusel=3a)
:020000020000FC
:100000007FE97DBFBC9A61E00AD062E008D064E07D
:1000100006D068E004D0C49A0CD0C498F4CF76B36C
:100020007623E9F3C49A05D0C49876B37623E9F72A
:10003000089593E00197F1F708952863292032305D
:0A004000303620522E536D697468AB
:00000001FF
rich smith
Feb 13, 2009, 06:55 PM
Fuse info has been added. h=ef l=3a (9.6mhz) Thanks for noticing Paul.
pipsqueak
Mar 22, 2009, 03:52 PM
Also works with Tiny25/45/85, Mega8515, Tiny26, 2313, and similar AVR chips w/o modification. .....
The diagram shows Tiny13 pinout for a servo connector and Corona 410 RX. It works with 6, 8, and more channels but must be at least 4. Let me know if you see any typos or have questions.
Dear Rich,
This looks great - just what I need. I'd like to use it with a Tiny26, partly because that's what I have spare at home, but also because it would be great to use more channels - Could you let me know the appropriate pin outs, by any chance?
Thanks,
Pip
rich smith
Mar 22, 2009, 11:57 PM
Tiny26 is a great micro. Has more ADC than any other chip of it's type.
Just match b0 w/b0, b1 w/b1, etc.. Should work fine but different fuse bits are needed (internal osc). Note that a new program is required to process more than 4 chan. Works with 5ch, 6ch, etc. RX/TX but extra channels are ignored.
Dear Rich,
This looks great - just what I need. I'd like to use it with a Tiny26, partly because that's what I have spare at home, but also because it would be great to use more channels - Could you let me know the appropriate pin outs, by any chance?
Thanks,
Pip
pipsqueak
Jun 07, 2009, 04:45 AM
Tiny26 is a great micro. Has more ADC than any other chip of it's type.
Just match b0 w/b0, b1 w/b1, etc.. Should work fine but different fuse bits are needed (internal osc). Note that a new program is required to process more than 4 chan. Works with 5ch, 6ch, etc. RX/TX but extra channels are ignored.
Hi Rich,
I've been using your fantastic converter for a couple of months now - thanks again for posting the code.
I've been using your HEX on a Tiny13 (i.e. four channels only) - making an almost exact-looking replica of yours.
Btw, If there are any arduino users out there who'd want to decode the PPM that comes out of this, I'll post the modified sketch I use at the bottom:
However Rich, It would be really great to get a version to handle more channels - Ie. use the extra pins on the Tiny26 version. However, without the source I can't make the tweaks above that you mentioned.
So I was wondering, would you either possibly be up for (a) tweaking your code, and posting a HEX for a new version that could handle up to 8 inputs, or (b) posting the source so that I could have a go myself - If successful I'd post the version back to the thread
No matter what, I'm really grateful to have found such a neat 4 channel solution - So thanks again.
Cheers,
Pip
// TX PPM INPUT STUFF
#define TXINPUTPIN 8 // Define TX PPM input signal - HARDCODED (so changing this won't make any difference)
unsigned int serinp[8]; // For the input PPM signal
#define TX_PITCH serinp[0] // Related to the PPM order and wiring
#define TX_ROLL serinp[1]
#define TX_THROTTLE serinp[2]
#define TX_YAW serinp[3]
/************************************************** *****************************
Setup
************************************************** *****************************/
void pmm_setup()
{
// Setup the TX PPM input
pinMode(TXINPUTPIN, INPUT); // Ensure the TX PPM pin is input
setup_timer1(); // Start the timer that does the PPM
}
/************************************************** *****************************
Functions & Subroutines
************************************************** *****************************/
void setup_timer1(){
//disable all interupts
TIMSK1 &= ~( _BV(TOIE1) | _BV(ICIE1) | _BV(OCIE1A) | _BV(OCIE1B));
//set timer mode
TCCR1A &= ~( _BV(WGM11) | _BV(WGM10) );
TCCR1B &= ~( _BV(WGM12) | _BV(WGM13) | _BV(ICNC1));
//capture raising edge
TCCR1B |= _BV(ICES1); //capture raising edge
//prescaler 1/8
TCCR1B |= _BV(CS11);
TCCR1B &= ~( _BV(CS12) | _BV(CS10) );
//disable outputs
TCCR1A &= ~( _BV(COM1A0) | _BV(COM1A1) | _BV(COM1B0) | _BV(COM1B1));
//enable capture interupt
TIMSK1 |= (1<<ICIE1);
}
ISR(TIMER1_CAPT_vect){
static unsigned int lasticr; //icr at last caputre
static unsigned char cserinp; //current input servo
unsigned int licr;
//TCCR1B ^= _BV(ICES1);
licr=ICR1-lasticr;
lasticr=ICR1;
if (licr<10000) { //pulse not super long - so Ok, otherwise totally ignore
if(licr>5000){ //pulse too long, means start of new frame
cserinp=0;
serinp[cserinp]=licr;
cserinp++;
}else if(licr>500){ //pulse good, take reading, go to next channel
serinp[cserinp]=licr;
if(cserinp<8){
cserinp++;
}
}else{
//too short, nothing to see here
}
//updateTXVals(); // So at the end lets update our calibrate vals
}
}
rich smith
Jun 07, 2009, 04:34 PM
However Rich, It would be really great to get a version to handle more channels - Ie. use the extra pins on the Tiny26 version. However, without the source I can't make the tweaks above that you mentioned.
Unfortunately I don't have easy access to source on most of these build threads because the projects have been archived for years. Generally I just read the hex out of chips laying around. Fortunately fuses were not blown.
The fact that it runs on all those different chips tells me it's not limted by OC channels as I first thought but actually by the number of input pins. I was confusing this with another AVR build thread I put up.
I vaguely recall the method now and it is ridiculously simple. Must be if only 20 instructions long! It should be easy to do a 7 channel version that will run on all the same chips as this one. I'll see if I can throw something together (if somebody else don't put one up here first).
rkovvur
Jun 07, 2009, 11:49 PM
Just curious:
Where would you use the pwm-ppm converter ?
rich smith
Jun 08, 2009, 10:08 AM
Just curious: Where would you use the pwm-ppm converter ?
It was originally developed for a wireless buddy box but also for FMA and Paparazzi autopilots so they don't have to use special receivers or hack into a regular one to get PPM.
Posted here in response to a request from another thread which didn't involve either application but I don't recall the details.
One thing that puzzles me is Pips connection with Ardupilot. It already has excellent PWM inputs for regular unmodified RX. Don't really see where PPM is needed there.
Acetronics
Jun 08, 2009, 11:24 AM
Just curious:
Where would you use the pwm-ppm converter ?
Hi, Rkovvur
Will be perfect for Wireless link between Master and Pupil transmitters ... ;)
i.e.
Alain
Tomapowa
Jun 08, 2009, 11:39 AM
This might even be a simpler non-PIC/AVR solution for converting multiple PWM signals into a single PPM signal.. simply add more diodes for more channels/inputs:
http://www.rcgroups.com/forums/showpost.php?p=7897866&postcount=35
http://static.rcgroups.com/forums/attachments/4/0/6/0/2/a1403458-221-aRcPwmToPpmMultiplexer_070722153600.jpg
rich smith
Jun 08, 2009, 11:49 AM
This might even be a simpler non-PIC/AVR solution for converting multiple PWM signals into a single PPM signal.. simply add more diodes for more channels/inputs
Apparently simple is in the eye of the beholder. :) If you're going to hack into a RX then better to just tap into the PPM signal. One wire.
I do the one-wire mod on occasion but for standard RX a PWM to PPM converter comes in handy. Specially if your trying out different receivers.
Tomapowa
Jun 08, 2009, 12:02 PM
huh? :confused:
This diode-based circuit simply connects to the receiver outputs (using servo connectors or even a 3x? socket). It then combines the individual PWM signals together (since they are normally sequentially updated), outputing a single PPM signal (easier and safer than attempting to solder a wire on the fine lands of the PCB). Isn't that what your AVR solution/code does?
Acetronics
Jun 08, 2009, 12:15 PM
Hi, Tomapowa ...
You just have forgotten the 300 µs separating pulses ... :eek:
your scheme doesn't work at all ...even with a monostable multivibrator. it's not so simple as that.
And we do not talk here about receivers that output two or three channels at the same time ( Futaba T series ... )
Alain
Tomapowa
Jun 08, 2009, 12:25 PM
Hi, Tomapowa ...
You just have forgotten the 300 µs separating pulses ... :eek:
your scheme doesn't work at all ...even with a monostable multivibrator. it's not so simple as that.
And we do not talk here about receivers that output two or three channels at the same time ( Futaba T series ... )
Alain
Separating pulses...?? Explain? These pulse timings are inherent in the PWM channels as they are output sequentially on most receivers (that is.. one after another... not at the same time as you are thinking). The diodes pretty much combined the individual servo PWM signals, one after the other... into one PPM signal... makes sense? Plus... it is not my "scheme".. others appears to be using it for the mikrocopter projects (see link I prev. pasted). I'm going to test it tonight in fact... looks too simple.
Acetronics
Jun 08, 2009, 12:46 PM
there is ~ 15 ns between channels outputs with 4015/4017 decoders ... say hundreds of ns with µP decoders.
so, this scheme outputs a low level during the full 4 to 8 channels transmission, due to the diodes blocking time ... not exactly what you were telling us.
see Mr CAM Forum for a logic version of this sequence " reconstructor " ... that is working.
Alain
Tomapowa
Jun 08, 2009, 01:05 PM
there is ~ 15 ns between channels outputs with 4015/4017 decoders ... say hundreds of ns with µP decoders.
so, this scheme outputs a low level during the full 4 to 8 channels transmission, due to the diodes blocking time ... not exactly what you were telling us.
see Mr CAM Forum for a logic version of this sequence " reconstructor " ... that is working.
Alain
:confused:
The recovery times of the 1N4148 is around 4ns.
http://www.fairchildsemi.com/ds/1N/1N4148.pdf
You could always use faster schottkys with reverse blocking times of around ~100ps if you wanted to be more precise.
http://en.wikipedia.org/wiki/Schottky_diode
Test it yourself and tell us if it works! Others are using it successfully... supposedly.
Acetronics
Jun 08, 2009, 02:54 PM
Supposing this recovery time to be 0 ...
what will you do with the ns "needle" positive pulses generated ??? no ( usable ...) electronics is able to detect them !!!
Do you also don't think the wiring load is enough to " wipe" them ... ???
have a look here to confirm it is only supposed to be working !
http://www.rc-cam.com/forum/index.php?showtopic=2064
Alain
Tomapowa
Jun 08, 2009, 03:18 PM
needle pulses? Wire? Load? Please explain...
Arthur P.
Jun 08, 2009, 05:38 PM
Both Mr Cam Man and the mikrokopter.de shop sell working PWM to PPM converters for up to 8 channels. The simplest one, which isn't sold is based on some diodes and a single chip, the diagram for which can be found in the thread on getting PPM from the AR7000, which does not have PPM on board so no other way to get at it, unless you just directly interface a satelite receiver with the flight controler. That has also been done with the Mikrokopter. See the mikrokopter.de forum and wiki.
rich smith
Jun 09, 2009, 06:01 AM
needle pulses? Wire? Load? Please explain...
Alains comments definitely ring a bell now. Photo 1 shows pulse spacing of typical RX and as you can see it is more like 2us so the diode circuit will fail to generate useable PPM. With more expensive high speed diodes output will still not even vaguely resemble the original signal (photo 2, Hitec). These are representative of 99% of units on the market. Don't forget that something, usually a micro, has to make use of this signal. I clearly remember having to put a 300us high time into the code to get useable PPM.
PS I believe Alain's referring to stray capacitance in the wires which will pretty much eliminate "needle" pulses and result in no signal at all.
rich smith
Jun 09, 2009, 06:17 AM
The simplest one, which isn't sold is based on some diodes and a single chip, the diagram for which can be found in the thread on getting PPM.
If by "simpler" you mean 800% increase in component count then you are correct. :) Then there's the issue that it probably don't work.
BTW I found a couple Mega8 chips labled SRVPPM in my foam trays of prototype ICs and suspect it may be the 7 channel version I referred to earlier. Should work with Tiny26 and and any other AVR with "classic" i/o map. If there's still interest I'll check it out. Hopefully the fuses are not blown.
I also found a couple PIC 629 with same label but as Bush senior used to say "aaaaain't gonna do it....".
rkovvur
Jun 10, 2009, 03:23 PM
Sorry to ask this question again. I am an RC newbie.
I know that the TX/RX use PPM to communicate the codes for the ESC and servos. I believe the RX converts these PPM pulses to PWM so that servos and ESC can understand them.
I still am trying to figure out where this PWM to PPM converter is used.
question:
1: is this muxing all the PWM channels into a single PPM channel?
Thanks!
rich smith
Jun 10, 2009, 04:37 PM
I still am trying to figure out where this PWM to PPM converter is used.
question: 1: is this muxing all the PWM channels into a single PPM channel?
Thanks!
It was originally developed for a wireless buddy box but also for FMA and Paparazzi autopilots so they don't have to use special receivers or hack into a regular one to get PPM.
I actually posted my code up here in response to a request from another thread which didn't involve either application but I don't recall the details.
Or as Alain put it:
Hi, Rkovvur
Will be perfect for Wireless link between Master and Pupil transmitters ... ;)
Alain
And yes, it combines several servo signals into a PPM pulse train.
Arthur P.
Jun 10, 2009, 06:09 PM
A number of multikopter flight controlers such as for the Mikrokopter expect the the RX signal as a single PPM train as they themselves decode and further modify the control signals, mixing in their own corrections to keep the crafts stable and controlable before sending them on to ESCs or servos.
As GPS and flight stabilisation systems become more commonplace also in the AP/AV planes, we-ll probably see the interest in receivers which have a single PPM output (only or in addition to separate PWM servo outputs) increase as this does make much more sense for interfacing with an intelligent flight controler.
pipsqueak
Jun 11, 2009, 08:06 PM
Posted here in response to a request from another thread which didn't involve either application but I don't recall the details.
One thing that puzzles me is Pips connection with Ardupilot. It already has excellent PWM inputs for regular unmodified RX. Don't really see where PPM is needed there.
Hi Rich,
Thanks for the the update. Just to clarify - I'm not using an Arupilot, I'm using an arduino board to make an inexpensive DIY brushless quad (which gets combined with either Sparkfun Gyro / Accelerometer modules, or in my case the bargain $40 sensor board from a Walkera X-UFO 4 or 5 spares list). My recent post about this (in what's become a very long thread mostly driven by some great work by a guy called Mikro) is at:
http://www.rcgroups.com/forums/showpost.php?p=12402532&postcount=1825
In my case, I wanted (for wiring simplicity and also to help improve my code loop rates) to convert the PWM outputs from my Spektrum to RX into a PPM single-pin input into the AVR micro on the Arduino board.
Others on the that thread have opted and prefer to use a multi-pin PWM input in much the same way as the Ardupilot - it just wasn't quite what I wanted to go for with my quad implementation (video of it in flight with your converter at work below!):
http://www.youtube.com/watch?v=OkPO8dMjfcw
By way of background, before I built a version of Rich's converter I tried a converter that I'd bought from this site:
http://www.mftech.de/catalog/product_info.php?cPath=23&products_id=44
Like many others, it is really intended to be used to connect a standard RX's servo outputs into PC flight sim interface (e.g. when for a user who's TX doesn't have a buddy box connector). I found, in my case it was way too 'jittery' for use with a real quad (although good enough to use with a flight sim), and at the time I was buying, there were no alternatives in stock from the Mikrokopter or other sources - It was then I gave your code a go on a spare ATTiny13 I had lying around, and it did exactly what i was looking for.
I'm really pleased to have found something that works well for me - So thanks again Rich!
Cheers,
Pip
pipsqueak
Jun 11, 2009, 08:17 PM
BTW I found a couple Mega8 chips labled SRVPPM in my foam trays of prototype ICs and suspect it may be the 7 channel version I referred to earlier. Should work with Tiny26 and and any other AVR with "classic" i/o map. If there's still interest I'll check it out. Hopefully the fuses are not blown.
.
@Rich,
Hi - if you were able to grab & share the firmware off a 7 channel version, I'd be very interested - I've got some Tiny26's around, so it would actually be ideal!
Cheers,
Pip
rich smith
Jun 12, 2009, 09:09 AM
@Rich,
Hi - if you were able to grab & share the firmware off a 7 channel version, I'd be very interested - I've got some Tiny26's around, so it would actually be ideal!
Cheers,Pip
Luckily the chips were unlocked so here's code. Should work unmodified on a Tiny26 too or any old AVR with a port B. Pinout should be same as the Tiny13 one with extra channels added on after 4. Just from memory, it's been a few years.
No chance to test it myself because my Futabas batt is dead and also I don't have a Mega8 socket wired up. Please post result so we'll know. Photo would be nice too so others can benefit.
SRVPPM83.HEX:
:020000020000FC
:100000007FE97DBFBC9A61E010D062E00ED064E071
:100010000CD068E00AD060E208D060E406D060E866
:1000200004D0C49A0CD0C498EECF76B37623E9F30B
:10003000C49A05D0C49876B37623E9F7089593E07F
:100040000197F1F708952863292032303036205285
:060050002E536D69746877
:00000001FF
Arthur P.
Jun 13, 2009, 05:54 AM
If by "simpler" you mean 800% increase in component count then you are correct. :) Then there's the issue that it probably don't work.
BTW I found a couple Mega8 chips labled SRVPPM in my foam trays of prototype ICs and suspect it may be the 7 channel version I referred to earlier. Should work with Tiny26 and and any other AVR with "classic" i/o map. If there's still interest I'll check it out. Hopefully the fuses are not blown.
I also found a couple PIC 629 with same label but as Bush senior used to say "aaaaain't gonna do it....".
The simple PWM to PPM converter described here http://www.rcgroups.com/forums/showpost.php?p=8083471&postcount=6 in the thread on getting PPM from a RX without PPM stage such as the AR7000 http://www.rcgroups.com/forums/showthread.php?t=714299&highlight=ppm works fine. I-ve been flying multikopters with it for more than a year now. Further improvements to this circuit, including a 3V regulator to ensure better performance and also of including a PIC to capture the AR7000 failsafe mode and correct for that, are described in the RC CAM Man forum here: http://www.rc-cam.com/forum/index.php?showtopic=2064&st=20
Another PWM to PPM converter described here:
http://www.rcgroups.com/forums/showthread.php?t=984041&highlight=ppm
Using the search function within RC Groups can be very useful to avoid re-inventing the wheel.
rich smith
Jun 13, 2009, 06:42 AM
Arthur, as I've shown with scope diagrams above those circuits may work with some older RX but the "needle" pulses are too small for popular modern DSP units. If someone absolutley fears flashing ICs (uPhobia) then it is possible to build one with linear components but many RX will not work and even on those that do work the signal does not resemble PPM. Signal timing will be very unfriendly for flight computers. And again the component count is many times that of uP based designs.
That method also fails completely on RX that output servo pulses at the same time.
BTW your last link (James request for PWM2PPM) is the one that prompted this thread. That other application I was trying to recall was Mikrocopter mixer.
Thanks for providing those links earlier like the Turnigy 6a ones. I now have 3 more huge threads to subscribe. Don't know how I missed them before.
My signal misses the opening 0.3msec spike. And seemingly the MK wants to see a full 0-5-0V transition to trigger the timer. So with the signal straight out of the converter it sees channels 2 through 7 but thinks these are channels 1 through 6. And with the inverted signal it sees channels 1 through 6 as 1 through 6, but doesn't see 7.
The simple PWM to PPM converter described here http://www.rcgroups.com/forums/showpost.php?p=8083471&postcount=6 in the thread on getting PPM from a RX without PPM stage such as the AR7000 http://www.rcgroups.com/forums/showthread.php?t=714299&highlight=ppm works fine. I-ve been flying multikopters with it for more than a year now. Further improvements to this circuit, including a 3V regulator to ensure better performance and also of including a PIC to capture the AR7000 failsafe mode and correct for that, are described in the RC CAM Man forum here: http://www.rc-cam.com/forum/index.php?showtopic=2064&st=20
Another PWM to PPM converter described here:
http://www.rcgroups.com/forums/showthread.php?t=984041&highlight=ppm
Using the search function within RC Groups can be very useful to avoid re-inventing the wheel.
kanchana
Jul 11, 2009, 08:54 AM
Luckily the chips were unlocked so here's code. Should work unmodified on a Tiny26 too or any old AVR with a port B. Pinout should be same as the Tiny13 one with extra channels added on after 4. Just from memory, it's been a few years.
No chance to test it myself because my Futabas batt is dead and also I don't have a Mega8 socket wired up. Please post result so we'll know. Photo would be nice too so others can benefit.
SRVPPM83.HEX:
:020000020000FC
:100000007FE97DBFBC9A61E010D062E00ED064E071
:100010000CD068E00AD060E208D060E406D060E866
:1000200004D0C49A0CD0C498EECF76B37623E9F30B
:10003000C49A05D0C49876B37623E9F7089593E07F
:100040000197F1F708952863292032303036205285
:060050002E536D69746877
:00000001FF
Does this cod work for mega 8 or any other code for mega 8
kanchana
Jul 11, 2009, 12:50 PM
Luckily the chips were unlocked so here's code. Should work unmodified on a Tiny26 too or any old AVR with a port B. Pinout should be same as the Tiny13 one with extra channels added on after 4. Just from memory, it's been a few years.
No chance to test it myself because my Futabas batt is dead and also I don't have a Mega8 socket wired up. Please post result so we'll know. Photo would be nice too so others can benefit.
SRVPPM83.HEX:
:020000020000FC
:100000007FE97DBFBC9A61E010D062E00ED064E071
:100010000CD068E00AD060E208D060E406D060E866
:1000200004D0C49A0CD0C498EECF76B37623E9F30B
:10003000C49A05D0C49876B37623E9F7089593E07F
:100040000197F1F708952863292032303036205285
:060050002E536D69746877
:00000001FF
Does this cod work for mega 8 or any other code for mega 8
rich smith
Jul 13, 2009, 05:19 AM
Does this cod work for mega 8 or any other code for mega 8
Yes. Any AVR that has "original" address for Port B like Mega8, Mega8515, and all of the Tiny family.
DanNsk
Jul 16, 2009, 11:50 AM
I have ATtiny12l , which is max 4mhz, can i use unmodified original code for this converter, or it needs to be changed, or unluckily i can not use that at all ?
rich smith
Jul 17, 2009, 07:44 AM
I have ATtiny12l , which is max 4mhz, can i use unmodified original code for this converter, or it needs to be changed, or unluckily i can not use that at all ?
The 4mhz spec is for use with very low voltage (1.8v). At 5v the chip runs at 8mhz and higher so there is no problem. In fact I've run them at 20mhz with xtl.
Also note this program is pretty much frequency indpendent. 8mhz will give about 300us gap which is close to real PPM.
DanNsk
Jul 17, 2009, 09:13 AM
The 4mhz spec is for use with very low voltage (1.8v). At 5v the chip runs at 8mhz and higher so there is no problem. In fact I've run them at 20mhz with xtl.
ATtiny12L datasheet says 2.7 - 5.5V , 0-4 MHz, but ok thanks , i'll try.
rich smith
Jul 17, 2009, 09:39 AM
ATtiny12L datasheet says 2.7 - 5.5V , 0-4 MHz, but ok thanks , i'll try.
IIRC there are charts at the end of the spec that show more details. But you get the idea.
SadSack
Aug 10, 2009, 10:26 AM
Well this looks great. Few Q:
Try for hour or so and don't appear to work with my futaba 2.4 but could be fuse's set wrong.
1: Will it work with Futaba 2.4 and/or Spektrum RX ?
2: fuse? what should it be for attiny 45
3: See other code for 4 or more channels. But only have attiny 13/45/85. Could i use a pair of attinys ?? to give me 6/8 channels ?
Hoping i can go wireless on Phoenix Sim
rich smith
Aug 11, 2009, 08:00 AM
1: Will it work with Futaba 2.4 and/or Spektrum RX ?
2: fuse? what should it be for attiny 45
3: See other code for 4 or more channels. But only have attiny 13/45/85. Could i use a pair of attinys ?? to give me 6/8 channels ?
1. As long as servo pulses do not all start at the same time it should work.
2. Any setting for 8mhz no WDT. I use fuseh=d7 fusel=e2 for my Tiny45. Actually almost any clock will work, even the stock 1mhz setting, but faster gives more accurate PPM train.
3. Using a pair will result in two separate PPM signals so not sure if this is useful.
kanchana
Sep 21, 2009, 01:19 PM
I ave 8 channel version programmed in a atmega8 chips whic i can ship if interested
rich smith
Sep 21, 2009, 02:18 PM
I ave 8 channel version programmed in a atmega8 chips whic i can ship if interested
If you're willing to do it on a non-profit basis that sounds fine. I released my code as a contribution to RCG hobbyists and would have no problem if others passed on the favor.
druzara
Sep 23, 2009, 09:09 AM
Luckily the chips were unlocked so here's code. Should work unmodified on a Tiny26 too or any old AVR with a port B. Pinout should be same as the Tiny13 one with extra channels added on after 4. Just from memory, it's been a few years.
No chance to test it myself because my Futabas batt is dead and also I don't have a Mega8 socket wired up. Please post result so we'll know. Photo would be nice too so others can benefit.
SRVPPM83.HEX:
:020000020000FC
:100000007FE97DBFBC9A61E010D062E00ED064E071
:100010000CD068E00AD060E208D060E406D060E866
:1000200004D0C49A0CD0C498EECF76B37623E9F30B
:10003000C49A05D0C49876B37623E9F7089593E07F
:100040000197F1F708952863292032303036205285
:060050002E536D69746877
:00000001FF
Thanks rich! 7 channel hex image does work :D Verified even on an obsolete 8MHz 2313 that I had otherwise no use for these days :P
Just a couple of observations that I have noticed that others may find useful:
1.You must supply pulses to all 7 inputs PB0-PB3, PB5-PB7 as there are some blocking codes that will hang if any channel(s) are missing. Which led me to modify the code slightly for a 6 channel Spektrum 6100 reciever.
2.Your receiver must output pulse sequence in order from PB0 to PB7, otherwise, the generated PPM will be all messed up. I found out the hard way by wiring up a Spektrum 6100 receiver with a DX7. It turns out the channels are sequenced in the following order:
1 Aileron
2 Aux
3 Elevator
4 Rudder
5 Throttle
6 Gear
This sequence appears to be dependent on the transmitter, using an Eflite LP5DSM, the pulse sequence is in order of the receiver header pins.
1 Throttle
2 Aileron
3 Elevator
4 Rudder
5 Gear
6 Aux
rich smith
Sep 23, 2009, 09:59 AM
Thanks for verifying! It would be wonderful if you and Kanchana posted your code so others could take advantage. A local fellow has modified for 5 channel and I'm trying to get a copy to post. I would personally find your 6ch more useful than any of the other versions.
Maybe some day I'll get a chance to upgrade to a version that does not require fixed number of channels. Probably would be more than couple dozen instructions though. :eek:
Thanks for clearing up the pinout issue too. Makes it easier for those who don't have a scope.
SadSack
Sep 23, 2009, 10:00 AM
Thanks rich! 7 channel hex image does work :D Verified even on an obsolete 8MHz 2313 that I had otherwise no use for these days :P
Just a couple of observations that I have noticed that others may find useful:
1.You must supply pulses to all 7 inputs PB0-PB3, PB5-PB7 as there are some blocking codes that will hang if any channel(s) are missing. Which led me to modify the code slightly for a 6 channel Spektrum 6100 reciever.
2.Your receiver must output pulse sequence in order from PB0 to PB7, otherwise, the generated PPM will be all messed up. I found out the hard way by wiring up a Spektrum 6100 receiver with a DX7. It turns out the channels are sequenced in the following order:
1 Aileron
2 Aux
3 Elevator
4 Rudder
5 Throttle
6 Gear
This sequence appears to be dependent on the transmitter, using an Eflite LP5DSM, the pulse sequence is in order of the receiver header pins.
1 Throttle
2 Aileron
3 Elevator
4 Rudder
5 Gear
6 Aux
Any chance of sharing code ?
And how did you work out correct conections ? I'm hopeing to use futaba 2.4 and i don't have a scope :)
rich smith
Sep 23, 2009, 10:02 AM
One minute later!!! :) :) :) :)
SadSack
Sep 23, 2009, 10:04 AM
or maybe i can do a best guess from this :eek: http://jreise.de/PPM/R617FS.html
SadSack
Sep 23, 2009, 10:05 AM
or maybe i can do a best guess from this :eek: http://jreise.de/PPM/R617FS.html
Hoping i can use this with Phoenix sim lead
rich smith
Sep 23, 2009, 10:25 AM
Das schaltplan ist einfach!
SadSack
Sep 23, 2009, 10:40 AM
even with babelfish all greek to me :D
ergocentric
Sep 23, 2009, 11:29 AM
This might even be a simpler non-PIC/AVR solution for converting multiple PWM signals into a single PPM signal.. simply add more diodes for more channels/inputs:
http://www.rcgroups.com/forums/showpost.php?p=7897866&postcount=35
http://static.rcgroups.com/forums/attachments/4/0/6/0/2/a1403458-221-aRcPwmToPpmMultiplexer_070722153600.jpg
Something like a eight input nor/or gate?
http://www.premiumorange.com/daniel.robert9/Digit/images/4078.GIF
Edit: Good for most older receivers that don't sync servo movement
druzara
Sep 23, 2009, 04:16 PM
Thanks for verifying! It would be wonderful if you and Kanchana posted your code so others could take advantage. A local fellow has modified for 5 channel and I'm trying to get a copy to post. I would personally find your 6ch more useful than any of the other versions.
Maybe some day I'll get a chance to upgrade to a version that does not require fixed number of channels. Probably would be more than couple dozen instructions though. :eek:
Thanks for clearing up the pinout issue too. Makes it easier for those who don't have a scope.
sure thing! will post asm and hex files when i get home this evening, wanted your permissions first since it was "reverse engineered" from your hex :o
druzara
Sep 23, 2009, 11:30 PM
Here they are, enjoy!
Atmel ASM file:
; Atmel Win32 AVR Disassembler V1.01 by SXPILOT450
; Byte Address & ASCII Column by WagnerLip - 2009
;
; Instruction ADDR HEXA OPERANDS BYTE# ASCII NEXT 8
; ------------------ ---- ---- -------- ---- ----------------
;
; Modified by Druzara/Rex 09/22/2009
; http://acholic.turningaway.net
;
; 6 Channel operation for Spektrum 6xxx receivers
; PPM output on PB7, inputs on PB0-PB5
; AT90S2313 8MHz
; changes to original code are commented out but left in source
.DEVICE AT90S2313
.INCLUDE "2313def.inc"
.cseg
.org 0
ldi r23, 0x9F ; 0000 E97F 0000 Setup stack pointer
out SPL, r23 ; 0001 BF7D 0002
; sbi DDRB, 4 ; 0002 9ABC 0004 PB4 as ppm output
sbi DDRB, 7 ; 0004 PB7 as ppm output
avr0003: ldi r22, 0x01 ; 0003 E061 0006 load r22 with bit to test
rcall avr0015 ; 0004 D010 0008 call avr0015 to set output
ldi r22, 0x02 ; 0005 E062 000A repeat for all bits
rcall avr0015 ; 0006 D00E 000C
ldi r22, 0x04 ; 0007 E064 000E
rcall avr0015 ; 0008 D00C 0010
ldi r22, 0x08 ; 0009 E068 0012
rcall avr0015 ; 000A D00A 0014
; ldi r22, 0x20 ; 000B E260 0016
ldi r22, 0x10 ; 000B E260 0016
rcall avr0015 ; 000C D008 0018
; ldi r22, 0x40 ; 000D E460 001A
ldi r22, 0x20 ; 000B E260 0016
rcall avr0015 ; 000E D006 001C
; ldi r22, 0x80 ; 000F E860 001E
; rcall avr0015 ; 0010 D004 0020
; sbi PORTB, 4 ; 0011 9AC4 0022
sbi PORTB, 7 ; 0011 9AC4 0022 ppm out high
rcall avr001F ; 0012 D00C 0024 short delay
; cbi PORTB, 4 ; 0013 98C4 0026
cbi PORTB, 7 ; 0013 98C4 0026 ppm out low
rjmp avr0003 ; 0014 CFEE 0028 loop for next cycle
avr0015: in r23, PINB ; 0015 B376 002A test PB bit masked
and r23, r22 ; 0016 2376 002C by r22
breq avr0015 ; 0017 F3E9 002E
; sbi PORTB, 4 ; 0018 9AC4 0030
sbi PORTB, 7 ; 0018 9AC4 0030 set ppm out high
rcall avr001F ; 0019 D005 0032 short delay to inject gap
; cbi PORTB, 4 ; 001A 98C4 0034
cbi PORTB, 7 ; 0013 98C4 0026 ppm out low
avr001B: in r23, PINB ; 001B B376 0036 wait until current
and r23, r22 ; 001C 2376 0038 channel is done
brne avr001B ; 001D F7E9 003A
ret ; 001E 9508 003C
avr001F: ldi r25, 0x03 ; 001F E093 003E delay for proper gap between pulses
avr0020: sbiw r24, 0x01 ; 0020 9701 0040 ie: "needle" glitch as generated
brne avr0020 ; 0021 F7F1 0042 by diode circuits
ret ; 0022 9508 0044
ori r18, 0x38 ; 0023 6328 0046 '(c) 2006 R.Smith'
and r2, r9 ; 0024 2029 0048 ') 2006 R.Smith..'
cpi r19, 0x02 ; 0025 3032 004A '2006 R.Smith....'
cpi r19, 0x60 ; 0026 3630 004C '06 R.Smith......'
subi r18, 0x20 ; 0027 5220 004E ' R.Smith........'
subi r18, 0x3E ; 0028 532E 0050 '.Smith..........'
ori r22, 0x9D ; 0029 696D 0052 'mith............'
ori r23, 0x84 ; 002A 6874 0054 'th..............'
.exit
and the hex file:
:020000020000FC
:100000007FE97DBFBF9A61E00ED062E00CD064E072
:100010000AD068E008D060E106D060E204D0C79A58
:100020000CD0C798F0CF76B37623E9F3C79A05D002
:10003000C79876B37623E9F7089593E00197F1F72F
:100040000895286329203230303620522E536D69AE
:020050007468D2
:00000001FF
thanks again, rich!
rich smith
Sep 24, 2009, 07:58 AM
Here they are, enjoy!
thanks again, rich!
Thank you!
Now I don't have to hunt down my source. This will make it a trivial matter to change number of channels too. :D
SadSack
Sep 24, 2009, 09:27 AM
Nice one thanks druzara :)
I'll guess you used scope to find out which pin order ?
druzara
Sep 24, 2009, 03:21 PM
Nice one thanks druzara :)
I'll guess you used scope to find out which pin order ?
aye, was troubleshooting it with scope when it worked for eflite and not with dx7 TX.
btw, worked fine with Phoenix sim. Wireless infront of a projected screen is just like a day in the park except the part where i am looking for the broken parts in the grass. :p
SadSack
Sep 24, 2009, 03:27 PM
hmmmmm guess i'll figure it out other boring way then.
Q: could that be complied to run on mega 88v? Got to order otherwise
Thx
rich smith
Sep 24, 2009, 05:08 PM
hmmmmm guess i'll figure it out other boring way then.
Q: could that be complied to run on mega 88v? Got to order otherwise
Thx
Easy to figure channels. Just move a servo from one to the other and wiggle TX sticks.
To work with 88 you need to change addresses for Port B.
SadSack
Sep 29, 2009, 04:41 PM
Well ATTINY2313-20PU 8-BIT came to day :)
Well built it and well few issues...
Unsure of fuse setting, appears too work. Still rather be on same page.
Well may untrained eye it appears to be inverted but you tell me how its wrong
I've used same setting to pick both signels
First pic is PPM output from 12FG trainer port
http://www.rcgroups.com/forums/showatt.php?attachmentid=2788488&stc=1
Next output from convertor. Looks like pins PB0~PB06 in order go into Futaba R606FS in order :) PB0=ch1 PB1-ch2 and so on, nice.
http://www.rcgroups.com/forums/showatt.php?attachmentid=2788489&stc=1
So any help would be great, Thanks
SadSack
Sep 29, 2009, 04:46 PM
btw have tried my specktrum module and that appears to be inverted too.
And not guessed channel order either.
rich smith
Sep 30, 2009, 04:02 AM
btw have tried my specktrum module and that appears to be inverted too.
And not guessed channel order either.
All servo PWM signals are activie hi. My Hitec TX PPM signals are active hi too so that's what the code outputs. Other TX may be active low so If your quad, autopilot, etc expects that you can add a transistor (i.e. 2n7000) on the output to invert or mod the code.
And ch1-7 inputs are PB0-6. They must be in order for this to work right.
SadSack
Sep 30, 2009, 05:53 AM
hoping for code fix...this will be very handy for sim. And 1 mcu few leads simple :)
But can't code myself ;( Can't do much...apart from read(kinda) and drive soldering iron!
SadSack
Sep 30, 2009, 09:12 AM
Would this be what your saying ?
http://flyheli.helitron.eu/images/flusim/simrx10.gif
http://translate.google.com/translate?hl=en&sl=de&tl=en&u=http%3A%2F%2Fwww.flyheli.de%2Fflugsim%2Fsimrx.ht m
SadSack
Sep 30, 2009, 09:17 AM
or this...
http://users.belgacom.net/TX2TX/tx2tx/image/fig2-03.gif
http://users.belgacom.net/TX2TX/tx2tx/english/tx2txgb2.htm
rich smith
Sep 30, 2009, 09:19 AM
Would this be what your saying ?
http://flyheli.helitron.eu/images/flusim/simrx10.gif
http://translate.google.com/translate?hl=en&sl=de&tl=en&u=http%3A%2F%2Fwww.flyheli.de%2Fflugsim%2Fsimrx.ht m
Yes, however if using an N-FET like 2n7000 the resistors may not be needed. Op amps and logic gates will work too. Many ways to do the old polarity switcheroo. NPN with the resistors may be easier to procure though.
SadSack
Sep 30, 2009, 09:23 AM
well i can follow and look but unless i see it i can't figure it out :)
SadSack
Oct 01, 2009, 04:31 PM
futaba Working!!!!!! Excellant, Thanks very much for your time and effort.
And thanks too druzara for 6 channel asm and tweak :)
Thanks guys, Phil
vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.