Close



Results 1 to 10 of 476

Threaded View

  1. #11
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    Quote Originally Posted by kfahn View Post
    Care to share that toggle code? I am not sure where to start with writing that, but it strikes me that it would be incredibly useful!
    Its hardly any code. I'll look at my older code base archives and see if I can hunt it down. It also was a little bit smart. There are certain pins that are deemed to be 'Sensitive'. It did not mess with any of those. And in fact, there was no reason to mess with them because those have important stuff connected up to them. You aren't going to be connecting new stuff to them.

    Update: Here it is. I don't remember exactly what was going on. The posted code includes the original M42 command and then 3 more versions done by me to scan. You probably want to start with the M43 to get a rough idea where your pin is located (numbered). And then maybe edit the M44 and M45 to limit the search across less pins.

    If you connect up your volt meter to a pin and let this run, it should tell you where it is and when you see something happen on the volt meter you can reset the board and start over using the M42 command to verify things. You would use the pin numbers you learned from the scan to limit your search and locate the pin.
    Code:
        case 42: //M42 -Change pin status via gcode
          if (code_seen('S'))
          {
            int pin_status = code_value();
            int pin_number = LED_PIN;
            if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
              pin_number = code_value();
            for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
            {
              if (sensitive_pins[i] == pin_number)
              {
                pin_number = -1;
                break;
              }
            }
          #if defined(FAN_PIN) && FAN_PIN > -1
            if (pin_number == FAN_PIN)
              fanSpeed = pin_status;
          #endif
            if (pin_number > -1)
            {
              pinMode(pin_number, OUTPUT);
              digitalWrite(pin_number, pin_status);
              analogWrite(pin_number, pin_status);
            }
          }
         break;
         
      case 43: //M43 - Roxy hack to look for GPIO pins
            int pin_number;
            int i;
         
            SERIAL_PROTOCOLPGM("M43 - Roxy GPIO Hackery:\n");
            SERIAL_PROTOCOLPGM("HIGH/LOW: ");
            SERIAL_PROTOCOL(HIGH);
            SERIAL_PROTOCOLPGM("/ ");
            SERIAL_PROTOCOL(LOW);
            SERIAL_PROTOCOLPGM("\n");
            for( pin_number=0; pin_number<55; pin_number++)  {
              SERIAL_PROTOCOLPGM("Pin  ");
              SERIAL_PROTOCOL(pin_number);
              for(i = 0; i < sizeof(sensitive_pins); i++)    {
                if (sensitive_pins[i] == pin_number)     {
                  SERIAL_PROTOCOLPGM(" Sensitive!\n");
                  goto NEXT_GPIO;          
                }
              }
    
              pinMode(pin_number, OUTPUT);
              delay(50);
              digitalWrite(pin_number, LOW);
              delay(500);
              digitalWrite(pin_number, HIGH);
              delay(1000);
              digitalWrite(pin_number, LOW);  
              delay(500);        
    //          analogWrite(pin_number, HIGH);
              pinMode(pin_number, INPUT);
              delay(50);
              SERIAL_PROTOCOLPGM("\n");
    NEXT_GPIO: ;
            }
            SERIAL_PROTOCOLPGM("Done...\n\n");
        break; 
        
     case 44: //M44 - Roxy hack to look at GPIO pin values for input value change
            int pin_being_examined;
            int ii, iii, jj;
            
            pin_being_examined=11;
            iii=-1;
            SERIAL_PROTOCOLPGM("M44 - Roxy GPIO Hackery:\n");
            
            pinMode(pin_being_examined, INPUT_PULLUP);
            delay(50);
            
            for( jj=0; jj<10; jj++) {
              do {
                ii = digitalRead(pin_being_examined);
              } while(ii==iii) ;
              iii = ii;
              SERIAL_PROTOCOLPGM("Pin  ");
              SERIAL_PROTOCOL(pin_being_examined); 
              SERIAL_PROTOCOLPGM(" : ");
              SERIAL_PROTOCOL(ii); 
              SERIAL_PROTOCOLPGM("\n");
            }
            SERIAL_PROTOCOLPGM("Done...\n\n");
        break; 
        
        case 45: //M45 - Roxy hack to look for GPIO pins
            
            SERIAL_PROTOCOLPGM("M45 - Roxy GPIO Hackery:\n");
            SERIAL_PROTOCOLPGM("HIGH/LOW: ");
            SERIAL_PROTOCOL(HIGH);
            SERIAL_PROTOCOLPGM("/ ");
            SERIAL_PROTOCOL(LOW);
            SERIAL_PROTOCOLPGM("\n");
            for( pin_number=28; pin_number<=31; pin_number++)  {
              SERIAL_PROTOCOLPGM("Pin  ");
              SERIAL_PROTOCOL(pin_number);
              for(i = 0; i < sizeof(sensitive_pins); i++)    {
                if (sensitive_pins[i] == pin_number)     {
                  SERIAL_PROTOCOLPGM(" Sensitive!\n");
                  goto NEXT_GPIOx;          
                }
              }
    
              pinMode(pin_number, OUTPUT);
              delay(50);
              digitalWrite(pin_number, LOW);
              delay(500);
              digitalWrite(pin_number, HIGH);
              delay(1000);
              digitalWrite(pin_number, LOW);  
              delay(500);        
    //          analogWrite(pin_number, HIGH);
              pinMode(pin_number, INPUT);
              delay(50);
              SERIAL_PROTOCOLPGM("\n");
    NEXT_GPIOx: ;
            }
            SERIAL_PROTOCOLPGM("Done...\n\n");
        break;
    Last edited by Roxy; 01-19-2015 at 11:42 AM.

Posting Permissions

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