基于opencv的图像分析,PID算法,串口发送,单片机接收,输出脉冲继而控制步进电机转动

编程入门 行业动态 更新时间:2024-10-05 11:16:15

基于opencv的图像分析,PID算法,串口发送,单片机接收,输出<a href=https://www.elefans.com/category/jswz/34/1771345.html style=脉冲继而控制步进电机转动"/>

基于opencv的图像分析,PID算法,串口发送,单片机接收,输出脉冲继而控制步进电机转动

基于opencv的图像分析串口发送,单片机接收,输出脉冲继而控制步进电机转动
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDebug>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include "imagebuffer.h"
#include "wlinkusbcamera.h"
using namespace cv;
#include<QTimer>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void Init() ;
    void PidControl(int,int,int,int);
    void sendSerialPortData(long , char,long );
    void handleSerialError(QSerialPort::SerialPortError error,bool &);
private slots:
    void on_clearButton_clicked();
    void on_sendButton_clicked();
    void on_openButton_clicked();
    void Read_Data();
    void slot1();
    void on_PidChange_valueChanged(int value);
    void on_PidChange_sliderReleased();
    void on_PidChange_sliderPressed();
    void on_pushButton_clicked();
    void on_pushButton_2_clicked();
    void on_pushButton_3_clicked();
private:
    Ui::MainWindow *ui;
    QSerialPort *serial;
    WLinkUsbCamera *tab ;
    QTimer *timer;
    int LastError;               //Error[-1]上一次
    int PrevError;               //Error[-2]上两次
    int Output;
};
#endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <opencv2/opencv.hpp>
#include "opencv2\highgui\highgui.hpp"
#include <QMessageBox>
#include<QDebug>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),LastError(0),PrevError(0),Output(0)
{
    ui->setupUi(this);
    Init();
    qDebug()<<"sioflong"<<sizeof(long)<<sizeof(int)<<sizeof(char);

更多推荐

基于opencv的图像分析,PID算法,串口发送,单片机接收,输出脉冲继而控制步进电机转动

本文发布于:2024-02-07 05:59:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1754351.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脉冲   串口   单片机   算法   步进电机

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!