pulseout duty cycle

Ghostbear

Member
Hi all,

I'm giving this a last shot before giving up on the 08M2 and seeing if I can shoehorn the 14M2 into the available space :)

Ive got code that is generating two frequencies - 1 x 57.6kHz 'carrier' and 1 x 1800hz 'hit' frequency for an IR based ranged combat system for Live Roleplay.

Ideally I want it on an 08M2 chip, due to the space requirements at the moment. The code below generates the basic signal and works ok, BUT I'm finding the power I can push through the IR LED is limited, mainly due to the duty cycle of the pulsout command (Without it I can push up to 130mA (before I chickened out as the LED is only rated for just over 100mA :)), with it... 10mA)

Is there a way to either increase the duty on the pulsout command? alternatively, is there a way internal to the chip to drop the 57.6kHz frequency (by 4 I beleive) so that I can output the PWM 57.6 signal with max duty cycle, then quarter the frequency with the same duty cycle?

I was thinkiong of having a loop running that checks the PWM pin for HIGH condition and every 4th one, turn the 2nd output pin on then off to replicate it, but having tried it it was less than succesful, although that may be down to me more than the cjip.

Code is below.

Code:
symbol counter = w0

init:

SETFREQ M32
let counter = 0
low c.1
low c.4
pwmout C.2, 138, 416 ;57600 pulse
pause 500

main:
for counter = 1 to 100 ;output 1800hz pulse
				low c.1
				pulsout c.1,140
				low c.1
				pauseus 2
				
			next
Thanks in advance all.
 

Ghostbear

Member
Another way I've just thought about is using the data signal modulator etc on the pic itself.

The only thing is I believe it needs 2 separate signal sources as I can use the DSM on the 14M2 to AND two PWM signal together while enabling to two pwm pins to be freed up for other use.

So, what I'm thinking is along the lines of:

Setup PWM for frequency 1
Assign frequency 1 to the DSM module (which U believe then frees up the PWM pin
change the PWM to frequency 2
Assign frequency 2 to DSM to AND together with frequency 1

Anyone got any thoughts?
 

hippy

Technical Support
Staff member
You could do it that way and I was going to suggest that. There is only one PWMOUT channel on the 08M2 but you can use that to generate your 57.6kHz signal then probably modulate that at 1.8kHz using HSEROUT.

I am not sure that increasing duty ( of carrier or modulator ) would be the solution to your distance problem. That would normally be solved by pumping as much current through the LED as possible and using more than one LED. Higher current is usually achieved using a transistor or FET switch and connecting the LED to a higher voltage and/or using a low current limiting resistor.

For laser tag type systems I have seen, the transmitter usually has an optical focusing mechanism to ensure all the IR goes out in one direction as a beam, for example -

http://www.lasertagparts.com/mtoptics.htm
 

Ghostbear

Member
You could do it that way and I was going to suggest that. There is only one PWMOUT channel on the 08M2 but you can use that to generate your 57.6kHz signal then probably modulate that at 1.8kHz using HSEROUT.
I'll give it a shot then and see how we go.

I am not sure that increasing duty ( of carrier or modulator ) would be the solution to your distance problem. That would normally be solved by pumping as much current through the LED as possible and using more than one LED. Higher current is usually achieved using a transistor or FET switch and connecting the LED to a higher voltage and/or using a low current limiting resistor.
It has, hardware wise it's setup so that on a constant signal, the LED is getting 100mA.

When I put a single PWM signal to it, the current drops, depending on the duty cycle, which a 90% gives about 80mA

If I use just the pulsout, then the current drops to 10mA

Hence the process of elimination narrowing it down to the pulsout command and the duty cycle

For laser tag type systems I have seen, the transmitter usually has an optical focusing mechanism to ensure all the IR goes out in one direction as a beam, for example -

http://www.lasertagparts.com/mtoptics.htm
I know, the lens assembly we're using for this particular design increases the range from 3m to about 15m :)
The problem with the whole thing is that these circuits are fort the Ppg pistolsfrm Babylon 5 which are tiny, hence the 08M2 chip :)
 

oracacle

Senior Member
it maybe a case that the hardware still isn't correct. If you are using a FET I would suggest that you look at driving it in a totem pole type arrangement, this will require a higher voltage.
On of the problems with PWM signals is rise times. If the signal is gone before the FET, and for that matter the LED, as risen to it peak it will only draw a limited amount of current. IIRC average LED rise time is about 2.5ns, your pulse length should be around 17361ns based on your 57.6khz. check the rise time of your drive hardware, it should be less than 18µs (for turn on, rise, turn off and fall time total) at the very least. check the data sheet to ensure you have the correct drive circuit for that response time.
It maybe a case of actually driving the hardware with a constant current source of some description, this should "force" the set amount of current through the device.
How are you measuring the current under PWM condition as well? most equipment wont measure current at more than a few hertz, let alone into the kilohertz range, as a result you may not be getting an accurate reading for the amount of current flowing
 

hippy

Technical Support
Staff member
Untested ...

Code:
#Picaxe 08M2

Symbol B3600_4 = 1000000 / 3600

HSerSetup B3600_4, %10010 ;  1800Hz at 50% @ 4MHz

PwmOut C.2, 16, 33        ; 57600Hz at 50% @ 4MHz

PokeSfr $FC, %11000000    ; SFR $39C MDCON
PokeSfr $FD, %10001010    ; SFR $39D MDSRC
PokeSfr $FE, %00000000    ; SFR $39E MDCARL
PokeSfr $FF, %10100100    ; SFR $39F MDCARH

Do
  For b0 = 1 To 5         ; 5 x 5 bits x 4 bytes = 100
    HSerOut 0, ( $55, $55, $55, $55 )
  Next
  Pause 1000
Loop
 

Ghostbear

Member
How are you measuring the current under PWM condition as well? most equipment wont measure current at more than a few hertz, let alone into the kilohertz range, as a result you may not be getting an accurate reading for the amount of current flowing
I'm going on a mix of average current with multimeter and relative brightness of the LED.

I'll have a look at the rise/fall time of the 2n2222 transistors to see what there like (I'm at work at the mo) and see about improving that as well.
 

Ghostbear

Member
Untested ...

Code:
#Picaxe 08M2

Symbol B3600_4 = 1000000 / 3600

HSerSetup B3600_4, %10010 ;  1800Hz at 50% @ 4MHz

PwmOut C.2, 16, 33        ; 57600Hz at 50% @ 4MHz

PokeSfr $FC, %11000000    ; SFR $39C MDCON
PokeSfr $FD, %10001010    ; SFR $39D MDSRC
PokeSfr $FE, %00000000    ; SFR $39E MDCARL
PokeSfr $FF, %10100100    ; SFR $39F MDCARH

Do
  For b0 = 1 To 5         ; 5 x 5 bits x 4 bytes = 100
    HSerOut 0, ( $55, $55, $55, $55 )
  Next
  Pause 1000
Loop

I'll give it a test tonight and see.

Thanks :)
 
Top