Teensy Laser Control (Obsolete thread)

TheHermit

Well-known member
Sorry, Folks.
The remaining info in this thread is now obsolete.
So, I've requested that it be deleted for a fresh start regarding my T4 Laser Synth project, which will be more informative and current.
Many thanks to Paul, Frank B, Dmax, MarkT, and those who have helped me to overcome the teething problems, indicated within this thread.
The following chapter to the T4 Laser Synth project wouldn't have been possible without your excellent tech support.
Sincere apologies for the inconvenience.
TheHermit
😎
 
Last edited:
As I understand it laser controllers need DC-coupled signals, so you need to be aware some audio DACs and CODECs
have in-built high-pass filters designed to remove DC offsets, though typically these are configurable. DC offsets
can damage speakers and it is common to remove these in an audio signal path (digitally or in analog, like the Teensy
Audio adapters which have DC blocking capacitors on linein and lineout).
 
The CS42448 is supported by the audio library - and the digital connections are the same as with any other I2S chip.

But you're right, I'd probably just use the PT8211, too.

 
Are you able to confirm that it is as simple as running a jumper from the PT8211's DIN to a spare pin on the Teensy 4.1, then altering the sketch?

You can't just choose any spare pin. Only certain pins can transmit digital audio.

The pin functions are documented in 2 places. First is the pinout card, which comes with Teensy 4.1 and can also be found on the Teensy 4.1 product page, and also this page.

https://www.pjrc.com/teensy/pinout.html

The digital audio pins are shows in yellow.

card11a_rev3_web.png


While this serves as reference material, the compact format doesn't really communicate the finer details of exactly how you can really use these pins. For that sort of detail, you need the 2nd main documentation source.

The audio design tool is where the audio library software features are documented.

https://www.pjrc.com/teensy/gui/

If you haven't used the design tool, this 31 page tutorial is a good place to start. There's also a walkthrough video which closely follows the 31 pages of content, if you prefer watching a demo.

https://www.pjrc.com/store/audio_tutorial_kit.html

You might skip to part 2 which begins on page 8, if you just need to learn how to use the design tool.

As you click on each item in the left side, you'll see its documentation appear on the right hand side. All of the input and output features have a "Hardware" section which explains which pins are used.

As a practical matter, if you will connect 2 different audio chips, you will need to create a design using this tool which the software features that communicate with those chips. So before you buy parts, before you start connecting wires, use this tool to make your plan.

When you drag the various features onto the canvas, if you put 2 or more onto your design which can't work together due to a hardware resource conflict, you will see little yellow error triangles appear. A message with a (probably terse) explanation of the conflict might appear too. The point is this can help you to immediately know whether you have chosen outputs which can work together, and you can see the documentation about which pins each uses. That documentation panel offers quite a lot of other info too, which can really help you. Best to read it carefully.
 
Last edited:
One other minor point. I2S is mentioned above. The audio shield with SGTL5000 chip always uses I2S.

CS42448 can use either I2S or TDM. Normally TDM is used, because it requires fewer signals and works just as well. If you will use this board or make a similar design, know that the connections are routed for TDM, not I2S.

Of course you can find TDM fully documented in the design tool, and it's hardware conflict detection is aware of the reuse of the same "SAI" hardware for either I2S or TDM (but not both) on each separate SAI port. So please, do yourself a favor and spend some time experimenting with the design tool and reading the documentation panel for the features you will use. It can save you a lot of trouble by showing you the details and alerting you early on to ideas which would end up causing a hardware resource conflict, and when you do come up with a conflict-free plan, you'll be able to choose the correct pins for connecting the various digital audio signals.
 
I2S_quad and PT8211_2 would work. But that needs all pins (ok, without input) from the 2nd I2S (AKA "SAI") port.
However I have no idea if removing the capacitors from the shields is ok.
 
None of these audio DACs are really designed for DC output. They may give some DC offset when they're supposed to be zero.

Most of them also use an internal voltage reference which is "stable" (at least in an audio bandwidth sense) but not "precise", so the exact voltage you get for full scale output is difficult to know and may vary from chip to chip.

Trying to use these parts anyway for a DC coupled control signal will probably require a carefully crafted circuit. You might need trim pots to calibrate / adjust the DC zero and full scale gain.

The fully differential output of CS42448 might be easier, since you'll know the 2 pins are supposed to be the *same* voltage when the output is zero, even if that exact voltage is unpredictable. Maybe a difference amplifier circuit could work? It might need to be followed by an amplifier where you can adjust the gain slightly, so you get the full scale output to the 1.0V level you want.
 
On the other hand, would the 4 channels of the Adafruit DAC consume four I2C addresses, including 0x60, 0x61, 0x62, and 0x63, and still conflict with the reconfigured SGTL5000's address of 0x62?
If that's the case, then my final straw to grasp for would be to utilize the T3.6's onboard DAC to provide the 5th audio channel output, along with the 4 channels from either the SGTL5000 or Adafruit's DC coupled DAC.
"Are we there, yet?"🤔

I2C is incredible slow compared to I2S. And if the adresses conflict, you have find a way around it...
 
HI TheHermit I'm looking at building a controller for my home made laser and would like to you know if you have moved forward with your project ? just in case you didn't know the signal from the controller to follow the ILDA standard it should output differential signals for the Galvo's so most DAC boards made for music/audio will work but you will not get the full range of deflection from the galvo's so I'm looking at designing a 6 channel DAC board with a 12 bit dual channel DAC for the galvo's and two 8bit dual channel DAC's for the RGB signals and obviously one channel spare for now. anyway I just wanted to say I'm looking at getting something together as and when I have some free time so I will let you know how I get on.
 
" Is this not a circuit that connects to the differential inputs of a Galvo driver card" Yes that is correct, I named the jpg file Galvo driver because I have a quite a few other files that are driving other parts of my laser system and they are all at the preamp stage. Yes you could add the inverting amp to your unidirectional correction amps. "a member of the PL forum" Probably I sign up to forums and then forget I'm a member lol... I'm looking at using the Microchip DACs as I already have a few in my parts bin. if I remember right the MCP4802 and a MCP4822 both are dual channel the 02 being 8 bit and the 22 12 bit they have an SPI Interface so with some simple 74 logic I should be able to have 2x 02 DACs plus a 22 giving me all the channels I need. I hope to make a start on the board this weekend but I've been trying to find the time for the last 3 or 4 weeks lol...
 
I will be very interested to see how this works. you really need your system to update the galvo and rgb DACs at the same time for the best results , will you optimize the X/Y signals before you send them to the galvo DACS ? here is a picture of what I have so far, I'm using a Pixelblaze sensor expansion board to run a FFT spectrum on an audio signal and output the level of 32 frequency bands to one of the serial ports on teensy that way the teensy just needs to read those values saving a load I've still got a shit load of programming to do before its anywhere near ready... I'm going to use laserboy to optimize/convert DXF files that I will make in 3ds Max as I know that software like the back of my hand.. I will let you know how I get on as well as keep an eye on your project ..
all the best

Teensy_LC.jpg

Laser_01.jpg
 
Last edited:
Like you I used to work with Lasers bloody great beasts that needed 3 phase power and water cooling most of them where made by spectra physics and used a krypton and argon gas mix, I always wanted my own but for practical and money reasons I never got anything bigger than a 5 mW He-Ne tube, so with the Diodes being so cheap now I decided to finally build a laser projector. its just for my own person use as I'm not in the laser game anymore.

edit... "The small scan angle and offset is due to having only 0-3.3 V p-p coming from the Teensy's audio DACs." simply place an op-amp in line between the teensy and the amp boards input that should fix your gain problem.
 
Last edited:
Well I've been up most of the night unable to sleep for some unknown reason ?? ....

ok my amp is much more simple, its more or less the same differential amp I posted at the top of this page.differential amp.jpg I will add some voltage protection before I get the PCB printed if I ever get it that far as it may just end up in a box as it is lol, I have most of the main code running now so I'm able to do tests now. I have a pixelblaze sensor board taking care of the FFT so the Teensy is free to do everything else its really simple to use, I can generate patterns on the fly but to do anything other than mathematical based roulette curves I'm going to need to be able to read ILDA files, right now I'm using Laserboy to convert the ILDA files to .WAV then I'm reading those, although I have to convert those files from 6 channel to two channel as I've yet to convert the C function I found online that only read one channel to six, I've got it reading two channels just to test the idea so it should only be a matter of adding a few more lines of code in the function, but the problem I do have right now is reading a large file as the function writes to a buffer and then reads out from that buffer which is no good if the file it a few Mbyte in size as it just causes the Teensy to crash :( I'm really not a programmer at all and I'm learning C++ as I go along or should I say stumbling along as I go lol, I will post up in these forums if I cant work it out so maybe someone will help out :)
anyway chat soon :)
 
"So, you're using the pixelblaze sensor to digitize ILDA imagery converted to .wav" No the Pixelblaze is only used for the FFT algorithm its running, the Teensy will do everything else :).. forgive me if you already know this but your sketch wont generate an optimized signal so when running at high speed it will cause problems when it comes to stopping the Galvos at a given point also a change of direction will also produce some ringing and over shoot. the Galvos have a mass that needs to be taken into account so you really need to optimize the signal before feeding it into the amps, You can think of the galvos as a set of low pass filters that will have peaks in their resonance at certain frequency's and that can play havoc with the frequency response. none of this will really matter if all you want to do is to display lisajous type patterns but anything other than that and you really should look into something else to generate the signals. also this is me being a little anal so please forgive me but your sketch will not generate true vector imagery because its output will be linear, vector imagery is generated point to point so its more on the generating coordinates by using a geometry base system and as such is a better choice for what we are trying to do here. of cause I could be wrong in my presumptuous bollocks that Ive just posted and you are adding something to optimize your signal which could by default also make it a more vector based system :) anyway whatever path your taking all that really matter is you get something working and you enjoy doing it.
chat soon dude :)

My system uses the SPI bus so those audio sketches wont work with it but thanks anyway :) oh and make sure you don't overdrive your galvos with that sketch because they can easily be permanently damaged by to high a frequency as well as to high a voltage..
 
cool :) and yes the pixelblaze sensor board is a great little board :) I'm not going to worry about midi control at all right now as its not something I need with this project I want the unit to be totally self contained I also ready have laser show that I can run on a laptop but the whole point of this project is that I don't have to carry around a computer. I want to be able to just plug it in and it will just run.. :)
 
Thehermit... How are you getting on with this project? I'm now able to project ilda files by using laserboy to convert them to wave files first. The results are quite good.
 
Hi TheHermit so sorry for the very late reply but I've been away working and not been able to get much time online . anyway great to see your project is moving forward :) "I'm only getting the top right quadrant of the total scan range" did you fix this problem ? sounds like your missing the - or the + side of the signal from your amps ? anyway hope you sorted it :) I've not had any time to work on my project but i hope to get back into it very soon ... to answer your questions.. I'm now using 8 pin op-amps (just what I had at hand the first board was the 16 pin devices) and yes it takes just under 3 volts from the DACs, and yes it does balance the offset and more or less doubles the gain to fully drive the galvos, the gain and offset can be adjusted so if set up correctly it should provide the ILDA standard ILDA output. Yes I'm using the Teensy to play wave files from the SD slot. it actually works really well and its great to see it projecting animations and cool pictures but I'm going to look into rewriting the code to play ILDA files directly but I know nothing of the format so will have to do a bit of homework on that subject :)

Yes the T4 is a great bit of kit that's for sure :) Im quite looking forward to building a synthesizer with it in near future but I've go so much on my plate right now :(
anyway I look forward to hearing from you
chat soon :)
 
Last edited:
Cool write up :) and nice video too, I have a Patten generator in the software that does similar things. I must say I didn't known about those OPA188 op-amp, so I may have a look at getting a few, I've got hold a few ARM STM32 F030F4P6 development Boards for Ebay, They use the same MCU that the pixelblaze sensor board uses, as the pixelblaze code is open source I could modify it so it would work on the development Boards, these boards cost under £5, rather than the £30 odd cost of the pixelblaze sensor board, so if you do look at going down that path give me a buzz and I will send you the code. I'm hoping to get back on my lazer project soon :)
 
I cant get hold of those OPA188 op-amps, right now everywhere seems to have a long lead time so I cant really offer much help but I will let you know how I get on with them later on. I agree the e T4.1, is a beat and with PJRC's Audio library its super bit of kit, the reason I'm using the stm mcu it preform the FFT analysts is because its quite resource hungry. I want to maximize the time the teensy spends drawing the laser show itself. plus the output from that FFT code is really nice to work with any its there if you fancy a go at a later date :)
 
Back
Top