HOW-TO: BUS PIRATE V1, IMPROVED universal SERIAL interface

We use the Bus Pirate to interface a new chip without writing code or creating a PCB. based on your feedback, and our experience using the original Bus Pirate to demonstrate various parts, we updated the design with new features and more affordable components.

There’s also a firmware update for both Bus Pirate hardware versions, with bug fixes, and a PC AT keyboard decoder. check out the new Hack a Day Bus Pirate page, and browse the Bus Pirate source code in our Google code SVN repository.

We cover the design updates and interface a digital to analog converter below.

Concept overview

The Bus Pirate started as a collection of code fragments we used to test new chips without limitless compile-program-run development cycles. We released it in a how-to and used it to demonstrate a bunch of serial interface ICs in our parts posts. This post introduces an updated design with new features and a bunch of improvements.

Surface mount design

Pull-up resistors on all bus lines with external voltage source

Software resettable 3.3volt and 5volt power supplies

Voltage monitoring of all power supplies

An external voltage measurement probe

Cheaper parts

Perangkat keras

Click for a full size schematic image (PNG). The circuit and PCB are created using the freeware version of Cadsoft Eagle. All the files for this project are included in the project archive linked at the end of the article.

Microcontroller

We used a Microchip PIC24FJ64GA002 28pin SOIC microcontroller (IC1) in this project. The power pins have 0.1uF bypass capacitors to ground (C1,2). The 2.5volt internal regulator requires a 10uF tantalum capacitor (C20). The chip is programmed through a five pin header (ICSP). A 2K pull-up resistor (R1) is required for the MCLR function on pin 1. read a lot more about this chip in our PIC24F introduction.

RS-232 transceiver

An economical MAX3232CSE RS232 transceiver (IC2) interfaces the photo to a PC serial port. This chip replaces the expensive through-hole MAX3223EEPP+ used in the previous version of the Bus Pirate. The serial interface will work with a USB->serial adapter.

Bus pull-up resistors

The original Bus Pirate has 3.3volt pull-up resistors on 2 pins, but a lot of of our tests required additional external resistors. The updated design has pull-up resistors (R20-23) on the three main bus signals (data in, data out, clock) and the chip select (CS) pin.

A row of jumpers (SV5) connects each resistor to an external voltage supplied through the Vext terminal (X4). Through-hole resistors are used like jumper-wires to make the PCB much easier to etch at home.

We couldn’t find an sophisticated way to control an arbitrary voltage pull-up resistor variety from a 3.3volt microcontroller. If you have any ideas, please share them in the comments.

Sumber Daya listrik

VR1 is a 3.3volt supply for the microcontroller and RS232 transceiver. VR2 is a 5volt supply. Both require two 0.1uF bypass capacitors (C3-C6). J1 is a power supply jack for a common 2.1mm DC barrel plug. 7-10volts DC is probably the optimal power supply range.

The original Bus Pirate had dual power supplies, 3.3volts and 5volts, so a lot of ICs could be interfaced without an additional power supply. A major nuisance was the lack of a power reset for connected chips. If a misconfigured IC needed to be power-cycled, we had to disconnect a wire. We got so worn out of this routine that we added a software controlled reset to the updated design.

VR3 (3.3volts) and VR4 (5volts) are TI TPS796XX voltage regulators with an enable switch. A high level on pin 1 enables the regulator. A pull-down resistor (R13,R12) makes sure that the regulators are off when the photo isn’t actively driving the line, such as during power-up initialization. The datasheet specifies a large capacitor on the input (C23, C21) and output (C24, C22) pins, we used the same 10uF tantalum we use everywhere. An additional, optional, 0.1uF capacitor (C12,C11) can improve regulation.

The switchable regulators are powered by VR2, a 5volt supply.  We did this because the maximum input for VR3 and VR4 is 6volts, leaving the device with a narrow 5.2-6volt power supply range. VR2 will work well above 10volts, and supplies an appropriate supply for the other regulators.

VR3 (3.3volts) has plenty of headroom to operate from a 5volt supply. VR4 (5volts) will lose about 0.2volts, but 4.8volts remains well within the acceptable range for a lot of 5volt chips. In practice, and under light loads, we see less than 0.1volts drop-out from VR4.

Voltage monitoring

Voltage monitoring is a new feature we’re really ecstatic about. has your project ever mysteriously stopped responding because of an accidental short circuit? The Bus Pirate’s power supplies are equipped with voltage monitoring that can discover a change in power levels.

Each monitored signal is connected to an analog to digital converter (ADC) through a resistor voltage divider. two 1Resistor 0K (R10, R11 di atas) Membagi tegangan input menjadi dua, sehingga memungkinkan untuk mengukur hingga 6,6volts dengan mikrokontroler foto 3.3volt.

Bajak bajak laut memiliki empat monitor tegangan. Pasokan listrik 3.3Volt dan 5Volt dipantau, seperti tegangan eksternal yang diumpankan ke resistor pull-up. Monitor keempat terhubung ke Pin 9 dari header output untuk membuat probe tegangan.

PCB.

Klik untuk diagram penempatan ukuran penuh (PNG). Dewan adalah desain yang seharusnya satu sisi, kami terukir di lab pada PCB yang menahan foto satu sisi. Di atas, dekat C13, dua kabel jumper bertemu di satu via; Kami menyolder satu kawat jumper ke yang lain di bagian belakang papan.

Daftar Bagian

Bagian
Nilai

IC1.
Pic24fj64ga002 (SOIC)

IC2.
MAX3232CSE (SOIC-N)

Vr1.
LD1117S33 3.3VOLT Regulator (SOT223)

Vr2.
Regulator LD1117S50 5VOLT (SOT223)

Vr3.
TPS79633 3.3VOLT Regulator (SOT223-6)

Vr4.
Regulator TPS79650 5VOLT (SOT223-6)

C1-13.
0.1uf Kapasitor (0805)

C20-24.
10UF Tantalum Capacitor (SMC A)

R1.
Resistor 2000 ohm (0805)

R2,3.
390 ohm resistor (0805)

R4-13.
Resistor 10000 ohm (0805)

R20-23.
2.2K-10K ohm resistor (melalui lubang)

LED1,2.
LED (0805)

J1.
2.1mm power jack.

X2, x4.
Screw Clamp (2 terminal) * Diuji

X3.
konektor port serial perempuan DB9 * belum diuji

ICSP
0,1 “header pin, lurus

Sv4.
0,1 “tajuk pin atau header terselubung

SV5.
0,1 “header pin, lurus

Firmware.

Firmware ditulis dalam C menggunakan versi demonstrasi gratis dari kompiler Foto C30. Pelajari semua tentang bekerja dengan foto ini dalam pengantar kami ke seri Photo 24F.

Firmware paling saat ini diposting di halaman bajak laut Bus Hack A Day. Sumber saat ini ada di repositori SVN Kode Google kami.

Menggunakannya

Diagram di atas menunjukkan pinout bajak laut bus.

Kami membuat kabel dengan klip buaya pada akhirnya, dan menambahkan label ke setiap kawat sehingga kami tidak perlu merujuk ke tabel ini setiap kali kami berinteraksi chip baru.

Jika Anda tahu konektor atau kabel yang luar biasa, harap tautkan ke mereka di komentar.

LTC2640 SPI Digital ke konverter tegangan analog

Linear Technology LTC2640-LZ8 adalah Digital 8bit ke Analog Converter (DAC) yang diprogram dari SPI. DAC pada dasarnya adalah pembagi tegangan yang dapat diprogram. Mereka bermanfaat untuk menciptakan kembali bentuk gelombang, seperti sinyal audio. DAC 8bit memiliki 255 interval antara 0 dan tegangan referensi, bagian L yang kami gunakan memiliki referensi 2.5Volt internal.

LTC2640 hanya hadir dalam paket SOT223-8 kecil, jadi kami membuat adaptor breadboard di profil chip DIP-8. Jejak LTC2640 kami termasuk dalam arsip proyek yang terpasang di akhir artikel ini.

Skema di atas menunjukkan sirkuit tes kami untuk LTC2640. Ini membutuhkan catu daya 2.7-5volt, kami menggunakan pasokan 3.3volt bus bajak laut. C1 adalah kapasitor bypass antara pin listrik dan tanah. Pin 8 adalah pin reset rendah-rendah, ikat tinggi untuk operasi normal. PIN 7 adalah output DAC, menghubungkan probe pengukuran tegangan bajak laut (ADC) di sini.

Bajak laut bus.
LTC2640 (pin #)

MUSI
Sdi (3)

JAM
Sck (2)

CS.
CS / LD (1)

ADC.
Vout (7)

+ 3.3volts.
Clr (8)

+ 3.3volts.
VDD (5)

Gnd.
GND (4)

Kami menghubungkan bajak laut bus ke LTC2640 seperti yang ditunjukkan pada tabel. LTC2640 tidak memiliki pin output data, koneksi SPI ini tetap tidak digunakan.

Perpustakaan SPI Perangkat Keras dan Perangkat Lunak Bus Pirate Bajak Laut dan Perangkat Lunak Raw3Wire kompatibel dengan antarmuka SPI LTC2640. Kami menggunakan perpustakaan SPI; Jika Anda menggunakan pustaka Raw3Wire pastikan untuk memilih output pin normal.

Hiz> m <-elect mode 1. Hiz. 2. 1-kawat 3. UART. 4. I2C. 5. SPI. 6. JTAG. 7. Raw2Wire. 8. RAW3WIRE 9. PC di keyboard Mode> 5 <-spi atau Raw3Wire Set mode 900. Tetapkan kecepatan: 1. 30khz. 2. 125khz. 3. 250khz. 4. 1MHZ. Kecepatan> 1 <-test dengan kecepatan rendah ... 102 SPI Siap SPI>

Tekan M untuk menu mode bajak laut bus, pilih 5 untuk mode SPI. Ada banyak opsi konfigurasi untuk modul SPI, gunakan opsi default untuk semuanya. Setelah mode SPI siap, kita perlu mengkonfigurasi catu daya.

SPI> P <-power Setup Pasokan W / W Beralih Pasokan 3.3Volt? 1. No 2. Ya Mode> 2 <-use 3.3Volt suplai W / W Mengalihkan Persediaan 5Volt? 1. No 2. Ya Mode> 1 <-Jangan menggunakan suplai 5volt Pasokan 9xx dikonfigurasi, gunakan w / w untuk beralih 9xx Monitor Tegangan: 5V: 0.0 | 3.3V: 0.0 | VPullup: 0.0 | SPI>

P Membuka menu Catu Daya Bajak Laut Bus. Kami menggunakan pasokan 3.3Volt tetapi bukan suplai 5volt. Monitor tegangan memverifikasi bahwa catu daya mati.

Spi> w <-capital w (konyol css) memungkinkan catu daya Pasokan 9xx 3.3Volt aktif SPI> V <-Voltage monitor 9xx Monitor Tegangan: 5V: 0.0 | 3.3V: 3.3 | VPullup: 0.0 | SPI>

Modal ‘W’ memungkinkan setiap catu daya yang dipilih di menu sebelumnya, ‘W’ kecil menonaktifkannya. V Menampilkan monitor tegangan suplai, yang sekarang menunjukkan 3,3Volts output dari pasokan 3.3Volt.

Sekarang konfigurasi selesai, kami dapat mengirim perintah ke LTC2640 di atas bus SPI. LTC2640 memiliki protokol antarmuka 24bit (3byte). Byte pertama adalah perintah, diikuti oleh dua byte data. LTC2640 tersedia dalam versi 8,10, dan 12bit; Versi 8bit menggunakan byte pertama untuk mengatur DAC Value, dan abaikan byte kedua.

SPI> [0B00110000 255 0] <- Atur DAC ke Full 110 SPI CS diaktifkan 120 SPI Tulis: 0x30 <-Write DAC Command 120 SPI Tulis: 0xff <-DAC Nilai 120 SPI Tulis: 0x00 <-Donan 140 CS Dinonaktifkan SPI>

Setiap perintah SPI dimulai dengan mengaktifkan pin pilih chip ([). Byte pertama adalah perintah untuk memperbarui DAC (0B00110000), diikuti oleh nilai untuk output (255), dan byte ketiga yang diabaikan (0). Perintah berakhir dengan menonaktifkan chip pilih (]).

Kami menggunakan DAC 8bit dengan 255 langkah tegangan, output diatur ke 255 adalah 100%. Kita dapat menggunakan probe tegangan bajak laut untuk mengukur output.

SPI> D <-Measure Voltage Probe tegangan 9xx: 2.5Volts <-DAC output SPI>

D memicu pengukuran tegangan. Tegangan output DAC adalah 100% (255/255) dari referensi internal, 2.5Volts.

SPI> [0B00110000 0 0] D
110 SPI CS diaktifkan
120 SPI Tulis: 0x30 <-Write DAC Command 120 SPI Tulis: 0x00