|
So I'm trying to find some example Arduino sketches for LDR / photoresistor based backlight dimming. I see plenty of examples for LIGHTING an LED when a photoresistor comes into play, but I can't find anything that anyone has used for dimming an LCD backlight based on ambient light. Especially considering that I have three lighting values to worry about (red, green and blue). I know i'll most likely have to constrain as well as map values but i'm lost outside of that. http://dotblue.pastebin.com/m76802509 Here is my sketch thus far, minus any sort of code for dimming. Is anyone Arduino/Processing smart or C smart that can help with dimming code? Thanks EDIT: I have the light resistor code in place that tells me if the ambient light is dark, dim, light, bright or very bright over the serial monitor. If I could somehow make it so that based on one of these 5 values it darkens/brightens the colors appropriately. I'm fine with either getting fading set up so it fades brightness smoothly OR just changes between certain brightnesses by adding 0-200 or so to each of the color values based on the dark/dim/light/bright/very bright values. I just don't know how to implement it... Allistar fucked around with this message at 19:35 on Feb 6, 2010 |
# ? Feb 6, 2010 17:19 |
|
|
# ? Jun 11, 2024 11:20 |
|
1. Figure out what level of light the photoresistor is detecting. 2. Determine what brightness the LCD should be at based on that level. 3. Tell the LCD to adjust its brightness. Do that once every second or every few seconds or however often you feel is needed. It sounds like you have everything in place. What's the problem? Edit: Or maybe you should tell us a bit more about your hardware if you don't know how to adjust the brightness on the LCD to begin with Unparagoned posted:I want to make an advanced tens machine. (http://www.amazon.com/LGMedSupply-Platinum-Electronic-Stimulator-Physical/dp/B001PT9QW8). I prefer PICs and they still are the most popular microcontroller line on the planet by far, but the amount of hobbyist-level documentation for AVRs has vastly overtaken PICs because of the out of control popularity of the Arduino line of project boards. Though to be honest it's my perception that many people who learn with the Arduino kits end up being completely useless at doing anything that isn't handed to them. The PIC product line is massive, with hundreds of 8-, 16-, and 32-bit products available with different combinations of peripherals and amounts of memory. You can easily find a part that fits nearly any application you can think of. The 8-bit and 16-bit parts are similar enough that learning how to use one of them will make it a lot easier to work with any other part in the line (the 32-bit parts are actually quite a bit different for some reason). The ability to reuse code and concepts across so many different parts is really nice and can make it easy to begin new projects without having to reinvent anything. Whatever you choose, though, you'll want to get familiar with it before you hop into signal generation. There's a lot of stuff you'll need to learn first or you'll just get lost and frustrated. BattleMaster fucked around with this message at 20:20 on Feb 6, 2010 |
# ? Feb 6, 2010 20:03 |
|
BattleMaster posted:1. Figure out what level of light the photoresistor is detecting. OK, I have the code in place! Is there something relatively easy i can do to make it a "smooth" fade instead of the jerky fading i have now due to how it's set up? http://dotblue.pastebin.com/d3baa7d37 The hardware is an RGB Backlit character LCD with common anode, which means 255 is low and 0 is high. Right now I have a few if statements in place where if LDR value is this, then lightIndex = that. Then I add the lightIndex value to the existing colorIndex value. It works, I've tested it... just not as "smooth" as I'd like. All suggestions and criticism is invited.
|
# ? Feb 6, 2010 22:27 |
|
A really "cheap"* way to do a smooth fade is to store the desired value of the brightness and current value of the brightness and to periodically check to see if they're equal. If they're not equal, find out if the current brightness is dimmer than or brighter than the desired brightness. If it's dimmer, have it increase the brightness a little. If it's brighter, have it decrease the brightness a little. Keep doing that until the brightness is equal. *There might be better ways but this one is quick and easy Edit: Example: Let's say the current brightness is 128 and you want it to be 255. When your program checks that it will find out that 255 is greater than 128 so it needs to make the screen dimmer. It will increment it to 129. Then the next time it checks it will find out that 129 is still less than 255 so it will increment it to 130. Repeat until brightness is equal to 255. If at some point the desired brightness is changed to 64, you will need to start decrementing it until it's equal to 64. And so on. Use some kind of timing mechanism so that not only do changes happen at exact intervals for consistency, but so that your program can tend to its other duties in between brightness updates. Once you get it working, play around with the timing and increments to get the desired speed and smoothness. BattleMaster fucked around with this message at 22:51 on Feb 6, 2010 |
# ? Feb 6, 2010 22:43 |
|
Something like this should work:code:
You can also scale the relative brightness up or down. Just multiply lightScaler by 1.1 or 0.8754 or whatever. For fading in between colours, you basically want to implement this: So for each phase, one of the RGB values will be held high, one will be held low, and one will be changing. The changing one will use a similar system as the light scaling above. edit: woops, use this code, not the one quoted below ante fucked around with this message at 05:56 on Feb 7, 2010 |
# ? Feb 6, 2010 23:01 |
|
ante posted:Something like this should work: How fast are AVRs at floating-point math? Can it do that enough times per second to make it look smooth without slowing everything else down? I guess it won't need to do it that many times a second but I've had trouble doing significant amounts of floating point math even on PIC18s clocked at 40MHz so I'm wondering if that AVR will be able to do it fast enough. I've learned to avoid using anything more complicated than unsigned chars unless I really have to. BattleMaster fucked around with this message at 00:55 on Feb 7, 2010 |
# ? Feb 7, 2010 00:49 |
|
He doesn't really have any need for code efficiency. It shouldn't take a significant amount of time to go from one end to the other. There are only 256 possible steps. I'd agree with you if it speed was a requirement here, but I don't think it matters. ante fucked around with this message at 01:06 on Feb 7, 2010 |
# ? Feb 7, 2010 01:03 |
So a member of our tesla coil group made a time lapse video of them prepping the secondary coil: http://www.youtube.com/watch?v=hQ1bylyXg_M I'm not in this video. Maybe I'll get him to set up a camera so I can do a time lapse video of me soldering up the next telemetry/control board.
|
|
# ? Feb 7, 2010 03:55 |
|
Could someone help me understand a little transistor theory? I'm trying to multiplex some nixie tubes. As you can see in my schematic, the transistors at the top are hooked up to the tubes' anodes and are used to enable/disable each tube. The transistors on the bottom allow me to control which digit in the tube lights up (I've drawn tubes with only 3 elements because I'm lazy; the actual tubes have 10). I use a microcontroller to rapidly switch the tube enable transistors and digit transistors to get a 2-digit readout. In practice, the bottom half of my design works - if I hook my tube anodes directly to power, I can switch the individual digits of the tube with transistors hooked up to the cathodes. The transistors at top, however, don't seem to work. In other words, the transistors seem to be able to sink current but not source it (right?). Would my design work if I replaced the NPN transistors at the top with PNP transistors and controlled them with negative logic? Transistors are MPSA42 and resistors are 10K.
|
# ? Feb 7, 2010 19:21 |
|
Oh yeah, and the schematic, dumbass!
|
# ? Feb 7, 2010 19:21 |
in that configuration you're using the high side transisors as emitter followers, so the emitter voltage will be the base voltage minus 0.6V, so about 4.4V when the digital line goes high. Not enough to light the tubes (and if they did, you'd dissipate a huge amount of power across the transistors). Properly disconnecting a circuit from such high voltages with logic level signals would be slightly complicated, unless you use use some isolation method (which would be a good idea anyways). Optocouplers or relays would work well. Alternatively, you could ditch high side control altogether and logic AND the low side signals with your enable signal, or something similar.
|
|
# ? Feb 7, 2010 19:34 |
nobody- posted:Would my design work if I replaced the NPN transistors at the top with PNP transistors and controlled them with negative logic? ANIME AKBAR is pretty much right, unless you can get your microcontroller to put out 2 or 3 volts over the anode voltage of the nixie tube (~150V), that will never work. In order to turn the transistor on, Vb has to be higher than Ve, and that is simply not going to happen with your design as-is. The right answer is to use a PNP transistor and control them with a MPSA42. This schematic has a good example of what I mean: http://www.geekysuavo.org/nixer/nixer-sch.png Waffleimages pukes on the image, so you will have to live with a link. They use MPSA92 (the PNP equivalent to the '42) to select a nixie. When the '42 is driven hard, it pulls the PNP base down and it starts conducting. When the '42 is pulled low and turned off, the PNP base voltage rises until it turns off.
|
|
# ? Feb 7, 2010 20:02 |
|
Ok, thank you guys so much! I was originally thinking about using an optocoupler for the high side, but I wasn't sure what specs I should look for other than a really high collector-emitter voltage. Are there any inherent drawbacks with using the MPSA42 - MPSA92 switching method as opposed to an optocoupler, other than the higher risk of accidentally frying the entire circuit?
|
# ? Feb 7, 2010 20:15 |
|
Can anyone explain to me what a bias tee is? According to Wikipedia it seems to separate high and low frequencies, but I'm not sure what that has to do with biasing.
|
# ? Feb 8, 2010 00:00 |
2 questions. 1. What is the difference between a boost regulator and a capacitor? 2. Why must the resistance along a circuit sum up to 0? (Kirchoff's law)
|
|
# ? Feb 8, 2010 19:33 |
Popete posted:2 questions. 1. Usually a boost regulator is used to take a lower voltage (say a 1.5V battery) and regulate it up to a higher voltage (say, 3.3V for a microcontroller circuit). These circuits (it's not a single component, even if it comes in a single package) often contain capacitors to smooth the output voltage along with other functionalities. The two objects aren't really connected except one will probably include the other; it's like asking what is the difference between a car and a muffler. 2. They don't? Resistance can't sum to zero because you would need 'negative resistance' and while there might be some cute mathemagic way to make this happen, it's not actually Kirchoff's laws say anyways; they state the voltage around a closed loop and the currents in and out of a single node must sum to zero, and are pretty much based around the idea of conservation of energy. Any current flowing into a node has to go somewhere, after all.
|
|
# ? Feb 8, 2010 19:50 |
|
A boost converter is a DC-DC converter. That means it converts one DC source to a different value. A capacitor is a single component that stores energy. You've got Kirchoff's laws a little mixed up. The potential (voltage) in a closed circuit must equal to zero, and the current in any given node must also equal zero. For the first one, take a look at this: The battery is putting out 15V, and ALL of that 15V is applied to the resistor. Therefore the resistor has an equal and opposite polarity, making the sum of voltages in the circuit zero. A node is any point on the circuit that connects to three or more components. This law is harder to prove in mspaint, but the reasons are the same as the first one.
|
# ? Feb 8, 2010 19:58 |
Delta-Wye posted:1. Usually a boost regulator is used to take a lower voltage (say a 1.5V battery) and regulate it up to a higher voltage (say, 3.3V for a microcontroller circuit). These circuits (it's not a single component, even if it comes in a single package) often contain capacitors to smooth the output voltage along with other functionalities. The two objects aren't really connected except one will probably include the other; it's like asking what is the difference between a car and a muffler. Sorry ya I misstated Resistance when I meant the Voltage around a circuit, but I guess that makes sense in a conservation of energy way.
|
|
# ? Feb 8, 2010 21:26 |
ante posted:A node is any point on the circuit that connects to three or more components. This law is harder to prove in mspaint, but the reasons are the same as the first one. So is this just saying that before the voltage/current re-enters the source it will equal 0? I just thought measuring voltage after it runs through a resistor still came out to a set voltage and not 0.
|
|
# ? Feb 8, 2010 21:28 |
|
Popete posted:So is this just saying that before the voltage/current re-enters the source it will equal 0? I just thought measuring voltage after it runs through a resistor still came out to a set voltage and not 0. Voltage is across things, current is through things. Talking about voltage "through" a resistor doesn't mean anything. E: This is also why you put your multimeter in series with something to measure current, but you put it in parallel with something to measure voltage.
|
# ? Feb 8, 2010 21:46 |
Popete posted:So is this just saying that before the voltage/current re-enters the source it will equal 0? I just thought measuring voltage after it runs through a resistor still came out to a set voltage and not 0. It sounds like you have a pretty iffy understanding of what current and voltage are, and that is going to make it hard to understanding Kirchhoff's laws. from http://physics.about.com/od/electromagnetics/f/KirchhoffRule.htm: quote:Since current is the flow of electrons through a conductor, it cannot build up at a junction, meaning that current is conserved: what comes in must come out. When performing calculations, current flowing into and out of the junction typically have opposite signs. and quote:Kirchhoff's Voltage Law comes about because the electrostatic field within an electric circuit is a conservative force field. As you go around a loop, when you arrive at the starting point has the same potential as it did when you began, so any increases and decreases along the loop have to cancel out for a total change of 0. If it didn't, then the potential at the start/end point would have two different values. For me the weirdness came from using the voltage law to solve for currents and the current law to solve for voltages, but once you get down nodal and net analysis techniques are really just a lot of algebra no matter how big or nasty looking the circuit is.
|
|
# ? Feb 8, 2010 21:49 |
Delta-Wye posted:For me the weirdness came from using the voltage law to solve for currents and the current law to solve for voltages, but once you get down nodal and net analysis techniques are really just a lot of algebra no matter how big or nasty looking the circuit is. Ah ya I was just looking at those equations for our next lab, was just trying to get a jump start on it.
|
|
# ? Feb 8, 2010 22:08 |
Popete posted:Ah ya I was just looking at those equations for our next lab, was just trying to get a jump start on it. Ah, an EE student. The first EE class at my school was the weeding class for the degree program (as if the rest of the classes weren't rough enough) and we really cranked through a lot of this stuff in short order and it left my head spinning. Here are some ideas, although I'm not sure how useful they will be. The whole purpose of Kirchoff's laws is to give you a relationship between currents or voltages in the circuit, and Ohm's law connects the two K's laws together. If you had a node with four elements, as so, without Kirchoff's laws you would know nothing. With the law, you know an equation, i2 + i3 = i1 + i4 which gives you a HUGE step in the right direction. This is the purpose of Kirchoff's laws! You know a relationship between those values and you can use that relationship, in concert with the other relationships in the circuit, to find the actual values. As an aside, even if you are wrong about the flow of current, and a few are notated backwards on the diagram compared to their flow in real life, you'll just get a negative value and everything works itself out if you stick to a convention. Delta-Wye fucked around with this message at 00:16 on Feb 9, 2010 |
|
# ? Feb 9, 2010 00:06 |
|
Weed out classes are a bitch
|
# ? Feb 9, 2010 03:08 |
Ya I was just looking over the formulas, I see it's useful for determining unknowns of current/voltage so is that all its really saying? Or am I missing out on some fundamental theorem behind Krichoff's laws? P.S. I wanna start practicing on my own with some basic circuitry, can anyone tell me if this is worth it? Or a piece of crap? I really just wanna do basic breadboard stuff nothing big at the moment. http://www.seeedstudio.com/depot/adjustable-breadboard-power-supply-p-566.html?cPath=73
|
|
# ? Feb 9, 2010 04:20 |
|
That's pretty neat, actually. Some of the programs I've seen (including mine) had a course that involve designing and building your own DC supply, which is a great idea. You may or may not have something like that. If not, then yeah, that seems like a pretty useful board for a pretty reasonable price. Cell phone chargers are often the right voltage too, if you can get those cheaply.
|
# ? Feb 9, 2010 04:25 |
Popete posted:Ya I was just looking over the formulas, I see it's useful for determining unknowns of current/voltage so is that all its really saying? Or am I missing out on some fundamental theorem behind Krichoff's laws? You are missing the fundamental theorem behind Kirchhoff's laws, but I wouldn't worry about it. In fact, I would be totally stoked if I were you, taking a class where you get to use the best parts of Maxwell's equations (the resulting circuit analysis methods) without having to do the worst parts (MATH). Popete posted:P.S. I wanna start practicing on my own with some basic circuitry, can anyone tell me if this is worth it? Or a piece of crap? I really just wanna do basic breadboard stuff nothing big at the moment.
|
|
# ? Feb 9, 2010 04:49 |
ante posted:Weed out classes are a bitch by most standards I was "weeded out" of several core requirement classes. if I recall correctly I got a C in my intro to circuits class. Popete posted:Or am I missing out on some fundamental theorem behind Krichoff's laws? kirchoff's current law basically says that charge, and therefore current (which is moving charge), is conserved. It can't simply appear or disappear from existence. At steady state, the net current flowing through any closed surface (or into a node) will be zero. kirchoff's voltage law is derived directly from maxwell's equations (or more specifically, faraday's law of induction). For the special case where there is no change in magnetic flux (a fine assumption in most cases), the integral of electric field around any closed path will be zero. This is a fancy way of saying that net voltage around any closed loop must be zero. I also failed electromagnetic physics the first time I took it.
|
|
# ? Feb 9, 2010 05:11 |
I'm glad I'm not the only one who had trouble with this the first time looking at it. I was starting to get freaked out if I was behind or not understanding everything completely at this point. But I suppose with more practice and when I take more circuitry classes this all becomes second nature. Delta-Wye: was the a variable power supple? I kinda want a variable one just so I can test out different voltages and such. But then again having a slightly higher voltage PS would allow me to actually do some cool little projects. Speaking of which anyone have any easy electronics projects they really liked? Preferably cheap.
|
|
# ? Feb 9, 2010 06:24 |
|
Stick with a fixed 5v supply for now, probably. When you really need something else, look up datasheets for an LM317 and some of the other ones mentioned above. They usually provide pretty simple diagrams that work well.
|
# ? Feb 9, 2010 06:36 |
ya I just bought that USB breadboard PS, got a bunch of nice breadboard wires, a kit of a ton of different resistors/conductors/LED's, a breadboard, and USB cable. All for about $22 needless to say I'm pretty excited to start messing around.
|
|
# ? Feb 9, 2010 07:07 |
ante posted:Stick with a fixed 5v supply for now, probably. When you really need something else, look up datasheets for an LM317 and some of the other ones mentioned above. They usually provide pretty simple diagrams that work well. Nevermind, I think that will be fine too! All that typing for nothing To expound, The 78XX parts put out a steady voltage (3.3, 5, 9, 12 in the order I listed them) and are dead-simple to use - they have 3 pins, input, ground, and output. Long as the input is at least a couple volts above the output, you get clean short-protected DC power that is usually good to 1A if you get the bigger packages. If you look at the datasheet for the LM317, you'll see it can be used for all sorts of crazy stuff from constant current supplies to adjustable voltage supplies depending on how it's hooked up and what value resistors you use. The datasheets usually give quite a few inspirational circuits and a simple equation to use to find the corresponding resistor values. I feel like I'm sperging out badly and honestly, I probably am. I just don't have anywhere in RL to yap about this stuff and I end up feeling repressed
|
|
# ? Feb 9, 2010 07:13 |
haha I hear ya, so this is probably stupid but where are all these 78xx power supplies being sold? Can they just be plugged into a normal wall outlet?
|
|
# ? Feb 9, 2010 08:00 |
|
Delta-Wye posted:
Sperg away, man. When people ask me what I do in school, I just say "mathy stuff" and change the subject Popete posted:haha I hear ya, so this is probably stupid but where are all these 78xx power supplies being sold? Can they just be plugged into a normal wall outlet? They're chips. You'll need to build a case, solder all of the necessary components(including the 78xx regulator) onto a prototyping board or something (<-- easiest/fastest/cheapest permanent solution), then cut up an AC power wire and solder it in. This is what I've been using for the last couple years ante fucked around with this message at 08:29 on Feb 9, 2010 |
# ? Feb 9, 2010 08:20 |
ante posted:Sperg away, man. When people ask me what I do in school, I just say "mathy stuff" and change the subject Well poo poo gonna have to find a guide to do that. Ya I pretty much gave up explaining what a Computer Engineer does, everyone just assumes I'm IT. Even my parent's don't understand what it is, my older brother is a CS major so they assume its about the same thing.
|
|
# ? Feb 9, 2010 20:03 |
|
Popete posted:Well poo poo gonna have to find a guide to do that. Ya I pretty much gave up explaining what a Computer Engineer does, everyone just assumes I'm IT. Even my parent's don't understand what it is, my older brother is a CS major so they assume its about the same thing. I usually explain it as either a cross between EE and CS, or as an EE degree with an emphasis on micro-controllers rather than power electronics. My title at work is an EE, but my degree is CpE v v
|
# ? Feb 9, 2010 20:48 |
|
I had a date with a girl over a year ago. I mentioned that I was in electrical engineering, so she goes, "Oh, you're going to be an electrician?"
|
# ? Feb 9, 2010 20:52 |
I just flat out don't tell people "computer engineering" because I don't think I can handle one more person say "Oh! This IT job you're working is perfect for you!" . I think I need to do some networking. EDIT: I guess it goes both ways. We have four employees doing "project management" in one form or another (for a systems team of five and a software team of four) and honestly I don't know what they do either Delta-Wye fucked around with this message at 21:06 on Feb 9, 2010 |
|
# ? Feb 9, 2010 20:56 |
|
Delta-Wye posted:We have four employees doing "project management" in one form or another (for an systems team of 5 and a software team of 4) and honestly I don't know what they do either They probably don't know themselves
|
# ? Feb 9, 2010 21:03 |
|
|
# ? Jun 11, 2024 11:20 |
Hillridge posted:I usually explain it as either a cross between EE and CS, or as an EE degree with an emphasis on micro-controllers rather than power electronics. My title at work is an EE, but my degree is CpE v v I think 90% of people would be lost at micro-controllers as well though. It's sad that all the gadgets people use today which are designed by EE/CMPE people no one knows where it comes from. Truly is magic blue smoke.
|
|
# ? Feb 9, 2010 21:27 |