脉冲继而控制步进电机转动"/>
基于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_OBJECTpublic: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_Hmainwindow.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算法,串口发送,单片机接收,输出脉冲继而控制步进电机转动
发布评论