dnsalter (Customer) asked a question.

Communicating with an Arduino using GPIO

The deeper I go into planning my code, the more I realize that driving 2 different stepper motors directly from the P1AM-100 seems like a less than optimal solution. To make sure that I can control my stepper drivers directly and separately from the logic of the main controller (I worry about timing all of my other I/O at the same time as the pulsing for the driver), I want to add a secondary controller (likely an Uno as I have one on hand, but I might downsize to a Nano) that would accept an input from the P1AM-100 to tell it when the motors have to move.

 

My only concern now, is that almost all of the Arduino boards are 5v (which is good, because most stepper drivers are also 5V) but the GPIO of the P1AM-100 only works with 3.3V. How could I send a digital signal from the P1AM-100 to a 5V Arduino? From what I'm reading I might be able to just connect them directly without any issues as the Arduino would recognize 3.3V as a logic HIGH but I want the solution to be robust. Is there a better option?


    • dnsalter (Customer)

      I was hoping that I wouldn't have to add anything more, but I want this to be as robust as possible so this looks like it's the way to go. Thanks!

    • dnsalter (Customer)

      Would something like this work then?

       

      The only thing I'm concerned about here is that there are 2 different grounds for the P1AM-GPIO and the UNO R3. My apologies for the rough AutoCAD drawing.

      levelcompensator

      Expand Post
      • z28z34man (Customer)

        The level converter appears to be correct but if you are trying to talk serial between the P1AM and the UNO the P1AM hardware serial is pin 13 and 14 and you call serial1 in the sketch

         

      • dnsalter (Customer)

        So I don't need serial communication, all I need to do is trigger 2 different events that the Uno (or similar controller) will handle rather than the P1AM. Essentially, I want pin 0 on the P1AM-GPIO to be HIGH when event_1 has to happen, and then pin 1 on the P1AM-GPIO to be high when event_2 has to happen

      • z28z34man (Customer)

        Not a problem. i saw that you where using pins 0 and 1 on the UNO are those are its serial pins. if you are not using the serial on the UNO and have other pins available I would suggest switching to different pins for digital input that way you can put in some serial debugging in the UNO sketch to help in development.

  • Tinker (Customer)

    If you are using the P1AM-GPIO module, description says; "These pins include basic overvoltage, undervoltage, and overcurrent protection." Which should protect the SAMD from 5V ( however I wouldn't try it with 24V ) so it is likely you can directly connect it to a 5V Arduino without the level shifter. I suppose it is possible that you might need a pull up resistor to 5V (maybe 10k) at the 5V Arduino input, or use:

    As of Arduino 1.0.1, it is possible to enable the internal pullup resistors with the mode

    INPUT_PULLUP

    .

     

    I suppose one could also connect to an Arduino input pin configured for analog input which would not expose the P1AM to any external voltage, but alalogread is slower than digitalread and one would need a comparison, so I don't think it is a "good" idea, but a possibility anyway.

    Expand Post
    • dnsalter (Customer)

      Honestly, the extra cost of adding the level shifter and time wiring it all is pretty negligible so I think I might just go with that to be safe. I could definitely use the soldering practice...

       

      Do you happen to know of any issues that could arise from having an Arduino in the same enclosure as the P1AM and all the other associated wiring?