Here are some notes on the design/project for discussion, based on
recent emails. Please free to comment/edit/agree or disagree.
1/ Communications to router. RS232 has been suggested as a first pass
as its simpler than USB and uses very little of the micro's CPU load.
RS232 is available on WRT54Gs via soldering a few wires (3V3 levels).
2/ A risk for me is the sound quality thru the A/D and D/A of the
microcontroller, however Marco suggests that the quality is
acceptable. I would like to rig something up with a telephone handset
to check this out, for example just digitise the speech and send via
RS232 to a x86 PC running Asterisk. This would require some Asterisk
channel driver hacking, perhaps to chan_oss which currently uses /dev/
dsp.
3/ What chip should we start with? Marco has suggested the ATmega8
($2). I am also looking at dspic, they are pricey ($7). Prices are
Qty 1 USD from http://www.digikey.com. The dspic has a 500 kps A/D
which makes multiple audio channels a possibility, ATmega8 just 15
kbps I think.
4/ Another possibility for connectivity is Ethernet. However the
chips are expensive, for example RTL8029, or DM9000A ($5). One idea I
had was to build out own Ethernet interface using a CPLD and VHDL/
Verilog code. This is not as crazy as it sounds, especially for a
short-haul link, fixed IP and MAC: http://www.fpga4fun.com/10BASE-T.html.
You can get Xilinx XC9536 chips for $2 that would be suitable.
Ethernet is the "natural" interface for routers, so this would be a
nice soilution. Also easy to extend over 100's of metres.
5/ One other major task is rigging up a ring generator using the
micro. My idea is to use the PWM & comparator to implement a switch
mode DC-DC converter. This would take 12V and generate say 100VDC.
We then modulate the DC-DC output voltage to generate a high voltage
sinusoid to ring the phone. This is how the FXS chip sets work, for
example silicon labs 3210. You can see the DC-DC part of the silicon
labs design here
(Q7, Q8, Q9):
http://www.rowetel.com/ucasterisk/downloads/fxsmod-0.33.pdf
I would love to hear all of your comments :-) I will buy a AVR or PIC
development board next week and get started.
Please feel free to ask me more questions (e.g. about the echo
canceller). I have a lot of stuff in my head that would be useful to
dump to this list.
Thanks,
David
You could also look at the
Ethernet - http://www.microchip.com/ParamChartSearch/chart.aspx?branchID=111&mid=10&lang=en&pageId=74
or
USB - http://www.microchip.com/ParamChartSearch/chart.aspx?branchID=121&mid=10&lang=en&pageId=74
PIC.
Cheapest USB PIC is $2.99 in volume, or $3.76 in 1-25 quantities from
Microchip Direct
Cheapest Ethernet PIC is $4.24 in volume, or $5.33 in 1-25 quantities
from Microchip Direct
Both need minimal supporting components, the USB PIC needs just an
oscillator while the Ethernet PIC also needs some magnetics (which
I've found a bit hard to source).
There sample rate is only around 100ksps however (@ 10Bits), but that
should be enough for one line.
I think you should look at doing most of the echo cancellation and
other things, not on the device. You just have so much more power on
the computer and you can do quite a few other interesting things to
help reduce echo. Although on the PIC with 1 line there should be
plenty of CPU power. The thing would be running at 12MHz (instruction
speed) and the device has a inbuilt 8x8bit 1-instruction multiplier.
PIC's also have better tools to work with them. See the GNU PIC page.
It would be really cool if we could fix up the simulator so that it
could simulate the USB/Ethernet modules on these devices.
The dsPIC's are not worth the effort, they are expensive and much
better devices can be gotten from the same price (from TI or others).
The only thing they have going for them is that they are very simple
to program.
Hope this helps.
Tim Ansell
I have spoken to a friend re implementing an Ethernet interface in
CPLDs. He says the problem is that it would require an FPGA with plenty
of internal RAM for the packet buffer (several hundred bytes even for
short packets) which rules out low cost FPGAs.
> I think you should look at doing most of the echo cancellation and
> other things, not on the device. You just have so much more power on
> the computer and you can do quite a few other interesting things to
> help reduce echo.
Moving some of the DSP into the router is also a possibility that we can
consider. Hmmm, I wonder if the router instruction set includes any
efficient multiply instructions?
The problem with these routers is that (unlike a x86) they are not
particularly powerful, so the DSP capabilities of something like the
ATmega chips (2 cycle, 16 bit multiply) might be helpful. Marco has
shown with his designs that real time DTMF decoding is possible, and I
have estimated that the simple echo can we require should also be
possible.
Anyway, perhaps we should check out the CPU load of doing the DSP on
both the router and micro, and see what results we get.
> The dsPIC's are not worth the effort, they are expensive and much
> better devices can be gotten from the same price (from TI or others).
> The only thing they have going for them is that they are very simple
> to program.
>
> Hope this helps.
It certainly does, thanks Tim :-)
- David
I have had a look at the PICs with buily in Ethernet, e.g.
PIC18F66J60. Do you know of any readily available development
systems? They seem to be a new release. Also, for PIC work in
general, what sort of starter kit/development system would u
suggest?
I have located a local (.au) source for ATMega dev systems,
http://www.futurlec.com.au.
Cheers,
David
Depends on how long you want to wait :P
I'll be doing some later this year. Currently I don't know of any
development boards with either the either the Ethernet PIC or the USB
PIC.
Tim Ansell
I tried to post a reply yesterday, but something must have gone wrong
- sorry if this ends up as a double post.
You might have already seen this, but the only development board I've
found for the ethernet PIC is the PICDem.net 2 Demonstration board,
DM163024 - http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en028217.
It uses the PIC18F97J60 chip. I haven't found a distributor for it
though - the only place I've found to get it is Microchip themselves -
http://www.microchipdirect.com/productsearch.aspx?Keywords=dm163024.
They sell it for US$165, and it has a shipping date of 2 May, so it
will cost more and be a longer delay than to set up for the AVR
platform.
The next cheapest way I've seen of getting an ethernet interface is
Microchip's SPI ethernet controller ENC28J60. It sells for $3.72 ea
from Microchip ($3.54 qty 100), or about $7 ea from Digikey. So using
it with the ATmega8 is going to work out about $1 more than the PIC.
I'm also not sure what effect the networking would have on available
CPU cycles and flash memory - it might be necessary to change to a
different device I suppose.
Matt
I hope to have my development board available in kit form for about
$AUD25 (for Ethernet) and about $AUD20 (for USB).
The price is mainly dependent on my ability to source cheap PCB's.
> The next cheapest way I've seen of getting an ethernet interface is
> Microchip's SPI ethernet controller ENC28J60. It sells for $3.72 ea
> from Microchip ($3.54 qty 100), or about $7 ea from Digikey. So using
> it with the ATmega8 is going to work out about $1 more than the PIC.
> I'm also not sure what effect the networking would have on available
> CPU cycles and flash memory - it might be necessary to change to a
> different device I suppose.
>
> Matt
>From what I understand the ENC28J60 is being discontinued. When I
contacted Microchip for samples they were unsure if production was
continuing.
Tim Ansell
> The next cheapest way I've seen of getting an ethernet interface is
> Microchip's SPI ethernet controller ENC28J60. It sells for $3.72 ea
> from Microchip ($3.54 qty 100), or about $7 ea from Digikey. So using
> it with the ATmega8 is going to work out about $1 more than the PIC.
Thanks for pointing that chip out Matt. So it now looks like we now
have several interface options that could be used to build a $10 ATA:
+ Ethernet via the SPI Ethernet controller
+ Ethernet via a Ethernet PIC
+ USB via a USB PIC
+ USB via a software implementation on a PIC/Atmel (perhaps on a small
stand-alone device due to the CPU load).
+ RS232 on just about any chip
To get started I have ordered an ATmega16 dev system (I chose this just
because it was easily available locally). I would like to try a subset
of Marco's code, in particular pipe some audio to and from the micro via
RS232 and check out the sound quality.
Cheers,
David
> I hope to have my development board available in kit form for about
> $AUD25 (for Ethernet) and about $AUD20 (for USB).
>
> The price is mainly dependent on my ability to source cheap PCB's.
I have just been thru the exercise of sourcing cheap PCBs - there are
some remarkably low prices available from China. For example I am
getting 5 IP04 PCBs, which are 200mm x 100mm 2 layer boards that look
like this:
http://www.rowetel.com/ucasterisk/images/ip04.png
for US$3 each! Tim, for a small dev system PCB in Qty 100 say I would
imagine < $1 each.
Cheers,
David
I hope to have my development board available in kit form for about
$AUD25 (for Ethernet) and about $AUD20 (for USB).
The price is mainly dependent on my ability to source cheap PCB's.
>From what I understand the ENC28J60 is being discontinued. When I
contacted Microchip for samples they were unsure if production was
continuing.
I have just been thru the exercise of sourcing cheap PCBs - there are
some remarkably low prices available from China. For example I am
getting 5 IP04 PCBs, which are 200mm x 100mm 2 layer boards that look
like this:
http://www.rowetel.com/ucasterisk/images/ip04.png
for US$3 each! Tim, for a small dev system PCB in Qty 100 say I would
imagine < $1 each.
> David, can you let me know the details of who you decided to go
> through? Have you spoken to anyone who's used them before? What's the
> quality like? Do they charge a setup fee?
Well actually a friend in China has set this up for me:
However I am sure it is possible to contact companies there directly. I
am expecting my IP04 PCBs today, so will report on the quality then.
Setup was about $35.
> I've been trying to find a place to make up boards myself, the most
> likely place so far is here in Singapore, and is going to cost about
> US$6 ea for a run of 4 BF1 boards, but there's almost $200 artwork and
> setup costs for the first run.
Well that's not too bad, the bf1 is a largish board.
Cheers,
David
>
> >
Just like to point out that the USB PIC's come in PDIP form and can
easily be worked with on veroboard. They only require 5 supporting
components (2 capacitors, 4MHz crystal, 1 USB Connector and 1
Resistor).
I would recommend just ordering a few free samples from Microchip.
Tim Ansell
Thanks,
David
Well, I'm working on the RS-232 phone idea. I think it has the best
chance of being the cheapest, easiest to build, debug and get
going as fast as possible -- not to mention very easy to interface
with.
Ultra-minimalistic approach: an ATMega8 with the ADC nearly
directly connected to the microphone and the PWM-based audio
output going to a lowpass filter and to the loudspeaker. A buzzer
on another ping replaces the ringer. Seven pins handle the keypad
scanning.
I'd particularly like to see if we can do all this while using only
the serial port's power (about 5-6 mA tops). I'm using a small
NiCad battery to get a little more current to supply some extra
current to make the buzzer loud enough to act as a ringer.
The code for the AVR Contest may be a little too much for
this project. The strict timing imposed a somewhat annoying
code structure. The whole MMC/SD think is not needed. It's
possible to make the whole thing a lot simpler than that.
I've considered and postponed the idea of making an
analog phone to RS232 converter. As you pointed out earlier,
generating the correct voltages and currents is tricky and likely
to blow past the $10 budget.
I'll keep you guys posted on my results.
--Marco "Kiko" Carnut
--www.postcogito.org
> Well, I'm working on the RS-232 phone idea. I think it has the best
> chance of being the cheapest, easiest to build, debug and get
> going as fast as possible -- not to mention very easy to interface
> with.
>
> Ultra-minimalistic approach: an ATMega8 with the ADC nearly
> directly connected to the microphone and the PWM-based audio
> output going to a lowpass filter and to the loudspeaker. A buzzer
> on another ping replaces the ringer. Seven pins handle the keypad
> scanning.
Excellent! So are you using the case/keypad/chassis of an existing
telephone? I guess you don't need DTMF decoding & and echo canceller,
so that will save a lot of MIPs and implementation time. Nice :-)
You know one idea I had for a _very_ cheap keypad was to use just a bare
PCB - the resistance of your finger crossing two nets would be enough to
tie a net high or low. I am not sure how robust the keypad would be
over time, perhaps gold plating could be used for the contacts. BTW my
finger tip measure 1.1 Mohm (dry) :-) That way to "phone" would be a
PCB with the micro, the keypad area of the PCB, and a connector for a
phone handset (mic + speaker).
> I'd particularly like to see if we can do all this while using only
> the serial port's power (about 5-6 mA tops). I'm using a small
> NiCad battery to get a little more current to supply some extra
> current to make the buzzer loud enough to act as a ringer.
RS232 power is a really cool idea. The nicad (or a large capacitor) is
a good idea for short powers burst, recharge over time. I guess you
need to determine if 5-6mA max current drain can be sustained over time,
say during a long phone call.
> I'll keep you guys posted on my results.
Thanks. I have received my ATMega16 system just today so will take a
look at that over the next 1-2 weeks. Right now I am very busy bringing
up my http://www.rowetel.com/ucasterisk/ip04.html IP-PBX board, a
related embedded telephony project.
Would any one out there like to look at modifying Asterisk to handle
speech sample I/O via RS232?
Cheers,
David
>
> --Marco "Kiko" Carnut
> --www.postcogito.org
>
>
>
I've been working with a BF537 board and David's 4FX hardware for a
few months and I'm quite excited to have the opportunity to
contribute.
> Would any one out there like to look at modifying Asterisk to handle
> speech sample I/O via RS232?
I'm currently working with a few of the Asterisk channel drivers with
the intent to create a chan_rs232 driver. My initial goal is to
communicate between two asterisk machines via the serial port.
Other than introducing myself, I don't have much to report - yet.
Brian
> > Would any one out there like to look at modifying Asterisk to handle
> > speech sample I/O via RS232?
>
> I'm currently working with a few of the Asterisk channel drivers with
> the intent to create a chan_rs232 driver. My initial goal is to
> communicate between two asterisk machines via the serial port.
Excellent, thanks for the help. Testing between two PCs is a good idea.
I would suggest that one PC emulates the micro. It doesn't need to run
*, just send audio samples at a rate of 8kHz over the RS232. You might
be able to do this with a simple pipe or redirection from the command
line:
cat dev/dsp > /dev/tty
On the * machine I would suggest chan_oss is very close - just replace
the reads to OSS with reads from the serial port. It can be conveniently
controlled from the CLI to make testing easy.
Cheers,
David