Skip to content

Servo control or console output (serial) : with UNO WiFi Rev2, you must choice ! #22

Open
@danielrueil

Description

@danielrueil

Servo library allows to control a servo by sending pulses to the servo. Using the library with UNO R3 gives correct results : a constant pulse duration in myservo.write (int) gives a stable servo position. Using the library with UNO WiFi Rev2 gives correct duration in 95% of time but random duration in 5% of time. So, the servo does random position jumps.

After a couple of days of research, I understand the issue is linked to simultaneous usage of Serial and Servo. Uncomment Serial.begin(115200) makes the issue disappear. This issue is blocking.

My environnement :

  • IDE 1.8.8
  • Servo library 1.1.3
  • Card type declared in IDE : Arduino Uno WiFi Rev2
  • Registers emulation: none (ATMEGA4809)
  • Pin D2 used to send pulses

test sketch :

#include <Wire.h>        // for communication with a Sharp device
#include <Servo.h>     
#define  POS_MIN 550 
#define  POS_MAX 2250 
#define  servo_pin  2    // servo pulses pin

Servo my_servo;

void setup() 
{
  my_servo.attach(servo_pin, POS_MIN, POS_MAX); 
  my_servo.write(POS_MIN); 

//********************************************************************

//  Serial.begin(115200); => uncomment this line makes the issue visible with a scope
/*
  delay(2000);
  Serial.println("   ");
  Serial.println("UnoWiFi_basic_test");
*/
//********************************************************************

  Wire.begin();
}
void loop() 
{                    
    process_test();  
}  
void process_test()       
{
    int angle = 675;
    mon_servo.write(angle); 
    Serial.print(" ");
    Serial.println (angle);
    delay(20); 
}   

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions