Aaron P (Customer) asked a question.

Issues Detecting P1AM-100

For a while I could upload programs just fine but all of a sudden My computer cannot detect when my PLC is connected. I have tried using different computers but that does not work. If there is no external power source the LED on the P1AM-100 does come on when plugged in so I know it has power. The only thing that somewhat helps so far is resetting the PLC, unplugging it and plugging it back in again. This at least makes it that the com is visible but it does not always show as a P1AM-100. The only program I was able to upload when I tried this a few times was an example program that turns the LED on or off dependent on the lever on the front of the PLC.


  • FACTS_MikeSc (AutomationDirect)

    I may have replicated your issue but you would have to know what the previous code was and if it was the cause. If you do I would replicate the issue and then adjust the code to fix it for confirmation.

     

    Going by the code you posted above, I can replicate the issue from the symptoms you described by uncommenting the line:

    1. int Activate = P1.readDiscrete(2,1);

    You have to first call P1.init() before using any of the library function calls to the module's like readDiscrete, writeDiscrete, ect.

     

    We do have channel labels that you could use to make the your code look cleaner.

    There's an example under P1AM -> Basic -> ChannelLabels. Below is a use case.

    1. // Channel Label
    2. channelLabel Activate = {2,1};
    3.  
    4. // Usage
    5. P1.readDiscrete(Activate);

     

    Expand Post
    Selected as Best
  • FACTS_MikeSc (AutomationDirect)

    Are you not able to load programs anymore? You should still be able to load programs as long as the com port shows up. Double check the Device Manager -> Ports. Anything that shows up there the Arduino IDE will pull into their list of available com devices also.

  • Aaron P (Customer)

    I have a temporary solution. If I reset the P1AM-100 and close all instances of IDE and reopen then reconnect the controller to my computer the com reappears.

    I seems as though if I upload a program that the PLC cannot run it will disconnect and not appear under any com to connect to until I do the previously mentioned fix.

    I have the starter kit and am trying to get a better understanding of how to use this PLC and it is frustrating that I get locked out from uploading a mistake.

     

    A previous mistake that locked the PLC was when i tried defining certain terminals like i would with an arduino to make the rest of the code easier as shown below. I do not have the original code that made the error though.

     

    #include <P1AM.h>

     

    //int Activate = P1.readDiscrete (2,1);

    //int Relay = P1.write(1,3)

     

    void setup() {

      while (!P1.init()){

        ; //Wait for Modules to Sign on  

      }

      pinMode(LED_BUILTIN,OUTPUT);

      digitalWrite(LED_BUILTIN,LOW);

    }

     

    void loop() {

    if (P1.readDiscrete(2,1)==HIGH){

        digitalWrite(LED_BUILTIN,HIGH);

      P1.writeDiscrete(HIGH,1,3);

      delay(100);

      P1.writeDiscrete(LOW,1,3);

      delay(100);

    }

      digitalWrite(LED_BUILTIN,LOW);

    }

     

    Expand Post
  • FACTS_MikeSc (AutomationDirect)

    I may have replicated your issue but you would have to know what the previous code was and if it was the cause. If you do I would replicate the issue and then adjust the code to fix it for confirmation.

     

    Going by the code you posted above, I can replicate the issue from the symptoms you described by uncommenting the line:

    1. int Activate = P1.readDiscrete(2,1);

    You have to first call P1.init() before using any of the library function calls to the module's like readDiscrete, writeDiscrete, ect.

     

    We do have channel labels that you could use to make the your code look cleaner.

    There's an example under P1AM -> Basic -> ChannelLabels. Below is a use case.

    1. // Channel Label
    2. channelLabel Activate = {2,1};
    3.  
    4. // Usage
    5. P1.readDiscrete(Activate);

     

    Expand Post
    Selected as Best
  • Aaron P (Customer)

    I think that fixed my issue. Thank you for the extra info as well!

    Where can I go to get a comprehensive list of all the commands the P1AM has? I have been going off of the example you can pull up in IDE so far.

  • Darren360 (Customer)

    Hey Guys,

     

    The API Reference linked to above has been a fantastic discovery as I have been learning to program the P1AM in the Arduino IDE. I also really appreciate the configuration tool for the modules. Still a newbie and have not used the configuration tool in any of my programming but knowing it is there is huge. I am sure I will get to it very soon.

     

    In my learning I have been studying the Arduino reference library here: Arduino Reference - Arduino Reference and had been wondering where the same reference was for the P1AM - the link above solves the question.

     

    Would it be too much to ask if that P1AM API reference could have a list at the top with all the functions grouped so we could easily link to the function? Kind of like what they did in the Arduino reference. It is fine the way it is, but I have to scroll a lot to find what I am looking for. 😀

     

    Cheers,

    Darren

     

    Expand Post