July 18th, 2011

Bus Pirate case


I was looking around for a small case to put by Bus Pirate in and I found these Microchip sample bins in which the Bus Pirate fits just nice. No need to make any openings cause I’ll only be using it for storage probably. Checkout the pics below.

December 14th, 2010

Logic Analyzer on PicKit2

Pretty much every time I tried to work with some sort of digital interface I run into some kind of trouble where a logic analyzer would have saved me hours of blind debugging and posting to various forums. Same thing happened when I decided to try the TMP121 temperature sensor from TI which has an SPI interface. It was the first time I worked with SPI on a pic32 and as expected nothing worked for the first try. The code for setting the SPI interface and reading from it seemed correct, I took it from the “32 bit peripheral lib user guide” from Microchip.

 //configure SPI
//start reading T1
mPORTEClearBits(BIT_0);		// pull CS low to prepare for reading
T1 = ReadSPI1();		// read 16 bit word
mPORTESetBits(BIT_0);		// pull CS high

So what else could be wrong ? Well at this point it could be a faulty sensor or incorrect use of the SPI interface maybe I wasn’t generating the clock correctly or maybe some wiring issue. This is the point where you need to have a logic analyzer. While I don’t have a proper logic analyzer I do have a PicKit2 and it can emulate a 3 channel, modest logic analyzer. I hooked up one of channels to the SCK pin and I noticed I wasn’t getting any clock signal. But why isn’t the clock being generated ? The answer came from the Microchip forums, the guys there pointed out that in order to generate the clock signal you have to issue a dummy write. By issuing a dummy write you start generating the clock and you can do the reading. So I added a new line to the code and tried again:

//configure SPI
//start reading T1
mPORTEClearBits(BIT_0);		// pull CS low to prepare for reading
SPI1BUF = 0x00;			// this sends a 0x00 just to make the clock toggle in order to read
T1 = ReadSPI1();		// read 16 bit word
mPORTESetBits(BIT_0);		// pull CS high

This time I also connected a second channel from the logic analyzer to the SDI pin on the pic32 (data in) and it worked 🙂 , here is the capture:Capture of TMP121 output data on SPI bus

As you can see on channel 2 there are 16 clock cycles corresponding to the 16 bit word sent by the TMP121 and on channel 3 connected to SDI(data in on pic32) is the actual binary temperature. If we analyze the data on Ch3, for every falling SCK edge we get 0001101010100000 we can discard the first bit cause its the sign bit (0 = positive , 1 = negative) and plug the rest of the bits in a calculator just to check the data.

binary data in windows calculator

note: windows calc discards the leading 0's

Next we convert to decimal and we get a value of 6816.

decimal data in windows calculator

6816 is not quite the number that we were looking for, but remember the data is represented in two’s complement so we have to divide it by 256 to get the actual temperature in degrees C.

actual temperature in windows calculator

The result after division by 256 is 26.625 degrees C. This was the room temperature at the time of this test. From here on everything is simple, I know I’m getting the right data out of the sensor its just a matter of processing and using it. And here is a picture of the PCB I made for the TMP121 in SOT23-6 package. Probably one of the smallest PCB I made at home, 3010 mm.

TMP121 temperature sensor PCB

Now I’m seriously thinking about getting the Logic Sniffer from Dangerous Prototypes, it’s a must have.

October 31st, 2010

MPLAB X is cool

You need to a flashplayer enabled browser to view this YouTube video

The new MPLAB X IDE from Microchip, still beta looks pretty cool and with new functions like code auto-complete, the ability to preselect which tools are used on which project, history, its gonna be a hit. I think the most useful function in MPLAB X is the history which allows you to go back and remove modifications you’ve made to the code. The code auto-complete is also nice. Let’s hope it passes the beta stage soon. Watch the video to learn more.

USB Bus Pirate

The USB Bus Pirate is a great project that can be used for testing new chips without writing any code. It is a universal serial interface device that is connected to the PC using the USB port.  The Bus Pirate currently supports serial protocols such as 1-Wire, I2C, SPI, JTAG, asynchronous serial and also has many other various features including PWM, frequency and voltage measurement, bus sniffers, pull-up resistors, and switchable 3.3volt and 5volt power supplies. The device receives commands from the user via a serial terminal.

The brain of the Bus Pirate is the PIC24FJ64GA002 microcontroller from Microchip, which is powered by a 3.3volt regulator. The programming pins are connected to a five pin header located on the lower edge of the PCB. The Bus Pirate is powered using the 5v supply at the USB port which is filtrated using a ferrite bead and a capacitor. The USB to serial connection is done using the FT232BL USB UART chip from FTDI.

The device possesses both 3.3v and 5v switchable supplies that are deactivated by default until a command is given. The circuit can be reset from software if needed. Also, the Bus Pirate has a CD4066BC quad bilateral switch that gives control over multi-voltage pull-up resistors, four voltage dividers connected to A/D converters which enable the pic to measure up to 6v DC, and three LEDs for power, mode, and voltage regulator status located on the upper side of the PCB.

The latest firmware of the Bus Pirate contains a modified bootloader from Microchip, so the firmware can be upgraded using the USB or the serial connection. A detailed procedure of upgrading is available in the link, as well as parts list, pictures and schematics. The Bus Pirate is available for purchase from Hackaday with worldwide shipping at $30.

USB Bus Pirate: [Link]

This is just a board I made to work with at school because normally I would not build anything on pic. I just wanted to show once again, that using the photo etching technique and some effective component placing you can obtain really nice results wether your building trough hole or SMT. The board has a quad op-amp for inputing and outputing analog signals and a max232 to provide a serial interface. It will be mainly used to gather data from sensors and send it on the serial interface to a computer.

PIC16F876 development board

© 2007-2011 YourITronics | Any logo, trademark and project represented here are property of their respective owners | Wordpress | Privacy Policy    RSS