Andy's LEGO® Mindstorms® Page
About this site
  
What's New?
  
Standard Disclaimer
Quite C
  
Francesco Ferrara
  
Getting Started
  
Installing Quite C
  
Compiling a project
  
Sample Code
Chess
  
The Robot Chess Project
  
Programming Chess
  
First Attempt
  
Version 0
  
Version 1
  
The Program
  
The State of Play
  
The User Interface
  
The Move Generator
  
The Move Applier
  
The Rating Algorithm
  
The Search Algorithm
  
Putting it all together
  
The Robot
  
The Head
  
Moving the head
  
Movies
  
Downloads: Source Executables, MLCad Models
4-in-a-Robot
  
4-in-a-Robot - the Robot
  
The 4-in-a-Robot Base
  
The 4-in-a-Robot Delivery Mechanism
  
The 4-in-a-Robot Controller
  
4-in-a-Robot - the Code
  
The 4-in-a-Robot Algorithm
  
The 4-in-a-Robot Control Programming
  
The 4-in-a-Robot Robot-less version
  
Installing 4-in-a-robot
  
Playing the robotless 4-in-a-robot
  
View the source code
Speech
  
The problems with speech
  
Sounds familiar
  
H8 Timers Background
  
Trial and Error
  
Volume Zapper
  
Actually Speaking
  
Speak.c - the code
  
The VB code generator
Some ideas for the future
  
Room positioning robot
  
Neural Net Bot
  
Pianola
  
Text to speech
LEGO® Mindstorms® Links

[268703]

Trial and Error

  After having a good look through the hardware documentation, I realised that the 8bit Timer 0 output could run as high as 8MHz - that would be too much for any speaker, so what would the effects on the RCXs speaker be?

I wrote a few test programs to have a go. Hmmm, lots of hissing. Whooo grating scratching noises. Oh dear, nothing at all. Try again - lots of times.

What I eventually found worked was

  • Set speed/8
  • Set reset counter on A
  • Set Output High on A
  • Set Output Low on B
  • Set A=32

This will create an extremely high frequency square wave. Now, by varying B between 0 and 16, we can control how wide the peaks of the square are. This affects the amplitude of the speaker (Eureka). Note you can't actually hear any sound yet - the square wave has a frequency of 65KHz, which is inaudible, although might annoy your pets (If they're bats).

What we have to do next is use another square wave made out of the super high frequency wave. Easy enough to do - just enable and disable the timer very quickly. I did this with a couple of nesting loops to get a zapping sound (i.e. frequency value goes from high to low by using the frequency value as the limits of a dummy inner loop - take a look at the next page and things will become clear).

The next page is the source code to the zapping program. It gives a quite discernable amplitude variation (although not perfect, could do with a bit of tweaking).


Back to: H8 Timers Background

Show Topic: Speech

Next Page: Volume Zapper