Temperature framework UWB DWM1000 open source project acquisition

Before Bowen open source framework set uwb, behind several blog posts will be developed based on the simple open-source framework. Let uwb users a clearer understanding of this basecode based development work.

Here content is done, collect dwm1000 temperature and sent to another node, another node through a serial printer, that is, the temperature here is a remote collection of works. Course possible to use any master stm32 acquisition sensor, to transmit data as described herein packaged idea to another node.

Increasing the temperature in 1 tx_main.c acquisition function, and do authentication.

Temperature acquisition function

uint16 BPhero_UWB_Get_Temperature(void)
{
    uint16 register_result;
    uint16  Temperature = 0;
    /* Note on Temperature: the temperature value needs to be converted to give the real temperature
     * the formula is: 1.13 * reading - 113.0
     * Note on Voltage: the voltage value needs to be converted to give the real voltage
     * the formula is: 0.0057 * reading + 2.3
     * input parameters:
     * @param fastSPI - set to 1 if SPI rate > than 3MHz is used
     *
     * output parameters
     *
     * returns  (temp_raw<<8)|(vbat_raw)
     */
    register_result = dwt_readtempvbat(1);
    //Temperature = (((register_result&0xFF00)>>8)*1.13 - 113)*100;
    return (register_result>>8);
}

Tx_main reading the temperature information function, may be acquired to verify the correct temperature information. tx_main verification code is as follows:

int tx_main(void)
{
    bphero_setcallbacks(Tx_Simple_Rx_Callback);
char temp_result[5]; int temp = 0 ; /* Infinite loop */ dwt_enableframefilter(DWT_FF_DATA_EN); dwt_rxenable(0); while(1) { // BPhero_Distance_Measure_Specail_TAG(); Delay_us(10000);//5ms Delay_us(10000);//5ms temp = (BPhero_UWB_Get_Temperature()*1.13 - 113); temp_result[0] = (temp/100)+0x30; temp_result[1] = (temp%100/10)+0x30; temp_result[2] = (temp%10)+0x30; temp_result[3]='\n';temp_result[4]='\0'; USART1DispFun(temp_result); } }

 Mainly read the temperature, and the temperature of one hundred ten serial bits sent separately from the display. Relative to the previous function tx_main basecode, except that the temperature reading function and, in the while (1) Enable RX, while commenting out the transmission codes (1), this is mainly, RX greater power, temperature changes can clearly be seen. Actual later will return the same.

After compiling download, serial port to receive the temperature information:

You can find that time received, dwm1000 documents can be stable at around 53 degrees, using a heat gun is heated, the temperature will be higher.

2 above test has been completed, start modifying tx_main, the data to be transmitted into the tx_message.

A tx_main restored to their original function, which retain only the call to send function, consistent with basecode

int tx_main(void)
{
    bphero_setcallbacks(Tx_Simple_Rx_Callback);  
    while(1)
    {
      BPhero_Distance_Measure_Specail_TAG();	
    }
}

B in the temperature in the transmission message information into package 

void BPhero_Distance_Measure_Specail_TAG(void)
{
    int temp = 0 ;
    // dest address  = SHORT_ADDR+1,only for test!!
    msg_f_send.destAddr[0] =(SHORT_ADDR+1) &0xFF;
    msg_f_send.destAddr[1] =  ((SHORT_ADDR+1)>>8) &0xFF;

    /* Write all timestamps in the final message. See NOTE 10 below. */
    final_msg_set_ts(&msg_f_send.messageData[FIRST_TX],  tx_node[(SHORT_ADDR+1) &0xFF].tx_ts[0] );
    final_msg_set_ts(&msg_f_send.messageData[FIRST_RX],  tx_node[(SHORT_ADDR+1) &0xFF].rx_ts[0] );

    msg_f_send.seqNum = distance_seqnum;
    msg_f_send.messageData[0]='D';
    msg_f_send.messageData[1]=(SHORT_ADDR+1) &0xFF;
	
    temp = (BPhero_UWB_Get_Temperature()*1.13 - 113);
    msg_f_send.messageData[2]=(temp/100)+0x30;
    msg_f_send.messageData[3]=(temp%100/10)+0x30;
    msg_f_send.messageData[4]=(temp%10)+0x30;

Can be seen that compared with the previous basecode, in messageData [2'3'4] packaged the temperature information, only need rx stage, the same read messageData [2'3'4] to.

Note psduLength this length, not less than the length of the data to be sent, or will receive incomplete data.

 dwt_writetxdata(psduLength, (uint8 *)&msg_f_send, 0) ; 

C rx_main.c reading the same reading messageData [2'3'4] 

            switch(msg_f->messageData[0])
            {
                case 'D'://distance
                    msg_f_send.messageData[0]='d';
                    msg_f_send.messageData[1]=msg_f->messageData[1];

                    temp_result[0] = msg_f->messageData[2];
                    temp_result[1] = msg_f->messageData[3];
                    temp_result[2] = msg_f->messageData[4];
                    temp_result[3] = '\n';
                    temp_result[4] = '\0';
                    temp_result[5] = 1;  

Wherein temp_result [5] for the successful reception flag, which when set will successfully received 1, while (1) In accordance with this, the print temp_result

while (1)
    {
        if(temp_result[5] ==1)
        {
            USART1DispFun(temp_result);
            temp_result[5] = 0;
        }
    }

This paper finish

 

Open source code URL: www.51uwb.cn

 

Guess you like

Origin www.cnblogs.com/tuzhuke/p/12077671.html