Close

Frame Driver Construction: MCU

A project log for Laser Galvo Clock

Clock projected onto the wall with cheap laser galvos

Alan GreenAlan Green 06/25/2019 at 11:140 Comments

I spent the past few days soldering up the PIC32 MCU and getting it to work with the Raspberry Pi. 

It's Going To Work. Hooray! There were a couple of tweaks to the schematic, one dead PIC32, and a couple of moments of utter confusion with Microchip's MPLAB Harmony, but we're now in a good place.

Goals

I did this first since the PIC32 is an unknown for me - hence something that might go wrong. If it wasn't going to work, I needed to know early.

As a proof of concept, I had the PIC32 use a timer to blink an LED in a pattern. It also acted an SPI slave, ready to accept data from the RPi that it would use to change the LED blinking pattern.

Planning and Construction

Initial Planning SheetThe picture to the right is a scan of my first planning sheet. While constructing it, I made a few changes, which you can see in the larger image, below.

One of the nice things about working on a Blueboard#01 is that one can almost always try a new configuration if something doesn't work. It also lends itself to constructing a circuit in stages.

The picture below is me getting excited about soldering up my first PIC32. Flux is on the footprint, and moving the chip into position.

My First PIC32, Ready to solder
Ready to solder

The end result was fairly neat, with only a few solder blots. Most of the wiring is hidden on the back of the board.

And the final planning sheet:

Planning sheet, after further iteration
Planning sheet, after further iteration

Software and Testing

The PIC32 sets up one timer peripheral and one SPI slave peripheral. It has a buffer containing a pattern.

I used the MPLAB Harmony framework, the MPLAB IDE and the the MPLAB Snap programming tool. Microchip should send me a T-shirt.

On the RPi side, I used Python and spidev. Spidev appears to be installed by default, which is great. It's pretty straight forward to send a bunch of bytes to an SPI slave.

Here it is, all together. The laptop has a window open to the RPi, the RPi is wired to the PIC on the Blueboard#01, and the Blueboard#01 is being probed by the oscilloscope. 

Everything working nicely

There are a lot of wires. I did this because the PIC32 is highly configurable, and I wanted to make sure I had the connections right, so I used 0.1" header pins pressed into the Blueboard#01, with dupont wires to make temporary connections. I'll solder in permanent connections, behind the board now that I know it works.

The oscilloscope is probing via a row of 0.1" header pins pushed into the Blueboard#01. With SPI running a 1 MHz clock, there were no problems at all. Channel 3 (magenta) is the clock:

Oscilloscope trace at 1MHz
No problems at 1MHz

It also works at 20MHz. This is suprising to me, given all the dupont wires going everywhere. At 20MHz, the waveforms are less well defined:

Lessons Learned

Next Steps

Next up, I'll solder up the DAC and op-amps. 

Discussions