Dear All, Running on TI MSP430, a sigma-delta AD design, read a signal from UART RX, do SD AD, and then output to UART TX. Setup: UART is 9620 baudrate. 1 bit Sigma-delta AD. Switched-capacitor input. load capacitor 14pF ( need to change? ) 1.2V reference voltage ( provided by internal ) Here is partial code: ///////////////////////////////////// ... unsigned int RXTXData,results; .... while (1) { RX_Ready(); // UART ready to RX one Byte _BIS_SR(CPUOFF + GIE); // Enter LPM0 Until character RXed SD16CCTL0 |= SD16SC; // Set bit to start conversion while ((SD16CCTL0 & SD16IFG)==0); // Poll interrupt flag results = SD16MEM0; // Save CH0 results (clears IFG) _NOP(); if (results >32767) { results=results-32767; RXTXData=results/26.214; } if (results == 32767) { RXTXData=0; } if (results <32767) { results=32768 - results; RXTXData=results/26.214; } TX_Byte(); // TX Back RXed Byte Received } //////////////////////////// It is easy to know the result will be saved to SD16MEM0, but guessing that codes after _NOP() are doing decimation filter right? Bad on decimatin filter, could you please advice? Questions: Why minus 32767 and divide 26.214? I guess that divide 26.214 is to reduce the operation frequency( am I right? ), but why minus 32767 ? Thank you very much for your advice! Best regards, Boki.
MSP430, sigma-delta AD
Started by ●June 27, 2006
Reply by ●June 27, 20062006-06-27
"Boki" <bokiteam@ms21.hinet.net> ???????:1151427807.622155.123870@j72g2000cwa.googlegroups.com...> Dear All, > > Running on TI MSP430, a sigma-delta AD design, read a signal from UART > RX, do SD AD, and then output to UART TX. > > Setup: > UART is 9620 baudrate. > 1 bit Sigma-delta AD. > Switched-capacitor input. > load capacitor 14pF ( need to change? ) > 1.2V reference voltage ( provided by internal ) > > Here is partial code: > ///////////////////////////////////// > ... > unsigned int RXTXData,results; > .... > > while (1) > { > RX_Ready(); // UART ready to RX one > Byte > _BIS_SR(CPUOFF + GIE); // Enter LPM0 Until > character RXed > > SD16CCTL0 |= SD16SC; // Set bit to start > conversion > while ((SD16CCTL0 & SD16IFG)==0); // Poll interrupt flag > results = SD16MEM0; // Save CH0 results (clears > IFG) > _NOP(); > > if (results >32767) > { > results=results-32767; > RXTXData=results/26.214; > } > if (results == 32767) > { > RXTXData=0; > } > if (results <32767) > { > results=32768 - results; > RXTXData=results/26.214; > } > > TX_Byte(); // TX Back RXed Byte > Received > > } > > //////////////////////////// > > It is easy to know the result will be saved to SD16MEM0, but guessing > that codes after _NOP() are doing decimation filter right? > > Bad on decimatin filter, could you please advice? > > Questions: > > Why minus 32767 and divide 26.214? > > I guess that divide 26.214 is to reduce the operation frequency( am I > right? ), but why minus 32767 ? > > Thank you very much for your advice! > > Best regards, > Boki. >Doing shift ? due to unsigned ?
Reply by ●June 27, 20062006-06-27
"Boki" <bokiteam@ms21.hinet.net> wrote in message news:1151427807.622155.123870@j72g2000cwa.googlegroups.com...> results = SD16MEM0; // Save CH0 results (clears > IFG) > _NOP(); > if (results >32767) > { > results=results-32767; > RXTXData=results/26.214; > } > if (results == 32767) > { > RXTXData=0; > } > if (results <32767) > { > results=32768 - results; > RXTXData=results/26.214; > }> It is easy to know the result will be saved to SD16MEM0, but guessing > that codes after _NOP() are doing decimation filter right?I very much doubt it -- it just looks like the code after _NOP() just performs scaling.> Why minus 32767 and divide 26.214?Because apparently the input device connected to your A/D produces voltages that are supposed to be interpreted as 1250 down to 0 (1250=32768/26.214) as the input voltage rises from 0 to half the A/D's reference voltage, and then 0 to 1250 as it ranges from half the reference up to the reference. This assumes the ADC produces codes from 0-65535 as the input voltages rises from 0 to the reference voltage; this is not at all true on some ADCs, so should be checked in the part's data sheet. The test for "results == 32767" appears unnecessary if you change the first "if" statement to include "if (results >= 32767) ..." What is the A/D converter input connected to? ---Joel Kolstad
Reply by ●June 27, 20062006-06-27
On 27 Jun 2006 10:03:27 -0700, Boki <bokiteam@ms21.hinet.net> wrote:> Dear All, > > Running on TI MSP430, a sigma-delta AD design, read a signal from UART > RX, do SD AD, and then output to UART TX. > > Setup: > UART is 9620 baudrate. > 1 bit Sigma-delta AD. > Switched-capacitor input. > load capacitor 14pF ( need to change? ) > 1.2V reference voltage ( provided by internal ) > > Here is partial code: > ///////////////////////////////////// > ... > unsigned int RXTXData,results; > .... > > while (1) > { > RX_Ready(); // UART ready to RX one > Byte > _BIS_SR(CPUOFF + GIE); // Enter LPM0 Until > character RXed > > SD16CCTL0 |= SD16SC; // Set bit to start > conversion > while ((SD16CCTL0 & SD16IFG)==0); // Poll interrupt flag > results = SD16MEM0; // Save CH0 results (clears > IFG) > _NOP(); > > if (results >32767) > { > results=results-32767; > RXTXData=results/26.214; > } > if (results == 32767) > { > RXTXData=0; > } > if (results <32767) > { > results=32768 - results; > RXTXData=results/26.214; > }The sequence of ifs looks very odd to me. I would understand it better if the last two were else ifs. Assuming that they means else ifs, which is a big assumption, this seems to be code that gets absolute value of deviation of SD16MEM0 from 32768, normalized to whatever by dividing by 26.214. i> TX_Byte(); // TX Back RXed Byte > Received > > } > > //////////////////////////// > > It is easy to know the result will be saved to SD16MEM0, but guessing > that codes after _NOP() are doing decimation filter right? > > Bad on decimatin filter, could you please advice? > > Questions: > > Why minus 32767 and divide 26.214? > > I guess that divide 26.214 is to reduce the operation frequency( am I > right? ), but why minus 32767 ? > > Thank you very much for your advice! > > Best regards, > Boki. >
Reply by ●June 28, 20062006-06-28
Joel Kolstad =E5=AF=AB=E9=81=93=EF=BC=9A> "Boki" <bokiteam@ms21.hinet.net> wrote in message > news:1151427807.622155.123870@j72g2000cwa.googlegroups.com... > > results =3D SD16MEM0; // Save CH0 results (clears > > IFG) > > _NOP(); > > if (results >32767) > > { > > results=3Dresults-32767; > > RXTXData=3Dresults/26.214; > > } > > if (results =3D=3D 32767) > > { > > RXTXData=3D0; > > } > > if (results <32767) > > { > > results=3D32768 - results; > > RXTXData=3Dresults/26.214; > > } > > > It is easy to know the result will be saved to SD16MEM0, but guessing > > that codes after _NOP() are doing decimation filter right? > > I very much doubt it -- it just looks like the code after _NOP() just per=forms> scaling. > > > Why minus 32767 and divide 26.214? > > Because apparently the input device connected to your A/D produces voltag=es> that are supposed to be interpreted as 1250 down to 0 (1250=3D32768/26.21=4) as> the input voltage rises from 0 to half the A/D's reference voltage, and t=hen 0> to 1250 as it ranges from half the reference up to the reference. This > assumes the ADC produces codes from 0-65535 as the input voltages rises f=rom 0> to the reference voltage; this is not at all true on some ADCs, so should=be> checked in the part's data sheet. > > The test for "results =3D=3D 32767" appears unnecessary if you change the=first> "if" statement to include "if (results >=3D 32767) ..." > > What is the A/D converter input connected to? > > ---Joel KolstadYes, you are right, "results =3D=3D 32767" is unnecessary. It is a pulsation application, what I strange is the output will become a 'V' form... 0~32767: when RX higher, the output TX value becom lower. 32768~65535: when RX higher, the output becom higher. Still can't understand why do this.. Best regards, Boki.