Jump to content


  • Content Count

  • Joined

  • Last visited

About VictorBG

  • Rank
    Noob Class

Profile Information

  • Location
    Quebec, Canada
  1. Hello! I am a fresh beginner in the domain of embedded systems and this MSP430F5529 is my very first development board. I am now trying to make an ADC conversion and send it through the UART to try a signal treatment algorithm with real-world values. I used an example code in Energia that i modified a little bit: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); // Comment: I see many people preferring the 115200 BR for this board. // Is there a particular reason for this choice? } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin A3: int sensorValue = analogRead(A3); // Comment: I think the F5529 actually writes its ADC results on 12 bits. // Should i try to use a long, 16-bit integer? // print out the value you read: Serial.println(sensorValue); } The Energia console gives me expected readings, using an AA battery and an old function generator. For my first UART tests, I tried using Processing, a multipurpose javascript program that i use for drawing. import processing.serial.*; float[] y; // Array to contain the values read through the UART Serial myPort; // Create object from Serial class int val; // Data received from the serial port void setup() { // I define the size of the drawing board to be 600 X 400 pixels. size(600, 400); // I initialize my 'y' array y = new float[width]; for(int i = 0; i<width; i++){ y[i] = 0.0; } // This is to open the correct port. The number in square brackets might vary. String portName = Serial.list()[3]; // Here i define the baudrate, so it's the same as the one in Energia. myPort = new Serial(this, portName, 9600); } void draw() { // This draws a white background background(255); // This tells that i want to draw with the color black. stroke(0); for (int i = 0; i<width; i++){ // For every entry in my 'y' array, I draw a black dot. point(i,y[i]); } // I read a new value from the UART and feed it to my "update" routine. val = myPort.read(); update(val); } void update(int value){ // I shift every value to the left in my array. // This is to get a "strip-chart" feeling to my graph. for (int i = 0; i<width-1; i++){ y[i] = y[i+1]; } // For the last value, i use the value read from the serial port. // I convert it so that i have a correspondance: // min(UART) = bottom of screen, max(UART) = 2^12 - 1 = 4095 = top of screen. y[width-1] = (float)height - value * (float)height / 4095.0; // I also print the UART read value to this software's console for debugging. print(value,"\n"); } What prints on the console is a repetitive pattern of something like 13-10-48-13-10-48-etc. when my pin is grounded. When it's not grounded i get pretty much the same exact numbers with a little bit more variations. At first I thought it was a long int problem with the UART, beacause of the 12-bit ADC conversion, but i'm not so sure anymore. Help me! Thank you very much! readVoltage_ver1.ino