KillaCycle (Customer) asked a question.

Can I add a 3rd "Tx only" TTL serial channel?

I have a P1AM-200 and I have a P1AM-SERIAL and a P1AM_GPIO module. I am using both ports to listen to two separate RS-485 devices. I would like to add a 3rd "Tx only" port to transmit a speed command to a VFD (using a P1AM-GPIO pin with a separate TTL to RS-485 dongle.)

I suppose I could "bit bang" my own driver, but I would greatly prefer using one of the many Tx Only Arduino libraries available. However, they seem to all require the library "#include <util/delay_basic.h>". Are there any that don't? Is there a simple workaround or a library that does its own tiny CPU time delays?

 

Thanks in advance,

 

Bill D.


  • FACTS_MikeSc (AutomationDirect)

    Sorry for the late response.

     

    Have you looked into SoftwareSerial? This library is one people commonly use when it comes to adding more serial channels.

     

    I'm guessing the other libraries you're trying out are not compatible with the P1AM200?

    • KillaCycle (Customer)

      SoftwareSerial compiles for me if I select another board, say a Mega.

      When I select P1AM-200, the compiler throws the error:

      • KillaCycle (Customer)

        The compiler throws the error:

        Compilation error: SoftwareSerial.h: No such file or directory

    • KillaCycle (Customer)

      Even though it is far from perfect, the library "DumbTXSWS.h" appears to compile with the P1AM-200 board selected.

      I haven't actually tried it with the hardware, but it does offer a Tx only solution that doesn't use <util/delay_basic.h> and it does compile.

      https://github.com/WestfW/Duino-hacks/tree/master/DumbTXSWS

      (There is typo in the example. "DumbTXSWS mySerial(10, 11); // RX, TX" should be something like:

      #include "DumbTXSWS.h

      #define TX_PIN A2 // Pin to use for serial port, transmit only

      #define INVERT_LOGIC 1 // Start with the Tx pin HIGH or LOW, 1= HIGH 0 = LOW

      DumbTXSWS mySerial(TX_PIN, INVERT_LOGIC);

       

      Any thoughts?

       

       

      Expand Post
  • FACTS_MikeSc (AutomationDirect)

    Oh I'm sorry. It's been a while since I have did anything with serial for the P1AM's. It appears I found a SoftwareSerial library previously that is in my Arduino library directory which is why SoftwareSerial was compiling for me lol.

     

    Website Reference: https://github.com/FYSETC/SoftwareSerialM

    Library Directory:  /users/<user>/Documents/Arduino/libraries

     

    You can download the library and drop it into your Arduino libraries folder.

     

    As for the library you mentioned, I haven't seen or used that one but if it offers the functionally you're looking for that I don't see a reason not to. I would test it out for sure though.

     

    Let me know if you make progress or need some more assistance.

    Expand Post
    • KillaCycle (Customer)

      Thank you very much for finding this. Indeed, it looks like a SAMD51 capable (and thus P1AM-200 capable) version of SoftwareSerial. However, when I add the zip library, the IDE says that it has indeed loaded it, but I can't see it in the library manager. Even changing the target board doesn't seem to bring it into view in the library manager, which is surprising.

      I also don't seem to find any example code whatsoever in the repository. Not at all sure how I would go about creating an instance of SoftwareSerialM in my code, or exactly what library I would need to include.

       

      Expand Post
    • FACTS_MikeSc (AutomationDirect)

      When you add libraries manually these won't show up in the library manager.

       

      The Softwareserial library is a built-in Arduino library that's not compatible with the SAMD51. The library that I referenced adds that compatibility.

       

      The code is pretty similar to using Serial functions.

      Website Reference: https://docs.arduino.cc/learn/built-in-libraries/software-serial/

      Expand Post