On Fri, Oct 12, 2001 at 07:43:04PM +0200, CeDeROM wrote:
> I made such circuit on AT89C52 microcontroller, but chip is too slow for
> that job.

Odd .. I'd expect you could get away with using a timer or something,
but those timers may not be very good at PWM generation ..

> So I've diecided to use PC as a "fast microcontroller".

I'd really advise you against this.  PCs are not good
microcontrollers.  Trying to do a class D in software is .. well ..
I'd be interested to see if it could be done, but I doubt very much it
would work very well, if at all; the OS just won't be able to give you
processor time when you need it.  And you'll need a lot of it.

> But why not to write kernel module - the PC would stand on Linux.
> 
> So I have to write special driver for this amplifier.
> I think that writting it in assembly language would be the fastest
> choice.
> The speed is critical - I have to generate a signal of frequency more
> than 1MHz
> (or more - faster output frequency = better sound).
> I also, with sampling frequency of 11kHz/22kHz/44kHz, have to take
> samples form
> /dev/dsp (or some other sound output) and give them to output (serial
> port).

What you could probably get away with is doing the necessary EQing and
signal conditioning in software, and sending samples to a PWM
generation circuit.  But you'd need a fast interface.  One thing you
could try is using a S/PDIF output, connecting it to a S/PDIF
receiver, and converting that into PWM using a micro or even a CPLD.
There is absolutely _no way_ a regular RS-232 serial port (is that
what you meant?) will give you the bandwidth you need for this.

Even better: with this setup, you wouldn't need a kernel module at
all; you'd simply use existing ALSA drivers to generate a S/PDIF
stream.  Of course, your stream would not be "true" digital audio - it
would instead be specially made to generate PWM for your H-bridge -
but that's fine; the soundcard wouldn't care.

> I'd like not to invoke any libraries to program (totally platform
> independecy).

Hate to say it, but _total_ platform independence is an ideal we all
(except Microsoft) strive for, but can never really achieve.  Use
libraries - save yourself some time.  Plus, by running on Linux,
you're already very platform independent: and if you don't write a
kernel module, you can run on other _processors_ simply by doing a
recompile, if you don't use assembly in your user-space code.

> As for now I have one question - are there some timer functions in
> kernel?

Oh yes, but they are 100% unsuitable for doing real-time PWM, even at
baseband.  They're just event timers.

> If I finish it, lets make it part of ALSA project...?

Now _that_ would be interesting: class D support as part of ALSA!  You
could build a super high-powered amp for, say, US$100, including case.
:)

But still, I don't think this sort of thing really belongs in ALSA,
necessarily - I think it would be better done as a user-space program,
using the PC for the DSP stuff and an external S/PDIF circuit (or
something) for PWM.  (USB is another possibility.)

cheers

-- 

Michael Ashton <[EMAIL PROTECTED]>
----
Pray for:
- the souls of those who have lost, and will lose, their lives, as a
  result of the US terrorist attacks;
- the souls of those responsible, that they may see the destruction
  they have wrought, and repent, before it is too late;
- the United States, that its people will return to God for strength,
  and forgive; for the attackers "know not what they do";
- the agents of justice on Earth, that they may speedily do God's 
  will, whatever that may be.


_______________________________________________
Alsa-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

Reply via email to