Jump to content
43oh

sinusoidal peak detection msp launchpad and energia


Recommended Posts

hi there, 

i'm trying to measure impedance by applying sinusoidal wave to a chemical gel. it cannot operate by dc voltages. 

i can achieve to measure resistance from a dc circuit and send the solution to an LCD screen by reading two channels as follows:

 

my code: 
 
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


 void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  lcd.print("impedance :");
}


  void loop() {
    int sensorValue1 = analogRead(A0);
  int sensorValue2=analogRead(A1);
   // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
   float voltagech1 = sensorValue1 * (5.0 / 1023.0);
   float voltagech2 =sensorValue2 * (5.0 / 1023.0);
   float current= (voltagech1-voltagech2)/50;
   float impedance=voltagech2/current;


   delayMicroseconds(50);
          // display each character to the LCD
  lcd.setCursor(0,1);
  lcd.print(impedance);
      }
   
I'm using msp launchpad ver 1.5 G2553 chip on it. Since i cannot read ac voltages without offsetting and since offset voltage corrupts my sample, i really need to apply sinusoidal signals (10, 100,500, 1000 Hz, ~3 Vpp) and detect the peaks and use as my sensorValue's. Any sample code will be appreciated. thank you in advance..
Link to post
Share on other sites

No need to use a sine wave. Generate square waves with the MSP430. One end of your sensor goes to the pin with the square wave, the other to the midpoint of a voltage divider of the MSP430 power supply. Tie the input of an A/D channel there, take measurements at both polarities of the square wave and subtract one from the other for the net voltage. Essentially a bridge circuit, your unknown is working against the impedance of the voltage divider. If your resistors are 2K then the impedance of the divider is 1K. Choose the resistors to scale the sensor gel. If the impedance is too low you will load the MSP430 output, too high and the A/D converter will have offset errors (and S/H errors if you use more than one channel). All of those problems can be worked around with more parts, but you have the basis for a full system of one channel with only two resistors, two channels with only four resistors.

 

Make sure you never stop the square wave unless you turn the pin into an input! Else your sensor will have electrolytic damage.

 

Hope this helps.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...