• analogWrite on Maxi

     Lukas updated 3 years, 7 months ago 2 Members · 2 Posts
  • koderjan

    Member
    June 17, 2020 at 1:29 pm

    Hello,

    I’m experiencing a strange phenomenon with two Controllino Maxi devices (One regular Maxi and one Maxi automation).

    The devices are connected to a 24V power supply and I’m using analogWrite to set voltage at a certain level, but I can only set it to 0V or to 4.8V.

    I created a very basic script with a for loop which increases the value for analogWrite from 0 to 250, and back to 0 again.

    I notice that when the for loop (while counting up) reaches a value of approx.. 150 the pin goes from 0 to 4.8V

    and when counting down from a value of 250 the voltage drops to 0V when approx. 150 is reached.

    If this is helpful for you, I can send you a video which shows this behavior through wetransfer or whataspp (30 sec, 113 Mb).

    My expectation is to be able to set the voltage anywhere between 0V and 24V.

    Is this a fabrication error or am I missing something?

    This is the code I’m using to test:

    #include

    #define DbgPrintLn(X)

    Serial.println (X);

    //-- Declaration of some global variables

    int GPinNo = CONTROLLINO_A1;

    int GMaxValue = 250;

    int GDbgFreq = 1;

    int GDelayStep = 50; //ms

    //-- Setup section

    void setup() {

    //-- Start Serial

    Serial.begin(115200); // start serial for output

    while (!Serial) {

    ; // wait for serial port to connect. Needed for Leonardo only

    }

    delay(1500);

    Serial.println(F("Serial started"));

    pinMode(GPinNo, OUTPUT );

    delay(10000);

    }

    //-- Main routine

    int lLoop = 0;

    int lValue = 0;

    void loop() {

    lLoop++;

    DbgPrintLn(" ");

    DbgPrintLn("Loop #" + String(lLoop));

    //-- Go up

    for (int i = 0; i < GMaxValue; i++) { lValue = i; analogWrite(GPinNo, lValue ); if ((i % GDbgFreq) == 0) { DbgPrintLn("Value: " + String(lValue)); } delay(GDelayStep); } //-- Go down for (int i = GMaxValue; i > 0; i--) {

    lValue = i;

    analogWrite(GPinNo, lValue );

    if ((i % GDbgFreq) == 0) { DbgPrintLn("Value: " + String(lValue)); }

    delay(GDelayStep);

    }

    //-- Set to 0 and wait a moment

    analogWrite(GPinNo, 0 );

    delay(5000);

    }

    Thank you!

  • Lukas

    Member
    August 10, 2020 at 12:33 pm

    Hello Jan,

    Arduino function analogWrite() does not set real analog value to a pin, but runs PWM signal with fixed frequency and variable duty cycle.

    So with the standard MAXI you can have only 24 V PWM signal out of the output. (Please note that CONTROLLINO_A1 is analog input pin.).

    And if you get 4,8 V, you obviously measure it at the pinheader, which is not correct – please use the screw terminals.

    With the MAXI Automation the situation is better – there are two real analog outps there – please see our example.

    Thanks,

    Lukas

Viewing 1 - 2 of 2 replies

Log in to reply.

Original Post
0 of 0 posts June 2018
Now