女人自慰AV免费观看内涵网,日韩国产剧情在线观看网址,神马电影网特片网,最新一级电影欧美,在线观看亚洲欧美日韩,黄色视频在线播放免费观看,ABO涨奶期羡澄,第一导航fulione,美女主播操b

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

如何使用MATLAB GUI從基于Arduino的IR轉(zhuǎn)速表讀取RPM

454398 ? 來源:網(wǎng)絡(luò)整理 ? 作者:網(wǎng)絡(luò)整理 ? 2019-11-21 16:37 ? 次閱讀

步驟1:在MATLAB

打開您的MATLAB,然后鍵入命令:“ guide”

如果一切正常,將打開一個(gè)窗口供您設(shè)計(jì)布局。如果無(wú)法獲取該窗口,請(qǐng)檢查您的MATLAB安裝中是否包含該模塊。我的MATLAB版本是R2012b,安裝了默認(rèn)設(shè)置和軟件包。

讓我們假設(shè)您在輸入“指南”后會(huì)感覺很好。放置窗口組件如下:

-1切換按鈕

-2靜態(tài)文本

按圖片所示排列布局(實(shí)際上,布局要只要您易于使用和閱讀,就可以通過修改屬性檢查器中的“字符串”值來更改每個(gè)對(duì)象中的文本(任何您想要的內(nèi)容)(選擇對(duì)象-右鍵單擊-屬性檢查器,或雙擊)

然后,保存該GUI圖形文件。

步驟2:編寫代碼

ARDUINO代碼

arduino的代碼與您在此處可以找到的代碼基本相同:https://www.instructables.com/id/Infrared-Tachomete 。..但因?yàn)檫@里我僅想要顯示rpm值(而不是rps值以及所有的“ rps”和“ rpm”文本),所以我編輯了一些行(那些具有Serial.print()的行,因?yàn)橐郧霸摮绦蛑荚陲@示讀數(shù)在記事本式串行監(jiān)視器上,但現(xiàn)在我們只需要rpm值即可輸入到靜態(tài)文本字符串中)。好的,為了方便快捷,我將代碼復(fù)制到此處,您可以自行檢查以與之前的代碼進(jìn)行比較。請(qǐng)記住,arduino代碼的主要目的只是將值傳遞給串行comm,因此該程序僅作為示例,如果您有自己的程序?qū)⑷魏巫x取到的傳感器的值打印到串行,然后忽略此操作即可。

int sensorvalue;

int state1 = HIGH;

int state2;

float rps;

float rpm;

long prevMillis = 0;

long interval = 100;

long currentTime;

long prevTime = 1;

long diffTime;

int sensorthreshold = 30; // this value indicates the limit reading between dark and light,

// it has to be tested as it may change acording on the

// distance the leds are placed.

// to see what number is good, check the sensorvalue variable value

// as printed out in the serial monitor

void setup()

{

Serial.begin(9600);

pinMode(13,OUTPUT); // assign pin 13 led as indicator because we cannot se the IR light

}

void loop()

{

sensorvalue = analogRead(0); // read from pin 0

if(sensorvalue 《 sensorthreshold)

state1 = HIGH;

else

state1 = LOW;

digitalWrite(13,state1); // as iR light is invisible for us, the led on pin 13

// indicate the state of the circuit.

if(state2!=state1){ //counts when the state change, thats from (dark to light) or

//from (light to dark), remember that IR light is invisible for us.

if (state2》state1){

currentTime = micros(); // Get the arduino time in microseconds

diffTime = currentTime - prevTime; // calculate the time difference from the last sensors meet-up

rps = 1000000/diffTime; // calculate how many rev per second - good to know

rpm = 60000000/diffTime; // calculate how many rev per minute

unsigned long currentMillis = millis();

// print to serial at every interval - defined at the variables declaration

if(currentMillis - prevMillis 》 interval){ // see if now already an interval long

prevMillis = currentMillis;

Serial.println(rpm); // this line is edited from the code in the prev instructable

}

prevTime = currentTime;

}

state2 = state1;

}

/* only for testing to determine the sensorthreshold value

delay(500);

Serial.println(sensorvalue);

*/

}

MATLAB代碼

在MATLAB GUI布局設(shè)計(jì)窗口中,單擊“查看-編輯器”(或在工具欄中找到?jīng)]有手的紙和鉛筆的圖片)。將打開一個(gè)編輯器窗口,其中已經(jīng)編寫了一些代碼,MATLAB為您編寫了它們,沒問題。只為切換按鈕編寫回調(diào)函數(shù),其余代碼可以保留不變。就我而言,我將切換按鈕命名為OnOffToggle,因此編寫代碼的函數(shù)是函數(shù)OnOffToggle_Callback(hObject,eventdata,handles)。 rpmdata,所以我們只想將rpm數(shù)據(jù)打印到屏幕上即可。還有一件事,請(qǐng)確保在編寫代碼時(shí)將arduino連接到正確的COM端口。在這段代碼中,我寫了COM3,因?yàn)槲覍rduino連接到了COM3。

然后保存您的m文件。

下面是完整代碼(僅編輯OnOffToggle_Callback函數(shù)):

function varargout = gui(varargin)

% GUI MATLAB code for gui.fig

% GUI, by itself, creates a new GUI or raises the existing

% singleton*.

%

% H = GUI returns the handle to a new GUI or the handle to

% the existing singleton*.

%

% GUI(‘CALLBACK’,hObject,eventData,handles,。..) calls the local

% function named CALLBACK in GUI.M with the given input arguments.

%

% GUI(‘Property’,‘Value’,。..) creates a new GUI or raises the

% existing singleton*. Starting from the left, property value pairs are

% applied to the GUI before gui_OpeningFcn gets called. An

% unrecognized property name or invalid value makes property application

% stop. All inputs are passed to gui_OpeningFcn via varargin.

%

% *See GUI Options on GUIDE‘s Tools menu. Choose “GUI allows only one

% instance to run (singleton)”。

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help gui

% Last Modified by GUIDE v2.5 14-Mar-2015 01:06:09

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct(’gui_Name‘, mfilename, 。..

’gui_Singleton‘, gui_Singleton, 。..

’gui_OpeningFcn‘, @gui_OpeningFcn, 。..

’gui_OutputFcn‘, @gui_OutputFcn, 。..

’gui_LayoutFcn‘, [] , 。..

’gui_Callback‘, []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before gui is made visible.

function gui_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% varargin command line arguments to gui (see VARARGIN)

% Choose default command line output for gui

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes gui wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = gui_OutputFcn(hObject, eventdata, handles)

% varargout cell array for returning output args (see VARARGOUT);

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure

varargout{1} = handles.output;

function currentEdit_Callback(hObject, eventdata, handles)

function currentEdit_CreateFcn(hObject, eventdata, handles)

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,’BackgroundColor‘), get(0,’defaultUicontrolBackgroundColor‘))

set(hObject,’BackgroundColor‘,’white‘);

end

function OnOffToggle_Callback(hObject, eventdata, handles)

button_state = get(hObject,’Value‘);

if button_state == get(hObject,’Max‘)

set(handles.OnOffToggle,’String‘,’Stop‘);

drawnow;

i=2;

while i 》 1

rpmdata = serial(’COM3‘,’BaudRate‘,9600); % this Baud rate should be the same as that in Arduino code

fclose(instrfindall);

fopen(rpmdata);

b = fscanf(rpmdata);

set(handles.textCurrent,’String‘,b);

drawnow;

delete(rpmdata)

if get(hObject,’Value‘) == get(hObject,’Min‘)

break

end

end

set(handles.OnOffToggle,’String‘,’Start‘);

drawnow;

rpmdata = serial(’COM3‘,’BaudRate‘,9600);

fclose(rpmdata);

end

步驟3:運(yùn)行Rpm Reader

完成代碼后,連接arduino,然后轉(zhuǎn)動(dòng)旋轉(zhuǎn)并運(yùn)行程序(編輯器或布局編輯器窗口上的綠色三角形類似游戲的按鈕)。程序的一個(gè)窗口將會(huì)出現(xiàn)(我的如圖所示),單擊切換按鈕,您將在那里看到車輪的當(dāng)前轉(zhuǎn)速。

責(zé)任編輯:wv

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • matlab
    +關(guān)注

    關(guān)注

    188

    文章

    2998

    瀏覽量

    233235
  • Arduino
    +關(guān)注

    關(guān)注

    188

    文章

    6492

    瀏覽量

    190105
  • RPM
    RPM
    +關(guān)注

    關(guān)注

    0

    文章

    45

    瀏覽量

    17899
收藏 人收藏

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    無(wú)刷暴力風(fēng)扇方案,轉(zhuǎn)速與靜音的完美平衡

    轉(zhuǎn)速、強(qiáng)風(fēng)力和低噪音,使暴力風(fēng)扇迅速成為市場(chǎng)上的熱門產(chǎn)品。今天來跟大家分享其利天下技術(shù)的130000rpm無(wú)刷暴力風(fēng)扇驅(qū)動(dòng)方案。一、方案設(shè)計(jì)亮點(diǎn):高性能與便攜性的完美結(jié)合主控芯片:采用高性能32位
    的頭像 發(fā)表于 04-22 18:07 ?1043次閱讀
    無(wú)刷暴力風(fēng)扇方案,<b class='flag-5'>轉(zhuǎn)速</b>與靜音的完美平衡

    STM32G431用MCSDK5.4.8進(jìn)行PMSM永磁同步電機(jī)FOC控制,轉(zhuǎn)速上升到3500rpm無(wú)法繼續(xù)上升怎么解決?

    使用MCSDK 5.4.8 生成工程,在上位機(jī)軟件中啟動(dòng)電機(jī),設(shè)置目標(biāo)轉(zhuǎn)速達(dá)到3500rpm后,再設(shè)置更大就無(wú)法繼續(xù)升高了,轉(zhuǎn)速達(dá)不到3500rpm以上,而且還會(huì)緩慢減速,請(qǐng)問這是什么
    發(fā)表于 03-10 08:04

    請(qǐng)問ST無(wú)刷電機(jī)控制器-最高控制可調(diào)節(jié)轉(zhuǎn)速是多少?

    需求:我使用 13英寸(13*6.5)的螺旋槳,要實(shí)現(xiàn)我的電機(jī)轉(zhuǎn)速控制調(diào)節(jié),在 4000~6500RPM 進(jìn)行控制和調(diào)節(jié),請(qǐng)問你們的電機(jī)、電調(diào)板產(chǎn)品可以實(shí)現(xiàn)控制嗎,你們產(chǎn)品會(huì)有相關(guān)攻略限制嗎,例如功率和電流限制,最大控制轉(zhuǎn)速可以
    發(fā)表于 03-10 06:19

    用于課題的無(wú)線轉(zhuǎn)速霍爾傳感器,新人應(yīng)該哪里開始學(xué)習(xí)

    完全沒電路的基礎(chǔ),但是課題上導(dǎo)師要求設(shè)計(jì)一款無(wú)線的霍爾轉(zhuǎn)速傳感器,電池供電然后通過無(wú)線技術(shù)去讀取傳感器上的轉(zhuǎn)速。想請(qǐng)教下各位大佬應(yīng)該哪里開始學(xué)習(xí)比較好,或者是有現(xiàn)成的產(chǎn)品可以去模仿學(xué)
    發(fā)表于 01-08 10:36

    入門設(shè)計(jì)讀取數(shù)據(jù)開始

    說明文檔,它是每個(gè)器件的靈魂所在,提供了關(guān)于該器件的所有關(guān)鍵信息。通過仔細(xì)閱讀數(shù)據(jù),工程師可以了解到器件的工作原理、性能參數(shù)、電氣特性、機(jī)械尺寸以及應(yīng)用示例等重要內(nèi)容。這些信息將幫助我們更好地理解器件的特性和功能,
    的頭像 發(fā)表于 12-23 10:40 ?437次閱讀
    入門設(shè)計(jì)<b class='flag-5'>從</b><b class='flag-5'>讀取</b>數(shù)據(jù)<b class='flag-5'>表</b>開始

    霍爾開關(guān)AH402F在轉(zhuǎn)速表中的應(yīng)用,替換HAL1881和SS460

    霍爾開關(guān)AH402F在轉(zhuǎn)速表中的應(yīng)用,替換HAL1881和SS460
    的頭像 發(fā)表于 12-09 10:02 ?551次閱讀
    霍爾開關(guān)AH402F在<b class='flag-5'>轉(zhuǎn)速表</b>中的應(yīng)用,替換HAL1881和SS460

    2010款起亞賽拉圖車發(fā)動(dòng)機(jī)轉(zhuǎn)速表指針不動(dòng)

    2010款起亞賽拉圖車發(fā)動(dòng)機(jī)轉(zhuǎn)速表指針不動(dòng)廣西普鑫澤源汽車銷售服務(wù)有限公司李康林故障現(xiàn)象故障診斷故障排除一輛2010款起亞賽拉圖車,搭載G4ED發(fā)動(dòng)機(jī),累計(jì)行駛里程約為17.2萬(wàn)km。車主反映,車輛
    的頭像 發(fā)表于 10-31 08:03 ?531次閱讀
    2010款起亞賽拉圖車發(fā)動(dòng)機(jī)<b class='flag-5'>轉(zhuǎn)速表</b>指針不動(dòng)

    集成IR R600數(shù)據(jù)

    電子發(fā)燒友網(wǎng)站提供《集成IR R600數(shù)據(jù).pdf》資料免費(fèi)下載
    發(fā)表于 09-04 11:26 ?0次下載

    lm2917n-8無(wú)輸出怎么解決?

    您好,最近在用LM2917做一個(gè)轉(zhuǎn)速表,但按照datasheet的圖19典型電路連接,發(fā)現(xiàn)無(wú)輸出,更換元件也是沒有效果。然后又改電路按照?qǐng)D28接法,輸出脈沖信號(hào)。但仍然無(wú)輸出,換了好幾顆芯片了依然如此都無(wú)奈了,請(qǐng)各位幫幫忙!!
    發(fā)表于 09-02 06:25

    Arduino Nano 和 NodeMCU ESP8266 讀取 DHT11 環(huán)境溫濕度數(shù)據(jù)及 OLED顯示

    Arduino Nano 和 NodeMCU ESP8266 讀取 DHT11 環(huán)境溫濕度數(shù)據(jù)及 OLED顯示
    的頭像 發(fā)表于 08-13 18:04 ?1901次閱讀
    <b class='flag-5'>Arduino</b> Nano 和 NodeMCU ESP8266 <b class='flag-5'>讀取</b> DHT11 環(huán)境溫濕度數(shù)據(jù)及 OLED顯示

    IR615如何實(shí)現(xiàn)VPN鏈路備份?

    目的:IR615的鏈路備份(WAN為主鏈路、Wi-Fi做STA為鏈路),當(dāng)VPN建好后,WAN口主鏈路無(wú)線網(wǎng)絡(luò)為備用鏈路。設(shè)備固件版本:2.3.0.r5114。拓?fù)洌? 1. 配置IR設(shè)備wan口
    發(fā)表于 07-25 08:27

    變頻器怎么外接電流轉(zhuǎn)速表

    需要外接電流轉(zhuǎn)速表來測(cè)量電機(jī)的電流和轉(zhuǎn)速。 電流的作用 電流是一種測(cè)量電路中電流大小的儀器。在變頻器系統(tǒng)中,電流
    的頭像 發(fā)表于 07-19 11:17 ?4092次閱讀

    簡(jiǎn)單轉(zhuǎn)速表電路圖 轉(zhuǎn)速表的定義和應(yīng)用

    轉(zhuǎn)速表,顧名思義,是用來測(cè)量和顯示旋轉(zhuǎn)設(shè)備轉(zhuǎn)速的儀表。它通常被安裝在需要監(jiān)測(cè)轉(zhuǎn)速的設(shè)備上,如汽車發(fā)動(dòng)機(jī)、電機(jī)、風(fēng)扇、造紙機(jī)、塑料加工機(jī)械等。轉(zhuǎn)速表通過接收并處理來自旋轉(zhuǎn)設(shè)備的信號(hào),將其
    的頭像 發(fā)表于 07-10 17:33 ?3473次閱讀
    簡(jiǎn)單<b class='flag-5'>轉(zhuǎn)速表</b>電路圖 <b class='flag-5'>轉(zhuǎn)速表</b>的定義和應(yīng)用

    來寫個(gè)代碼,改變你的電機(jī)轉(zhuǎn)速

    一、KV值"KV值"是一個(gè)常用的參數(shù),它表示電機(jī)的轉(zhuǎn)速常數(shù)。KV值定義為電機(jī)在無(wú)負(fù)載條件下,每增加1伏特電壓時(shí),電機(jī)轉(zhuǎn)速增加的轉(zhuǎn)數(shù)(rpm)。換句話說,KV值是電機(jī)轉(zhuǎn)速與供電電壓
    的頭像 發(fā)表于 07-03 08:10 ?1593次閱讀
    來寫個(gè)代碼,改變你的電機(jī)<b class='flag-5'>轉(zhuǎn)速</b>

    MATLAB GUI的暫停執(zhí)行與繼續(xù)執(zhí)行問題

    MATLAB小白發(fā)問,各位大神,我想在GUI界面放一個(gè)或者兩個(gè)按鈕,實(shí)現(xiàn)程序的暫停和繼續(xù)執(zhí)行,比如:1到100計(jì)數(shù),計(jì)到45,按暫停鍵暫停,再按或者按另一個(gè)按鈕,繼續(xù)計(jì)數(shù),46開始
    發(fā)表于 06-21 12:34