Move to PIC Microcontrollers

I started, as with many others programming the Arduino. This post is more about moving away from Arduino towards PIC and the reasons for doing so. But don’t get me wrong, Arduino is a great platform and very powerful.

Introduction

Firstly PIC and Atmel are now the same company, Microchip, who have always develope the PIC chips and recently bought out Atmel. One of my decisions to switch was the thought about the future of Atmel and would Arduino maybe one day use PIC instead of AVR.

I am the type of programmer that likes to know as much as possible what is going on, I found myself very early on learning how to directly manipulate the registers with AVR on Arduino and trying as much as possible to move away from the libraries.

As a beginner the libraries are fantastic, you can download programs and easily upload them to your board and modify for your own needs, it is so much easier to program Arduino than PIC at this stage.

But I soon found myself wanting to make my own PCBs and taking the AVR chip off the Arduino board and then wanting to expand to the 40 pin chips (ATMega 644) and programming them via the SPI interface with the USBAsp.

PIC is similar to this with the PICKit.

Programming PIC vs Arduino

The programming environment for Arduino is easy, USB to your board, upload the sketch, done.
Alot of work is done via the Arduino platform that you don’t really need to worry about at an early stage.

With PIC you have to do everything, setup the oscillator registers, all the configuration bits. But this is what I like, more deeper control into the microcontroller.

But once you’ve done this a few times, it’s quite straight forward to look at the datasheet and set the registers, all the config bits are done in MPLAB X.

Why I move to PIC

The simple reason I moved to PIC is the greater choice of microcontroller available. You can use the parametric search and find the chip that’s perfect for your job. A 28 pin with 2 UARTS, the ATMEGA 328 only has one, same pin count.
And of course the greater feeling of control with the software and programming.

I feel personally PIC is a more professional platform.

PCBWay PCB Review

Many years ago when I first started with electronics, back in the mid to late ’90s I tried to build my own projects, struggled with stripboard and they never looked great. I tried the etch your own PCBs with the marker pen and Ferric Chloride. It was OK But never the best!

I gave up with electronics back then and it’s only in the last few years I have regained that passion I had when I was young.

Being able to have my own PCBs produced, from my design on the computer really has opened up a whole new world.
Thanks to PCBWay.


I am really impressed with the service and quality from PCBWay. This new set of boards arrived on the 27th July and were only ordered on the 22nd.

Choosing a different solder mask always takes slightly longer to produce which I understand, but this only took just over 4 days to be produced and shipped to the UK.

There are many different solder mask colours to choose from, I have yet to sample them all but at the moment I really like the blue finish.

 

The first thing I noticed was the very shiny and smooth finish, the board looks very professional.
When desiging boards on a computer screen it is really nice to see them actually produced and in your hand.

The whole process I found very easy, the website is easy to use, you can track the status of your order online every step of the way.

 

Everything fits perfectly, all holes are drilled exactly as designed.

If you can get your boards within 100x100mm you can get 10 PCBs for $5 at PCBWay. Costs of course increase when you want larger boards, or multi layer boards due to the extra manufacturing required. But even then you still get a very reasonably priced professional PCB.

 

Custom PCBs

A batch of new PCBs have arrived from PCBWay.

I have recently stared to use PCB Way for my PCBs, they are a very efficient service and have a very fast delivery time. The factory manufacture them in 24 hours or a little longer if the board is more complicated. Then it’s down to the couriers for the delivery time. I have had them within 7 days sometimes much faster.

Once you upload your gerber file they do an engineering check to make sure everything is OK for production, and you can monitor the progress every step of the way.

www.pcbway.com

There’s a variety of solder mask colours available from the standard green.

Please see my YouTube channel for more information

June 2020 Project updates

This is what to expect in the coming months on my YouTube channel.
I build a lot of things with the Z80, this being a specialist interest I am going to develop circuits that can be more accessible for anyone to build.

Upcoming:

PT2399 Chorus upgrade for the Z80 Synthesizer
Z80 sequencer
Audio Power amplifier and associated accessories, VU Meters / Audio mixers etc
PIC Based DCO
Programmable mono synth prototype

 

PT2399 Chorus
The ‘Little Angel’ design has been tested and modified to work with the higher voltage line level outputs of the synthesizer, the board will be mounted¬† above one of the voice boards and routed with a switch to enable and disable the effect.

Z80 Sequencer
All PCBs have been completed, this project will be on going as there is lots of programming to do, assembly and design.

Audio Power Amplifier
A series of videos about the amplifier build and projects you can complete yourself such as a simple audio mixer and VU meters.

PIC Based DCO
I am developing a chip based on a PIC16F15356 running on a 16MHz Crystal that can output a square wave for the DCO.
This can be developed as a control chip or a DCO complete board that is more accessible to people to build.

Programmable mono synth
A project that will probably for now remain as a prototype but all designs will be public, another project that is accessible.

RH-101 Synthesizer – Complete

This is the completed version of my SH-101 style synthesizer

 

The synth has a single 3340 voltage controlled oscillator with square, saw and a sub octave that can be all mixed together at different levels. The sub octave uses a 4093 schmitt trigger NAND gate to generate a pulse from the saw wave (we don’t use the square output as this has PWM adjustment and we want our sub to be a 50% square) This pulse goes into a 4013 divider where it is divided down twice (-1 and -2 octave), then there is a rotary switch with 3 options and a diode steered -2 octave with 75% duty cycle.

Once the oscillators have been mixed they go into a 3320 filter, using the virtual ground summing node the filter provides. The final VCA is a 3360.

Modulation

There is a single 3310 envelope generator which uses a re trigger option so the envelope can be re triggered when a new key is pressed.
The envelope output goes to the filter CV via a level pot but also distributes out to the VCA and PWM

VCA: Switch between Gate or Envelope trigger
PWM: LFO1 or Envelope with adjustable level
Filter: Envelope (adjustable), LFO2 (adjustable) and direct CV control with Resonance

The entire synth fits on a small PCB and is controlled with a PIC 16F1516 and a dual MCP4922 DAC (which does the oscillator CV and the key track offset voltage)
It’s a single mono synth with MIDI In, there is no patch storage available, this just gets too expensive and difficult sometimes.

LFOs

There are 2 LFOs, 1 is for the PWM and 2 is for the filter, with and adjustable level. The LFO is square wave only and is generated from the MIDI clock with 3 options:
1: Beat
2: 8th Note
3: 16th Note

Below is a link to the whole repository including:
PCB Files in KiCAD
Software in MPLAB X  (For PIC 16F1516)

https://drive.google.com/drive/folders/1VtsbTb-uA2jX1FQZ5N9y59OMS3xPtcG2

All the downloads are completely free and this project is open source, but please consider donating, there has been alot of time put into the testing and design.

https://www.paypal.me/rhelectronics

Sample and Hold

Sample and Hold was the way to get more than one analog output from a single DAC.
We can analog multiplex on reading analog inputs, this lets us multiplex outputs too.

How it works

There is a single DAC which is connected to an analog multiplexer chip such as the 4051, this is an 8 channel. The output of the multiplexer has a small capacitor before a voltage follower buffer. The size of the capacitor is dependent on the refresh rate, i.e how often the CPU loops round and updates the output values. 100nF works quite well if the outputs are updated every loop.

Operation

Set DAC value
Set output address
Sample
Next address
Loop

The ‘sample’ part above uses the inhibit input of the 4051 to do just that, inhibit the output while the DAC and address are being written, then the output can be enabled allowing the voltage to be stored in the hold capactitor.

The image above is simplified, single channel, the AI is Analog In. The capacitor before the second buffer is our hold capacitor, when the C input is enabled, the voltage from AI is stored and transferred to AO. The 4051 multiplexer replaces this switch, giving us 8 outputs.

Most 80s synthesizer schematics use sample and hold for all the control voltage parameters, I don’t use this method anymore because DACs are easier and cheaper now. But however there may be occasions where this could be still used, if I design any 80s based system then it is worth using to make the circuit more authentic!.