08M to generate a servo pulse for r/x switched circuits

ashleylad

Member
Hi all. I have been making r/c led lighting circuits which are turned on or off via a spare r/x channel PPM pulse

Here is an example of code to detect an on pulse greater than 170ms using an 08M pin 4

start:
pulse:
pulsin 3,1,b2 ; read pulse on pin 4
if b2 < 170 then pulse ; if pulse is less than 1.7ms then go back to pulse and read again
if b2 >= 170 then go ; if pulse is greater than 1.7ms goto go start running led flash pattern

go:

'flashing program here

goto pulse ;go back to pulse and make sure state has not changed.


It can often be a pain having to plug in a spare rx and setting the transmitter up just to test the circuit.

I tried to write a short code after looking at data sheet for a 08M to generate a pulse to drive the input pin of the circuit to be tested:-


start:
main:
pulsout 4,180 ;generate a pulse of 1.8ms on pin 3 08M
pause 20 ; wait 20ms
goto main


I know its rough. Tried it but it did not work. Not got access to a scope but logic probe was pulsing away on pin 3. Put the r/x on instead and it worked.
I must be overlooking something obvious. Scratching my head.

Any ideas anyone.

cheers

Ash
 
Last edited:

westaust55

Moderator
Note that while the PULSIN will seemingly work with a byte variable, according to the Manual it should really be a word variable.
 
Last edited:

ashleylad

Member
Well as usual looks like I have wasted people's time. Sorry for that. I have got it working. Don't no what when wrong bad connection? Pull everything out the breadboard and started from scratch. I knew it must be something silly, as on paper it should and does work just fine. Very useful little device now to inject a servo pulse to any circuit. Thanks again and apologies.

Ash
 
Hi Ash,
I did something like this some time ago to switch on and off position lights (flashing 800 msec/sec), anti collision light(flashing 2 x 200 msec/sec.) and landing lights of a flying model. I used a three position switch on the rc transmitter, so that I could switch the landing lights on and off additionally to the rest. Perhaps the coding is useful for you.

Code:
#rem
Blinkmodul für Flugmodelle
Version PICAXE 14m

Impulse für Kanal 7 - 3fach Schalter meiner MC 16:

Schalterstellung Aus: 107
Schalterstellung Mitte: 149
Schalterstellung Ein: 191

#endrem
#Picaxe 14M

 
#Ifndef 14M
 #Error "Dieses Programm läuft nur auf PICAXE 14M"
#EndIf 

symbol servo_eingang = 1
symbol servo_impuls = w0
symbol servo_mitte = 148
symbol servo_max = 190

symbol zeit = w1

symbol rot_ein = 0
symbol rot_aus = 800
symbol gruen_ein = 500
symbol gruen_aus = 300
symbol acl_ein1 = 100
symbol acl_aus1 = 200
symbol acl_ein2 = 400
symbol acl_aus2 = 500

symbol rot = 1
symbol gruen = 2
symbol acl = 3
symbol lsw = 4


start:
pulsin servo_eingang,1,servo_impuls
'debug
if servo_impuls >= servo_max then
  high lsw
  	else
  low lsw
end if
if servo_impuls > servo_mitte then
	for zeit = 0 to 900 step 50
		if zeit = rot_ein then
			high rot
  	endif
		if zeit = rot_aus then
	  	low rot
		endif
		if zeit = gruen_ein then
			high gruen
  	endif
		if zeit = gruen_aus then
	 		low gruen
		endif
		if zeit = acl_ein1 then
			high acl
  	endif
		if zeit = acl_aus1 then
	  	low acl
		endif
		if zeit = acl_ein2 then
			high acl
  	endif
		if zeit = acl_aus2 then
	  	low acl
		endif
		pause 50
	next zeit

	goto start
else
	low gruen
	low rot
	pause 50	
end if
 

ashleylad

Member
sierra_uniform many thanks for sharing your code, I will have to brush up on my German! I have tried lots of different circuits combinations, and had lots of fun. Made a fair few for friends. I have been looking at a way to change to different sequences by switching the auxillary on the transmitter. Need to spend more time learning to write code!

srnet, many thanks for the tip. I have one built into my watt meter, did not think of that one. I got the circuit working so will probably lash it up on a stripboard module to plug into my breadboard. Sure it will come in handy and I have learnt to impliment another short piece of Pic basic!

Thanks again

Ash
 

tony_g

Senior Member
hi ash,
glad to see im not alone in using picaxe for rc lighting. one thing i managed to add to my set was a learn process so i could get the picaxe to read the pulsin value of my dx6i output and store it to the eeprom and use that as its reference value for turning the lights on or off. initially i did program it with the two preset values i wanted based on guessing but found it easier to make the pic learn the value i decided it should use for either function if you want to try that anytime i can pass that snip of code onto you. im still kinda new to this but have been making a full set of lights for a scale heli fuselage but i wanted to turn them on or off one at a time and with one 3 position return to centre switch. i have 5 different lights i can individually turn on one at a time. being as i like scale modelling it works in this manner: from lights of every brief pull of the switch turns the lights on in this order, 1 adjustable dual beacon 2 solid red green and white nav 3 adjustable strobe 4 landing lights 5 optional searchlight output. still needs some fine tuning but its working as its supposed to.

took a vid showing the functions,enjoy

http://youtu.be/69YAxDSAbC4
 

ashleylad

Member
Hi Tony, great work and video thanks for sharing. I like the idea of switching modes well done. Still not looked at accessing the eeprom part but I think it's long overdue. Pretty much a novice but I am improving. Have you thought about the gear switch on the top for mode changing? as it's often not used. I did read somewhere that a dx6i can be modded to 8 channels very easily. I also have a dx6i handy little tx for the price. I would be interested in having a look at a bit of the code. I found I have learnt more by code examples than anything off the forums. You can PM or post here if you do not mind.

One idea I have had is fitting a flap type pot onto the dx6i and and using increments to change flash pattern. Say six to eight different pulse intervals. I am going to try this next. Just got hold of my first 18M2 chips to play with.

thanks again

Ash
 
Top