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.
Hello all,
I am new to the forum and to the MSP430. I have a MSP430 Launchpad Rev. 1.4 and have a couple of questions, regarding a project which I'm currently building.
I try to build a spectrometer (from this instruction) using a photo transistor and a stepper motor from an old CD-drive. So I have an Easy Driver breakout board to do my dirty job. So I don't use a serial to usb breakout board for communication between my PC and the MSP430 instead I use the launchpad itself and my first question is which jumpers should I remove/change in order to be able to send serial commands to my MSP430 from my PC? Do I have to change the position of TXD and RXD horizontally (the board is Rev 1.4)?
My second question is that regarding the instruction I have to attach the emitter of the photo-transistor to P1_3, but I've noticed that the MSP430 has a hardware push button named P1_3 do I have to constantly press this button in order to get data from my photoransistor, attached at P1_3?
And my third question is that regarding the instruction I can use the RST (S1) pin as a +3V out is this true and do I have to change the jumpers to be able to use the RST (S1) as a +3V output.
Here is my code.
//I/O Below const int StepperMotor = P2_4; const int StepperDirection = P2_5; const int Sensors[] = {P1_3}; // Add more sensors here! //Constants for calibration below! const double nm = 405; // Known Calibration source Frequency const double x = 37.65; // Distance of point above the "Screen" const double D = 50.00; // distance to the "Screen" const double degreesperstep = 1; // Degrees per step for the stepper motor const double microstepping = 8; // This allows for you to determine how often you want the Sample to be taken (inverse microstep) const double mmPerRotation = 2.76; // This is the distance between the two teeth of the spindle which moves the sensor up and down const double heightofTray = 38.00; // Under estimate this a bit const double starty = 32.35; //32.35 /////////////////////////Fiddle with the below at your own risk!/////////////////////////////////////////// const double stepsperrotation = 360/degreesperstep; const double microstepsuntilend = heightofTray/mmPerRotation * stepsperrotation * (microstepping); const double d = (nm*1e-9)/sin(atan(x/D)); //const double d = 720e-9;//const double x = (nm*1e-9*d); int wavelengthvIntensity[sizeof(Sensors)-1]; int datafile = 0; double cnt = 0; char buf[30]; double tempnm = 0; double currenty = 0; const double zero = starty-x; char ksk = '0'; void setup() { pinMode(PUSH2, INPUT_PULLUP); Serial.begin(9600); // Hah, I forgot to add this in Special thanks to tommy_goh1997 for spotting the bug! pinMode(StepperMotor, OUTPUT); pinMode(StepperDirection, OUTPUT); digitalWrite(StepperMotor, LOW); digitalWrite(StepperDirection, LOW); //When Restarted the stepper motor will lower the sensor to the lowest. for (int i=0;i<sizeof(wavelengthvIntensity);i++) { pinMode(Sensors[i], INPUT); } for (int i = 0; i < microstepsuntilend; i++) { digitalWrite(StepperMotor, HIGH); delayMicroseconds(250); digitalWrite(StepperMotor, LOW); delayMicroseconds(250); } digitalWrite(StepperDirection, HIGH); } void loop() { if (ksk == '1') { ksk = 0; cnt = 0; while (cnt < microstepsuntilend) { for (int i=0;i<sizeof(wavelengthvIntensity)-1;i++) { wavelengthvIntensity[i] = analogRead(Sensors[i]); Serial.print(wavelengthvIntensity[i]); Serial.print(", "); } Serial.println(tempnm); digitalWrite(StepperMotor, HIGH); delayMicroseconds(1); digitalWrite(StepperMotor, LOW); delayMicroseconds(1); cnt++; //Serial.println(currenty); currenty = zero+((cnt/microstepsuntilend) * heightofTray); tempnm = d*sin(atan((x+currenty)/D))*(1e9); } digitalWrite(StepperDirection, LOW); for (int i = 0; i < microstepsuntilend; i++) { digitalWrite(StepperMotor, HIGH); delayMicroseconds(250); digitalWrite(StepperMotor, LOW); delayMicroseconds(250); } digitalWrite(StepperDirection, HIGH); Serial.println("$"); } ksk = Serial.read(); }
Regards,
Plamen
P.S. Please excuse my English. I am not a native speaker.
**Attention** This is a public forum