analogWrite on Maxi

Stuck? We'll be happy to help!
Post Reply
Posts: 2
Joined: Wed Jul 10, 2019 8:25 am

analogWrite on Maxi

Post by KoderJan » Wed Jun 17, 2020 1:29 pm


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:

Code: Select all

#include <Controllino.h>

#define DbgPrintLn(X)   Serial.println (X);

//-- Declaration of some global variables
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
  Serial.println(F("Serial started"));

  pinMode(GPinNo, OUTPUT );


//-- Main routine
int lLoop = 0;
int lValue = 0;

void loop() {
    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));  }

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

    //-- Set to 0 and wait a moment
    analogWrite(GPinNo, 0 );
Thank you!

User avatar
Posts: 75
Joined: Tue Dec 18, 2018 3:44 pm

Re: analogWrite on Maxi

Post by Lukas » Mon Aug 10, 2020 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.


Post Reply