By adding an oscilloscope mode I noticed that PD2 is connected to potentiometer (as a pull-up Vcc). It was necessary to have an independent from the potentiometers button. Now PD3 (INT1) is used to go through different display modes.
In the oscilloscope mode you can amend TimeScale with the left potentiometer.
This weekend I’ve reviewed the sampling procedure used in the spectrum analyser and increased the sampling frequency, by moving it from interrupt procedure into the main loop. Furthermore I added some display modes of analyser spectrum. Display mode can be changed by pressing PD2 / INT0. Button is a shortcut to GND. On Pong Board it is the coin insertion “switch”.
Audio spectrum analyser driven by Atmega AVR seems to be a one of the favourite topics. Pong board gives us a nice display with 12 column ten LEDs each. This makes this display a perfect one for a spectrum analyser. I will not elaborate here any mathematics part of a spectrum analysis. What you need is a discrete Fourier transformation (DFT) or better to say a respective fast algorithm so called FFT. Luckily FFT (its fixed point version) was implemented for Atmega AVR by ChaN in 2005. See for details http://elm-chan.org/works/akilcd/report_e.html. I reused his code and by adding some neccessary lines I made out of the Pong board an audio spectrum analyser.
The audio signal is connected to the Right Potentiometer via 100µF capacitor. A really bad solution
The results are not bad – see two examples.
Remark: in the second video I used some commercial music. It has been flatten by my monitor speakers and microphone from digi cam but we know youtube . I hope they will not remove this clip or get rid of the soundtrack.
I’m quite satisfy with so simple implementation and a pretty good result. I would add here kind of op-amp as a input filter. Max239 from ChaN’s projekt seems to be a good idea. From the application point of view I would look closer to the size of the buffer used for data samples. A decrease to 32 and getting 16 results fits much better to our small display. And more display effects would make this more interesting.
The sounds at the begining part is not the best, I will make the video once again if someone will ask for
In the first video I used two free programs from http://www.marchandelec.com: very simple function generator and third octave real time spectrum analyser. It is a pity there is nothing similar under linux. The only one I found it was python based tone.py: http://aa6e.net/software/tone/index.html. It does not work for me in my new Pulse Audio environment (padsp does not solve anything). Another peace of software, a command line tonegenerator: http://www.lns.com/papers/tonegen/ works fine with padsp.
Any your feedback regarding Pong Audio Spectrum Analyser or a function generator under linux is highly appreciated.
After I had finished a “car race” for Pong board I switched to C. In my modest opinion Bascom is realy strange. As a preparation for my own pong version I needed some “printf” function. Unfortunately pong “screen” resolution does not offer too much space. 3 and a half simple characters pushed me to write a scroll version.
If you are going to write any text, numbers or whatever it might be interesting for you to look at the code.
I defined almost complete ASCII character set (small letters are missing). You can scroll a text from right to the left in a defined window. The text can be placed either in the SRAM or in the PROGRAM memory. It is a simple C null terminated text. The speed of scrolling can be amended with right potentiometer. In the source code you can find also a simple string print function.
Download the AVR 4 Studio / WinAVR files from here
Actually the first application I wrote for Pong Board from Conrad was a “car race”. This was mostly a quick & dirty prove of concept. I wanted to test the board and learn some basic features of atmega8. By the way I’ve never wrote a single code for atmega µControler before .
Any way here you have a next version of Need for Speed with a huge screen resolution of 12×10 pixels.
Download the bascom source and hex files from here.
Although it was only a quick attempt to make something different from ping-pong and a learning by doing approach You can find in the source code some interesting parts.
1) I’m initializing the random generator based on the value from ADC in order to make the road different each time.
2) The road is calculated in that way that there is always enough pleace for the car. The road outline/direction changes at least after two steps forward, in order to avoid a rapid changes left-right-left-right.
Probably I will rewrite this in c and add some more features
Download the AVR 4 Studio / WinAVR files from here
My code provides you some additional features in compare to the “original” firmaware of the Pong Board.
You can setup speed of the game in a more convenient way. Game’s result is displayed with digits. I created a bit more complex pong physics, by calculating dynamic of the pad movement. The quicker you move your pad the bigger is an angle the ball mirror. If there will be any demand to elaborate this or any other part of the code let me know.