Show Posts
Pages: [1] 2
1  Using Arduino / Motors, Mechanics, and Power / Re: Switching on/off a 120VAC motor on: February 03, 2013, 06:12:48 pm
I take a lot of stuff apart and I almost always keep the PCBs, so I'm sure I've got something lying around that has a PNP transistor on it that I can salvage.

Thanks for the responses guys. I know this is just a whim project, but it's helping me to better understand some of these things, how they work and whatnot.
2  Using Arduino / Motors, Mechanics, and Power / Re: Switching on/off a 120VAC motor on: February 02, 2013, 11:54:17 pm
I'm trying to avoid buying anything, especially for projects that are just whims, it probably won't actually turn into anything, but it's something I'd like to try.
3  Using Arduino / Motors, Mechanics, and Power / Switching on/off a 120VAC motor on: February 02, 2013, 11:11:25 pm
I'm pretty sure I understand how this needs to be done, but I want to make sure so I don't ruin my Arduino or anything else. I have a 120VAC geared motor that I want to be able to switch on and off using the Arduino. If I understand right, I'll need to use a relay. While relays that can be switched with 5V and less than 40mA and will switch 120VAC+ do exist, I don't have one...I have a relay that can be switched with 12V and will switch 120VAC+. What I believe I can do is use the Arduino and a transistor to switch a separate 12V source which will in turn switch the relay, which will power the motor.

Am I understanding this right? The Arduino switches the transistor, allowing the 12V source to switch the relay, which will enable power to the motor. Do I need a special transistor? Right now I have some TN4403's, TN2907's and TN3906. I read that I need a TIP120, I can only assume it's because the ones I have won't handle 12V or something.
4  Using Arduino / Sensors / Re: Help with TMP37 temperature sensor on: February 02, 2013, 12:28:48 am
I think I've figured it out. My math for the C to F conversion was wrong (backwards), so I was getting the right C temperature but the wrong F temp.

Since the TMP37 reads 500mV at 25° and has a scale of 20mV/°C, that means that 0°C is 0mV, so I didn't need to subtract the .5 (500 mV), just divide the calculated mV by 20. Right now it's reading 30.29°C/86.53°F in my room, which feels right (I said before I really hate cold). Final sketch:

Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
#define aref_voltage 3.3

int tempPin = 1;
long tempReading;
float avgTemp;
 
void setup(void) {
  analogReference(EXTERNAL);
  lcd.begin(16,2);
  lcd.clear();
  lcd.setCursor(0,0);
}

void loop(void) {
  for(int i = 0; i < 400; i++) {
    tempReading += analogRead(tempPin);
    delay(1);
  }
 
  avgTemp = tempReading / 400;
 
  double mv = avgTemp * ((aref_voltage * 1000) / 1024);
  double tempC = mv / 20;
  double tempF = (tempC / 5 * 9) + 32.0;
  lcd.clear();
  lcd.print(tempC);
  lcd.print(" C");
  lcd.setCursor(0, 1);
  lcd.print(tempF);
  lcd.print(" F");
  tempReading = 0;
  delay(1000);
}

I'm sampling the sensor 400 times then averaging the reading, then converting that to a mV value by multiplying by ((aref_voltage * 1000) / 1024), then dividing by 20 to get °C. The reason I do aref_voltage * 1000 is because aref_voltage is 3.3, I need 3300. All seems well now.
5  Using Arduino / Sensors / Re: Help with TMP37 temperature sensor on: February 01, 2013, 09:00:57 pm
To be honest, I'm not completely sure why I'm subtracting .5 either...I just thought about it. The article I was reading was about the TMP36, which reads 500mV at 0°C, so that's why they subtracted .5 (.5V = 500mV), but the TMP37 reads 500mV at 25°C, and has an interval of 20mV/°C, 500/20 = 25, which means that at 0°C, the reading is 0mV, so I should just take the mV reading and divide by 20.

The reason I'm multiplying by 200 is because, in the sketch I'm using, the voltage is calculated to actual volts, not millivolts (.65 instead of 650, for example), but even now that doesn't make sense to me...I've confused myself.

I think I need to change my sketch to calculate actual mV and not volts.

Code:
int reading = analogRead(A0);
double mv = reading * ([input voltage] / 1024); // To convert the analog 0-1023 value to a mV value relative to the input voltage
double tempC = mv / 20;
double tempF = (tempC * 9 / 5) + 32;

Edit: Read through the second link you posted (the one from bristolwatch.com) and the sketch used in that example is awful. Tons of errors that needed to be fixed, and when I finally got it working it says it's 481°F in my room. Also looked at the library, also bad, said that it was like 302°F (and I did use setARefVoltage(3.3), so it wasn't that)). I'm not sure what the heck the problem is here, but I'm starting to get frustrated because I know that it's not 62°F in my room, which is what my modified code (from above in this post) is saying.
6  Using Arduino / Sensors / Re: Help with TMP37 temperature sensor on: January 31, 2013, 10:06:06 pm
I just can't believe that humidity is making up that much of a difference. Right now the device is reading 55.03°F. There is no possible way it's 55° in my room, the rest of the house is much cooler and the AC (in the living room) is set to turn on at 75°. I unplugged and replugged the Arduino from USB and it's now reading 53.87°F. I also removed the sensor from the breadboard and put in another one (I have two of the same kind), then unplugged and replugged the Arduino and it started at 65° and dropped down (quickly at first, then slower) to around 56°. It is not that cold in here, it never gets that cold in here, or anywhere else in the house for that matter, I hate cold.
7  Using Arduino / Sensors / Re: Help with TMP37 temperature sensor on: January 31, 2013, 02:13:21 pm
That still doesn't explain why my readings seem to be off. Applying your math to an example analog value from the sensor of 200:

200 * 4.887586 = 977.52
(977.52 - 500) * 0.05 = 23.88 (°C)
23.88 * 1.8 + 32 = 74.98 (°F)

And my math:

200 * (5000/1024) = 976.56
(976.56 - 500) / 20 = 23.83 (°C)
(23.83 * 9 / 5) + 32 = 74.89 (°F)

The difference is .05°C (and I did my math above assuming I was using 5V as the Vs, I'm actually using 3.3V with aref so it's more precise and less noisy). I don't think the way I'm doing the math itself is wrong, I'm just wondering why the number coming out seems wrong. Right now it says it's 72.43°F in my room, but it feels a lot hotter to me. I have no way of verifying the actual temperature in the room.
8  Using Arduino / Sensors / Help with TMP37 temperature sensor on: January 31, 2013, 09:47:35 am
I recently received a few free samples of this device from analog.com because I wanted to try to modify my old analog thermostat and make it digitally controlled. The device has 3 pins: Vs, out and GND, and it operates between 2.7 and 5.5V. Here's the datasheet:

http://www.analog.com/static/imported-files/data_sheets/TMP35_36_37.pdf

The 37 in particular reads in 20mV/°C, is designed for the 5°-100°C range and has a reading of 500mV at 25°C. Initially I simply plugged in 5V to the Vs, GND to the ground pin and the out pin to A0 on the Arduino, then I read the analog input, adjusted it to convert the 0-1023 analog reading to a mV value like this:

Code:
int reading = analogRead(A0);
float mv = (reading * 5.0) / 1024.0;

Then subtracted 500 and divided by 20 to get degrees C. This is where I'm not sure I'm doing it right. Basically, I don't believe what the sensor is saying the temperature is in my room. Right now it's saying it's 77.07° F (25.04° C). I know that it's hotter than that (it gets really hot in my room). Here's my current sketch. I'm using 3.3V aref and printing to an LCD.

Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
#define aref_voltage 3.3

int tempPin = 1;
int tempReading;
 
void setup(void) {
  analogReference(EXTERNAL);
  lcd.begin(16,2);
  lcd.clear();
  lcd.setCursor(0,0);
}

void loop(void) {
  tempReading = analogRead(tempPin);
  float voltage = tempReading * aref_voltage;
  voltage /= 1024.0;

  float temperatureC = (voltage - 0.5) * 200 ;
  float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
  lcd.clear();
  lcd.print(temperatureC);
  lcd.print(" C");
  lcd.setCursor(0, 1);
  lcd.print(temperatureF);
  lcd.print(" F");
  delay(1000);
}

The article I was reading to help me figure out how to set this thing up was using a TMP36, which is slightly different than the 37. From the datasheet:

Quote
The TMP36 is specified from −40°C to +125°C, provides a 750 mV output at 25°C, and operates to 125°C from a single 2.7 V supply. [...] Both the TMP35 and TMP36 have an output scale factor of 10 mV/°C.

Quote
The TMP37 is intended for applications over the range of 5°C to 100°C and provides an output scale factor of 20 mV/°C. The TMP37 provides a 500 mV output at 25°C.

The difference I see is that the 36 reads 500mV at 0°C whereas the 37 reads 500mV at 25°C. My tiny tired brain can't work out what I'm supposed to do to account for this.

I'm hoping someone here who is less tired and has a bigger brain can help me figured the math out for this.
9  Using Arduino / Displays / Unknown spec LCD help? on: October 23, 2012, 06:54:05 am
I found a little cheapo digital camera on clearance at Walgreens (one of those with the built in memory and crappy quality). It was $5, so I figured what the heck. The first thing I did was, obviously, take it apart. The camera can act as a webcam, so I can use that function right now, but the thing has a little LCD screen on it. I mean tiny, 1" x .75". It has a part number on it, but Google didn't come up with anything, so I was wondering if you guys might be able to help me figure out how to get this little guy running on my Arduino Uno. The part number is TXDC096C-1V3m printed on the ribbon that connects the screen to the camera. If I had to guess at it's resolution, I might say 90x60 or possible even 45x30. It's tiny.

Anyway, I'd really like to get something on this screen through the Arduino, any help you guys might be able to provide would be fantastic.
10  Using Arduino / General Electronics / Re: Control an Xbox 360 controller analog stick on: January 12, 2012, 02:13:09 pm
It only took me about 3 seconds with the sandpaper. Make sure it's fine-grit though, 220 should be about as low as you go. It's just metal contacts underneath.

And I'll look into that switch, thanks.
11  Using Arduino / General Electronics / Re: Control an Xbox 360 controller analog stick on: January 11, 2012, 09:04:27 pm
I am soldering to the button pads. I found that using a small piece of fine-grit sandpaper works great to scratch off the coating, and it also etches the contacts a little so solder sticks to it no problem. I just checked with a multimeter which contact was + and which was -, then had to figure out why pulling the pin high wasn't causing a button press (turned out that I was using a PNP transistor instead of an NPN one, so I had to set the pin to high, then pull it low to "push" the button). I wrote a simple program in C# to communicate with the Arduino through serial and allow me to assign buttons (in the program) to "push" the buttons on the controller.
12  Using Arduino / General Electronics / Re: Control an Xbox 360 controller analog stick on: January 11, 2012, 02:26:07 am
Dude, sorry it took me so long to reply, the site hasn't been loading for me for the last few days. I'd love to play (I haven't played much Halo lately, what with Skyrim and all), I'll send you a FR.

Anywho, thank you so much for all the awesome information, I've placed a sample order for that specific digital pot from analog.com (it was free!), I expect to get it on the 16th. When I do, I'll definitely refer back to your post and figure this out. If all goes well, I'll let you know.

Thanks again, I really appreciate it. It's nice to talk about this kind of thing to someone who understands exactly what I'm going for (not that GoofBallTech didn't, but you know the Arduino side of this, and also the Halo side)

One thing though, how do I tell if my controller is a common wire or common ground? How does it matter, like, how would I wire it differently for one or the other?
13  Using Arduino / General Electronics / Re: Control an Xbox 360 controller analog stick on: January 06, 2012, 02:52:58 pm
I don't know if you're familiar with or have ever played Halo: Reach, but there is a theater mode in which you can take screenshots and move the "camera" around. in theater there is a feature called pan cam which shows the position and heading of the camera. I make spherical panoramas using this feature (example: http://hrci.me/pano/reflection) by placing the camera at a certain place and taking multiple screenshots. I'll start with the camera pointing at, say, 90 degrees, take a screenshot, then rotate exactly 30 degrees and take another, and repeat 12 times for a full rotation. Then I'll rotate the camera up 15 degrees and do it again. In total I get 13 full rotations spaced by 15 degrees vertically, I end up with 156 screenshots which I stitch together into a full spherical panorama. I have to be very careful not to tap the left stick or triggers because that will move the camera and even the slightest difference in camera position totally screws up the stitch and I have to redo it all.

The reason I want this mod is because rotating exactly 30 degrees is a pain in the arse, even with the controller sensitivity turned all the way down, and I'm a perfectionist. If I were able to very finaly control the sticks without touching the controller (and so not risking moving the camera) it would be a LOT easier to make these panoramas. I could make a macro that would rotate the camera at a certain speed for a specific amount of time, then hit the appropriate buttons to take and save a screenshot. I could essentially automate the entire picture taking process with a few simple loops and some logic.

Also, sorry for the very verbose explanation, I tend to do that, but I hope I gave you enough information to understand what I'm going for.
14  Using Arduino / General Electronics / Re: Control an Xbox 360 controller analog stick on: January 06, 2012, 11:45:08 am
Ok then, I'll go ahead and get that digital pot from SparkFun, that should be a simpler solution, right? Basically it does the exact same thing that a physical potentiometer does, but can be controlled via digital signals, meaning that I could use the Arduino to set the pot to a specific value between 0 and 1.5V and it would be a real analog signal? The whole reason I'm doing this is because I want very fine control of the sticks, particularly the rotation (right stick/triggers). For my application, I need there to be no chance of bumping the left stick (movement) at all, else I waste a lot of time and have to redo everything. Before I was simply holding the controller and keeping my fingers as far away from the right stick and triggers as possible, but my hand starts to cramp holding the controller like that, so I want to be able to control it from the computer. Plus, writing some macros would be nice.

At any rate, that digital pot you linked would be the way to go?

Edit: From what I've read, the pots in the controller are linear 10k, but I used a multimeter, set to the 20k setting, to test the resistance between the two outer leads and I got a reading of 1.5 (which I assume means 1.5k, since the meter was set to the 20k setting). I tested between the right and middle leads, then the left and middle leads and got a reading of 4.1k then tested the left and middle leads and got 3.3k. That doesn't make any sense to me. I'm 100% positive I wasn't pushing the sticks at all, I had the thing clipped in my helping hands tool.

Edit 2: Since I don't really know anything about digital pots, could you point me in the direction of a really good, high resolution one. Looks like the SparkFun one you linked to only has 129 steps, which might not be enough to accomplish that fine control that I need. Like I said, I really know very little about these things, so any help I can get will be useful.
15  Using Arduino / General Electronics / Re: Control an Xbox 360 controller analog stick on: January 06, 2012, 05:49:54 am
I did some calculations with a multimeter and setting an analog write value of 80 gave me 1.51V, so I tried sending that to the wiper of the voltage divider and it spun to the right, indicating that the wiper was closer to GND. I set it to 127 and it centered, but jittered, setting it to 255 made it go full spin to the left, 0 made it full spin to the right. No clue why, but that's what's happening. I've read on multiple Xbox hacking forums that the voltage going through the pot really doesn't matter since it's just a voltage divider, replacing the 100k variable resistor with a 1k or a 1m would yield the same results, it's just dividing the voltage, whatever voltage is going from positive to ground, the controller uses it.

Unfortunately I'm not really in a financial situation where I can spend any money getting any extra stuff, even if it is only $1.50. Is there a way to do it without the digital pot?
Pages: [1] 2