简体   繁体   English

尽管 output 设置为 HIGH,为什么 Nucleo 144 上的引脚没有输出足够高的电压?

[英]Why is the pin on a Nucleo 144 not outputting a high enough voltage, despite the output being set to HIGH?

I am trying to control a stepper motor, using a A4988 driver along with a Nucleo 144 board with an STM32F767ZI on it.我正在尝试使用 A4988 驱动器和带有 STM32F767ZI 的 Nucleo 144 板来控制步进电机。

The A4988 driver expects a single rise in voltage to HIGH in order to step the motor. A4988 驱动器期望电压单次上升到 HIGH 以使电机步进。

Having made some voltage readings using a multimeter, I have found that during and even while the program is paused, there is a steady voltage of around 1.2V being output by the pin.使用万用表读取了一些电压读数后,我发现在程序暂停期间甚至在程序暂停期间,引脚 output 的稳定电压约为 1.2V。

I also added some lines to toggle an LED (built onto the board) whenever the output to the A4988 driver is toggled between HIGH and LOW, which works fine.每当 A4988 驱动器的 output 在 HIGH 和 LOW 之间切换时,我还添加了一些线来切换 LED(内置在板上),效果很好。

Here is the code:这是代码:

main.c main.c

#include "./headers/stm32f767xx.h"
#include <stdint.h>

int main(void)
{
    initMotor(0);
    initLed(0);
    uint32_t a = 0;
    while (1)
    {
        if (a >= 300000)
        {
            toggleLed(0);
            stepMotor(0);
            a = 0;
        }
        a++; 
    }
}

./drivers/motor.c ./驱动器/电机.c

#include "../headers/stm32f767xx.h"

void initMotor(int step_pin)
{
    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOGEN; // enable GPIOG clock
    GPIOG->MODER &= ~(0b11 << (step_pin * 2)); // clear bits
    GPIOG->MODER |= (0b01 << (step_pin * 2)); // set mode to OUTPUT
    GPIOG->OTYPER &= ~(0b1 << step_pin); // set output type to PUSH-PULL
    GPIOG->PUPDR |= (0b10 << (step_pin * 2)); // pull the pin down
    GPIOG->ODR &= ~(0b1 << step_pin); // set output to LOW
}

void stepMotor(int step_pin)
{
    GPIOG->ODR ^= (0b1 << step_pin); // toggle between LOW and HIGH
}

./drivers/led.c ./drivers/led.c

#include "../headers/stm32f767xx.h"

void initLed(int pin)
{
    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN; // enable GPIOG clock
    GPIOB->MODER |= (0b01 << (pin * 2)); // set mode to OUTPUT
    GPIOB->OTYPER &= ~(0b1 << pin); // set output type to PUSH-PULL
    GPIOB->ODR &= ~(0b1 << pin); // set output to LOW
}

void toggleLed(int pin)
{
    GPIOB->ODR ^= (0b1 << pin); // toggle between LOW and HIGH
}

I've verified, using a multimeter, that the voltage being provided to the board via an STLINK USB is 5V (which I believe is sufficient), and the driver is also receiving the correct voltage of 5V.我已经使用万用表验证了通过 STLINK USB 提供给电路板的电压为 5V(我认为这已经足够),并且驱动器也接收到正确的 5V 电压。

I do not believe this to be a problem to do with the A4988 driver.我不认为这与 A4988 驱动程序有关。 I have tried multiple of the same driver from various manufacturers, and still I get the same result.我尝试了来自不同制造商的多个相同驱动程序,但仍然得到相同的结果。 The motors are also being supplied a high enough voltage (12V) but are not drawing it all in.电机也提供了足够高的电压(12V),但并未全部投入。

I have come to the conclusion that it is most likely an issue originating from the Nucleo 144 board, but a little stuck as to what the actual issue is.我得出的结论是,这很可能是源于 Nucleo 144 板的问题,但对于实际问题是什么有点卡住了。

I am using GPIO G pin 0, which is labelled "IO" on the board.我正在使用 GPIO G 引脚 0,它在板上标记为“IO”。

Any suggestions as to what I should try next, or ideas as to what it could be, are greatly appreciated.任何关于我下一步应该尝试什么的建议,或者关于它可能是什么的想法,都非常感谢。


As requested, here is a diagram of my setup:根据要求,这是我的设置图:

图表

If you configure the output to be PUSH/PULL, adding a PULLDOWN resistor will divide the output voltage over the resistor.如果您将 output 配置为 PUSH/PULL,则添加一个 PULLDOWN 电阻会将 output 电压分压到该电阻上。 Do not use PU/PD resistors with PP, because it is always driven and doesn't need a PU/PD.不要将 PU/PD 电阻与 PP 一起使用,因为它总是被驱动并且不需要 PU/PD。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM