Senior Design Project Help

hgmjr

Joined Jan 28, 2005
9,027
So you are using LED on pin D13 as an indicator of whether your relay is energised or not. That is a good idea. I was just temporarily confused.

hgmjr
 

Thread Starter

ripcus10

Joined Apr 13, 2012
56
It is an led put in place of the relay. The led that I'm put in place of the relay is on the main board right across from the COM cable. It is a green light that has an "L" next to it. It is a digital output that you can program to do what ever you want
 

hgmjr

Joined Jan 28, 2005
9,027
I am with you now.

That LED is referenced to VCC. That explains why the LED is always on. The arduino is never detecting voltage at any of the three axis inputs so it is setting the output LOW. That will turn on the LED all the time.

hgmjr
 

Thread Starter

ripcus10

Joined Apr 13, 2012
56
If I understand what you are saying, the arduino doesn't see any input from the accelerometer so it thinks that the input is below the low limit that i set in the program?
 

hgmjr

Joined Jan 28, 2005
9,027
Maybe what you should do is change your software to look for a value from the accelerometer that exceed a certain value rather than looking for the value to be within a window. Then you can reduce the value until the LED indicates a change.

hgmjr
 

Thread Starter

ripcus10

Joined Apr 13, 2012
56
Ok I did check the accelerometer output yesterday and they are all around 1.5V output when resting to the board. My thinking is that maybe I have the cables hooked up to the wrong inputs?
 

hgmjr

Joined Jan 28, 2005
9,027
I would be more inclined to believe that the output from the accelerometer should be nearly zero volts when the accelerometer is at rest. 1.5V sounds suspicious.

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,027
From the pictures that you have supplied, it looks like there are three pins associated with each analog input. One is the analog signal (the one closest to row of analog pins). The middle one is ground and the one furthest away is +5V. This is according to the labels that I can see. Do you agree?

If so then the red wire coming from the accelerometer (+5V) should be on the outside pin. The black wire (ground) should be on the middle pin. And the blue wire (signal pin denoted "S") should be on the inner most pin.

Check your documentation to make sure that it agrees with my interpretation.

hgmjr
 

Thread Starter

ripcus10

Joined Apr 13, 2012
56
That is correct. However one of the wire assemblies is not put together the same as the other. The red and blue wires are switched. That is the one that is plugged into slot three or the one farthest to the right.

If I'm reading the datasheet provided for the accelerometer correctly then it says that at zero g's the accelerometer will output about 1.65V. In my program I will remove the lover end of the limit to see if i can get the led to turn off. Here is the link for the datasheet for the accelerometer.

http://www.robotshop.com/content/PDF/datasheet-dfr0068.pdf
 

hgmjr

Joined Jan 28, 2005
9,027
There is one more software problem that needs to be overcome.

Notice that all three axes are controlling the single LED. That means they are in competition with each other. If one axis turns it on, the other two axes will almost immediately turn the LED off if they are not activated.

This is going to require you to use a bit more logic to control the single LED properly from three possible inputs.

hgmjr
 

Thread Starter

ripcus10

Joined Apr 13, 2012
56
I commented out the lower limit of the ranges that I set and the result was the same. The led is still constantly on. I don't know if this has to do with the binary not being correct. I do know that the microcontroller is a 10-bit controller. When Chris was helping me earlier we said that 512(decimal) was considered the midpoint and went + and - from there to set our limits
 

hgmjr

Joined Jan 28, 2005
9,027
Maybe it would be easier for you to express the values you are looking for as decimal rather than binary. Then you would not be faced with the need to translate between binary and decimal.

hgmjr
 

Thread Starter

ripcus10

Joined Apr 13, 2012
56
So if I changed my code from this
Rich (BB code):
  if(analogRead(xpin)>0B0001011110)
  { digitalWrite(relaypin, HIGH); }
To this:
Rich (BB code):
 if(analogRead(xpin)>607)
  { digitalWrite(relaypin, HIGH);
That should work?
 

hgmjr

Joined Jan 28, 2005
9,027
So if I changed my code from this
Rich (BB code):
  if(analogRead(xpin)>0B0001011110)
  { digitalWrite(relaypin, HIGH); }
To this:
Rich (BB code):
 if(analogRead(xpin)>607)
  { digitalWrite(relaypin, HIGH);
That should work?
Yes.

There is still the matter of three inputs controlling one output to address.

You could temporarily comment out all but one axis test just to convince yourself that a given axis is working. Chrisw1990 recommended this early on as I recall.

hgmjr
 

Thread Starter

ripcus10

Joined Apr 13, 2012
56
SUCCESS!! I commented out all the lines except for the x-axis and changed the binary to decimal. When I hit the accelerometer against my hand the led would turn on and then back off. I then changed the program to the relay pin and it also worked when i hit the accelerometer against my hand.

With that now being discovered what is the next step to get the controller to read all three axis at a time?
 
Top