This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F413: Code to test different input level and give the same readout

Part Number: MSP430F413


I have a test probe that reads the conductivity of a solution and have written a code

to read the conductivity and display on the LCD.

The probe needs to be calibrated to a 5 ppt level every time it is used.

I have encountered that after measuring about 20 probes, every probe will give a different

readout of say 5.0ppt, 5.2 ppt, 6 ppt as a example.

Is there a code that can adjust the input read for the different probes to read about the same

for the same solution used.

  • Hello,

    Thank you for your request.

    Since the MSP430F413 doesn't have any ADC modules, I'm assuming that it's being used inside the test probe along with an external ADC to measure the conductivity of the solution. Is this true? I'm curious about the analog-to-digital conversion implementation. Ideally, when you calibrate several test probes, the readings should all be the same conductivity for a specific solution, but that doesn't seem to be happening for you.

    Can you explain what the "ppt" units represent? Is it parts-per-trillion or something else? This is important because if you've reached your resolution limit of your system, this would explain why there are different results even after calibrating the devices.

    I may not fully understand your issue, so please provide more details or correct my assumptions.

    Regards,

    James

    MSP Customer Applications
  • As a follow-up, is the MSP430F413 being used in an existing product or is it being used in development of a new product? The reason that I ask is that this part is one of our older devices, and we offer many newer devices that have many additional features and more importantly, features (such as an integrated ADC, non-volatile FRAM memory) that could be more beneficial for your application.

    Regards,

    James

    MSP Customer Applications

  • Hi,

    Yes we're using the external ADC to measure. It'll convert the input to digital.

    It then feeds into P16/CA0 pin.

    The firmware is written as :

    Meas_ADC;    Subroutine: Meaure A/D Converter, BCD A/D Result --> ADCData
    ;            R15 used as working register and not saved
    ;---------------------------------------------------------------------------

     bic.b   #CAPD3,&CAPD 
     MOV.B #CAON,&CACTL1   ; Comparator on
     BIS.B   #P2CA0,&CACTL2   ; P2.3+ P2.4-

     MOV #01440h,COUNTER5   ;30mS delay for ref start-up.
    W_DELAY 
     DEC COUNTER5    ;See datasheet for details.
     JNZ W_DELAY
     CLR ADCData   ; Clear ADCData register

     CALL #Sample_ADC   ; Sample --> ADCData+Previous
     CALL #Sample_ADC   ; Sample --> ADCData+Previous
     RRA ADCData
    Meas_Over
     CLR.B &CACTL1   ; Comparator off
     BIC.B   #P2CA0,&CACTL2  ; P2.3+ P2.4-
     BIS.b   #CAPD3,&CAPD 

     RET

    Sample_ADC

     MOV #04096,R15   ; 12-bits  10 Mar

    ; PreCharge Capacitor
    Pre_ADC
     BIS.B #DAC_Out,&P1OUT  ; Set power to capacitor
    C1
     BIT.B #CAOUT,&CACTL2  ; Comparator out hi/low?
     JNZ C1
          ; Adjust and integrate DAC Pulse
    Test_DAC
     BIT.B #CAOUT,&CACTL2  ; Comparator hi/low?
     JNZ Low1    ; Jump --> Low
    High1   
     BIC.B #DAC_Out,&P1OUT  ; Reset power to capacitor
     JMP Meas_
    Low1
     BIS.B #DAC_Out,&P1OUT  ; Set power to capacitor
     NOP
     INC ADCData   ; Increment ADCData
    Meas_  
     DEC R15    ; Decrement Loop Count
     JNZ Test_DAC   ; Measurement Loop Over?
     BIC.B #DAC_Out,&P1OUT  ; Reset power to capacitor
     XOR.B #CAEX,&CACTL1   ; invert comparator terminals
     RET

    ppt refers to parts per thousand. We're measuring the conductivity of the liquid in ppt.

    rgds

  • The MSP430F413 can capture analog signals, convert them to digital values and process them. In my circuit
    application the analog input is thru' Pin 47(P16/CA0). The firmware was written by our previous engineer who has already left us.
    As I am relatively new in these area, the code written seems to charge and recharge the capacitor inside the MSP430.
  • Hello,

    Thanks for the additional details. It helps me better understand the context of your question.

    Based on the code above, it seems like the comparator in the MSP430F413 is used to read in the digital output of the discrete ADC. Can you share this portion of the schematic and the part number of the ADC?

    Also, this application is very interesting. I'm definitely not a chemist, so I'm curious how consistent measuring the conductivity of a fluid would be. I'm sure this would depend on the solution (now I understand why you've been using this term) and the distribution of the particles (e.g. I would assume the conductivity would change over time as things settle to the bottom versus being shaken up). As an electrical engineer, I've calibrated devices using constant voltage and constant currents, which would seem more stable than what a solution would be. Do you know what the expected variation in ppt for this solution? I'm asking this because the issue you're observing could depend on the solution instead of the sensing side. I could be wrong here, especially if you've observed consistent measurements after calibration before.

    Regards,

    James

    MSP Customer Applications
  • As can be seen from the schematic the input to P16/CAO is from a filter circuit. After filtering, the analog signal is fed

    to the P16/CAO input.

    I was thing for a range of input, after feeding to P16/CA0 input pin of MSP430, it'll produce 1 output. As the probe reading will varies,

    but after filtering and through coding will only display a single reading.

    Example Probe 1 reads 5.0 ppt, Probe 2 reads 6.0 ppt for solution of 5 ppt. Probe 2 reading is out by 1 ppt. I am trying to narrows this

    reading to 0.2 ppt that is it reads at most 5.2 ppt instead of 6.0 ppt.

    Was looking whether by changing some coding whether it can reduced this.

  • I'm sorry, but the schematic image didn't get attached to your post. When you click "Reply", then click "Use rich formatting" at the bottom right of the reply window. When this new view loads, click the "Insert/Edit Media" button that's shown below.

    Regards,

    James

    MSP Customer Applications

  • After looking at Section 23.2.3 in the MSP430F413's User's Guide, it mentions that the output of the comparator can be used with or without internal filtering. When the control bit CAF is set, the output is filtered with an on-chip RC-filter. Any comparator output oscillates if the voltage difference across the input terminals is small. Internal and external parasitic effects and cross coupling on  and between signal lines, power supply lines, and other parts of the system are responsible for this behavior as shown in Figure 23−2.

    The comparator output oscillation reduces accuracy and resolution of the comparison result. Selecting the output filter can reduce errors associated with comparator oscillation. In the assembly code that you shared above, I don't see the CAF bit being set in the CACTL2 register. Doing this should improve your results.

    Regards,

    James

    MSP Customer Applications

  • Hello Kin,

    Has your issue been resolved?

    Regards,

    James

    MSP Customer Applications

**Attention** This is a public forum