Has anyone successfully tried the Coda Effects relay switching?

Started by Nocaster Cat, January 22, 2017, 08:33:14 AM

Previous topic - Next topic

Nocaster Cat

DISCLAIMER - PROGRAMMING IS NOT MY STRONGEST SKILL

Link to the article - http://www.coda-effects.com/2016/08/relay-bypass-with-anti-pop-system.html

Benoit's article uses the C programming language to program the PIC and even though he step by steps it, I've run in to issues. The first time I tried to program the PIC the circuit and LED would turn on but not off, so I erased the PIC and started over. Now nothing happens and the only way I can get the relay to switch states is by connecting pins one and two of the 12F675.

Here is the layout I used - http://effectslayouts.blogspot.com/2016_11_01_archive.html

I have tried...

1) Copying and pasting the code into MPLab.

2) Typing the code line by line into MPLab.

3) Erasing and re-coding the 12F675 several times.

I'm not a coder but I'm guessing that brackets ("{}") are used to start and stop commands and it seems that in this part of the code the bracket in red is throwing things off.

if (state == 1) { // effect on
            GP0 = 1; // LED on
            GP5 = 1; // relay on
            GP4 = 0; }
        else { // effect off
            GP0 = 0; // LED off
            GP5 = 0; // relay off
            GP4 = 0;
        }
      }
   __delay_ms(10);
}

In MPLab if you click on any bracket, it will highlight the start and stop of that command and the bracket in bold red does not correspond to any command start. In fact if it's left in the code, it causes an error and you can't compile the code but if you remove the extra bracket so the code will compile but the PIC doesn't work. Any ideas?

Also, are photoFET's overly sensitive to heat? Could I have fried the photoFET while soldering it in and should I be socketing them?

Thanks in advance.


slacker

I haven't tried the project but from looking at the code if you remove the bracket you've highlighted in red it won't work correctly. After you've removed that bracket if you go up to the section that starts while(1) { // main loop and highlight the opening bracket you'll see that closing one is a few lines down, the while(1) means that bit of code within those two brackets will loop forever and the program will never get to the code below there, which if why nothing happens.
I think if you leave the red bracket where it is and delete this one in red below, the code should work. I don't know if this is how it should be though because it leaves the __delay_ms(10); at the very end of the code floating about doing nothing as the code will never get to it. Probably the best thing to do is try and get in touch with Benoit and ask him to correct the error.

if(GP1 == 0) { // if the switch is activated
          __delay_ms(15);
          if(GP1 == 0) {
              __delay_ms(200);
              if(GP1 == 1) {
                  changestate = 1;
              }
              else {
                  changestate = 0;
              }
              }
          }
          __delay_ms(10);
      }

Nocaster Cat

Quote from: slacker on January 22, 2017, 10:32:00 AM
I haven't tried the project but from looking at the code if you remove the bracket you've highlighted in red it won't work correctly. After you've removed that bracket if you go up to the section that starts while(1) { // main loop and highlight the opening bracket you'll see that closing one is a few lines down, the while(1) means that bit of code within those two brackets will loop forever and the program will never get to the code below there, which if why nothing happens.
I think if you leave the red bracket where it is and delete this one in red below, the code should work. I don't know if this is how it should be though because it leaves the __delay_ms(10); at the very end of the code floating about doing nothing as the code will never get to it. Probably the best thing to do is try and get in touch with Benoit and ask him to correct the error.

if(GP1 == 0) { // if the switch is activated
          __delay_ms(15);
          if(GP1 == 0) {
              __delay_ms(200);
              if(GP1 == 1) {
                  changestate = 1;
              }
              else {
                  changestate = 0;
              }
              }
          }
          __delay_ms(10);
      }

Thanks. I don't think I tried removing the last bracket because I thought the same thing, it leaves the 10ms delay dangling but I'll give that a try. I have reached out to Benoit, but there were errors in his code for his previous version of relay switching and I thought I'd reach out and see if anyone had any ideas.

Nocaster Cat

So deleting the last closed bracket doesn't work, you get compilation errors.  >:(

slacker

The bracket I meant isn't at the end it's in the debouncing section near the top of the code, check the snippet I posted, sorry if I confused you talking about the end of the code.