37.9khz pulse

marzan

Senior Member
Hello.I need to create a 37.9kHz pulse for a infrared beam sent to a infrared receiver. Is there a better way than using a 555 timer chip? I need to use 2 or 3 irLEDs to receivers 1 metre away.

Thanks.
Marz.
 

inglewoodpete

Senior Member
All of the current PICAXE models can supply PWM from at least 1 pin. Using the PWMOut Wizard from the PICAXE Menu of the programming editor, input 37900Hz and 50% duty cycle to get a square wave at the frequency you want.
 

Haku

Senior Member
I was at one point trying to get some precice high frequency PWM outputs (over 300khz) and discovered that the pwmout wizard 'lies', even though you plug a frequency in and the wizard gives you a pwmout setting it doesn't automatically mean that the chip will output that precice frequency at that duty cycle.

I discovered through use of the calibfreq command you can tweak the pwmout by slightly adjusting the speed the Picaxe is running at.

You will need a multimeter with an accurate frequency counter to accompish this though.
 

Dippy

Moderator
marzan, follow IP advice. Though to guranteee anything you'll need a scope or meter described by Haku.
One or two other funnies with PWM wizard have been mentioned before but it is very useful.
Of course, you can always calculate it yourself.


Haku, you should be aware that PIC's PWM cannot produce every frequency under the sun.
Basically it is a clock and dividers.
For example, you cannot (straight from PWM command) get exactly 300kHz on a 4MHz clock, but you can get closer with a 16MHz clock.
This little problem needs to be remembered. Tweaking OSCTUNE can, as you say, adjust things.
If you do the calculations based on the PIC data sheet you will see.
You will also see that Duty steps change with frequency.
Everyone should be aware of the limitations.
 

marzan

Senior Member
Thanks for the replies everyone. Using a Picaxe was my backup plan. It just seems a waste using an 08M2 just to generate a pulse. But I guess they are cheap :)

Marz.
 

Haku

Senior Member
Haku, you should be aware that PIC's PWM cannot produce every frequency under the sun.
I figured that out pretty quickly when playing with the pwmout wizard when it gave the same settings for two different frequencies inputted.

Previously I'd only used PWM for driving LEDs or motors and had no problems with using the settings from the pwmout wizard, but when it came to trying to get precise frequencies I found my Metrix MTX3283 was very useful for showing the true frequency as it can also show duty cycle in percent and milliseconds.
 

Dippy

Moderator
If you want to do calcs easily get hold of Pic Multicalc.
Whilst it is not PICAXE related you can quickly see the frequencies you'll get on a PIC.
Whilst the PICAXE Wizard is extremely useful it doesn't warn you about frequency 'errors' and step limitations.
It's a PIC hardware limitation that sadly doesn't get mentioned in the World of PICAXE.
I use it successfully with what you call 'raw' PIC programming.
 

Dippy

Moderator
Doesn't everything Nick?

By how much does it vary Nick?
Are some 555s better than others?
What are the OP's requirements for temperature range, accuracy and stability?


It's often nice to determine these things before simply poo-pooing it.
 

erco

Senior Member
Temperature stability? Honestly?

First, most of those IR receiver modules don't care much about +/- 1 khz. Certainly not over 1M the OP mentions. My 56 khz receivers pick up a 38 khz remote signal just fine.

Second, the 555's temperature stability is 0.005% per degree Celsius, per http://www.fairchildsemi.com/ds/LM/LM555.pdf . Sounds pretty decent to me. If the external RC values fluctuate much with temp, the OP can decide what's best for his application.

The analog 555 may be 40 years old, but don't dismiss it so quickly. It's still relevant and plenty useful in many situations. http://en.wikipedia.org/wiki/LM555 It's inventor died just this year. RIP Hans. http://www.eetimes.com/electronics-news/4394166/Hans-Camenzind-dies
 

eclectic

Moderator
my problem in a nutshell. it could be in the sun one minute, then in the shade. Starts off cool in the morning,then possilbly very hot in a couple of hours.

Marz
Would it not be best to give the big picture?

What, exactly are you trying to achieve?

e
 

erco

Senior Member
If this is for outdoors, IR may not even be a viable option. IR receivers get swamped pretty easily even by indirect sunlight. Ultrasonics may be a better route.
 

marzan

Senior Member
Would it not be best to give the big picture?

What, exactly are you trying to achieve?

e
It seems looking at the later posts that I did not see it might not be that big a deal.

What I am trying to do is make a wireless timing setup for dog agility. For this part I need to have 3 infrared beams transmitting between 2 poles around 1m apart. the 3 receivers are sending to an OR gate set up on an 08M2. When tripped it toggles the 2 LEDs set up on one pin from green to red. it then sends a wireless signal via Dorji modules, either a 1,2 or 3 depending on which pole it is (start, split time, end). The receiver will probably be connected to another 08M2 to filter out any mistakes or false triggers. The 08M2 will then be connected to another PICAXE chip with 3 interrupts which will control the timer circuit and the display via I2C.

Marz.
 

marzan

Senior Member
If this is for outdoors, IR may not even be a viable option. IR receivers get swamped pretty easily even by indirect sunlight. Ultrasonics may be a better route.
I actually had them working using 38khz receivers, but in a much more complicated setup several years back. I didnt seem to have any trouble if I put them inside a tube and drilled holes to line up with the IR leds.But it was only to the stage of getting 4 separate signals to trip on a receiver using holtek chips. I never got any further than that at the time.

Marz
 

Dippy

Moderator
Nice one Westy.

It should be remembered that many of these standard IR receivers don't like continuous 38kHz* beams.
Some, apparently, will reduce the sensitivity and some will stop output.
So, you MUST read the data sheet of your chosen device.

Example Solutions.
1. Pulse the modulated beam and use 'missing pulse' methods in the Rx end.
2. Find one that is happy with continuous beams.
3. Roll your own receiver (my own method in a long beam setup).

All the required beam receiving logic can be done on PICAXE.
Personally, I would use PICAXE on Tx so that you can add 'smart' options easily.
Good IRLED choice and sensible shrouding/shielding should allow error-free operation at several metres.


*Assuming you are using a 38kHz IR Rx module - there are a number of Fqs available.
 

marzan

Senior Member
@marzan
Have a read of this basic IR tutorial I posted. It will give you some insights into various aspects of IR comms.
http://www.picaxeforum.co.uk/showthread.php?17303-Infrared-(IR)-Communications-Basic-Tutorial
I have actually read your excellent summary and i am using the circuits described. The difference is I am not using it for communication. I am using it as a beam. your article describes why I am using 38kHz receivers. Not all receivers work the way I need them to. some only work for a short duration, like a "burst" transmission. I need them to stay low for a long time, as long as the beam is not broken. I think I will probably use the setup you have for more than one IRLED on an 08M2,- or possibly use one of the 08M smd boards that rev-ed kindly gave me with some orders :)
 

Dippy

Moderator
Then investigate the suggestions I made in Post20.(Our posts probably crossed).
I'm sure there are other techniques you can use.
For 'missing pulse' detection you can always sneak that 555 back in :)
 

marzan

Senior Member
Example Solutions.
1. Pulse the modulated beam and use 'missing pulse' methods in the Rx end.
2. Find one that is happy with continuous beams.
3. Roll your own receiver (my own method in a long beam setup).
@Dippy,can you point me to any ifo on the "roll your own" solution :)

Marz.
 

marzan

Senior Member
@Westaust55. In the diagram on the IR tutorial under the heading 6.2 Higher power/longer range. could I alter the resistor between B.5 and the transistor to enable the use of 3 LEDs and resistors?
(O.T do you have any connection to Task force 72?)

Marz.
 

Dippy

Moderator
I've hunted for old schematic but my 'filing system' has let me down :( Sorry.
This was 2 years BP (Before PICAXE) so a) it wasn't PICAXE BASIC , and b) it used a chip now extinct TBA2800 (?).

Basically;
IRLED (10uS 5% duty) --> PhD-TBAAmp -->PIC

I can't see any reason why this couldn't be replaced with an appropriate op-amp circuit.
In my design I need some different behaviour (as I needed crude range-finding) but I'm sure you could do a 'missing pulse' section.
If hardware you could use a 555 or it could be done in code.


Just so you don't get Westy out of bed to answer...
In Westy's 'Enhanced' circuit you should keep in mind all the voltage drops.
He has 2 Vce for the transistors and 2 Vfs for the IRLEDs using a 5V supply.You need to check the Vf value of your IRLEDs to see if it would work. i.e. ADD UP all the worst-case Vfs - some can be 2V
NOTE: Vf varies with temp so is also a function of Current and pulse-length.
If it's a problem there is no reason why you can't run paralleled LED+R x3. (Note LED+RESISTOR).
I haven't checked trans values so I'm assuming they are man enough


And note; if you start doing high-power pulses off a power line shared with PICAXE V+ you will almost certainly need healthy decouple/reservoir caps. Maybe Westy could add that to his schematics.
In my old circuit I had to add 10R/220uF LoZ otherwise it messed my PIC.
 

marzan

Senior Member
Just so you don't get Westy out of bed to answer...
lol he must go to bed early they`re 2 hours behind us here in S.A.
If not there is no reason why you can't run paralleled LED+R x3. (Note LED+RESISTOR).
that`s what I meant but couldn`t think of the correct term.I would have to change the value of the resistor I imagine to allow for the extra current?

Marz.
 

Dippy

Moderator
Yup, good old Ohm's Law+.
Remember I= V/R?

Well, add in the voltage drop terms across semis.
I= (Vsupply - VdropsoftransistorsandLEDs) / R
Rearrange to determine R.
 

SAborn

Senior Member
All Marz needs is a IR photo interrupter over 1 meter, so why not convert the 38khz frequency to a analog voltage on RX and monitor that.
I done that 10 yeaes ago for a driveway sensor (before picaxe) A beam break means no 38khz pulse, so no analog voltage, and as far as i know its still in operation.
 

AllyCat

Senior Member
they`re 2 hours behind us here in S.A.
Hi Marz,

Don't you mean 2.5 hours, since you guys in S.A. seem to like a half-hour offset relative to nearly everyone else in the world? ;)

Caused me no end of trouble last month, trying to find a suitable "City" for my "automatic" watch in Queensland which doesn't use Daylight Saving Time (so an hour off Sydney even though the same longitude and half an hour off Adelaide). :confused:

Cheers, Alan. (now sitting solidly on the Greenwich Meridian). :D
 

marzan

Senior Member
Hi Marz,

Don't you mean 2.5 hours, since you guys in S.A. seem to like a half-hour offset relative to nearly everyone else in the world? ;)

:D
Allan you are right. It pisses you off at times. Some states don`t do daylight savings at the same time. It confuses me and I live here!!

Marz
 

inglewoodpete

Senior Member
Don't you mean 2.5 hours, since you guys in S.A. seem to like a half-hour offset relative to nearly everyone else in the world?
Wow, Alan. You're up with your time zone details! Actually, we Western Australians like to think we are 21.5 hours ahead of South Australia and 21 hours ahead of the Oz east coast (summer time of course).
 

westaust55

Moderator
@Westaust55. In the diagram on the IR tutorial under the heading 6.2 Higher power/longer range. could I alter the resistor between B.5 and the transistor to enable the use of 3 LEDs and resistors?
Hi marzan,
apologies for not getting back earlier (a few things on here at the moment).

I think Dippy has pretty much responded to your IR query.

If you look at the BC548/BC558 datasheets they are rated at Ic(max) = 100 mA.
The Vce(sat) can be relatively low at 0.2 Volts if you get "good" transistors but at worst case can be 0.6 V as Dippy has mentioned.
On a 5V supply with three in series, I believe you have no chance. With three in parallel as Dippy has mentioned, each would be limited to approx 30 mA current.

For higher current you will need to change to the BC338/BC327 transistors which are rated to 800 mA. The datasheets give no typical Vce(sat) but the max is slightly higher as 0.7 V.
Then you can run three (or more in parallel) and drive then with higher currents.

(O.T do you have any connection to Task force 72?)
No - had never heard of the group, but in searching I see it is related to model boats.
 
Last edited:

SAborn

Senior Member
IWP,

HAPPY NEW YEAR

Now thats 2.5 hours aheads of you, and 2.5 hours you need to catch up for the year, and should you still feel the West is behind the central time by 21.5 hours, all can only say is its a difference in your mind, because Australia aint that big for it to take 21 hours for the sun to cross to reach you.

It must be hard to know the rest of Australia has been there before you. ;)

All the best for the new year.
 

Dippy

Moderator
"It must be hard to know the rest of Australia has been there before you."
- are you talking about my ex-wife?
 

westaust55

Moderator
still rather OT . . .

IWP,

HAPPY NEW YEAR

Now thats 2.5 hours ahead of you, and 2.5 hours you need to catch up for the year, and should you still feel the West is behind the central time by 21.5 hours, all can only say is its a difference in your mind, because Australia aint that big for it to take 21 hours for the sun to cross to reach you.
To add to the possible confusion in Western Australia in the region from just to the east of Caiguna through Madura, Mundrallia and on to the WA/SA border there is a time zone known as "Central Western Time Zone" of UTC+8:45 so 45 minutes ahead of the rest of Western Australian and well warranted due to the earlier sun rise/sunset times for that zone/region relative the Western Standard time for the rest of WA.

Although it has no official sanction, it is universally observed in this area, and "official" enough that there are large road signs (by Main Roads) along the Eyre Highway at each end of the zone advising travellers about the time zone and recommending to adjust their watches/clocks (otherwise they may arrive at a service station/settlement outside their normal trading hours). The Central Western Time Zone covers an area that is approx 300 km wide.

and . . .

A HAPPY NEW YEAR to ALL from me as well
 

marzan

Senior Member
a HAPPY NEW YEAR to everyone on the forum.

I milled some new boards this arvo so I will put them together tomorrow (work permitting) and see if they work.

BTW to put the time zones into context these maps might help:
upfromaustralia_2242_2596474.jpg
Considering WA is approx 40% of the continent you can understand why people get shirty about the 2 hour difference between central and western timezones. I dont know of another continent that does that
 
Last edited by a moderator:

SAborn

Senior Member
I just hate daylight saving time, the birds wake me up an hour earlier, my tile floors fade much faster with the extra hour of sunlight, and my solar panels make too much power to early in the day.

Why do man need to mess with a thing like time? (although if they wound the clock back 20 years i could handle that)
 

westaust55

Moderator
I just hate daylight saving time, the birds wake me up an hour earlier, my tile floors fade much faster with the extra hour of sunlight, and my solar panels make too much power to early in the day.
Yer gettin' like the farmer who complained (over 20 years ago) when metrication occurred.
Complained he could not sell his farm as it only produced half as much grain, was half the size and now twice as far out of town.
If he considered earlier currency change the farm was going to cost twice as much for someone to buy as well.


Why do man need to mess with a thing like time? (although if they wound the clock back 20 years i could handle that)
Be careful what you wish for - no PICAXE chips 20 years ago ;)
 
Last edited:

SAborn

Senior Member
Be careful what you wish for - no PICAXE chips 20 years ago
Yes i had considered that, but optical interests was priority 20 years ago, and not needing a micro to stimulate the mind back then.
Its just a pity how the optical images change to micro views within 20 years.
 
Top