Thursday, November 28, 2013

ADC error and Switch debouncing

Now that I have the IO hardware working, I have noticed a couple of issues in the potentiometers and switches inputs to the AVR:

  1. Potentiometers readings in the ADCs are not stable and seem to fluctuate
  2. Switch readings are bouncing on button press.
I found this great site: Newbie Hack where both topics are covered and clearly described. For the ADC stability issue, you can find this way of measuring the error. No info is giving on how to remove this problem, but I suppose a low pass filter should do. As for a way to do switch debouncing, you have it here

Still need to implement this solutions and try.

Update (12/03/2013):
Fixed the switch debouncing by only reporting switch changes after a certain number of unchanged reads, similarly as explained in the links above.
For the Potentiometers, I added some histeresys, I only report potentiometer changes when the read value exceeds the previously sent value by a certain amount, which gets rid of all bouncing issues, althought the cost is high as the potentiometer changes are not as smooth as they could be. still need to work on that.


JUNO6PM Enclosure

Been working lately on casing all the hardware. This is how the box is looking now:



And these are the internals:



Still need to add a power off switch, audio input jack (I plan to use the same hardware for guitar processing), external USB and Ethernet connector, but at least I have all the synth part hardware ready.

Sunday, November 17, 2013

Powering my RasPi

Just as many others, I got a small TFT monitor used in car reverse cameras. This monitor has a 12V DC input for power but, as SK Pang points out here, internally it has a 5V regulator and uses that for powering the unit. Unlike what SK Pang did, I did not need to replace the 12V power feed with a 5V one, what I did instead was get the 5V required for the Raspberry Pi from the monitor Regulator. 
My monitor is slightly different model from the one SK Pang has (although it looks identical externally).

The picture bellow shows how I connected a USB cable for feeding the RasPi:


And this is my RasPi powered by the monitor and showing a quick mock up of how the GUI will look. I used Mindchunk's OpenVG library to make that GUI (for now it is just a quick and dirty test).

Using Raspi Serial Port

Lately I have managed to find some time to dedicate to this project. I am currently working on the Hardware side, will have some pictures of the box I am making soon. I am also starting to do some GUI work using openVG. And just today I connected my AVR board to my Raspi via serial (was using PC before). I will be explaining the details of this last effort in this post.

So I am using the Raspberry Pi serial port to communicate with my AVR board handling all the control I/Os. I will explain here what I did for getting that to work:

The first step was to disable the console output via serial port. To do so, you need to edit the file /etc/inittab and comment out the following line:

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

And editing /boot/cmdline.txt removing the references to ttyAMA0. This:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Should look like this:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait 

This info is all coming from here.

Once that is done, since I am working at MIDI speeds, you need the change the the UART clock speed. I added this inside config.txt:

init_uart_clock=2441406
init_uart_baud=38400

And I modified the /boot/cmdline.txt again adding "bcm2708.uart_clock=3000000":

dwc_otg.lpm_enable=0 bcm2708.uart_clock=3000000 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait 

Then setting up your UART as 38400 magically makes it be 31250 and MIDI. This is coming from here, here and here.