Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Capstone Help

$
0
0

Hello I am a senior at Western Carolina University working on my Capstone.  I decided to use Energia because my project isn't code heavy and its simple to write down a couple lines of code and go.

 

The issue here is that I am writing a code that allows a laser and acoustic to "pulse".  My code pulses correctly but the frequency is too low for my receivers to pick up.  It is currently outputting 350-400 Hz when I need it at 40 kHz.  Is there a line I'm missing?  A better way to code?  Or should I switch to a 555 timer?

 

MSP430G2533

LaunchPad Rev 1.4

(Additional Information can be given if needed)

 

Code so far:

 

#define  led_pin  P2_1                 // Pin 2.1  
#define  sound_pin  P2_5            // Pin 2.5
int delay1 = 1000;
int delay2 = 2500;
int delay3 = 1500;
 
void setup() {
 
  pinMode (led_pin,OUTPUT);             // set pin 2.1 for output   
  pinMode (sound_pin,OUTPUT);        // set pulse pin as output
//  pinMode (Vread_pin,INPUT);
//  analogResolution(1023);                // divide the full duty cycle into 1024 steps
//  analogFrequency(40000);              // set the full duty cycle to 0.2 ms
//  Serial.begin(9600);                         // begin serial comm. at 9600 baud
}
 
void loop() {
  digitalWrite(led_pin, HIGH);         //1
  digitalWrite(sound_pin, HIGH);
  delayMicroseconds(delay1);
  digitalWrite(led_pin, LOW);         //2
  delayMicroseconds(delay3);
  for(int i=0; i<19; ++i) {                   //3
  digitalWrite(sound_pin, LOW);    
  delayMicroseconds(delay2);
  digitalWrite(sound_pin, HIGH);     //4   
  delayMicroseconds(delay2);
  }
  digitalWrite(sound_pin, LOW);
  delayMicroseconds(delay2);
}
  
 
 
 
 
As you can see this code literally just outputs voltage high and low then repeats.  It works for what I need but the receivers can't hear it.

Viewing all articles
Browse latest Browse all 2077

Trending Articles