Open MDAR opened 1 year ago
Using the I2C scanner in the default firmware of an AtomS3, I have discovered that the 8Servo unit has a base address of 0x25
It seems that the I2C address changes, depending on which device it's connected it
AtomS3 seems to be 0x54 M5stickC-Plus 0x25
Other than that, I can't get any result from it.
I've got to a point where the Servo is sent 180° and 0°
But nothing happens with the Servos.
The Servos twitch when they are powered up, so I have to assume they are working.
Is there anything I can do to test the outputs of the Servo connections to confirm the code is working?
can you offer any assistance?
I have tried all combinations in this script, but the servo's do nothing.
Could it be that the drive.enableServoPower(1);
line is not working?
Script I have tried
/*
*******************************************************************************
* Copyright (c) 2022 by M5Stack
* Equipped with M5StickC sample source code
* 配套 M5StickC 示例源代码
* Visit for more information: https://docs.m5stack.com/en/hat/hat_8servos_1.1
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/hat/hat_8servos_1.1
*
* Product: 8Servos HAT v1.1.
* Date: 2022/07/12
*******************************************************************************
Control the running and release of the servo.
控制伺服机的运行和释放
*/
#include <M5StickC.h>
#include <M5GFX.h>
#include "Hat_8Servos.h"
M5GFX display;
M5Canvas canvas(&display);
Hat_8Servos drive;
bool Arelease = false;
bool Brelease = false;
void btn_task(void *arg) {
while (1) {
if (M5.BtnA.wasPressed()) {
Arelease = !Arelease;
Serial.println("Button A Released");
}
if (M5.BtnB.wasPressed()) {
Brelease = !Brelease;
Serial.println("Button B Released");
}
M5.update();
vTaskDelay(20);
}
}
void setup() {
M5.begin();
display.begin();
// Wire.begin(); // Init wire and join the I2C network.
if (display.isEPD()) {
display.setEpdMode(epd_mode_t::epd_fastest);
display.invertDisplay(true);
display.clear(TFT_BLACK);
}
display.setRotation(1);
canvas.setTextDatum(MC_DATUM);
canvas.setTextColor(BLUE);
canvas.createSprite(display.width(), display.height());
canvas.setTextSize((float)canvas.width() / 160);
while (!drive.begin(&Wire, 0, 26, 0x25)) { // Top port
// while (!drive.begin(&Wire, 33, 32, 0x25)) { // Bottom Grove port
canvas.drawString("Connect Error", 30, 40);
canvas.pushSprite(0, 0);
vTaskDelay(100);
}
canvas.drawString("8SERVO HAT", 80, 10);
canvas.drawString("Click Btn A", 80, 20);
canvas.drawString("for release Servo", 80, 30);
canvas.pushSprite(0, 0);
xTaskCreate(btn_task, /* Task function. */
"btn_task", /* String with name of task. */
8096, /* Stack size in bytes. */
NULL, /* Parameter passed as input of the task */
1, /* Priority of the task. */
NULL); /* Task handle. */
}
void loop() {
if (Arelease) {
drive.enableServoPower(0);
canvas.fillRect(0, 40, 160, 40, BLACK);
canvas.drawString("SERVO RELEASE", 80, 50);
Serial.println("Servo released");
canvas.pushSprite(0, 0);
vTaskDelay(100);
} else {
canvas.fillRect(0, 40, 160, 40, BLACK);
canvas.drawString("SERVO RUNNING", 80, 50);
Serial.println("Servo running");
canvas.pushSprite(0, 0);
drive.enableServoPower(1);
vTaskDelay(100);
drive.setAllServoAngle(180);
// drive.setAllServoPulse(2500); // 180deg
// drive.setServoPulse(0, 2500); // 180deg
// drive.setServoAngle(0, 0);
Serial.println(String(drive.getServoAngle(0)));
vTaskDelay(600);
drive.setAllServoAngle(0);
// drive.setAllServoPulse(500); // 0deg
// drive.setServoAngle(0, 180);
// drive.setServoPulse(0, 500); // 0deg
Serial.println(String(drive.getServoAngle(0)));
vTaskDelay(600);
}
}
FYI
All "Tower Pro - Micro Servo gg SG90" or "Emax ES08MAII Analog Servo" servo's are brand new and have never been connected to anything else.
I get a small jitter from there when first powered up.
8Servo board has 9V external power
I think I have found one of the issues.
There are TWO 8Servo versions.
V1.1 which is an open PCB that connected to the HAT pins, with a battery on-board @ address 0x36 https://shop.m5stack.com/products/m5stickc-8-channel-servo-driver-hat
and a V1.0 outboard white version, with external power connections, which I have been trying to use with V1.1 examples. https://shop.m5stack.com/products/8-channel-servo-driver-unit-stm32f030
I have a V1.1, I'll try that now.
HOWEVER - I see a THIRD version on the website https://shop.m5stack.com/products/m5stickc-8servos-hat
So now I know which board / Unit I am using, I STILL can't get any response from the servo's, other than their jitter when they power up.
Any advice?
FYI
I have achieved some movement with the Outboard 8Servo unit on a StickC-Plus, using UIFlow, which proves it can and does work.
However, I need to figure out how to get it working with the Arduino code I have spent 3 weeks working on already
It took my 3 day to finally find this example for the HAT Servo
Which at least gives one working Servo to demonstrate with
Hi
I'm trying to add the 8Servo unit to my M5StickC-Plus
The first thing I always do is run your example to confirm everything is at least working as you intend it to.
On this occasion, all I can get out of the M5StickC-Plus is "Connect Error"
I have tried using the bottom Grove port with pins 32 & 33, but nothing changes.
What can you suggest I do next?