diff --git a/static/css/base.css b/static/css/base.css index 2c899c997de331bfaa173ceebf5f279f97c43473..0d4854a7fb3293c1f170d10b24b68aab046a0294 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -36,6 +36,14 @@ footer { font-family: 'Microsoft Yahei'; } +code{ + white-space: pre-wrap; + display: block; + color: #abb2bf; + background-color: #1b2426; + border-radius: 10px; +} + li { list-style: none; } diff --git a/wiki/pages/hardware.html b/wiki/pages/hardware.html index aac52794cb2f83844b5948fdda9d472ed89fa898..587b346195dceb7a13dbf6fd006ca7206dde2832 100644 --- a/wiki/pages/hardware.html +++ b/wiki/pages/hardware.html @@ -2,29 +2,44 @@ {% block htitle %}Hardware{% endblock %} {% block title %}Hardware{% endblock %} -{% block lead %}Hardware in iGEM should make synthetic biology based on standard parts easier, faster, better, or more accessible to our community.{% endblock %} +{% block lead %}Hardware in iGEM should make synthetic biology based on standard parts easier, faster, better, or more +accessible to our community.{% endblock %} {% block page_content %} <div class="row display ltext"> <h2>1. Motivation</h2> - <p>This project aims to study drug-resistant microorganisms in the ocean, and we have designed a portable marine drug-resistant microorganism detector for this field. Currently, there are testing tools such as enzyme markers, but these devices are costly and large, and most of the human-machine interfaces use a computer screen to connect to them and then perform the relevant operations, which is very inconvenient. Therefore, considering several aspects such as cost, portability and easy operation process, we developed a hardware system specifically adapted to our needs. The system is relatively small, can achieve rapid detection, and the human-machine interface is friendly and easy to operate.</p> + <p>This project aims to study drug-resistant microorganisms in the ocean, and we have designed a portable marine + drug-resistant microorganism detector for this field. Currently, there are testing tools such as enzyme markers, but + these devices are costly and large, and most of the human-machine interfaces use a computer screen to connect to + them and then perform the relevant operations, which is very inconvenient. Therefore, considering several aspects + such as cost, portability and easy operation process, we developed a hardware system specifically adapted to our + needs. The system is relatively small, can achieve rapid detection, and the human-machine interface is friendly and + easy to operate.</p> <p>Full view of the instrument:</p> <div class="opic large"> <img src="" alt="png"> </div> <h2>2. Hardware Components</h2> - <p>The system has 3 main modules, mainly divided into temperature regulation module, light path detection module and Android screen display module. The following shows the system block diagram.</p> + <p>The system has 3 main modules, mainly divided into temperature regulation module, light path detection module and + Android screen display module. The following shows the system block diagram.</p> <div class="opic large"> <img src="" alt="png"> </div> <h2 style="text-transform: capitalize;">2.1 Temperature regulation</h2> - <p>The samples need to be tested at a constant temperature, so here we made a heating film with a rated power of 20w and attached it to the surface of the heat-conducting aluminum according to its dimensions. Using a temperature sensor, the temperature sensor is inserted directly into the thermal conductive aluminum, so it is more accurate and real-time monitoring of the internal culture temperature of the thermal conductive aluminum. Using stm32f103c8t6 master control chip, with pid algorithm to control the temperature rise and final stabilization.</p> + <p>The samples need to be tested at a constant temperature, so here we made a heating film with a rated power of 20w + and attached it to the surface of the heat-conducting aluminum according to its dimensions. Using a temperature + sensor, the temperature sensor is inserted directly into the thermal conductive aluminum, so it is more accurate and + real-time monitoring of the internal culture temperature of the thermal conductive aluminum. Using stm32f103c8t6 + master control chip, with pid algorithm to control the temperature rise and final stabilization.</p> <p>Special thermally conductive aluminum, heating film and temperature sensor physically connected to.</p> <div class="opic large"> <img src="" alt="png"> </div> - <p>Assuming that the set temperature is 37℃, after the actual test, it can be obtained that it takes 260s to rise from room temperature 28℃ to the set temperature. the overshoot after reaching the set temperature is within 0.2℃, and the final temperature can be stabilized at about 37℃ with an error of ±0.1℃. Compared with some traditional enzyme markers, the time to warm up and reach the stable temperature is faster.</p> + <p>Assuming that the set temperature is 37℃, after the actual test, it can be obtained that it takes 260s to rise from + room temperature 28℃ to the set temperature. the overshoot after reaching the set temperature is within 0.2℃, and + the final temperature can be stabilized at about 37℃ with an error of ±0.1℃. Compared with some traditional enzyme + markers, the time to warm up and reach the stable temperature is faster.</p> <div class="opic annotation large"> <img src="" alt="png"> <p>pid algorithm to regulate the temperature</p> @@ -35,8 +50,15 @@ </div> <h2 style="text-transform: capitalize;">2.2 Optical path structure</h2> - <p>At the light source end, we use led light beads, which are small in size, consume less power at the same brightness, have high luminous efficiency, fast response time, and do not exist such as mercury, lead and other environmental pollutants, known as "green light source". Optical fiber is used to transmit the light path to the bottom of the culture chamber. We use special structural components to isolate each light source, avoiding interference from the bypass.</p> - <p>At the receiving end we use a photodiode, which transmits the generated fluorescence to the photodiode in the horizontal direction of the incubation chamber using an optical fiber. The photodiode receives the fluorescence and generates a photocurrent at the uA level, which is then detected through IV conversion, amplification circuits and A/D conversion.</p> + <p>At the light source end, we use led light beads, which are small in size, consume less power at the same + brightness, have high luminous efficiency, fast response time, and do not exist such as mercury, lead and other + environmental pollutants, known as "green light source". Optical fiber is used to transmit the light path to the + bottom of the culture chamber. We use special structural components to isolate each light source, avoiding + interference from the bypass.</p> + <p>At the receiving end we use a photodiode, which transmits the generated fluorescence to the photodiode in the + horizontal direction of the incubation chamber using an optical fiber. The photodiode receives the fluorescence and + generates a photocurrent at the uA level, which is then detected through IV conversion, amplification circuits and + A/D conversion.</p> <div class="tpic"> <img src="" alt="png"> <img src="" alt="png"> @@ -55,12 +77,14 @@ <img src="" alt="png"> </div> <h2 style="text-transform: capitalize;">2.3 Android screen display</h2> - <p>In order to improve good user experience, we have developed a software interface based on the off-the-shelf Android screen for users to use. The workflow of the whole instrument is clear on the Android screen. </p> + <p>In order to improve good user experience, we have developed a software interface based on the off-the-shelf Android + screen for users to use. The workflow of the whole instrument is clear on the Android screen. </p> <div class="opic large"> <img src="" alt="png"> </div> <h2 style="text-transform: capitalize;">2.4 Equipment Demonstration</h2> - <h3 style="text-transform: capitalize;">2.4.1 Set sample description, including sample name, incubation chamber temperature, test duration, etc.</h3> + <h3 style="text-transform: capitalize;">2.4.1 Set sample description, including sample name, incubation chamber + temperature, test duration, etc.</h3> <div class="opic large"> <img src="" alt="png"> </div> @@ -68,25 +92,37 @@ <div class="opic large"> <img src="" alt="png"> </div> - <h3 style="text-transform: capitalize;">2.4.3 Temperature is reached prompting the sample to be placed in the incubation chamber.</h3> + <h3 style="text-transform: capitalize;">2.4.3 Temperature is reached prompting the sample to be placed in the + incubation chamber.</h3> <div class="opic large"> <img src="" alt="png"> </div> - <h3 style="text-transform: capitalize;">2.4.4 Wait for the end of the test or click the End Test button to end the process.</h3> + <h3 style="text-transform: capitalize;">2.4.4 Wait for the end of the test or click the End Test button to end the + process.</h3> <div class="opic large"> <img src="" alt="png"> </div> - <p>To demonstrate the feasibility of a portable marine drug-resistant microbial assay, we used standard enzyme markers for the same samples in order to compare the results.</p> - <p>After the comparison of the results, the results of the portable marine drug-resistant microbial detector were basically consistent with those of the enzyme marker, which proved the feasibility of the portable marine drug-resistant microbial detector.</p> + <p>To demonstrate the feasibility of a portable marine drug-resistant microbial assay, we used standard enzyme markers + for the same samples in order to compare the results.</p> + <p>After the comparison of the results, the results of the portable marine drug-resistant microbial detector were + basically consistent with those of the enzyme marker, which proved the feasibility of the portable marine + drug-resistant microbial detector.</p> <h2>2.5 Circuit Design</h2> - <p>The circuit design of the portable marine drug resistance microbial detector was implemented using a PCB board, mainly with a main board and a receiver board. The off-the-shelf components are a 7" Android screen, temperature sensor, 20w heating film, Android screen for developing the software interface, after powering up, all the operations of the instrument can be realized using the buttons on the Android screen interface, and the user without any experience can fully master the operation of the instrument.</p> - <p>The main board mainly consists of voltage conversion module, stm32f103c8t6 module, receiver board interface, Android screen interface, serial port 1 interface, STLINK interface, temperature sensor interface, heating film drive circuit.</p> + <p>The circuit design of the portable marine drug resistance microbial detector was implemented using a PCB board, + mainly with a main board and a receiver board. The off-the-shelf components are a 7" Android screen, temperature + sensor, 20w heating film, Android screen for developing the software interface, after powering up, all the + operations of the instrument can be realized using the buttons on the Android screen interface, and the user without + any experience can fully master the operation of the instrument.</p> + <p>The main board mainly consists of voltage conversion module, stm32f103c8t6 module, receiver board interface, + Android screen interface, serial port 1 interface, STLINK interface, temperature sensor interface, heating film + drive circuit.</p> <h3 style="text-transform: capitalize;">Main board PCB:</h3>> <div class="opic large"> <img src="" alt="png"> </div> - <p>The receiver board mainly consists of a light source module, a photodiode module, a motherboard interface and an AD conversion module. -Receiver board PCB front:</p> + <p>The receiver board mainly consists of a light source module, a photodiode module, a motherboard interface and an AD + conversion module. + Receiver board PCB front:</p> <div class="opic large"> <img src="" alt="png"> </div> @@ -105,7 +141,10 @@ Receiver board PCB front:</p> <img src="" alt="png"> </div> <h2>Future improvements</h2> - <p>At present, the entire structure of the portable marine drug-resistant microbial detector is printed out by a 3D printer, so the printed structure will deviate slightly from the actual design of the 3D model, and the aesthetic appearance is relatively poor. The temperature sensor protrudes above the thermally conductive aluminum material, resulting in some unreasonable internal structure, but it does not affect the test.</p> + <p>At present, the entire structure of the portable marine drug-resistant microbial detector is printed out by a 3D + printer, so the printed structure will deviate slightly from the actual design of the 3D model, and the aesthetic + appearance is relatively poor. The temperature sensor protrudes above the thermally conductive aluminum material, + resulting in some unreasonable internal structure, but it does not affect the test.</p> <p>In order to solve the above problems, we have proposed several solutions.</p> <p>For the instrument appearance problem: the structure will be transferred to a professional foundry.</p> <p>For the temperature sensor problem:</p> @@ -114,294 +153,290 @@ Receiver board PCB front:</p> <h2>The related codes is following</h2> <h3>Temperature regulation by Pid algorithm:</h3> - <p>void PID_Calc(void)</p> - <p>{</p> - <p> if(pid.Sv > 50)</p> - <p> {</p> - <p> pid.Sv = 50;</p> - <p> }</p> - <p> pid.Ek = pid.Sv - pid.Pv;</p> - <p> if(pid.Ek > 1)</p> - <p> {</p> - <p> pid.OUT = pid.pwmcycle;</p> - <p> pid.SEk = 0;</p> - <p> pid.Ek_1 = 0;</p> - <p> }</p> - <p> else if(pid.Ek < -0.3)</p> - <p> {</p> - <p> pid.OUT = -pid.pwmcycle;</p> - <p> pid.SEk = 0;</p> - <p> pid.Ek_1 = 0;</p> - <p> }</p> - <p> else</p> - <p> {</p> - <p> pid.SEk += pid.Ek;</p> - <p> DelEk = pid.Ek - pid.Ek_1;</p> - <p> pid.Ek_1 = pid.Ek;</p> - <p> pid.Pout = pid.Kp * pid.Ek;</p> - <p> pid.Iout = pid.Ki * pid.SEk;</p> - <p> pid.Dout = pid.Kd * DelEk;</p> - <p> pid.out = pid.Pout + pid.Iout + pid.Dout;</p> - <p> if(pid.out > pid.pwmcycle)</p> - <p> {</p> - <p> pid.OUT = pid.pwmcycle;</p> - <p> }</p> - <p> else if(pid.out < -pid.pwmcycle)</p> - <p> {</p> - <p> pid.OUT = -pid.pwmcycle;</p> - <p> }</p> - <p> else</p> - <p> {</p> - <p> pid.OUT = pid.out;</p> - <p> }</p> - <p> }</p> - <p>}</p> - <p></p> + <code> + void PID_Calc(void){ + if (pid.Sv > 50) { + pid.Sv = 50; + } + pid.Ek = pid.Sv - pid.Pv; + + if (pid.Ek > 1) { + pid.OUT = pid.pwmcycle; + pid.SEk = 0; + pid.Ek_1 = 0; + } + + else if (pid.Ek < -0.3) { + pid.OUT = -pid.pwmcycle; + pid.SEk = 0; + pid.Ek_1 = 0; + } + + else { + pid.SEk += pid.Ek; + DelEk = pid.Ek - pid.Ek_1; + pid.Ek_1 = pid.Ek; + pid.Pout = pid.Kp * pid.Ek; + pid.Iout = pid.Ki * pid.SEk; + pid.Dout = pid.Kd * DelEk; + pid.out = pid.Pout + pid.Iout + pid.Dout; + + if (pid.out > pid.pwmcycle) { + pid.OUT = pid.pwmcycle; + } + else if (pid.out < -pid.pwmcycle) { + pid.OUT = -pid.pwmcycle; + } + else { + pid.OUT = pid.out; + } + } + } + </code> <h3 style="text-transform: capitalize;">The control code for the MCU is:</h3> - <p>void sys_initial(void){</p> - <p> delay_init();</p> - <p> LED_GPIO_Config();</p> - <p> DS18B20_Init();</p> - <p> PID_Init(500, 3, 16000, DEFAULT_TEMP);</p> - <p> Isr_Init();</p> - <p> USART1_Config();</p> - <p> USART2_Config();</p> - <p> PIDOUT_Init();</p> - <p> TIM3_Init();</p> - <p> TIM2_Init();</p> - <p> TIM4_Init();</p> - <p> TWI_Initialize();</p> - <p> //IWDG_Init(6,125);</p> - <p>}</p> - <p></p> - <p></p> - <p>void TIM3_IRQHandler() //500ms</p> - <p>{</p> - <p> static int sesc, sesc1;</p> - <p> u8 st;</p> - <p> st = TIM_GetFlagStatus(TIM3, TIM_IT_Update);</p> - <p> if(st != 0)</p> - <p> {</p> - <p> sesc++;</p> - <p> sesc1++;</p> - <p> TIM_ClearITPendingBit(TIM3, TIM_IT_Update);</p> - <p> read=read+1;</p> - <p> ReadTemp_flag = 1;</p> - <p> DS18B20_Get_Temp();</p> - <p> while(ReadTemp_flag == 0)</p> - <p> {</p> - <p> ReadTemp_flag = 1;</p> - <p> DS18B20_Get_Temp();</p> - <p> }</p> - <p> ReadTemp_flag = 0;</p> - <p> PID_Calc();</p> - <p> PID_out();</p> - <p> if(sesc>6)</p> - <p> {</p> - <p> send_temp();</p> - <p> sesc=0;</p> - <p> }</p> - <p> if(sesc1>9){</p> - <p> printf("%f\r\n",pid.Pv);</p> - <p> sesc1=0;</p> - <p> }</p> - <p> }</p> - <p>}</p> - <p></p> - <p></p> - <p>void TIM4_IRQHandler(){</p> - <p> u16 len=0;</p> - <p> u8 j;</p> - <p> if(TIM_GetITStatus(TIM4,TIM_IT_Update)!=RESET){</p> - <p> if(testMode==1){</p> - <p> pwmValueCheck();</p> - <p> FLASH_Unlock();</p> - <p> STMFLASH_Erase(PWM_SAVE_ADDR); STMFLASH_Write(PWM_SAVE_ADDR,(u16*)&pwm_value,sizeof(pwm_value)/2);</p> - <p> FLASH_Lock();</p> - <p> testMode=2;</p> - <p> }</p> - <p> TIM_ClearITPendingBit(TIM4,TIM_IT_Update);</p> - <p> }</p> - <p> return;</p> - <p></p> - <p>}</p> - <p></p> - <p></p> - <p>void TIM2_IRQHandler(){</p> - <p> static int sesc1,sesc2;</p> - <p> int i;</p> - <p> if(TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET){</p> - <p> sesc1++;</p> - <p> if(sesc1>500&&(first==1||done==1)){</p> - <p> send_temp();</p> - <p> done=0;</p> - <p> sesc1=0;</p> - <p> sendAdc();</p> - <p> }</p> - <p> if(sesc2>10){</p> - <p> if(testMode){</p> - <p> pwmValueCheck();</p> - <p> for(i=0;i<16;i++){</p> - <p> Usart_SendODData(USART2 ,0xF1 ,(0xB1<<8|i), adcTemp[i]);</p> - <p> }</p> - <p> FLASH_Unlock();</p> - <p> STMFLASH_Erase(PWM_SAVE_ADDR); STMFLASH_Write(PWM_SAVE_ADDR,(u16*)&pwm_value,sizeof(pwm_value)/2);</p> - <p> FLASH_Lock();</p> - <p> Usart_SendODData(USART2 ,0xF1 ,0xB300, 0x0000);</p> - <p> testMode = 0;</p> - <p> }</p> - <p> }</p> - <p> }</p> - <p> TIM_ClearITPendingBit(TIM2, TIM_IT_Update);</p> - <p>}</p> - <p></p> - <p>void sendAdc(void){</p> - <p> int i;</p> - <p> if(Ready_status ==1){</p> - <p> first=0;</p> - <p> getAdcValue();</p> - <p> for(i=0;i<16;i++){</p> - <p> Usart_SendODData(USART2,i,0x0001,adcValue[i]);</p> - <p> }</p> - <p> }</p> - <p>}</p> - <p></p> - <p></p> - <p>void send_temp(void){</p> - <p></p> - <p> u16 temp_h;</p> - <p> temp_h =pid.Pv*100;</p> - <p> Usart_SendODData(USART2,0xF1,0x7000,temp_h);</p> - <p> if(fabs(pid.Pv-pid.Sv)<=0.2&&temp_set==1){</p> - <p> Usart_SendODData(USART2,0xF1,0x9000,0);</p> - <p> temp_set=0;</p> - <p> }</p> - <p>}</p> - <p>void USART2_IRQHandler(void){</p> - <p> if (ReadTemp_flag==1){</p> - <p> ReadTemp_flag=0;</p> - <p> }</p> - <p> if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET){</p> - <p> save[i] = USART_ReceiveData(USART2);</p> - <p> if (save[0] == 0x36){</p> - <p> if(i<=len){</p> - <p> check ^= save[i];</p> - <p> }</p> - <p> i++;</p> - <p> }</p> - <p></p> - <p> if(i>=len+3){</p> - <p>if((check == save[len + 1]) && (save[0] == 0x36) && (save[len + 2] == 0xFF) && (save[1] == 0xF1)){</p> - <p> key = save[2];</p> - <p> switch(key){</p> - <p> case 0x03:</p> - <p>{</p> - <p> Usart_SendODData(USART2,0xF1 ,0x3000,0x0000); }break;</p> - <p> case 0x04:{</p> - <p> pid.Sv=0;</p> - <p> S_status = 0;</p> - <p> Ready_status = 0;</p> - <p> testMode=0; - <p> first=1;</p> - <p>Usart_SendODData(USART2, 0xF1, 0x4000, 0x0000);}break;</p> - <p> case 0x05:{</p> - <p>Usart_SendODData(USART2, 0xF1, 0x5000, 0x0000);</p> - <p> delay_ms(10);</p> - <p> SoftReset();</p> - <p> }break;</p> - <p> case 0x08:{</p> - <p> pid.Sv = save[3];</p> - <p> temp_set=1;</p> - <p> Usart_SendODData(USART2, 0xF1, 0x8000, 0x0000)</p>; - <p> }break;</p> - <p></p> - <p> case 0x09:{</p> - <p> Ready_status=1;</p> - <p> }break;</p> - <p> case 0x0a:{</p> - <p> }break;</p> - <p> case 0x0c:{</p> - <p> testMode=1; Usart_SendODData(USART2,0xF1,0xc000,0x0000);</p> - <p> }break;</p> - <p> case 0x0b:{</p> - <p> }break;</p> - <p></p> - <p> }</p> - <p> }</p> - <p> i=0;</p> - <p> for(n=0;n<=len+2;n++){</p> - <p> save[n]=0;</p> - <p> }</p> - <p> check=0;</p> - <p> }</p> - <p> }</p> - <p>}</p> - <p></p> - <p></p> - <p>void SoftReset(void)</p> - <p>{</p> - <p> __set_FAULTMASK(1);</p> - <p> NVIC_SystemReset();</p> - <p>}</p> - <p></p> - <p>void Usart_SendODData( USART_TypeDef * pUSARTx, uint8_t ch, uint16_t ch1, uint16_t ch2)</p> - <p>{</p> - <p> uint8_t temp1_h, temp1_l, temp2_h, temp2_l;</p> - <p> uint8_t a[12] = {0}, check = 0x36, i = 0;</p> - <p> a[0] = ch;</p> - <p> temp1_h = (ch1 & 0XFF00) >> 8;</p> - <p> a[1] = temp1_h;</p> - <p> temp1_l = ch1 & 0XFF;</p> - <p> a[2] = temp1_l;</p> - <p> temp2_h = (ch2 & 0XFF00) >> 8;</p> - <p> a[3] = temp2_h;</p> - <p> temp2_l = ch2 & 0XFF;</p> - <p> a[4] = temp2_l;</p> - <p> Usart_Send_Byte( pUSARTx, 0x36);</p> - <p></p> - <p> for( i = 0; i < 5; i++ )</p> - <p> {</p> - <p> Usart_Send_Byte( pUSARTx, a[i]);</p> - <p> check ^= a[i];</p> - <p> }</p> - - <p> Usart_Send_Byte( pUSARTx, check);</p> - <p>Usart_Send_Byte( pUSARTx, 0xFF);</p> - <p>}</p> - <p></p> - <p>void USART2_Config(void){</p> - <p> GPIO_InitTypeDef GPIO_InitStructure;</p> - <p> USART_InitTypeDef USART_InitStructure;</p> - <p>RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_USART1,ENABLE);</p> - <p> GPIO_InitStructure.GPIO_Pin =GPIO_Pin_2;</p> - <p> GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;</p> - <p> GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;</p> - <p> GPIO_Init(GPIOA, &GPIO_InitStructure);</p> - <p> GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;</p> - <p> GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;</p> - <p> GPIO_Init(GPIOA, &GPIO_InitStructure);</p> - <p> USART_InitStructure.USART_BaudRate = 115200;</p> - <p> USART_InitStructure.USART_WordLength = USART_WordLength_8b;</p> - <p> USART_InitStructure.USART_StopBits = USART_StopBits_1;</p> - <p> USART_InitStructure.USART_Parity = USART_Parity_No ;</p> - <p> USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;</p> - <p> USART_InitStructure.USART_Mode=USART_Mode_Rx|USART_Mode_Tx;</p> - <p> USART_Init(USART2, &USART_InitStructure);</p> - <p> NVIC_Configuration();</p> - <p> USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);</p> - <p> USART_Cmd(USART2, ENABLE);</p> - <p>}</p> - <p></p> - <p>static void NVIC_Configuration(void)</p> - <p>{</p> - <p> NVIC_InitTypeDef NVIC_InitStructure;</p> - <p>NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);</p> - <p>NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;</p> - <p>NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;</p> - <p>NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;</p> - <p>NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;</p> - <p>NVIC_Init(&NVIC_InitStructure);</p> - <p>}</p> + <code> + void sys_initial(void){ + delay_init(); + LED_GPIO_Config(); + DS18B20_Init(); + PID_Init(500, 3, 16000, DEFAULT_TEMP); + Isr_Init(); + USART1_Config(); + USART2_Config(); + PIDOUT_Init(); + TIM3_Init(); + TIM2_Init(); + TIM4_Init(); + TWI_Initialize(); + //IWDG_Init(6,125); + } + + void TIM3_IRQHandler() //500ms + { + static int sesc, sesc1; + u8 st; + st = TIM_GetFlagStatus(TIM3, TIM_IT_Update); + if (st != 0) { + sesc++; + sesc1++; + TIM_ClearITPendingBit(TIM3, TIM_IT_Update); + read = read + 1; + ReadTemp_flag = 1; + DS18B20_Get_Temp(); + while (ReadTemp_flag == 0) { + ReadTemp_flag = 1; + DS18B20_Get_Temp(); + } + + ReadTemp_flag = 0; + PID_Calc(); + PID_out(); + if (sesc > 6) { + send_temp(); + sesc = 0; + } + + if (sesc1 > 9) { + printf("%f\r\n", pid.Pv); + sesc1 = 0; + } + } + } + + void TIM4_IRQHandler(){ + u16 len = 0; + u8 j; + if (TIM_GetITStatus(TIM4, TIM_IT_Update) != RESET) { + if (testMode == 1) { + pwmValueCheck(); + FLASH_Unlock(); + STMFLASH_Erase(PWM_SAVE_ADDR); STMFLASH_Write(PWM_SAVE_ADDR, (u16 *) & pwm_value, sizeof(pwm_value) / 2); + FLASH_Lock(); + testMode = 2; + } + TIM_ClearITPendingBit(TIM4, TIM_IT_Update); + } + return; + } + + void TIM2_IRQHandler(){ + static int sesc1, sesc2; + int i; + if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) { + sesc1++; + if (sesc1 > 500 && (first == 1 || done == 1)) { + send_temp(); + done = 0; + sesc1 = 0; + sendAdc(); + } + + if (sesc2 > 10) { + if (testMode) { + pwmValueCheck(); + for (i = 0; i < 16; i++) { + Usart_SendODData(USART2, 0xF1, (0xB1 << 8 | i), adcTemp[i]); + } + FLASH_Unlock(); + STMFLASH_Erase(PWM_SAVE_ADDR); STMFLASH_Write(PWM_SAVE_ADDR, (u16 *) & pwm_value, sizeof(pwm_value) / 2); + FLASH_Lock(); + Usart_SendODData(USART2, 0xF1, 0xB300, 0x0000); + testMode = 0; + + } + } + } + TIM_ClearITPendingBit(TIM2, TIM_IT_Update); + } + + void sendAdc(void){ + int i; + if (Ready_status == 1) { + first = 0; + getAdcValue(); + for (i = 0; i < 16; i++) { + Usart_SendODData(USART2, i, 0x0001, adcValue[i]); + } + } + } + + void send_temp(void){ + u16 temp_h; + temp_h = pid.Pv * 100; + Usart_SendODData(USART2, 0xF1, 0x7000, temp_h); + if (fabs(pid.Pv - pid.Sv) <= 0.2 && temp_set == 1) { + Usart_SendODData(USART2, 0xF1, 0x9000, 0); + temp_set = 0; + } + } + + void USART2_IRQHandler(void){ + if (ReadTemp_flag == 1) { + ReadTemp_flag = 0; + } + + if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) { + save[i] = USART_ReceiveData(USART2); + if (save[0] == 0x36) { + if (i <= len) { + check ^= save[i]; + } + i++; + } + + if (i >= len + 3) { + if ((check == save[len + 1]) && (save[0] == 0x36) && (save[len + 2] == 0xFF) && (save[1] == 0xF1)) { + key = save[2]; + switch (key) { + case 0x03: + { + Usart_SendODData(USART2, 0xF1, 0x3000, 0x0000); + } break; + case 0x04: { + pid.Sv = 0; + S_status = 0; + Ready_status = 0; + testMode = 0; + first = 1; + Usart_SendODData(USART2, 0xF1, 0x4000, 0x0000); + } break; + + case 0x05: { + Usart_SendODData(USART2, 0xF1, 0x5000, 0x0000); + delay_ms(10); + SoftReset(); + } break; + + case 0x08: { + pid.Sv = save[3]; + temp_set = 1; + Usart_SendODData(USART2, 0xF1, 0x8000, 0x0000); + } break; + + case 0x09: { + Ready_status = 1; + } break; + case 0x0a: { + } break; + case 0x0c: { + testMode = 1; Usart_SendODData(USART2, 0xF1, 0xc000, 0x0000); + } break; + case 0x0b: { + } break; + } + } + i = 0; + for (n = 0; n <= len + 2; n++) { + save[n] = 0; + } + check = 0; + } + } + } + + void SoftReset(void) + { + __set_FAULTMASK(1); + NVIC_SystemReset(); + } + + void Usart_SendODData(USART_TypeDef * pUSARTx, uint8_t ch, uint16_t ch1, uint16_t ch2) + { + uint8_t temp1_h, temp1_l, temp2_h, temp2_l; + uint8_t a[12] = { 0}, check = 0x36, i = 0; + a[0] = ch; + temp1_h = (ch1 & 0XFF00) >> 8; + a[1] = temp1_h; + temp1_l = ch1 & 0XFF; + a[2] = temp1_l; + temp2_h = (ch2 & 0XFF00) >> 8; + a[3] = temp2_h; + temp2_l = ch2 & 0XFF; + a[4] = temp2_l; + Usart_Send_Byte(pUSARTx, 0x36); + for (i = 0; i < 5; i++) { + Usart_Send_Byte(pUSARTx, a[i]); + check ^= a[i]; + } + + Usart_Send_Byte(pUSARTx, check); + Usart_Send_Byte(pUSARTx, 0xFF); + } + + void USART2_Config(void){ + GPIO_InitTypeDef GPIO_InitStructure; + USART_InitTypeDef USART_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1, ENABLE); + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(GPIOA, & GPIO_InitStructure); + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; + GPIO_Init(GPIOA, & GPIO_InitStructure); + USART_InitStructure.USART_BaudRate = 115200; + USART_InitStructure.USART_WordLength = USART_WordLength_8b; + USART_InitStructure.USART_StopBits = USART_StopBits_1; + USART_InitStructure.USART_Parity = USART_Parity_No; + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; + USART_Init(USART2, & USART_InitStructure); + NVIC_Configuration(); + USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); + USART_Cmd(USART2, ENABLE); + } + + static void NVIC_Configuration(void) + { + NVIC_InitTypeDef NVIC_InitStructure; + NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); + NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(& NVIC_InitStructure); + } + </code> </div> - {% endblock %} +{% endblock %} \ No newline at end of file diff --git a/wiki/pages/partnership.html b/wiki/pages/partnership.html index 7cc2a6000fcaf75efc556b5dba2e500e1df8eb7b..6a441b718c36c0f880b86bb460588bc1d9099500 100644 --- a/wiki/pages/partnership.html +++ b/wiki/pages/partnership.html @@ -177,9 +177,10 @@ related to both of your projects.{% endblock %} <p>progress, we conducted several online meetings to discuss initial ideas for each other's projects, we presented our projects to Worldshaper-HZ and tried to find similarities and propose an overview design for a partnership. Together, we explored potential partnerships in the web lab and had in-depth discussions.</p> - <div class="opic annotation large"> - <img src="" alt="png"> - <p>Figure 2. Preliminary Partnership Meeting</p> + <div class="opic annotation large"> + <img src="" alt="png"> + <p>Figure 2. Preliminary Partnership Meeting</p> + </div> <h2>From mid May to mid June: communicate the project progress of both sides</h2> <p>The project has been underway for some time and we have been discussing with each other online based on the current state of affairs on issues related to the experiment and suggesting improvements. We decided to exchange @@ -329,9 +330,9 @@ related to both of your projects.{% endblock %} </div> <div class="opic annotation large"> <img src="" alt="png"> - <p>Figure 6. UESTC-BioTech was involved in the development of our brochur</p> + <p>Figure 6. UESTC-BioTech was involved in the development of our brochure</p> </div> </div> </div> - {% endblock %} + {% endblock %} \ No newline at end of file