Forum Replies Created

Viewing 1 - 4 of 4 posts
  • Johnnycatt

    Member
    May 4, 2021 at 11:01 pm

    Sounds great!

    I used mine to count the revolutions of a Sprocket so I’d know where items were on a conveyor.

    On the Conveyor, we are measuring the length of Telephone poles, then sorting them into bins by length — so far it’s doing great!

  • Johnnycatt

    Member
    May 4, 2021 at 9:46 am

    Leo,

    I am using the Screw Terminals A0 and A1.

    I am NOT using the <controllino.h> library, but just the basic “arduino coding.” I have made a mistake and uploaded my Arduino UNO code I was using for practice, NOT my Controllino Code (I will try to edit the original sketch).

    The Controllino code should read:

    unsigned long A = A0;

    unsigned long B = A1;


    NOTE: “unsigned long” is not needed here, but I originally used “int” for all my variables in the sketch and with a 600 pulse-per-revolution enocoder, I ran out of numbers very fast and replaced ALL my “int” with “unsigned long.”

    As for the Pull-up resistors, I soldered two 6.8kOhm resistors (in parallel) to the end of a wire. One resistor was put into A0 and the other in A1. The other end of the wire was connected to my 12V supply.


    AS for the encoder, Channel A from the encoder is ALSO in Screw Pin A0. Channel B is in Screw Pin A1 with it’s resistor. It is not a pretty solution, but it works perfectly.

    • This reply was modified 3 years, 6 months ago by  Johnnycatt.
    • This reply was modified 3 years, 6 months ago by  Johnnycatt.
    • This reply was modified 3 years, 6 months ago by  Johnnycatt.
  • Johnnycatt

    Member
    May 1, 2021 at 10:34 am

    You should be able to make serial data exchanges between the MKR WAN 1300 and the Controllino pin header.

    The Controllino Pin Headers allows access to the ATmega328P processor, just like you are using a regular Arduino UNO. Once they are connected, then it seems logical that the MKR WAN 1300 could send commands to Controllino.

    I have not tested this and have never used a MKR WAN 1300

  • Johnnycatt

    Member
    May 1, 2021 at 10:17 am

    For those who may need this answered in the future.

    After doing a bit of digging, I discovered this thread:

    https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library/issues/26

    Which eventually led to this solution:

    https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library/pull/32/commits/502b37939f477f97c52b6a42424611255b7f9f9a

    In short, I simply needed two “pull-up resistors.” To solve my problem and get the LPD3806 encoder working, I added a resistor (I used a 6.8kOhm) to both input pins (Input0 and Input1) in the same input screw terminals that the Encoder leads were attached. I connected the resistors to the 12v power supply.

    In the Code, I changed pinMode(1, INPUT_PULLUP); and pinMode(2, INPUT_PULLUP); to pinMode(1, INPUT); and pinMode(2, INPUT);

    WORKS GREAT! This is the code Used to read the encoder (I did not use the CONROLLINO.h library for this project):

    //***************************BEGIN CODE******************************

    unsigned long A = 3;

    unsigned long B = 2;

    unsigned long currentStateA;

    unsigned long lastStateA;

    unsigned long pulse;

    unsigned long previousPulse;

    void setup () {

    pinMode(A,INPUT); // not INPUT_PULLUP since we are attaching external Pullup reistors

    pinMode(B,INPUT); //not INPUT_PULLUP since we are attaching external Pullup reistors

    lastStateA = digitalRead(A);

    Serial.begin(9600);

    }

    void loop() {

    currentStateA = digitalRead(A);

    if (currentStateA != lastStateA && currentStateA == 1){

    if (digitalRead(B) != currentStateA) {

    pulse –;

    }

    else {

    pulse ++;

    }

    }

    lastStateA = currentStateA;

    //delay(1) you may need to add a very short delay here to de-bounce signal depending on // your speed (RPM)

    if (pulse != previousPulse) {

    Serial.println(pulse);

    }

    previousPulse = pulse;

    }

    //*******************************END CODE*****************************

    Controllino is a great product, I wish it had switches to disable the internal pull-down resistors to allow for “INPUT_PULLUP’ code to be used, but hopefully this answer helps someone in the future.

    • This reply was modified 3 years, 6 months ago by  Johnnycatt.
Viewing 1 - 4 of 4 posts