PDA

View Full Version : BS2 laser control



bcook65
03-15-2010, 05:46 AM
Hello,
I am currently working on a BS2 project to flash LEDs at specific frequencies. Currently I am using the FREQOUT to accomplish this, but without a Oscope I cannot verify this. Otherwise it does seem to work. As I need to control frequencies from 1 to 1000Hz this also seems the easiest way to do this.
The next part of my project involves flashing a Laser diode at the same frequencies as mentioned above.. I am using a red· laser at 635nm with built in driver, and the same program. THe laser runs on from 3-5Vdc. The BS2 is powering the laser, however, very dimly. I am measuring approx 1.23Vdc across the Leds above. Obviously not enough to run the laser diode.

Is there a means of telling the BS2 to increase voltage out? Or do I need to build some sort of voltage amp?
I am assuming from memory that there will be some sort of voltage drop as the frequency increases, if so how do I negate this?

Any Ideas?
Any help would be greatly appreciated as this has taken me quite a while to get to this point from having had to learn some of the programming for the BS2 and other stamps.

When I am finished, ultimately the goal is to flash either an array of leds and or Laser diodes at specific·frequencies and durations.
Below is the code for one of the projects. pretty simple and straight forward.

Thanks
Bill



'{$STAMP BS2}
'{$PBASIC 2.5}
'debug "this section tests each led"
DEBUG "Program Abscess", CR
DEBUG "Total Run Time = 15 minutes", CR
PAUSE 3000
x VAR Byte
· HIGH 15
· PAUSE 2000
· LOW 15
· HIGH 14
· PAUSE 2000
· LOW 14
· HIGH 9
· PAUSE 2000
· LOW 9
· PAUSE 2000
· 'DEBUG "LED TEST", CR
· 'FOR x = 1 TO 5
· 'DEBUG ? x
· 'HIGH 9
· 'PAUSE 100
· 'LOW 9
· 'PAUSE 500
· 'NEXT

· 'DEBUG "LED TEST Complete", CR
· 'PAUSE 3000
· 'debug "this section displays sequence frequncies"
· DEBUG "Frequency Display", CR
· HIGH 15
· PAUSE 2000
· DEBUG "Abscess - 802 Hz", CR
· FREQOUT 9, 3000, 802
· DEBUG "Lymphatics - 42 Hz", CR
· FREQOUT 9, 3000, 42
· DEBUG "Thymus - 73 Hz", CR
· FREQOUT 9, 3000, 73
· DEBUG "Pancreas - 66 Hz", CR
· FREQOUT 9, 3000, 66
· DEBUG "Skin - 363 Hz", CR
· FREQOUT 9, 3000, 363
· PAUSE 3000
· DEBUG "Starting Sequence", CR
· HIGH 14
· 'DEBUG "Section 1"
· DEBUG "(Sequence 1 - Abscess and Lymphatics)60 Sec 802hz and 42Hz)", CR
· FREQOUT 9, 60000, 802, 42
· DEBUG "(Sequence 2 - Abscess and Lymphatics)30 Sec 802hz and 42Hz)", CR
· FREQOUT 9, 30000, 802, 42
· DEBUG "(Sequence 3 - Thymus and Pancreas)60 Sec 73hz and 66Hz)", CR
· FREQOUT 9, 60000, 73, 66
· DEBUG "(Sequence 4 - Thymus and Pancreas)60 Sec 73hz and 66Hz)", CR
· FREQOUT 9, 30000, 73, 66
· DEBUG "(Sequence 5 - Skin)60 Sec 363Hz)", CR
· FREQOUT 9, 60000, 363
· DEBUG "(Sequence 6 - Skin)30 Sec 363Hz)", CR
· FREQOUT 9, 30000, 363
· 'DEBUG "Section 2"
· DEBUG "(Sequence 1 - Abscess and Lymphatics)60 Sec 802hz and 42Hz)", CR
· FREQOUT 9, 60000, 802, 42
· DEBUG "(Sequence 2 - Abscess and Lymphatics)30 Sec 802hz and 42Hz)", CR
· FREQOUT 9, 30000, 802, 42
· DEBUG "(Sequence 3 - Thymus and Pancreas)60 Sec 73hz and 66Hz)", CR
· FREQOUT 9, 60000, 73, 66
· DEBUG "(Sequence 4 - Thymus and Pancreas)60 Sec 73hz and 66Hz)", CR
· FREQOUT 9, 30000, 73, 66
· DEBUG "(Sequence 5 - Skin)60 Sec 363Hz)", CR
· FREQOUT 9, 60000, 363
· DEBUG "(Sequence 6 - Skin)30 Sec 363Hz)", CR
· FREQOUT 9, 30000, 363
· 'DEBUG "Section 3"
· DEBUG "(Sequence 7 - Abscess)60 Sec 802Hz)", CR
· FREQOUT 9, 60000, 802
· DEBUG "(Sequence 8 - Lymphatic)60 Sec 42Hz)", CR
· FREQOUT 9, 60000, 42
· DEBUG "(Sequence 9 - Thymus)60 Sec 73Hz)", CR
· FREQOUT 9, 60000, 73
· DEBUG "(Sequence 10 - Pancreas)60 Sec 66Hz)", CR
· FREQOUT 9, 60000, 66
· DEBUG "(Sequence 11 - Skin)60 Sec 363Hz)", CR
· FREQOUT 9, 60000, 363
· LOW 14
· PAUSE 500
· LOW 15
DEBUG "END"
END

erco
03-15-2010, 09:10 AM
Are you using a Homework board or BoE?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."

bcook65
03-15-2010, 09:54 AM
Homework Board at present..

erco
03-15-2010, 10:28 AM
Exactly what I suspected. HW Boards have inline 220 ohm resistors on all pins to protect against an accidental short. They limit the current to ~23 mA in the case of a dead short. That's causing too big of a voltage drop for your laser. It's perfect for an LED that requires 1.7V and 15-20 mA.

If you know the specs on your laser, find the proper series resistor to drive it off from 5V, which you can pull off Vdd on the HW board. I bet it's 25-30 mA at around 3V, if it's like a laser pointer. You can then add a transistor switch, like a 2N2222, which the HW board can drive through its built-in 220 ohm resistor. That transistor will drop (absorb) about 0.7 volts, so recalculate a new resistor based on using (5-0.7=) 4.3 volts.

If my numbers are close, you'll need a 68 ohm series resistor or thereabouts. Always check first!

BTW, FREQOUT sends a crazy sine-wave pulse, not a square wave, as you can see at https://ccrma.stanford.edu/~gary/controllers/ir.html
Might affect your results.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."

bcook65
03-15-2010, 11:15 AM
Its a 150mw laser module.. I can probably ohm it out and see what it is with the module.
Yeah I was thinking the sinewave might affect things.. And I think I saw a simple oscope circuit for a pc that I might be able to utilize.
That was going to be something else I needed to look up and see if I can do the square wave and generate the frequencies on the BS2 without too much complication.. Ive been racking my brains for some time trying to learn all this stuff.. I wish all stamps had a standardized language, gets kind of confusing. And right now, the BS2 (PBasic) seems to be the easiest of the languages.

Thanks for the help.. I appreciate anything I can get on this. I have a somewhat vested personal interest in getting this done as soon as I can for personal therapy that I have to have. Started off using RC circuits with SSRelays, which worked ok but was rather limited in scope.. The Micrcontrollers seemed to offer a simpler approach (save the language) and much wider scope .

Thanks
Bill

bcook65
03-15-2010, 11:17 AM
Also have an attiny 2313 I had considered using, but I need to learn the syntax and the language.. I know how to change a predefined set of parameters but dont know enough to be able to write a different program yet.

Bill

erco
03-15-2010, 11:30 AM
150 mW will take more power than I allowed for, so def check those specs. You can still use a 2N2222 transistor to switch up to 800 mA.

Yes, Stamps are easy to work with, lots of help in these forums. Plenty of people here are much smarter than me; I always learn something prowling through here.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."

bcook65
03-15-2010, 11:33 AM
THanks A Ton erco.. You have definitely helped a lot..

Bill

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Is it Beer Yet?

erco
03-15-2010, 11:39 AM
I'm just getting into lasers myself, building one of these:

http://www.philohome.com/sensors/lasersensor.htm

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."

bcook65
03-15-2010, 11:41 AM
Doh!.. O Wait.. My bad.. I am thinking of another module I have.. My green module is the 150mw one.. My red one is 5-10mw..
Sorry for the misinformation. It was still fruitful though. The end result will require a 20-50 High Output LED array or one or more lasers probably in the 15omw range..

**Sigh** must be early onset old age..:)

Bill

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Is it Beer Yet?

bcook65
03-15-2010, 11:44 AM
Oh thats A neat project

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Is it Beer Yet?

Tracy Allen
03-15-2010, 01:42 PM
The laser driver may limit the frequency response to a couple of Hertz, due to internal capacitors that protect the diode against power surges. Then again, maybe not. There are lots of types of driver circuits. Do you have data on it? If this is really a 150 mW diode, the necessary drive current may be in the range of 250 to 350 mA. 150mW diodes are very dangerous to the eyes especially if there is any chance of mishandling (but you knew that).

The switching frequencies produced by FREQOUT can be over 100 kHz, and an LED with resistor can easily keep up with that, as can a laser diode with fast current controller.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

bcook65
03-16-2010, 12:45 AM
Damn.. Is that why I am seeing all those red spots? :).. JK Unfortuneatly when I had originally procured the laser modules, it was more for fun and curiousity, and I did not save the spec sheets, which I now regret.. I may end up buying a couple more of the laser modules and or diodes.

But I got to admit, that having a lil 150mw green laser that when focused is hot enough to cut/melt thin plastics is still pretty cool.

I think i saw in the completed projects section of this forum a simple PC Oscope project, that I may go back and lok for. It would be nice to actually be able to see/verify my output frequencies and waveforms

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Is it Beer Yet?

bcook65
03-16-2010, 08:53 AM
**Sigh** My head is going to explode. Isnt there anything simple that can easily generate a wide range of square wave frequencies??
Is the Basic stamp the way to go with this or should I consider another chip? Propeller? Arduino? Others??

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Is it Beer Yet?

Tracy Allen
03-16-2010, 10:13 AM
I gather from your last comment that you don't really need sine waves of intensity from the LED or laser, and that square waves would be ok. The sine waves from the Stamp can be turned into square waves with a little extra hardware to filter out the PWM and to square off the result. That said, your project could migrate to the Propeller, and it can easily generate the time sequence of square waves you need.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

erco
03-16-2010, 11:29 AM
Bill: Your 1000 hz max is pretty low frequency. Not sure what the max bit-bang (high/low) freq of a Stamp is, but you could achieve some kind of square wave using that or pulsout in a tight loop.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."

bcook65
03-16-2010, 11:40 AM
Sine waves would probably work if they output at specific frequncies. Im thinking with the square waves I will get better duration than with the sine waves which a more gradual rise and fall from peak to peak or peak to trough. (sorry its been a while and I am very rusty with my terminology). This way with the square wave.. it goes from off, to peak power, to off and so forth, and the only thing that should very is the pulse width. And my led/laser output wont fluctuate so much from rise in slope and fall in slope..
Is the programming language similar with the propeller? and does it come as a kit like thehomework board? As you can see in above in a few prevous post, the language/program, on the BS2 is really simple, At least if it is doing what it is suposed to be doing.. hehe. That said.. I just really need the quickest, easiest and most cost effective means of achieving my goal.
The program code i posted is just one set of frequencies. In total, I need to generate about 60 frequencies, and run them singly or in groups.
Teach me thy ways, Master!...:)
hehe

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Is it Beer Yet?

bcook65
03-16-2010, 11:46 AM
As to the frequency range, I believe for this project all I need is from 1 to 1000Hz. Most of what I need for my particular app falls in that range. I looked at the Pulsout and at first glance found it confusing.. I will take another look though..

I need a stamp that will read my mind and just know what I want it to do and just configure itself. Now that would be a stamp worth having..:P

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Is it Beer Yet?

Post Edited (bcook65) : 3/16/2010 10:09:41 PM GMT

bcook65
03-17-2010, 06:06 AM
If I were to switch over to the Propeller chip to more easily attain my square wave frequencies,
1. which one of the kits below would be best? Or do you recommend something else?
They both appear to have usb, unless they posted a deceptive picture:

Propeller Education Kit – PropStick USB Version.. $99

Propeller Education Kit - 40 pin DIP Version ..$99

2. Can achieve my project goals more easily on these platforms? with minimal equipment?
3. The programming language, is it more difficult than the basic stamp or similar?

Someone had told me a couple months ago Arduino maybe a good way to go, but never having seen one or known anyone who has used one, I would not know..lol


Thanks
Bill

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Is it Beer Yet?