Author Topic: PIC Programming and Circuit Help Wanted  (Read 323 times)

0 Members and 1 Guest are viewing this topic.

swipesy

PIC Programming and Circuit Help Wanted
« on: October 26, 2017, 04:42:54 PM »
Hello everyone. New poster here, but I've been a reader here for years and have learned a lot from the various posts by people more knowledgeable than I, and for that I am grateful.

I'm good with analog circuits, but I just can't get my head around digital even though I'm a PHP programmer.  I'm a 56-year-old "retired" local scene musician (mostly classic rock) who has decided to build my own self-designed dream preamp. The channel circuits are now designed, breadboarded and tested, and are working fine and sounding great. Or, I should probably say, sound great to me. It will be an 8-channel beast with an acoustic channel (for piezo bridges), four effect loops, and a lot more. But now comes the hard part - figuring out how to control this multi-channel preamp remotely. Or, rather, how to handle the communication from the preamp to the pedal. Analog won't work well without a lot of wires (though that's how I will probably do it if digital doesn't work out), and I don't want to get into MIDI. I want to build the entire thing myself. And, being that this is basically a one-off kind of project, I would prefer not to spend all the time and money learning digital for just this one thing.

So ... can someone here help? If not I completely understand, it is kind of an off-the-wall request coming from someone who has never posted here before. Of course I will pay, if that makes any difference, as long as it's not an arm and a leg like some pro outfits have quoted! Without getting too deep into it right now, basically I'm looking for someone to write the code, program the chips, and help with the supporting circuit. Not the PCB, I can do that, but the schematic of necessary parts to make it work. I'm thinking the code wouldn't be that tough for someone who is familiar with it. I could probably write the code in PHP in a couple hours max, but that wouldn't work on a chip! (The code might help someone else understand what I'm looking for though, not sure.) I can get more specific with the details if someone is willing to help me out. I don't know exactly all it would entail, but I'm looking for two-way communication between the pre and the pedal, whether that means two sets of two chips (one for TX and one for RX on each end), or whatever is best. I would prefer some ins/outs to be latching in two separate groups with the remaining pins momentary, but I can use all momentary if that's easier code-wise (octal latches can substitute for that well enough). It can use all high/low logic inputs/outputs I would think, but that can be discussed. As for ins/outs, I'm looking at about 20, or is that too many?

Anyway, that's the short story. I'll be glad to provide any information anybody may want, whether it's about the code/programming/circuit or the plans for the preamp itself.

Thanks for your time!

Hatredman

Re: PIC Programming and Circuit Help Wanted
« Reply #1 on: October 26, 2017, 07:27:14 PM »


First of all, welcome.

I just can't get my head around digital even though I'm a PHP programmer.  ...  I don't want to get into MIDI. I want to build the entire thing myself ...  I'm looking for two-way communication between the pre and the pedal, whether that means two sets of two chips (one for TX and one for RX on each end), or whatever is best.?

OK, a few considerations:

1. Why not MIDI?

I can only see benefits.

 For starters, your hardware would be almost completely the same, whether you use MIDI or not. It's a matter of software, so why not?

Also, your preamp would be compatible with any MIDI device, including controllers, your DAW, keyboards etc.

And that doesn't prevent you from assembling your own foot controller. The only difference is that it would be a MIDI foot controller that you can also use for other purposes.

Another benefit: you WILL have to invent your own communication protocol between the foot controller and the preamp. With MIDi, it is already done - one less wheel to reinvent.

2.  About not learning digital

PHP is derived from C. If you know PHP, you can program a PIC or an Arduino for sure. Why not give it a try?

Just my twenty bucks (I spoke a lot more than a tuppence...)

.

Kirk Hammet invented the Burst Box.

markseel

Re: PIC Programming and Circuit Help Wanted
« Reply #2 on: October 26, 2017, 09:00:08 PM »
Well *if* you do want to use midi you could use this board: http://www.diystompboxes.com/smfforum/index.php?topic=114354.msg1105178#msg1105178

Easy to program in 'C'.  It's overkill but it's easy.  The board is just being used as a USB MIDI interface.  IN the example below the background task handles a FlexFX MIDI property from the USB host and sets the three GPIO ports to the analog signal path index (0 through 7).  Perhaps those three ports are then connected to a 3-to-8 decoder IC whose outputs control relay drivers or CMOS solid state analog switches.  Or you could issue some I2C writes to control a I2C port expander.

Code: [Select]
#include "main.h" // Defines config variables, I2C and GPIO functions, DSP functions, etc.
#include <math.h> // Floating point for filter coeff calculations in the background process.
#include <string.h>

// System configuration ...

const int   sample_rate      = 48000;
const int   dsp_chan_count   = 0;          // 0 channels to/from each DSP thread
const int   usb_output_count = 0;           // 0 USB audio class 2.0 output channels
const int   usb_input_count  = 0;           // 0 USB audio class 2.0 input channels
const int   usb_vendor_id    = 0x20B1;      // Use XMOS's free Windows driver
const int   usb_product_id   = 0x0008;      // Any value you want here
const char* usb_vendor_str   = "BitStream"; // Your company name
const char* usb_product_str  = "FlexFX";    // Your product name
const int   i2s_tdm_mode     = 0;           // 0 for I2S (Stereo), 1 for I4S, 2 = I8S
const int   i2s_sync_format  = 0;           // 0 for PCM, 1 for I2S

// Custom/example properties for this example application ...

#define PROP_VENDOR_ID      0x01 // Your USB vendor ID
#define PROP_PRODUCT_ID     0x01 // Your USB product ID
#define PROP_EXAMPLE        ((PROP_VENDOR_ID<<8)+PROP_PRODUCT_ID)
#define PROP_SELECT_PATH  (PROP_EXAMPLE+0x0001) // prop[1:5] = [selection, 0, 0, 0, 0]

// I2C helper functions for reading/writing registers on I2C periperhals ...

void i2c_wr_reg( int speed, byte dev_addr, byte reg_num, byte value )
{
    i2c_start( speed );
    i2c_write( dev_addr ); i2c_write( reg_num ); i2c_write( value );
    i2c_stop();
}

// The control task is called at a rate of 1000 Hz and should be used to implement audio CODEC
// initialization/control, pot and switch sensing via I2C ADC's, handling of properties from USB
// MIDI, and generation of properties to be consumed by the USB MIDI host and by the DSP threads.

void control( const int rcv_prop[6], int usb_prop[6], int dsp_prop[6] )
{
    // Process incoming properties from USB, set three output ports to the analog path selection index.
    if( rcv_prop[0] == PROP_SELECT_PATH )
    {
        int selection = rcv_prop[1];
        port_write( 0, (selection >> 0) & 1 );
        port_write( 1, (selection >> 1) & 1 );
        port_write( 2, (selection >> 2) & 1 );
    }
}

void mixer( int* usb_output, int* usb_input,
            int* i2s_output, int* i2s_input,
            int* dsp_output, int* dsp_input, const int* property ) {}

void dsp_initialize( void ) {}
void dsp_thread1( int* samples, const int* property ) {}
void dsp_thread2( int* samples, const int* property ) {}
void dsp_thread3( int* samples, const int* property ) {}
void dsp_thread4( int* samples, const int* property ) {}
void dsp_thread5( int* samples, const int* property ) {}

swipesy

Re: PIC Programming and Circuit Help Wanted
« Reply #3 on: October 26, 2017, 09:49:11 PM »
Hi Mark,

You nailed it perfectly: "If" I want to use MIDI. I don't. It's overkill and then some. Here's the reply I was just finishing to Hatredman, which actually included the word "overkill", and I've described the project a little more. Thank you!

------------------

Hi Hatredman,

Yeah, not quite a pony but certainly more than a shilling, if I get your reference correctly. :)

Why not MIDI? Well, it's like this:

1. Click a switch on the pedal, a switch on the pre turns on.
2. Press a button on the pre and that is reflected on the pedal's display.

That's it, and that's all it ever will be. MIDI is supreme overkill and I'm never going to be using either the preamp or pedal with anything else. I've already spent a good deal of time looking at the available DIY-style MIDI offerings. There is one I found that might work (FlexControl 14) but that one doesn't have enough I/O pins. The only other ones I found that were a decent fit aren't being made any more (the MIDIWidget is one example), they're expensive for the number of units I would need (encoder and decoder on each side, etc.), a lot of them use notes rather than CC/PC, they would still need to be configured and, frankly, MIDI doesn't really fit what I'm looking for. Also, if it breaks down anywhere I'll know how to repair it because I designed and built it myself. Communication between the pre and pedal is a small part of the project overall. This is something I've always thought about building for myself that doesn't exist and if I can get the programmed chips and work those into my circuits it would just make things easier, if not a bit more elegant.

Why not learn digital? Then again, why? I have never needed digital before as I have always used maybe two or three simple analog switching routines when needed, and I can't think of anything else I'd ever do that would use it. This project, though, is something where I think it would be beneficial. Beyond that, it would cost me too much. I'm not specifically referring to money, but to time. I spent a full week of free time a couple months ago (2-3 hours every evening) trying to understand the code and it's just not sinking in. What I want seems so simple code-wise too. Then I would have to buy the pic programmer, learn how to incorporate something digital - which I've never messed with - into my analog circuits, and hope that it all works. I finally decided it would just take too much time and effort and to simply use discrete wires for the binary data (off/on or high/low logic is all it is, after all).

However, recently I thought about asking directly for some help to make things easier, and that's something I don't normally do because I like to do things for myself. This might sound silly, but asking for this kind of help is a big step for me and I'm still not altogether comfortable with it. In my circle it's always me helping others!

DIGITAL!  Yuck!  :icon_lol:

Thanks again for your time!

[EDIT]

Oh, and if anyone is interested, here's a photo of the breadboarded gain channel, including the speaker sim (less one quad op amp). Sounds great through a full-range system! Looks like a rat's nest though, doesn't it? :o

[/EDIT]

« Last Edit: October 26, 2017, 10:30:39 PM by swipesy »

markseel

Re: PIC Programming and Circuit Help Wanted
« Reply #4 on: October 26, 2017, 10:55:58 PM »
Always fun to see the actual hardware!
Hmmm not sure what's worse a rat's nest of wires or a rat's nest of 'C' code. :icon_biggrin:

swipesy

Re: PIC Programming and Circuit Help Wanted
« Reply #5 on: October 31, 2017, 05:11:40 PM »
Hi all,

This past weekend I started sketching alternate plans and determined I can use direct wiring from the pedal to the preamp using a DB25 cable, so a PIC will no longer be needed. I want to thank everyone who read and/or responded to my topic. I appreciate it very much!

If anyone wants details on the entire project I'll be glad to explain it. I'm sure it will be something nobody has seen before. This is something I dreamed up on my own. Nobody I know of has ever built one, I've never seen one anywhere else, and if I could buy one I would. Everybody has their own likes and such, but since nobody makes what I've always wanted I just thought I'd build it for myself since I have that ability. I'm sure some people will even think it's stupid, and that's ok. Different strokes, right?

Thanks again everybody!