Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, an initiative of Stroud Water Research Center designed to help people advance knowledge and stewardship of fresh water.
New to EnviroDIY? Start here

Reposting: Library extension "Mod"

Home Forums Mayfly Data Logger Reposting: Library extension "Mod"

Viewing 2 reply threads
  • Author
    • #2321
      Heather Brooks

        (@arnoudc: Webmaster is reposting because users are unable to access content of original post.)
        Dear all, I got stuck when trying to run the sketch of Maxbotix sonar with sleeping and SD card.

        The error comes because I have not installed the library “Sodaq_PcInt_Mod.h” and “SoftwareSerialMod.h”.

        When checking the Github files, I see “EnviroDIY_SoftwareSerial_PCINT12@…” with indication of “Renamed SoftwareSerialMod”. Could anyhow tell me how I can resolve it? I tried downloading, extracting and renaming the file to “SoftwareSerialMod” but it did not work out…

        Also, where to find “Soday_PcInt_Mod.h?
        Thanks in advance.
        With friendly greetings,

      • #2324
        Sara Damiano

          If you’ve downloaded the libraries from https://github.com/EnviroDIY/Libraries, then you should be able to fix it by replacing (in your sketch, not in the library) every instance of “SoftwareSerialMod” with “SoftwareSerial_PCINT12” and “Sodaq_PcInt_Mod” with “Sodaq_PcInt_PCINT0”.

          Essentially, what happened is that these libraries all conflict with each other because each tries to monopolize all of the interrupt control registers within the processor chip. The processor in the Mayfly has 4 grouped interrupt registers (vectors 0-3 or A-D) which control interrupts on 8 pins each. Several years ago, Shannon made modified versions of the Software Serial and PcInt (and SDI12) libraries to force each to only work with a specific interrupt vector (instead of each trying to use all 4). At that point, she added the “mod” to each library name to note that it had been modified. As you noticed, sometime after she wrote the examples, I renamed those libraries from “mod” to “PCINT#” to specify which of the interrupt vectors each library had been modified to control.

          Because the modified versions do only have control of specific interrupt vectors (instead of all of them) you have to be careful which pins you try to use with each library:
          – Sodaq_PcInt_PCINT0 only works on vector A/0, so you can only assign interrupts to pins D24-D31 (aka A0-A7) using that library. If you’re only using this to assign a wake-up interrupt from the clock, which is attached at A7, that’s fine.
          – SoftwareSerial_PCINT12 only works on vector B/1 & C/2, so you can only fake a serial input/output on pins D8-D23. The way the pins on the Mayfly are routed, the only pins exposed in a grove jack for SoftwareSerial_PCINT12 are D10&D11. The Mayfly does have two hardware serial ports (which are always superior to a software serial port imitation) but these are taken up by the communication with the FTDI chip (ie, the communication with the USB) and the communication with the “Bee” socket.
          – SDI12_PCINT3 only works on vector D/3, so you can only use it on pins D0-D7.

        • #2325
          Sara Damiano

            If you don’t want to be limited as to which pin each library can control, you can set the pin change interrupt as “master” and use a different version of software serial that has been stripped of all interrupt register control: https://github.com/EnviroDIY/SoftwareSerial_ExternalInts.

            You could also use AltSoftSerial instead of SoftwareSerial because it doesn’t need interrupts. It can only be used with pin D6 as the receiver and D5 as the transmitter. You cannot use pin D4 if using AltSoftSerial.

            To use AltSoftSerial with a Mayfly or Mbili you must add these lines to the top of your sketch:

        Viewing 2 reply threads
        • You must be logged in to reply to this topic.