Results 1 to 5 of 5

Thread: PIC programming 101

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator N8YX's Avatar
    Join Date
    Feb 2007
    Location
    Out in the sticks
    Posts
    26,070

    PIC programming 101

    Anyone with development experience, please step inside...

    I have a memory unit for an NRD-515. JRC made two different versions - one a 24ch and another a 96 - with the only difference between them being the bank selector (or the lack thereof). An NDH-515 has 1 bank of 24ch whereas the NDH-518 has 4 banks of 24ch. A push button selects the active bank.

    PE1ABR has details of a modification to the NDH-515 which will allow 8 banks of 24ch to be selected. A rotary switch and diode matrix/pull-up resistor array is used to provide a 3-line BCD-coded output which provides for bank-select logic. This requires drilling the unit's front panel then labeling the bank numbers. If I'm going to do this I'd rather fabricate and paint a new front panel. And...since the existing channel readout is digital, I thought "Why not use a PIC, Arduino or BASIC Stamp to expand on the concept and have a digital bank indicator as well?" Doing a little digging, I found a motorcycle gear-counter circuit that uses a 16F628. The assembly code was provided. It has up-down inputs on Port A and uses Port B to drive a single 7 segment display.

    Perfect. Though my assembly skills are rusty as hell. Modifying this is going to be an exercise.

    What's a good, robust IDE for this family of PICs? I looked at MPLABX, and I don't need to buy their Pro compiler as I don't have a need for speed - so the freeware version should work fine. This thing is very simple in concept: Upon power-up and no previously active bank having been selected, default to Bank 0. Pull the three Port A output lines Low, then send a "0" character (defined in an array) out the Port B lines. Loop and look for a switch press (switches connected to two of the other Port A lines for up/down incrementing). Process the switch press accordingly, output the BCD control data on the Port A lines and digit display character data on Port B's lines...then wait for a period and see if no other switch press has occurred. If not in say, 2 minutes then write the Bank Number to a data location in the device's EEPROM. On subsequent loops, compare the existing bank number with the stored bank number; update if changed and keep looping if not.

    Upon subsequent power-ups, look for an existing Bank Number in EEPROM. If present, output the associated control/display data then loop and look for changes as above.

    I'd really like to simulate this before actually programming a physical device...and I'd like to write the code in C if possible. Suggestions, thoughts, ready-made code examples?
    "Everyone wants to be an AM Gangsta until it's time to start doing AM Gangsta shit."

  2. #2
    Whacker Knot WØTKX's Avatar
    Join Date
    Aug 2008
    Location
    Lakewood, CO
    Posts
    26,758
    "Where would we be without the agitators of the world to attach the electrodes
    of knowledge to the nipples of ignorance?" ~ Professor "Dick" Soloman



  3. #3
    Orca Whisperer N1LAF's Avatar
    Join Date
    Jul 2007
    Location
    Ledyard, CT
    Posts
    13,937
    Digikey has a wide range of socket-able development kits, some with built-in programmers.


    Microchip Curiosity 8/14/20 pin Eval boards, with built-in programmer $26


    Microchip Curiosity 28/40 pin Eval boards, with built-in programmer $40

    For button press, I use counters. when you have your code in place, you can toggle an output line and measure its frequency when running, tells you the period of your program loop. Knowing that, you can determine the counter value that will give you a positive button press, and compensate for minor switch bounce. You will be able to quickly change banks.
    Last edited by N1LAF; 05-09-2020 at 06:45 AM.

  4. #4
    Orca Whisperer N1LAF's Avatar
    Join Date
    Jul 2007
    Location
    Ledyard, CT
    Posts
    13,937
    Port B display C code...

    switch(banksel) {
    case 0: portb = 0x7e; break;
    case 1: portb = 0x30; break;
    case 2: portb = 0x6d; break;
    case 3: portb = 0x79; break;
    case 4: portb = 0x33; break;
    case 5: portb = 0x5b; break;
    case 6: portb = 0x5f; break;
    case 7: portb = 0x70; break;
    case 8: portb = 0x7f; break;
    case 9: portb = 0x7b; break;
    default: break;
    }

    depending of pull up or pull down logic is used, may need to invert the numbers.

  5. #5
    Orca Whisperer N1LAF's Avatar
    Join Date
    Jul 2007
    Location
    Ledyard, CT
    Posts
    13,937

    https://people.zeelandnet.nl/wgeeraert/index515.htm#ndh515


    Trying to understand what needs to be done. PIC can do this, more flexibility than using GALs.

    How about using a rotory encoder rather than up/down switches?
    Last edited by N1LAF; 08-31-2020 at 08:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •