"Custom" PWM

SilentScreamer

Senior Member
I'm not sure if this is at all possible but could a PICAXE (08M in this instance) be programmed to give multiple PWM routines off any output through programming. If it was changed to run at 8Mhz then pulse the outputs from the code at different speeds to get a number of fading outputs. This rough code idea might help explain what I mean.

Code:
#PICAXE 08M
setfreq m8

symbol LED = 1

let b0 = 100
let b1 = 20
let b2 = 0

main:
		do
		for b3 = 1 to 5
			high LED
			pause b0
			low LED
			pause b1
			next
		if b2=0 then
			let b0 = b0 - 5
			let b1 = b1 - 1
			if b0=0 then
				let b2 = 1
				endif 
			else
			let b0 = b0 + 5
			let b1 = b1 + 1
			if b0=1 then
				let b2 = 0
				endif
			endif
		loop
I think I saw this briefly mentioned in another thread but I can't find it through searching.
 

eclectic

Moderator
@SS
Have a play with the program below.

Code:
;Forum 04 03 09
#picaxe 08m

symbol rTime = b0
symbol gTime = b1
symbol btime = b2
symbol xtime = w2
symbol R_LED = 0
symbol G_LED = 1
symbol B_LED = 2
symbol dummy = 4  ; not connected

setfreq m8
 main:
 for rTime = 10 to 255 step 10
 for gTime = 0 to 255 step 10
 for bTime = 0 to 255 'step 5
  
 xTime = 766 - rTime - gTime - bTime
 PulsOut R_LED, rTime
 PulsOut G_LED, gTime
 PulsOut B_LED, bTime
 PulsOut DUMMY, xTime
 next
 next
 next
Then see

http://www.picaxeforum.co.uk/showthread.php?t=9747

http://www.picaxeforum.co.uk/showthread.php?t=8991

http://www.picaxeforum.co.uk/showthr...?t=9657&page=2

http://www.picaxeforum.co.uk/showthread.php?t=9930

e
 
Top