Webcontroller not showing monitored variables

Hi, the new version of the site is awesome, but I’m facing a problem with plotting on the simple foc web. The graphs just don’t show up, no matter what settings I try to set (as in the screenshot)

The data is visible when viewed in VS Code serial monitor. Also, if you click on Clear Output in SimpleFocWeb, the data will be displayed as well (as in the screenshot).

Here is my code:

#include <SimpleFOC.h>

#include "encoders/MT6701/MagneticSensorMT6701SSI.h"



BLDCMotor motor = BLDCMotor(7, 0.19, 300, 0.00004, 0.00003);

BLDCDriver3PWM driver = BLDCDriver3PWM(16, 17, 5, 4); 



#define SENSOR1_CS 13

MagneticSensorMT6701SSI sensor(SENSOR1_CS);



InlineCurrentSense current_sense = InlineCurrentSense(0.005, 50.0, 39, 36, _NC);


// instantiate the commander

Commander command = Commander(Serial);

void doMotor(char* cmd) { command.motor(&motor, cmd); }



void setup() {

  Serial.begin(115200);

  SimpleFOCDebug::enable(&Serial);


  sensor.init();

  motor.linkSensor(&sensor);


  driver.voltage_power_supply = 22; 

  motor.voltage_sensor_align = 0.7; 

  motor.voltage_limit = 2;

  sensor.min_elapsed_time = 0.001;


  if(!driver.init()){

    Serial.println("Driver init failed!");

    return;

  }


  motor.linkDriver(&driver);

  current_sense.linkDriver(&driver);

  if(!current_sense.init()){

    Serial.println("Current sense init failed!");

    return;

  }

  // link the current sense to the motor

  motor.linkCurrentSense(&current_sense);  

  driver.pwm_frequency = 20000;

  motor.torque_controller = TorqueControlType::estimated_current;

  motor.controller = MotionControlType::angle;

  // velocity loop PID

  motor.PID_velocity.P = 0.8;

  motor.PID_velocity.I = 5;

  motor.PID_velocity.D = 0.002;

  motor.PID_velocity.output_ramp = 1000.0;

  // Low pass filtering time constant 

  motor.LPF_velocity.Tf = 0.07;

  // angle loop PID

  motor.P_angle.P = 6.5;

  motor.P_angle.I = 0.0;

  motor.P_angle.D = 0.0;

  motor.P_angle.output_ramp = 0;

  // Low pass filtering time constant 

  motor.LPF_angle.Tf = 0.1;

  // current q loop PID 

  motor.PID_current_q.P = 0.01955;

  motor.PID_current_q.I = 57.41975;

  motor.PID_current_q.D = 0.0;

  motor.PID_current_q.output_ramp = 0.0;

  motor.PID_current_q.limit = 4;

  // Low pass filtering time constant 

  motor.LPF_current_q.Tf = 0.00053;

  // current d loop PID

  motor.PID_current_d.P = 0.01288;

  motor.PID_current_d.I = 57.41975;

  motor.PID_current_d.D = 0.0;

  motor.PID_current_d.output_ramp = 0.0;

  motor.PID_current_d.limit = 4;

  // Low pass filtering time constant 

  motor.LPF_current_d.Tf = 0.00053;

  // Limits 

  motor.velocity_limit = 75.0;

  motor.voltage_limit = 3;

  motor.current_limit = 5;

  if(!motor.init()){

      Serial.println("Motor init failed!");

      return;

  }

  if(!motor.initFOC()){

      Serial.println("FOC init failed!");

      return;

  }

  motor.target = 0; // one rotation per second

  // use monitoring with serial

  // comment out if not needed

  motor.useMonitoring(Serial);

    //display variables

  motor.monitor_variables = _MON_TARGET | _MON_VEL | _MON_ANGLE; 

    // downsampling

  motor.monitor_downsample = 100; // default 10

  command.add('M', doMotor, "Motor");

  Serial.println("Motor ready!");

  Serial.println("Set target velocity [rad/s]");

  _delay(1000);

}

void loop() {
  motor.loopFOC();

  motor.move();

  // motor monitoring

  motor.monitor();

  // user communication

  command.run();
}

Hey there!

I’ve moved the discussion to the new topic to make things easier to find for the users that might have similar issues.

It seems to me that you dont have the monitoring configured fully. Webcontroller requires the monitoring output to start and finish with the motor’s id (in your case M).
You can configure this with:

  // add the motor to the commander interface
  // The letter id (here 'M') of the motor
  char motor_id = 'M';
  command.add(motor_id,doMotor,"motor");

  // configuring the monitoring to be well parsed by the webcontroller
  motor.monitor_start_char = motor_id; // the same latter as the motor id in the commander 
  motor.monitor_end_char = motor_id; // the same latter as the motor id in the commander 

The data should be visible once this is added. :smiley:

I coudn’t find a driver.init() line in your setup routine, so the whole setup should end there, right?

driver.init() will be executed right in this line before checking for ‘true’, but which “whole setup” are you talking about? All settings are performed (as limits or pid) below in the code