Shop OBEX P1 Docs P2 Docs Learn Events
For all you model railroaders — Parallax Forums

For all you model railroaders

ArchiverArchiver Posts: 46,084
edited 2000-12-10 17:22 in General Discussion
[font=arial,helvetica]If you are running your trains with a power supply that has no sound, the
following little routine will give you a pretty good Diesel sound - not
perfect, but pretty good.

for x = 1 to 100
pwm 8, 250,9985
pwm 8, 250, 9986
next
pause 200
for x = 1 to 100
pwm 8, 250, 9986
pwm 8, 250, 9985
next
pause 200
for x = 1 to 400
pwm 8, 250, 9986
pwm 8, 250, 9985
next

This will generate two shorts and a long. ·By changing the "for x = " you can
generate whatever pattern you want.

You will need a speaker with a pre-amp. ·Best bet is a computer speaker from
Radio Shack or your computer store. ·Most of them have a pre-amp built into
on of the speakers, and they are relatively inexpensive. ·I cut the plug-in
jack off my speaker, and connected one of the two wires directly to my stamp
pin. ·You will have to try both wires to see which one is right. ·One gives
you very little sound, the other plenty of sound. ·Tie the shield to yiur
system ground.

Varying the duty cycle from 250 down decreases the volume, so I run at 250
and adjust my pre-amp. ·The cycles values, 9985, 9986, are very critical.
The only values that will work are from 9984 to 9988 - don't ask me how it
works. ·Have an idea your ear might be combining the frequencies to a
constant tone since it cycles so fast. ·Anthing below 9984 or above 9988 just
gives you pops in the speaker.

Hope it works for you.

Probably wouldn't hurt to put a 1K resistor between your output pin the the
pre-amp input.

Sid
[/font]
Sign In or Register to comment.