Show Posts
Pages: [1] 2
1  Using Arduino / Installation & Troubleshooting / Re: Serial monitor freezes, have to restart board again: on: February 21, 2012, 08:17:04 pm
also closing and re-opening the serial port does not work. my device works through COM 5, and once i close and open the serial port it says "COM 5 cannot be found"
2  Using Arduino / Installation & Troubleshooting / Serial monitor freezes, have to restart board again: on: February 21, 2012, 08:05:59 pm
So I have been having some issues reading some data from an IMU through the serial monitor. While rotating the IMU, sometimes the Serial monitor will freeze up, and not start again. No wires are removed completely from the board, but perhaps merely bumping them causes problems? I am concerned because I am using the IMU to build a quadcopter, and I do not want the arduino to simply freeze up during midflight and then crash. I was wondering if this is more of a hardware or software problem, and if it can be averted. One reason is because trying to take test data, it is annoying to have to unplug the USB from the board, and re-upload the code (the arduino does not respond to the reset button or anything else.) and of course mentioned before, I do not want the copter to crash later during actual testing. I pasted my code below which also uses a library that i have posted a link to.

IMU: http://www.pololu.com/catalog/product/1265/specs

LSM303 Library: https://github.com/pololu/LSM303


Code:
#include <Wire.h>
#include <LSM303.h>

#define buffer 20

LSM303 compass;

void setup() {
  compass.m_max.x = 470;
  compass.m_max.y = 295;
  compass.m_max.z = 344;
  compass.m_min.x = -526;
  compass.m_min.y = -624;
  compass.m_min.z = -574;
 
  //{-526, -624, -574};// maximum magnetometer values, used for calibration
//compass.m_min = {470, 295, 344};
  Serial.begin(9600);
  Wire.begin();
  compass.init();
  compass.enableDefault();
}
float avg_x [buffer];
float avg_y [buffer];
float avg_z [buffer];
char ptr;
float x,y,z;
void loop() {
  compass.read();
   x -= avg_x[ptr];
   y -= avg_y[ptr];
   z -= avg_z[ptr];

  avg_x[ptr] = compass.a.x;
  avg_y[ptr] = compass.a.y;
  avg_z[ptr] = compass.a.z;
    x += avg_x[ptr];
   y += avg_y[ptr];
   z += avg_z[ptr];
 if(++ptr>buffer - 1)
      ptr = 0;

  Serial.print("A ");
  Serial.print("X: ");
  Serial.print((int)x/buffer);
  Serial.print(" Y: ");
  Serial.print((int)y/buffer);
  Serial.print(" Z: ");
  Serial.print((int)z/buffer);

  Serial.print(" M "); 
  Serial.print("X: ");
  Serial.print((int)compass.m.x);
  Serial.print(" Y: ");
  Serial.print((int)compass.m.y);
  Serial.print(" Z: ");
  Serial.println((int)compass.m.z);
 
  delay(10);
}
3  Using Arduino / Programming Questions / Re: SPI PWM LED Driver on: December 08, 2011, 06:38:57 pm
I'm not quite sure what you're trying to tell me just by pasting the pin mapping of the Mega. Have you looked at my code? At the begining I defined the pins that are supposed to be used for MISO,MOSI,and CLK. I was wondering if I assigned them correctly with the code I wrote, or if they had to be defined a different way.

Thanks
David
4  Using Arduino / Programming Questions / SPI PWM LED Driver on: December 08, 2011, 06:13:51 pm
Hi Everyone,
So I have some programming experience, but I do not have alot of hardware programming experience. Currently I am trying to figure out this PWM LED driver (TLC5940NT, http://pdf1.alldatasheet.com/datasheet-pdf/view/146159/TI/TLC5940NT.html) that uses a SPI interface. I have some starting code (shown below) which is my vague idea to setup all the pins for talking to the chip (I am using the Mega2560). Although, I do not know how I can send the transmission in one big data block.

http://jwtanner.com/led_wheel/led_controller.html   I was looking at this guy's project and it kind of helped, but for simplicity I am just trying to find out how to work it on the basic level, so I have 2 LEDs one hooked up to pin 14, the other to pin 1 on the chip. I want to send 1000 just to those two pins, so I was trying figure out how to do it in one line.

Also I have been doing some reading about SPI, and it seems every chip has a slave select pin, but I cannot figure out for the life of me which is the SS pin on this chip (pg 7 datasheet).

Any help would be greatly appreciated!

David

Code:

#define MOSI 51//Master Out Slave In
#define MISO 50//Master In Slave Out
#define SPICLOCK 52//clk
#define LATCH 49//latch

setup void() {
  pinMode(MOSI,OUTPUT);   
  pinMode(SPICLOCK,OUTPUT);
  pinMode(LATCH,OUTPUT);
  pinMode(MISO,INPUT); 
 
 
}

loop void() {

  digitalWrite(LATCH,LOW);
  shiftOut(MOSI, SPICLOCK, MSBFIRST,0xE3);
  digitalWrite(LATCH,HIGH);
  shiftOut(MOSI, SPICLOCK, MSBFIRST,0x08);
  //I'm pretty sure there is a more efficient way of doing this, just giving an idea on what I'm trying to accomplish.
 
 
}

5  Using Arduino / Sensors / Re: Oddball arduino digitalRead() analogRead() inputs on: September 17, 2011, 01:39:52 am
Thanks all for your help. I ended up doing a clever fix in the programming. Because the input jumps around so much i made a count variable to basically figure out how long the input was high. The sensor when activated lasts about 3 seconds or so, long enough time to enter in to an if statement. I admit its not a total fix, it still bounces long enough for it to goof up, but you can tell the difference between the bugs and the actual activation. My code is below if anyone is interested, and i took out the 10k resistor. Turns out i didnt need it.

David


Code:

/*
David Shaw
dedshaw1612@gmail.com
Annoying Fine-Tuning of the Arduino/PIR setup
9/17/2011

Components Used:
Small White LED
50 Ohm resistor
DC_SS015 PIR Sensor
Arduino Uno


*/
  int pin2 = 2;
  int val = 0;
  int count = 0;



void setup() {               

 
  pinMode(9, OUTPUT);
  pinMode(3,INPUT);
  //setting up the Serial to print the results
 
  Serial.begin(9600);

}

void loop() {
 




//Basically the point of this setup was to investigate the pins b/c i was interested in the values  and so i have them read to the serial monitor.
//Because the input pin 3 jumps around so much (still dont know why), i initialize a varible to count how long the value of the input has been
//high. because it jumps around it wont be that way for long. Only when i activate the sensor does the DC current stay high long enough to exceed the
//count varible to send it into the if statement which acknowledges motion has been sensed. 8500 was an arbitrary guess, but it works great.
//But i based it upon the fact the analog reads 10,000 times a second so i just picked a high number assuming the digital pins read roughly the same
//rate. Although, im still tweaking it as i type this and its still going off, but ive reduced the error dramatically.
 
   for (int digiChannel = 0; digiChannel < 13; digiChannel++) {
            val = digitalRead(3);
           
              while (val)
              {
                count++;
                if(count >= 8500)
                {
              Serial.print("MOTION SENSED ");
              Serial.println("");
              digitalWrite(9, HIGH);
              delay(3000);
              count = 0;
                }
              val = digitalRead(3);


            }
             digitalWrite(9,LOW);

           
           
            Serial.print("binary at pin ");
            Serial.print(digiChannel);
            Serial.print(" is ");
            Serial.print(digitalRead(digiChannel));
            Serial.println("");
            delay(700);
         
        }



}

6  Using Arduino / Sensors / Re: Oddball arduino digitalRead() analogRead() inputs on: September 17, 2011, 12:13:01 am
yup. if i had it my way i would just hook the sensor up to the LED :/   unfortuantly my professor wont let me do that
7  Using Arduino / Sensors / Re: Oddball arduino digitalRead() analogRead() inputs on: September 17, 2011, 12:00:45 am
the sensor is fine. im staring at the benchmeter and its hooked up to the output. everytime i move it flicks to 3V and then back to 0 when i stand still. I dont think i changed anything to do with the analog reference.
8  Using Arduino / Sensors / Re: Oddball arduino digitalRead() analogRead() inputs on: September 16, 2011, 11:45:25 pm
I attached a .jpg for the sensor. DC_SS015
9  Using Arduino / Sensors / Re: Oddball arduino digitalRead() analogRead() inputs on: September 16, 2011, 11:30:33 pm
im running an Uno by the way, sorry if i didnt mention that earlier but i dont know if it makes a difference :/. So lefty your saying i should increase the voltage on my Vcc going to my sensor? I cant understand what changing any voltages would do anyway since its still reading from nothing. I just hooked up to the A0 pin and its reading 1023 on the serial when there is no output from the sensor
10  Using Arduino / Sensors / Re: Oddball arduino digitalRead() analogRead() inputs on: September 16, 2011, 10:31:35 pm
i attached a rough sketch. the 10k has the same effect whether its there or not.
11  Using Arduino / Sensors / Re: Oddball arduino digitalRead() analogRead() inputs on: September 16, 2011, 10:21:20 pm
im not sure what you mean, here is my code:

Code:

  int pin2 = 2;
  int val = 0;



void setup() {               

  pinMode(9, OUTPUT);
  pinMode(2,INPUT);
  Serial.begin(9600);

}

void loop() {
 

  val = digitalRead(2);    // read the input pin
  Serial.println(val);
  if (val)
  {
  digitalWrite(9, HIGH);
  delay(5000);
  digitalWrite(9,LOW);
  }
  delay(1000);



}


i have the sensor outputting to a breadboard. one wire from that goes to the pin 2, and the other wire i have a 10k resistor running to ground but nothing is happening. Do i have to ground all the unused pins?
12  Using Arduino / Sensors / Re: Oddball arduino digitalRead() analogRead() inputs on: September 16, 2011, 09:58:01 pm
alright well i read that if you dont put anything in the inputs your outputs will be random. so now i actually have a wire going into the board and trying to read it. at the same time im staring right at the bench meter and can tell when the PIR sensor notices im there. 3V when i move, and 0V when i stay still. Yet while its at 0V the led is still blinking. Anythoughts?
13  Using Arduino / Sensors / Oddball arduino digitalRead() analogRead() inputs on: September 16, 2011, 09:39:25 pm
So im messing with a PIR sensor that outputs a DC of 3V if it detects motion. My problem is im trying to get the arduino to read the input and light up an LED, and possibly later turn on a speaker. With no wires going into the inputs, the serial monitor jumps between 0's and 1's and the light goes on and off. same thing with the analog. My question is how am i supposed to know if the input coming in is actually driving the light, or if it is just whatever oddball thing is going on with my arduino?
David
14  Using Arduino / Programming Questions / Re: HTTP request connection failed on: September 13, 2011, 07:33:07 am
all my HTTP request projects are still not working. Its so frustrating, I dont understand what can be the problem. By the way though zoomkats website doesn't work. I even pointed my browser to that ip address and it doesn't work
15  Using Arduino / Programming Questions / Re: HTTP request connection failed on: September 09, 2011, 02:43:22 pm
connection still failed
Pages: [1] 2