analogWrite on Maxi

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

analogWrite on Maxi

Post by KoderJan » Wed Jun 17, 2020 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:

Code: Select all

#include <Controllino.h>

#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!

Post Reply