亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? msbl21xx.c

?? modbus 運(yùn)用事例
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
			0x00001 -> 	0x00016 (Digital Output 0 -> Digital Output 15)    
		 
\*=========================================================================*/

int msOutWr(unsigned wCoil, int bState)
{
	//  Check to see if a valid output channel is being called.  
	if ( wCoil > (OUTPUT_AMOUNT) )	return MS_BADADDR;
	//  update the shadow used in the msOutRd function.
	acShad[wCoil] = bState;
	// Update the digital outpu;
	digOut(wCoil,bState);
	return 0;
}

/*=========================================================================*\
	msIn:	(02:	Discrete Input Status)
		Used for reading the state of the individual digital inputs.
		
	  registers used;	   
	 		0x10001 -> 	0x10024 (Digital Input 0 -> Digital Input 23) 
	 			   
\*=========================================================================*/

int msIn(unsigned wCoil, int *pnState)
{
	//  Check to see if a valid input channel is being called.    
	if (wCoil > INPUT_AMOUNT)	return MS_BADADDR;
	//  Read the input and store it.
	*pnState = digIn(wCoil);
	return 0;
}

/*=========================================================================*\
	msInput:	(04:	Reading from a Input Register)  
		   
		For reading the individual CALIBRATED values of each adc inputs.
		Since Modbus deals with unsigned ints (words), and our VDC input
		function returns a float, the function will need to store the value
		as two registers type casted into unsigned ints for the Modbus 
		protocol to accept properly.  How this is done must be the same for
		both the Master and the slave.  This example shows one way to 
		accomplish that.  The Master must use the same method for decoding
		the two unsigned ints and convert it back to a float.  A sample of
		this is the msWrite function that converts 2 unsigned ints into a
		float for use with the DAC outputs.
		
		registers used;
		  	0x30001 -> 0x30002 = Float val of ADC 0    
			0x30003 -> 0x30004 = Float val of ADC 1  
			0x30005 -> 0x30006 = Float val of ADC 2  
			0x30007 -> 0x30008 = Float val of ADC 3  
			0x30009 -> 0x30010 = Float val of ADC 4    
			0x30011 -> 0x30012 = Float val of ADC 5  
			0x30013 -> 0x30014 = Float val of ADC 6  
			0x30015 -> 0x30016 = Float val of ADC 7  
			0x30017 -> 0x30018 = Float val of ADC 8  
			0x30019 -> 0x30020 = Float val of ADC 9  
			0x30021 -> 0x30022 = Float val of ADC 10 
		    
\*=========================================================================*/

int msInput(unsigned wReg, unsigned *pwValue)
{
	static float calVal;
	static unsigned int  uiVal[2];
	// Since it will take two registers per input, you must double the 
	// amount of register neccessary.
	if (wReg > (ADC_AMOUNT * 2) )	return MS_BADADDR;
	
	// if the input is odd the get the new adc value
	if ( !(wReg % 2) )
	{
  		// You must divide the wReg value by 2 when getting the proper channel	
		calVal = anaInVolts(wReg/2);    
		// move the adc float value int a holding array of 4 bytes
		*(float *) & uiVal[0] = calVal;
		// copy the first 2 bytes of the holding array into the register value
		*pwValue = uiVal[0];    
	}
	// if the register is even
	else
	{
		// copy the last 2 bytes of the holding array into the register value.
		// DO NOT recalculate the input value.
		*pwValue = uiVal[1];	   
	}
	return 0;
}

/*=========================================================================*\
	msWrite:	(03:	Writing to Holding Registers)  
		   
		Will write to the DAC channels (0-3)  This function will take a
		converted float valued (from 2 unsigned int  values) and update the
		DAC output values (in Volts 0-10VDC).  It also will update the 
		analog output shadow register aoShad[analog output] used in the
		msRead function.
		
		registers used;
			0x40001 -> 0x40002 = Float val for DAC 0
			0x40003 -> 0x40004 = Float val for DAC 1  
			0x40005 -> 0x40006 = Float val for DAC 2 
			0x40007 -> 0x40008 = Float val for DAC 0 
		
\*=========================================================================*/

nodebug
int msWrite(unsigned wReg, unsigned wValue)
{
	static unsigned int uiVal[2];
	static float fVal;
	if (wReg > (DAC_AMOUNT * 2) )	return MS_BADADDR;
	// Will store the first of the register pairs starting with the odd number  
	if ( !(wReg % 2) )  
	{
	  	uiVal[0] = wValue;
 	}
	// if the register is even
	else
	{
		
		// store the next register value
 		uiVal[1] = wValue;   
 		// typecast the two stored values and save it as a float value.
		fVal = 	* (float *) &uiVal[0];    
		if (fVal <= MAX_DAC_VOLTS)
		{
			// update the new analog output value.
 			anaOutVolts(wReg/2, fVal);
 			// store the new updated value into its shadow register.
			aoShad[wReg/2] = fVal;
		}
		else return MS_BADDATA;    
	} 
	return 0;
}

/*=========================================================================*\
	msRead:	(03:	Reading Holding Registers)
		Will read the DAC channels shadow register value.  
		
		The Data being sent comes from the shadow registers that are being
		updated by msWrite.
		
		registers used;
			0x40001 -> 0x40002 		float value of DAC channel 0
			0x40003 -> 0x40004		float value of DAC channel 1   
			0x40005 -> 0x40006		float value of DAC channel 2   
			0x40007 -> 0x40008		float value of DAC channel 3     

\*=========================================================================*/

int msRead (unsigned wReg, unsigned *pwValue)
{
	static unsigned int  uiVal[2];
	// Since it will take two registers per input, you must double the 
	// amount of register neccessary.
	if (wReg > (DAC_AMOUNT * 2) )	return MS_BADADDR;
	
	
	if ( !(wReg % 2) )
	{
  		// copy the first 2 bytes of the holding array into the register value
		*(float *) & uiVal[0] = aoShad[wReg/2];    
		*pwValue = uiVal[0];    
	}
	// if the register is even
	else
	{
		// copy the last 2 bytes of the holding array into the register value.
		*pwValue = uiVal[1];	 
 	}
	return 0;	
}


/******************* End of Modbus Functions  ******************************/


/******************* Main Function *****************************************\

	Basic setup of the controller.  Once Modbus is setup, a call to msRun()
	needs to be called continually called.  Other functionalities can be
	added as long as they do not block. (i.e while loops for loops etc.).

\***************************************************************************/

void main(void)
{
	auto int loop;
	// Clear the output shadow arrays at startup of this sample
	memset(acShad, 0, sizeof(acShad));	
	memset(aoShad, 0, sizeof(aoShad));
		  
	// initialize the SBC
	brdInit();
	// initializing the outputs to be Sourcing.
	digOutConfig(0xFFFF);
	
#if	(!MODBUS_TYPE)	 
	// Open Serial port D in ASCII mode 
	msaDinit(SLAVE_ADDRESS, MODBUS_BAUDRATE);
#else
	// Open Serial port D in RTU mode
	msrDinit(SLAVE_ADDRESS, MODBUS_BAUDRATE);  
#endif

	// If there are analog inputs required, get the cal. constants from the
	// eeprom.
	
	if (ADC_AMOUNT > 0 )
	{
		// read in the cal. constants.    
		for (loop = 0 ; loop < ADC_AMOUNT ; loop++) anaInEERd(loop);    
	}
	
	// If there are analog outputs required, get the cal. constants from the  
	// eeprom.
	
	if (DAC_AMOUNT > 0 )  
	{
		// read in the cal. constants.    
		for (loop = 0 ; loop < DAC_AMOUNT ; loop++) anaOutEERd(loop);    
	}
	 
	for( ;; )								
	{
 		// Modbus slave handler function.  It must be in a continous loop.
		msRun();     
		//	Other Costates Here!!! (Make sure your code does not block.)
	}
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品原创巨作av| 国产日产欧美一区| 日韩在线卡一卡二| 欧美日韩免费视频| 蜜桃久久av一区| 欧美一卡二卡三卡四卡| 蜜桃视频免费观看一区| 国产视频一区二区在线| 99视频一区二区| 亚洲高清免费在线| 日韩欧美中文字幕公布| 国产在线精品国自产拍免费| 国产欧美一区二区三区在线看蜜臀| 国产a级毛片一区| 一区二区三区欧美亚洲| 91精品国产综合久久久久久漫画 | 亚洲精品乱码久久久久久| 色婷婷亚洲精品| 日韩高清中文字幕一区| 亚洲精品一区二区三区99| 成人av资源下载| 亚洲444eee在线观看| 精品国产精品网麻豆系列| 波波电影院一区二区三区| 亚洲成av人片一区二区梦乃| 2024国产精品| 欧洲精品中文字幕| 国产麻豆视频一区二区| 亚洲男人的天堂在线aⅴ视频| 678五月天丁香亚洲综合网| 国产在线精品一区二区夜色| 亚洲欧洲av色图| 欧美成人在线直播| 一本到不卡免费一区二区| 久久激情五月激情| 亚洲精品中文在线影院| 精品奇米国产一区二区三区| 色婷婷久久久亚洲一区二区三区| 免费的国产精品| 亚洲综合小说图片| 国产午夜精品久久久久久久| 欧美精品丝袜中出| a亚洲天堂av| 国产中文字幕一区| 亚洲午夜私人影院| 日本一区二区三区久久久久久久久不| 精品视频在线免费观看| 成人午夜av影视| 久久99精品一区二区三区三区| 一区二区三区四区中文字幕| 国产亚洲午夜高清国产拍精品| 欧美日韩不卡在线| eeuss鲁一区二区三区| 精品一区二区三区在线播放| 亚洲综合视频在线| 国产精品短视频| 国产清纯白嫩初高生在线观看91| 日韩欧美你懂的| 欧美日韩一区二区三区视频| 99久久精品国产一区| 国产成人久久精品77777最新版本| 五月综合激情日本mⅴ| 成人欧美一区二区三区在线播放| 樱花草国产18久久久久| 国产三级精品三级| 精品毛片乱码1区2区3区| 日韩一区二区电影网| 欧美另类一区二区三区| 欧美无乱码久久久免费午夜一区| 色琪琪一区二区三区亚洲区| 成人av网站在线观看免费| 国产一区二区女| 国产黄人亚洲片| 国产精品亚洲一区二区三区妖精| 久久国产剧场电影| 久久99国产精品免费| 青青草91视频| 精品在线免费视频| 久久av老司机精品网站导航| 日本vs亚洲vs韩国一区三区二区| 天天影视涩香欲综合网| 日本伊人精品一区二区三区观看方式| 婷婷综合在线观看| 亚洲成av人片在线| 免费在线观看不卡| 国内精品国产三级国产a久久| 国内外成人在线| 国产成人av影院| 成人h动漫精品一区二区| 不卡一区二区三区四区| 色综合天天综合网天天狠天天| 欧洲中文字幕精品| 欧美日本在线播放| 日韩免费高清电影| 日本一区二区综合亚洲| 国产精品久久久久影院| 一区二区三区在线视频免费观看| 亚洲成人免费影院| 看片的网站亚洲| 床上的激情91.| 91成人在线免费观看| 欧美日韩黄视频| 精品电影一区二区三区 | 久久99精品久久久| 国产成人精品免费网站| 97久久精品人人爽人人爽蜜臀| 欧美午夜免费电影| 精品国产一区二区亚洲人成毛片| 中文字幕免费观看一区| 一区二区三区四区激情| 免费高清在线视频一区·| 成人免费毛片aaaaa**| 欧美中文字幕一区| 亚洲精品在线观| 亚洲同性gay激情无套| 日本不卡123| thepron国产精品| 欧美一区二区三区在| 欧美国产激情一区二区三区蜜月| 亚洲一区二区三区免费视频| 久久国产精品99精品国产| 色综合久久六月婷婷中文字幕| 日韩一区二区精品| 亚洲欧美一区二区三区国产精品 | 亚洲免费观看在线视频| 视频在线在亚洲| av电影在线不卡| 欧美精品一区二区三区高清aⅴ | 国产色产综合色产在线视频| 亚洲另类在线一区| 久久99久久99小草精品免视看| 91久久一区二区| 久久久久99精品一区| 日韩中文字幕亚洲一区二区va在线| 福利电影一区二区| 91精品国产91久久久久久最新毛片 | 国产夫妻精品视频| 欧美日韩电影在线播放| 国产精品免费视频观看| 麻豆精品精品国产自在97香蕉| 色哟哟欧美精品| 亚洲国产激情av| 激情综合色综合久久综合| 欧美日韩国产成人在线91| 国产精品传媒入口麻豆| 激情综合色播激情啊| 日韩亚洲欧美综合| 一级女性全黄久久生活片免费| av不卡在线播放| 日本一区免费视频| 国产精品一区免费在线观看| 日韩一区二区三区精品视频| 亚洲一区二区综合| 91在线国产福利| 国产精品久久久久久久久果冻传媒| 精品一区二区三区不卡| 欧美一区二区久久| 日韩一区欧美二区| 欧美色偷偷大香| 五月婷婷欧美视频| 欧美网站一区二区| 亚洲.国产.中文慕字在线| 在线观看日韩电影| 亚洲大片免费看| 欧美日韩电影在线播放| 视频一区二区三区在线| 欧美精品高清视频| 全部av―极品视觉盛宴亚洲| 欧美男生操女生| 美女视频免费一区| 亚洲免费在线播放| 在线观看免费视频综合| 亚洲高清视频在线| 91精品国产综合久久久久久久| 性做久久久久久久久| 538prom精品视频线放| 奇米影视在线99精品| 337p日本欧洲亚洲大胆色噜噜| 精品在线一区二区三区| 欧美激情在线看| 91在线精品一区二区| 亚洲午夜一区二区| 日韩欧美在线综合网| 国产东北露脸精品视频| 亚洲视频免费看| 精品视频一区二区三区免费| 日韩国产欧美在线视频| 精品成人在线观看| 粉嫩高潮美女一区二区三区| 亚洲欧美精品午睡沙发| 欧美日韩国产精品自在自线| 久久99国产精品尤物| 国产精品久久一卡二卡| 欧美日韩国产一级| 国产真实乱子伦精品视频| 亚洲欧美综合另类在线卡通| 在线看日韩精品电影| 精品午夜久久福利影院| 亚洲欧美一区二区在线观看| 精品视频色一区|