kicad – video tutorial

Kicad is an open source (GPL) software for the creation of electronic schematic diagrams and printed circuit board artwork.

schematic editor & cvpcb (transcript):

pcbnew (transcript):

V-USB kicad project (clean):
http://www.workinprogress.ca/wp-content/uploads/kicad_vusb.zip

Kicad:
http://kicad.sourceforge.net/wiki/index.php/Main_Page

Update:
http://kicad.1301.cz/

Libraries:
http://kicadlib.org/
http://per.launay.free.fr/kicad/kicad_php/composant.php

24

01 2010

filtering pwm for music

i would like to start by saying that this solution might not be the best… if any analog guru read this, please leave a comment.

for 2.75$ you can have a chip that is able to run at 64 mhz (phase-locked loop) and output a pulse width modulation at 250 khz. attiny85 is your friend here. i didn’t found any atmega with this option (pll)… the good news is that it’s fast enough to output a stereo WAV at 16 bits / 48 khz. if you are interested in this project, take a look here: http://elm-chan.org/works/sd8p/report.html

since i want to connect the pwm output in a power amplifier, i need to filter the signal. here’s the waveform of the pulse width modulation @ 440 hz:

pwm_signal

now let’s see if we use a simple RC low pass:

pwm_filtered_rc_osc

looks good to me, but then testing with a triangle instead of an oscillator revealed this:

pwm_filtered_rc_tri

that’s not beautiful… here’s a close-up:

pwm_filtered_closeup_rc

maybe using more passive filter could help, but since you need to use an op-amp as a buffer (so that your load doesn’t affect the RC filter), why not use a sallen-key topology. this will act as an active low pass filter and a buffer. let’s look at the results:

pwm_filtered_sk_tri

close-up:

pwm_filtered_closeup_sk

not perfect, but better!

SIMULATIONS
simple RC (250khz = -22db)

sallen-key second-order (250khz = -44db)

sallen-key third-order (250khz = -67db)

third-order is the best and using this method only 1 stage is needed.

when choosing the op-amp, consider this:
100 * highest Q * GBW = Gain Bandwidth Product (read about it here)
slew rate => 2V/µs
i am using a rail-to-rail input / output op-amp.

now simply add an electrolytic capacitor (100 uf) and you can feed an amplifier with the original pwm signal (hopefully).

29

11 2009

pure data external pthread template

This external for Pure Data is using POSIX Threads for avoiding glitches in the DSP. Any recommendation to tight it up?

threadtemplate.tar.gz

Bonus:
Le chat sort du sac


Get the Flash Player to see this player.

19

10 2009

V-USB tutorial (software-only usb for mega & tiny)

Arduino use the FTDI chip for usb communication. This chip is expensive and only surface mount. To save money and be able to make a PCB at home, i found a software-only implementation of USB for AVR (attiny, atmega): http://www.obdev.at/products/vusb/index.html.

vusb_schematic

You don’t need the 2 LEDs.
It’s a visual feedback (debug, bootloader).

vusb_breadboard

I am using an ATMEGA164p.
The example code need to be modify to fit your device (bootloader address, registers, EEPROM functions).

This tutorial is for people who have some experience or are patient. Please pardon my english.

1) breadboard your avr for programmation (SPI / JTAG)

2) download vusb (last version)

BOOTLOADERHID (optional)
3) download bootloadhid (last version)
This bootloader doesn’t require a driver (it’s HID). With it, you will be able to program your firmware without your programmer.

4) delete usbdrv, cp the usbdrv from vusb
5) open usbconfig.h – change the VENDOR and DEVICE name if you want
6) open bootloaderconfig.h – set the pin for usb (USB_CFG_DMINUS_BIT – USB_CFG_DPLUS_BIT) and if you want to be able to reset via usb (USB_CFG_PULLUP_IOPORTNAME). Change the bootloadcondition to suit your needs, i am using the EEPROM to write (from the firmware) and read (from the bootloader) for the condition +  2 leds (so i know that i am in the bootloader).

show code ▼

7) main.c: Edit your condition, mine looks like this:
show code ▼

8) edit the Makefile

You need to know the BOOTLOADER_ADDRESS of your device (learn more about bootloader). Basically your datasheet will tell you the Start Bootloader section (look for Boot Size Configuration) in word address. You need to multiply it by 2 (the toolchain works on BYTE ADDRESS). For example, the atmega164p for 1024 words, the address is: 1C00 * 2 = 3800.

I am using a 20mhz clock, V-USB can be clocked with 12 Mhz, 15 MHz, 16 MHz or 20 MHz crystal or from a 12.8 MHz or 16.5 MHz internal RC oscillator.

Finally, you need to set the fuse correctly:

  • Boot Flash section size = 1024 words
  • Uncheck Divide clock by 8 internally
DEVICE = atmega164p
BOOTLOADER_ADDRESS = 3800
F_CPU = 20000000
FUSEH = 0xd8
FUSEL = 0xff
PROGRAMMER = avrispmkII
PORT = usb
...

make fuse
make flash

Now that you have the bootloaderhid, let’s write a simple firmware to test it.

test.c

#define F_CPU 20000000

#include <avr/io.h>
#include <util/delay.h>

int main(void) {

	// Set Port B pins as all outputs
	DDRB = 0xff;

  while(1) {

    PORTB = 0xFF;
    _delay_ms(100);

    PORTB = 0x00;
    _delay_ms(200);

  }

  return 1;
}

then:
avr-gcc -mmcu=atmega164p -Os test.c
avr-objcopy -j .text -j .data -O ihex a.out a.hex

cd bootloader/commandline
edit main.c if you changed the VENDOR and PRODUCT string
make

You need to connect the usb cable while holding the reset button. 2 LEDs should light up and you should see in dmesg something like:

[ 1727.956432] usb 3-2: new low speed USB device using uhci_hcd
[ 1728.119279] usb 3-2: configuration #1 chosen from 1 choice
[ 1728.142142] generic-usb 0003:16C0:05DF.000A: hiddev97,hidraw4: USB HID v1.01 Device [YOURVENDOR YOURPRODUCT] on usb-0000:00:1a.0-2/input0

Do:
./bootloadHID -r a.hex

FIRMWARE

Now what you want in your custom firmware is a way to tell your device to go in the bootloader (so you don’t have to hold the reset button anymore). With this method in place, adding the reset button is optional, but recommanded (in case you break something in the firmware, you need a way to go back in the bootloader).

Remember, in the bootloader we are reading the EEPROM to see if we need to stay in the bootloader section, if not we load the firmware. So in the firmware we will write the EEPROM if we want to go in the bootloader.
show code ▼

You are ready to write the firmware for your application. Since you are using V-USB not only it let you upgrade your firmware very easily, but you can of course send and receive message between your computer and the device. Here’s an example of sending the value of a potentiometer to your computer and telling your device to blink a led at a certain speed. This example is for my device, Atmega164p.

vusbtut.tar.gz

WINDOWS
You can trick Windows so it doesn’t popup the driver installation when you plug your device. Your need to use a HID descriptor (Vendor type requests sent to custom HID class device).

hiddescriptor.h
show code ▼

usbconfig.h
show code ▼

Here’s an example for installing the software & driver:
edubeat.zip

HOST SOFTWARE

Here’s the most basic host software written in python.
show code ▼

HARDWARE

V-USB runs on any AVR microcontroller with at least 2 kB of Flash memory, 128 bytes RAM and a clock rate of at least 12 MHz. For example the ATTINY25 can do the job. The price of this chip is 1.66 USD!

TEMPLATE

Here’s my template for the Atmega164p. This firmware is ready for ADC free-running mode, SPI master (you need to +5V PB4), external interrupts (PORTC), EEPROM read / write, jump to bootloader.
show code ▼

MORE INFORMATION

You can find more information about the API / USB Device Class / Host Software on the wiki of V-USB.

30

08 2009

speech recognition & arduino

Speech recognition done with Simon

26

08 2009

4 bits / 4 channels

Based on:
http://code.google.com/p/4bitsynth/

Atmega48 / pwm: square, triangle, noise.

4bitspcb

Aphex Twin in 4 bits / 4 channels:

25

08 2009

face 2 blender

21

07 2009

gesture recognition in pure data with easystroke

14

07 2009

sphinx3 to pure data

1- Basic software installation

sudo apt-get install build-essential autoconf libtool automake libasound2-dev python-dev subversion sox libsox-fmt-all

2- Getting and installing Sphinx3

Download:
sphinx3
sphinxbase

mkdir sphinx && cd sphinx
tar xzpf sphinx3...
tar xzpf sphinxbase...
cd sphinxbase
./autogen.sh --prefix=/usr/local
make && make install
cd sphinx3
./autogen.sh --prefix=/usr/local
make && make install
ldconfig
cd python
nano setup.py (MODIFY THE PATHS)
python setup.py install

3- Download the patch, python script and lexical

wget http://puredata.info/Members/patrick/sphinx2pd
tar xzpf sphinx2pd.tar.gz
cd sphinx2pd
pd sphinx2pd.pd

Make your own lexical and language modeling files (optional)
Upload your textfile containing your puredata commands here:
http://www.speech.cs.cmu.edu/tools/lmtool.html

Download the gzip’d tar file & unzip it to /dic
Dump in binary:

svn co https://cmusphinx.svn.sourceforge.net/svnroot/cmusphinx/trunk/share/lm3g2dmp
cd lm3g2dmp && make && cd ..
lm3g2dmp/lm3g2dmp dic/XXXX.sent.arpabo dic
mv dic/XXXX.sent.arpabo.DMP dic/pd.dmp
mv dic/XXXX.dic dic/pd.dic

07

07 2009

electret microphone amplifier


What is the difference between MIC and LINE level?

Level refers to the relative strength of the signal and is measured in decibels. LINE level sources are much-amplified signals over MIC (microphone) level signals. Line level is usually between -10 to +4 dbm in strength while MIC levels are normally -60 dbm.

Line OUT signal voltage and impedance levels?
The line output “standard” designed to drive a load of 600 ohms or greater, at a mean signal level of 0.775V RMS. An exception exists in respect of compact disc players, where the output level is most commonly 2V RMS.

Preamplifier schematic
Thanks to Andy Collinson for sharing his circuit design.

bc549_schematic

How does it sound?
Electret microphone
Sensitivity: -35 to +4dB
Signal to noise ratio: 62dB
Recorded at 96000 hertz @ 24 bits

emc_kalimba.wav (right click and save)

Comparing this Electret microphone (6$ USD) with a r-f-t funkwerk m16 mk (1700$ USD tube microphone):

electret.wav (right click and save)
m16mk.wav (right click and save)

03

07 2009

-->