First Tinkering Project - Page 1
Forum section: electronics / beginners

author: selkathguy
author_rank: Unknown
timestamp: January 07, 2013, 05:57:00 am
content: Hi all,Definitely a young player here (at least to this EE stuff). I have never been in the industry and have never even taken any classes on the subject (yet). Been watching the blog videos on YouTube and thought I'd finally make my first post. This is my first real attempt at doing anything remotely interesting, but I've hit a snag and I have a hypothesis as to why I'm running into issues. I hope this will be a good way to introduce myself to the community and ask my first question!But first a short description:It's a little Arduino powered serial over laser setup. I'm not trying to create the world's fastest fiber transceiver, I just wanted to test a silly idea for open air transmission and thought it would be neat if it worked. I am using an Arduino Uno to drive the laser diode at the transmitter, and a smaller Nano at the receiver. I bought a 128x64 OLED display from Adafruit and slapped it onto the Nano over SPI.The goal:Trying to see if it is feasible to get a collimated beam of light to carry some kind of serial over it at any reasonable speed that could be useful for occasional burst transmissions from sensors, what have you.The technique:Just for testing purposes I am essentially only sending a clock (I use this term very loosely) at some static, predefined frequency that the receiver is pre-configured to receive. The only thing the receiver does is attempt to perform a sort of clock recovery and error-detection. The speed is horrible and the recovery errors are worse, but it does work. Kind of... Here are some pictures:The scope is hooked up to the receiving Nano at two points: The input to the ADC from the photoresistor (for detecting the light) [in yellow on the scope], and just a curious tap I had on the other side of the filter cap [in blue] (which made a big difference, but I still have little bits of occasional noise, as you can see remaining on the input). Also the "Error %" on the display is incorrect by two orders of magnitude. I'd be tickled with .1% error. Forgot to multiply it out in code oops. At least the receiver has one nice feature I built in that dynamically adjusts to ambient light and kind of does this pseudo-differential comparison, so it works even in a lit room. I just turned out the lights for additional "wank factor".The Problem:The pictures above show the setup working at pretty much maximum rate (200 cycles/sec) which is slow, but I cannot increase it because the signal becomes indistinguishable, looses amplitude, and generally falls apart at the receiver. I've checked the specs on the Arduinos and I know I'm still far out from approaching the delay of the AnalogRead() sampling, so it's not that. Also the transmitter voltage transitions look clean too. I have tried playing with different values of the components on the receiver but I can't seem to get the signal any better.My naive hypothesis:I'm using a standard photoresistor from radio shack (yeah I know) and I wouldn't be the least bit surprised if there's some sort of residual resistance characteristic at these higher frequencies. That the diode maybe doesn't stop conducting very quickly as the light suddenly goes out, I dunno. But then after thinking, maybe it isn't just the photoresistor. Perhaps it is the cheapo laser diode failing to shut down entirely in the trough time of the 'clock' and the fading effect of the laser turning off is going to be my limit here. Are these suspicions valid? I'm trying to learn how electronics work and what kinds of things could be affecting my setup. I'm working in my apartment and not a real lab or anything, so yeah yeah I need mats and stuff but in the meantime, any feedback is appreciated!

author: Psi
author_rank: Super Contributor
timestamp: January 07, 2013, 06:04:43 am
content: Are you driving the laser diode directly? or pulsing a laser diode module (with its own internal electronics)?Also, i'd use a phototransistor instead of a photodiode (only because they're easier to play around with the gain)

author: selkathguy
author_rank: Unknown
timestamp: January 07, 2013, 06:09:38 am
content: Quote from: Psi on January 07, 2013, 06:04:43 amDirect. The Arduino Uno can drive it directly without a significant voltage drop, and the transitions from 0v to 5v look good on the transmitter. Though that doesnt guarantee that the laser is not still glowing when the supply is suddenly dropped. That would explain the behavior I've noticed of the "cooldown" being more an issue than the "warmup" of the laser, which correspond to the rising and falling edges on the ADC input respectively.

author: SeanB
author_rank: Super Contributor
timestamp: January 07, 2013, 06:18:13 am
content: If you suspect the laser diode then drive it by shorting out the actual diode itself with a transistor, depending on the drive will determine what transistor type to use. Photodiodes work better at higher voltage into a constant current sink, preferably with a filter to remove unwanted light. You might want to try using a IR LED as both transmitter and receiver photodiodes. No visible light though, but they do switch fast.

author: Kremmen
author_rank: Super Contributor
timestamp: January 07, 2013, 10:13:23 am
content: Allow me to suspect the photoresistor. Without knowing what chemistry exactly applies here, it is hard to be precise. Still, some photoresistors of the CdS type can have time constants as slow as 100 ms and some, such as the PbSe type, as fast as 2 us. The reliably fastest (easy) detector would consist of a phototransistor driving the base of a normal NPN transistor so that the phototransistor is between base and ground and a bias resistor supplies the NPN transistor base current. This way the phototransistor Miller capacitance is only charged to Vbe of the NPN transistor and the circuit is reasonably fast. You can get even faster by biasing the phototransistor to its linear operating point (assuming its base lead is brought out) and then using a comparator circuit to detect the variations caused by changes in illumination ( of the transmitter that is. You also need to account for changes in the ambient illumination level on the interesting wavelengths).

author: dave_birdi
author_rank: Contributor
timestamp: January 07, 2013, 12:26:25 pm
content: I agree with this original hypothesis:Quote from: selkathguy on January 07, 2013, 05:57:00 amI remember doing something like this a while back but with an infra-red transmitter and diode and was able to transmit and decode without much issues from a distance of ~ 1 m. Read here:http://arduino.cc/forum/index.php/topic,10555.0.html*This guy claims more like ~ 15 m but meh, I don't think so.I personally don't think you'll have much success with this for actually sending serial data, but keep on experimenting.I seriously recommend playing around with infra red.

author: ptricks
author_rank: Frequent Contributor
timestamp: January 07, 2013, 02:04:19 pm
content: It is definitely possible with a laser source. I did this and can get speeds of 10Mbit over 100 meters with basic hardware. You need to modulate the signal and use a carrier frequency, without that the data will always be corrupted.http://en.wikipedia.org/wiki/ModulationFor receivers you can use what you have but a photo-transistor is much better idea. You can also use a standard 5mm LED. You should use an opamp as a buffer between the receiver and the mcu.using lasers for communcations:http://www.markettechinc.net/pdf/Diode%20Laser%20Application%20Note.pdf

author: selkathguy
author_rank: Unknown
timestamp: January 07, 2013, 02:14:04 pm
content: Quote from: SeanB on January 07, 2013, 06:18:13 amCan you explain the purpose of using a transistor on the laser in this case? I'm new but wouldn't that simply let me turn the laser on and off? I am already doing this buy sourcing the laser from a digital output pin on the arduino, which is still a distinguishable square wave. It seems to be handling it alright and the pattern on the diode's input looks pretty clean, or at least a lot cleaner than the receiver.

author: ptricks
author_rank: Frequent Contributor
timestamp: January 07, 2013, 02:24:19 pm
content: Quote from: selkathguy on January 07, 2013, 02:14:04 pmThe laser diode typically needs 30ma of current to perform best. When you power it with less current it may show an output but the output can contain a lot of , for lack of a better word, noise. Arduino are not capable of sourcing that much current reliably.http://talkingelectronics.com/pay/BEC-3/Page53.html

author: selkathguy
author_rank: Unknown
timestamp: January 07, 2013, 02:46:52 pm
content: Quote from: dave_birdi on January 07, 2013, 12:26:25 pmI have range tested my receiver and it seems to work just as well when its 10 meters away as it does when it is point-blank. The errors don't seem to creep up too much as a function of distance, not at this scale anyway. Thanks for the link!Quote from: dave_birdi on January 07, 2013, 12:26:25 pmOoh i do have an IR diode and detector pair... I might just go ahead and plug those in, but I am looking for straight line range, highly directional transmission.

author: selkathguy
author_rank: Unknown
timestamp: January 07, 2013, 02:52:26 pm
content: Quote from: ptricks on January 07, 2013, 02:24:19 pmOh I see. I figured the ardie would be good for 30-35mA but if that's not the case I definitely do need to change things a bit. How would I source the current then? Could I use just an LM7805 on the collector of the transistor, which is hooked up to a separate supply like a 9volt? (at only 35mA I think the head generated by the regulator would be nominal)

author: selkathguy
author_rank: Unknown
timestamp: January 07, 2013, 02:58:47 pm
content: Quote from: ptricks on January 07, 2013, 02:04:19 pmI'm big into radio so I am very familiar with the concepts of modulation, but I just don't know how to implement those mechanics in electronic design yet. That laser communication PDF is very helpful, thank you!

author: Colfaxmingo
author_rank: Contributor
timestamp: January 07, 2013, 03:36:30 pm
content: What happens exactly when you roll the frequency up? Does the amplitude drop 3db per decade? I'm wondering if you don't have a parasitic low pass filter due to the sensor.

author: selkathguy
author_rank: Unknown
timestamp: January 07, 2013, 04:20:18 pm
content: Quote from: Colfaxmingo on January 07, 2013, 03:36:30 pmNot sure about the exact attenuation per decade but it does attenuate. I'm inclined to think it's more to do with the photodiode/laser and here's why: at lower frequencies, the roll-off of from the waveform is the same, so after it settles high and plateus, on the falling edge it still decays at the same rate as when at higher frequencies. Could this still be the case in the event of a parasitic low pass filter?Actually I think what you say could be true as well, since a low pass filter would just kill clock edges (I think?). I want a spectrum analyzer now so I can test the frequency response of my detector circuit

author: PA0PBZ
author_rank: Super Contributor
timestamp: January 07, 2013, 09:28:51 pm
content: Quote from: selkathguy on January 07, 2013, 04:20:18 pmSeeing the yellow trace on your scope it looks like a triangle, it should look much more like a square wave if you want to up the frequency. So yes, there is some serious R/C stuff going on, can you post the schematics of the detector upto the ADC input?If you doubt the transmitting side, maybe you can just power the laser and put a rotating fan in front of it?

author: selkathguy
author_rank: Unknown
timestamp: January 07, 2013, 09:34:31 pm
content: Quote from: Kremmen on January 07, 2013, 10:13:23 amThanks for the awesome reply! I've got to do some wikipedia reading on some of that, but you've provided me learning material and a way forward!One question though about bias: I don't quite understand what it is. I've tried reading about it but I'm not quite grasping the concept though I see it in all sorts of IC applications.

author: Psi
author_rank: Super Contributor
timestamp: January 08, 2013, 01:06:48 am
content: Laser diodes behave like an LED up until you hit their lasing threshold. They also take some time to begin lasing.From memory i think you're supposed to modulated them between just above their lasing threshold and full current.Turning them completely off and on has a disadvanced. (probably speed related although i cant remember exactly)

author: selkathguy
author_rank: Unknown
timestamp: January 08, 2013, 02:03:27 am
content: Quote from: Psi on January 08, 2013, 01:06:48 amSuper useful info! I will need to tweak my transmitter then to kill some of the lasing transition time. Perhaps modulate by keeping it just above threshold and using the digital output of the pin to instead switch in and out an additional load resistor via a transistor? This would change the current without dropping the voltage as far as I understand, and might work!An Update: I've captured the difference between having the laser hit off-center of the photodiode and dead-center on it. It actually performs muchworseat the center, as shown below. I think this points to the fact that photodiodes are just terrible for this kind of application, which probably isn't surprising.Yellow is TX voltage on the laser.Blue is RX ADC input. Theres a lot of noise on the receive end, but I think most of it is out of band from what AnalogRead() will pick up. I still need to work on cleaning it up though. Also note the tiny variations I'm having to work with on the receive side (mV/Div on the Y axis). I will definitely be moving to a phototransitor setup but first I just want to attempt that IR substitute that was suggested.P.S.: I notice there's a momentary drop in voltage on the TX after the laser actually kicks on (barely visible in the GIF, right after TX goes high). It's small and it doesn't seem to be affecting the errors on the receiver as I have a holdoff period in place so it cant even detect new edges that soon on the RX side.

author: Psi
author_rank: Super Contributor
timestamp: January 08, 2013, 11:14:50 am
content: Yeah, something is very wrong, the signal should be much better than you're getting.A different sensor would be the first thing i'd try.actually, It almost looks like the laser is lasing for a split second and then falling below threshold.Are you sure this laser diode is ok, they're easy to damage and a damaged laser might do that.If it's damaged you might get a short laser pulse at power-on that visually looks like a continuous beam because of your repeated pulsing.Try run the laser at 100% continuous and see if you get a normal laser beam/dot to confirm its ok.

author: selkathguy
author_rank: Unknown
timestamp: January 08, 2013, 01:46:45 pm
content: The laser is continuously on with a DC supply. Doesn't seem to be showing fluctuations. Could it be that when the input goes to 5v, the laser takes just a tiny amount of time to turn on? Because what I am thinking is that when the laser first goes above its threshold it is drawing a lot more than its nominal runtime current, and it's causing it to drop out a little bit cause the ardie can only source so much. It comes up to speed super quickly though, and it does indeed appear to be on 50% of the time. Even did the "wave it against a wall really fast" test. I will try the IR though when I get home from work. It just might take me a bit of rework because my emitter takes 1.5-1.8v max and the ardie gives 3.3 minimum. (I'm trying to get a LM317 to do what I want and help me out here, but I think I am doing it wrong).

author: Colfaxmingo
author_rank: Contributor
timestamp: January 08, 2013, 02:59:57 pm
content: I think you should be operating your receiver like a Class A amplifier.You want it conducting all the time and modulate it so that it swings between the rails but doesn't distort.

author: selkathguy
author_rank: Unknown
timestamp: January 10, 2013, 10:05:24 pm
content: Quote from: SeanB on January 07, 2013, 06:18:13 amBingo. Infrared diodes. Thank you. Changed the code a tiny bit and had to lower the TX output voltage (thank you LM317) didn't touch anything else with the circuit. Didn't change the R/C characteristics or anything.Yellow: Transmitter Diode voltageBlue: Receiver ADC input.Compare this with the image a couple posts above...

author: selkathguy
author_rank: Unknown
timestamp: January 10, 2013, 10:55:17 pm
content: Didn't quite like that startup on the transmitter, it was causing the IR diode to have a <40% duty cycle which was messing with recovery at the receiver. So I removed the electrolytic from the LM317's adjust -> output, and the regulator no longer suffers the significant startup time and the duty cycle has returned to 50%.Furthermore, the receiver now reports less than 0.2% error in recovery. Problem is I've now lost the benefit of range that the laser had. Hmm.