PPM Controlled Pheonix {For Kurt}

Long time everyone.

First off this is the original thread viewtopic.php?f=8&t=6079
This is what I’m working with.

I’m posting this so I can get assistance from Kurt on what code to test out to read the PPM signal this device I assembled. The main goal is to Finally get the pheonix to work on Xan/Zenta’s old 1.3 code flawlessly much as how the ps2 remote option operated without shuddering/hiccups. It was not working well using pulsin for 7 channels due to the cpu being tied up for 7x20ms each pass… “NO BUENO”

As it stands I have tried no code for PPM the only thing I can find for PPM was this post by Kurt viewtopic.php?f=21&t=6629 although since it is assembly I’m looking for the basic code to go with it so I can simply test the output.

Once the code outputs 7 sets of digits I’ll be able to take that and adapt it for the Phoenix code.

I will then, start to try out the 2.0 code then ad on my individual leg control and then!! be done with it and show people!

Thanks again Kurt for the assistance In the past and I’m hoping to try some of your ppm code soon.

–Aaron

For anyone thats wondering what that circuit board is attached to my receiver it’s an Atiny2313 I assembled that converts 7 channels of pwm into 1 channel of PPM output. All the links to build it should be in the top url I posted.
Bot2.jpg
Bot.jpg
Side.jpg
Top.jpg

It might help if you could remind me exactly the format of your new PPM signals for the 7 channels.

Hey kurt.

Well I’m not sure what you mean by PPM format… I kinda assumed there was only one format although a picture is worth 1000 words. Attached is a screen shot of my oscilloscopes output…

I suppose “guessing here” that the two formats would possibly be an inverted version of what the scope shows, low then high vs high then low.

–Aaron

Yes, pictures are worth lots :smiley:
So it looks like the signal is inverted from my hacked version, which had a logic scan that looked like line 8 of:

So we should be able to use the same code that I did for that except invert some of the line levels for the captures…
In fact you might download and try the code from the thread: viewtopic.php?f=21&t=6629&start=15

It may only need a simple init change to interrupt on the falling edge instead of the raising edge.
ie change the line:

	TIOR0 = 0x40		; GRB set to input capture on rising edge

to

	TIOR0 = 0x50		; GRB set to input capture on falling edge

Again this has all of the standard limitations of the one in the other thread. That is it must be pin 10 as I am using Input capture on channel B here.

Kurt

That was fast!

Alright I hate to be a bother again, although It has been such a long time since I got into the coding mindset and looked at my phoenix code I’ve been modifying ages ago. Is it possible for you to provide a simple test program that outputs its values via serial. I would be able to load it on and then take that code and implement it in the RC code I have now.

I remember when the 2.0 code came out I wanted to put all of the code in one single bas file vs separate… I understood the reasoning behind making it separate which was for having 1 code base and multiple config files for control without touching the main code… it’s cool and all but a feature that would just confuse the snot out of me!

Anyway I figure you putting this into a single bas file vs me trying to fiddle with it would take you about 3 minutes… I could paypal you a couple bucks … you could cash that in and buy a servo or something heh

–Aaron

I guess it’s easier for me to take something that already works and put it into existing code making sure all the variables are all organized so the existing code and your code all play nice.

Hi Aaron,

As I responded awhile ago by PM about having a simple test program, for your setup. I extracted the code from the control file for Phoenix 2.0 and then simply wrapped a top level function over it… Did not have a chance to try it out. I have included it here as well in case anyone else wishes to try it out…

Again: for this code you would need to plug your PPM generator into P10 on the BB2…

Could not tell from last night’s PM if you have actually tried it out or not, but it sounded like you were scared off by the assembly language code that is the interrupt handler.

This code can be converted to Basic, it will not run as fast and again I have not tried running this!

Up at the top you need to change:

ONASMINTERRUPT TIMERWINT, HANDLE_TIMERW_ASM

to

ONINTERRUPT TIMERWINT_IMIEB, HANDLE_TIMERW

The basic version of the Timer interrupt would look something like:

;------------------------------------------------------------------------------
; HANDLE_TIMERW_IMIEB handler - The idea is to capture our current time
; 		value when the interrupt happens and then calculate a delta from the 
;		previous one.  If > some max we know that we are starting up a new run
;		of timings, else save away in the appropriate index value in our array
;		of timeing with 1 per logical channel.
;------------------------------------------------------------------------------
_wDelta	var	word

HANDLE_TIMERW:
	; Basic handles checking for ours and clearing the status
#ifdef DEBUG_LA
	toggle p4
#endif	
	_wGRB = GRB   ;
	
	if (_wGRB > _wGRBPrev) then 
		_wDelta = (_wGRBPrev - _wGRB) / 2 ; get delta time and convert to ms
	else
		_wDelta = 0xffff		; very large value - could probably simply do wrap...
	endif
	_wGRBPrev = _wGRB
	
	; OK Lets see what channel we are working on now...
	if _bNextChannel = (CNT_PPM_SIGNALS + 1) then
		_bNextChannel = CNT_PPM_SIGNALS	; won'd do anything until we get >2500 signal
		; Init mode
	else
		; need to check to see if the delta looks reasonable...
		if _wDelta < 800 then 
			fPPMSValid = 0    ; we don't have valid stuff
#ifdef DEBUG_LA
			toggle p5       ; show we got an error...
#endif	
			_bNextChannel = CNT_PPM_SIGNALS	; won'd do anything until we get >2500 signal
			
		elseif _wDelta < 2500
			; This is a valid range of signals...
			if _bNextChannel < CNT_PPM_SIGNALS then ; need to make sure not too many signals
				awPPMSInput(_bNextChannel) = _wDelta
				
				_bNextChannel = _bNextChannel + 1  ; set up for next channel
				
				if _bNextChannel = CNT_PPM_SIGNALS then
				    fPPMSValid = 1    ; we have a valid set of signals
#ifdef DEBUG_LA
					toggle p6       ; show that we have receive a valid set..
#endif	
				endif
			endif
		else  ; > 2500
			_bNextChannel = 0 		; assume the start of a new pass
		endif
	endif
	
	resume

test.bas (9.16 KB)