Results 1 to 22 of 22

Thread: microcontroller scanner

  1. #1
    Join Date
    Oct 2009
    Posts
    15

    Default microcontroller scanner

    Hey folks,

    I posted a few questions before the festive season about how to drive my DT25 galvos, and since then things have been coming along. I'm using a TI microcontroller to spit out the analogue signals for the galvos. I'm driving the galvos single ended: x- and y- are tied to ground, and only x+ and y+ are controlled.

    I can successfully make my laser show some lines here and there:

    Projection.JPG

    But you can see the text isn't written very well. On the left it's supposed to be block letters saying FHV, but you can see that the base of the letters is all curvy and innaccurate.

    Looking at the output of the DACs on a scope, we get this:

    DAC Output on Oscope.jpg

    it's upside down, but apart from that, the letters are nice and square. This seems to tell me that I'm doing something wrong with the way I'm talking to the galvos.

    I'm not sending the signals overly fast - I can already see the image flicker at this speed.

    I'm not making the image very big. This is operating straight from the output of the TI chip, so the signals are 0 - 3V (yeah I know I'm only using 1/4 of the display region, but adding an amplifying circuit adds another possible cause of the problem).

    So can anyone suggest how I can improve this? Unfortunately I have to give a presentation for uni next week, so while it's a proof of concept, it'd be nice to make it as pretty as possible.

    Thanks!

    Bonus: I haven't got the controller for the galvos on a heat sink yet, but the image is the same even when it is first turned on and everything is cold.

  2. #2
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    972

    Default

    Flicker with this kind of low point count will probably be you sending them too slow.

    The DT25 can easily handle 25Kpps that means 25K points per second.

    Also for the letters, use inbetween points instead of just at the corners.
    This should solve the curving

  3. #3
    Join Date
    Jan 2006
    Location
    Charleston, SC
    Posts
    2,147,485,444

    Default

    FourDee hit it on the head. You need more anchor points at the corners, and more points along the straight lines of the letters as well. If you can get the number of points in that image up to around 300 or so, it will look *much* better.

    Adam

  4. #4
    mixedgas's Avatar
    mixedgas is online now Infinitus Excellentia Ion Laser Dominatus
    Join Date
    May 2007
    Location
    A lab with some dripping water on the floor.
    Posts
    5,396

    Default

    PM me with a email and tomarrow or late tonight EST I'll send you a working demo copy of drawing software that adds corner points, blanking points, and anchor points to your images, then saves them as a ilda file. Some compiled code that takes a ilda file down to ascii numbers, is linked below, I'm assuming you store your image as data inline in your program.

    Which TI processor are you using?

    Grab ILDAREAD AND ILDAWRITE, run them in a dos box.

    http://www.laserfx.com/Backstage.Las...loadIndex.html

    You need to learn about corner points, anchor points and blanking points.

    Or you can get a copy of laserboy freeware and do something similar.

    This paragraph explains a lot in a few words:
    Quote:
    It also adds necessary anchor points in corners depending on the corner angle - more points at sharp angles, and less at obtuse angles - this allows you have good quality image on any system. Just draw what you want in any way, Anarchy Editor will carry out all the dirty work for you to make your image perfect.

    End quote
    Steve

  5. #5
    Join Date
    Oct 2009
    Posts
    15

    Default

    Speedy responses! Thanks guys.

    I didn't think to have several points around the corners to slow the mirrors down, I just implemented a delay at each corner to give the mirrors settling time. I'll try manually putting some more points in where I think they should go. Currently the F and the H only have about 15 points, the V has 65 and the big box thing has 388.

    I haven't had a chance to read through the documentation Steve, but I'll look into it tonight. You're correct that I'm just storing the data points inline in the code. I couldn't think of a better way to do it. I have MATLAB generate the data points (from a given image), and then I just copy paste the data points into the code.
    I have implemented blanking on the laser, it's just not happening in that photo.
    Corner points and anchor points I'm not so aware of.

    The controller is an MSP430 (8MHz, 2xDACs).

    Why do you need to put points along the straight lines as well as at the corners? Are the galvos prone to overshoot their mark?

  6. #6
    mixedgas's Avatar
    mixedgas is online now Infinitus Excellentia Ion Laser Dominatus
    Join Date
    May 2007
    Location
    A lab with some dripping water on the floor.
    Posts
    5,396

    Default Scanner feedback 101

    A untuned scanner amp responding to a square wave:
    From the dedicated and patient ELM CHAN:


    http://elm-chan.org/works/vlp/stpy1.jpeg



    Yes, a good tutorial is on line somewhere, but you may find how they are tuned to be interesting. Leave your tuning where its at, and work up your code.

    Your outputting a wave thats a bit faster then the standard scanner tuning is set up for. But GOOD JOB on getting output.

    Here: this is confusing if you dont know what a PID loop is yet.

    Proportional,
    A signal that is the raw feedback signal from the position sensor, chooses the direction and speed of the feedback. Has AC and DC parts.

    Integral,
    What amounts to a low pass filtered, DC coupled, version of the feedback, slows the scanner as it nears target.

    Derivative,
    What amounts to be a spike aligned with the edges of changes in the feedback,
    Used to slam the scanner to a stop and damp oscillations that occur as it stops. A carefully high pass filtered and processed version of the raw feedback signal, has no DC part. Ie its only there when a sharp , fast move occurs. Well, faster then a certain threshold. Set up to be opposite in polarity to the motion.



    Scanners want to overshoot (A body in motion remains in motion, Dr Newton's little law) and Oscillate , as the shaft and mirrors have resonances as well as inertia. The forces on a tiny galvo shaft are huge on a small scale. Remember, a fast square wave contains all high frequencies in its edges, and your outputting a lot of HF to cause excitation of the shaft's ringing.

    Overly complex but here:

    http://en.wikipedia.org/wiki/PID_controller

    See here for some understanding with scope waveforms.

    Speaking of scope waveforms, you galvo amps may have a feedback test point brough out for scan fail safeguards.. While randomly probing sensitive galvo amps with a scope is not a good idea until you have a passing grade and a finished product, you may find watching the feedback signals on your scope enlightening. (excuse pun)

    Schematia of the amp the Chinese copied first:

    I'm told many low cost modern amps are PII or some other mess, but the basic ideas are the same:

    Skywise kindly hosts this for me.. Its a combination of data for two types of scanners widely available when I was a kid.

    http://www.skywise711.com/lasers/scanner/scanner.html

    I'll get a copy of the software to you late tonight. Along with two standard unblanked 8 bit test patterns that might just fit in your micro.. Got enough ram left for 512 points times two ?

    Elm Chan has great scope pictures showing overshoot, and ringing, at his site: The ringing is the damped sine wave, the overshoot is the huge spike on the leading and falling edges just before the ringing.

    His tuning method is a bit different from what I was taught, but it works.

    http://elm-chan.org/works/vlp/report_e.html

    Ponder the following thought:

    In theory, if your software was fast enough, at a time T equal to one half the period of the jump, when you change angles, you applied a spike of one half the amplitude as your commanded position, and opposite in polarity, the galvo would slam on the brakes without having to have as much circuitry as it does. But since we command galvos from DC to 2.5 Khz or so, that is a lot of adjustable timing for the software to cope with. But you can try it if you had small jump, fixed spacing, between points. It wont work well for long jumps. Probably not a good idea until you get the basics working. In the old days, before the ILDA tuning standard, people adjusted the locations of the their points while watching the image, to get things right. But when you sent your image to a friend or business partner, it did NOT look good on their scanners. This is why I'd say don't adjust your tuning.

    Hint, the fastest way in Physics for a solid object to get from one position to another is to maximally linearly accelerate, and then half way there, maximally linearly decelerate at the same rates.



    Steve
    Last edited by mixedgas; 01-21-2010 at 12:19. Reason: I was taught to write huge, fast, detailed, History essays in college, and I enjoy it...

  7. #7
    Join Date
    Feb 2009
    Location
    East Coast of Southern Virginia
    Posts
    193

    Default Line Drawing Algorithm

    Everyone so far is right. You are asking the scanners to jump too far and then change direction to fast. You need to add some points in between. I would not suggest just adding points to the corners. You will eventually end up with bright dots at the corners and faint lines in between. I think you are more after a nice looking equal brightness line.

    A simple way to do this is with a line drawing algorithm such as Bresenham's algorithm (find it in google or the Wiki). While there are many many code examples I suggest you look at one of the open source or free source software packages out there. Monkey Tools (is a drawing package), Laser Boy, LFI Player (Source Forge). All of these I believe have C/C++ code for drawing in there. Just watch out for the licenses that are attached if you copy the source code. You can always peek and then write your own right?

    As the others stated there are other optimizations you can do. Mixed Gas was talking about the free demo for Anarchy laser show editor. I would like to point out that Monkey Tools is also free, with source code, can draw lines and can save ILDA files too! And... it isn't a demo.

    Nice project and ...

    Good Luck!

  8. #8
    Join Date
    Oct 2009
    Posts
    15

    Default

    Ah thanks for the theory Steve! I'm coming to the end of my EE degree, so I'm pretty comfortable with PID controllers. That's kind of why I thought it'd be best just to send corner points to the galvos - that way the control circuitry can deal with making the mirrors get there as fast as possible, without overshoot.
    Yeah the micro has enough memory for 55k points, so i'll try to implement those test patterns.
    I'm keeping the screwdriver away from the galvo controller, I get the idea they're usually tuned pretty well anyway.


    I'm using MATLAB to decide where the points should go, so it's fairly easy to make it spit out points equidistant along the line. In fact, that's how it was initially. I decided not to have points all the way along the lines and only at the corners, but I can't remember if that was to save space in the code, or because the image didn't come out right. I'll edit the MATLAB code and try again with data points equidistant on all the lines.

  9. #9
    mixedgas's Avatar
    mixedgas is online now Infinitus Excellentia Ion Laser Dominatus
    Join Date
    May 2007
    Location
    A lab with some dripping water on the floor.
    Posts
    5,396

    Default

    Hum, Chris, you think I would not take good care of him ???

    Steve

  10. #10
    mixedgas's Avatar
    mixedgas is online now Infinitus Excellentia Ion Laser Dominatus
    Join Date
    May 2007
    Location
    A lab with some dripping water on the floor.
    Posts
    5,396

    Default

    [QUOTE=jack;132835]Ah thanks for the theory Steve! I'm coming to the end of my EE degree, so I'm pretty comfortable with PID controllers.

    Sorry for the overkill explanation then... But there are others out there....

    Steve

  11. #11
    Join Date
    Feb 2009
    Location
    East Coast of Southern Virginia
    Posts
    193

    Default

    Quote Originally Posted by mixedgas View Post
    Hum, Chris, you think I would not take good care of him ???

    Steve
    Just trying to add to the conversation. Like I said you pretty much said it all...

  12. #12
    mixedgas's Avatar
    mixedgas is online now Infinitus Excellentia Ion Laser Dominatus
    Join Date
    May 2007
    Location
    A lab with some dripping water on the floor.
    Posts
    5,396

    Default

    Quote Originally Posted by cfavreau View Post
    Just trying to add to the conversation. Like I said you pretty much said it all...

    OK, I just sent him some recycled electrons, modulated in time and space....

    Steve

  13. #13
    Join Date
    Oct 2009
    Posts
    15

    Default

    So I had a go at implementing some of the test patterns you recommended Steve. The Lasermedia.ild turned out as a bit of a squiggle in the middle of the display region. The Grid Test.ild looked a little like this:

    IMAG0053.jpg

    It's a little better in person as there is more persistance (maybe just because the laser is kinda bright).

    Since the last photos I showed I've removed the delays in the code, and put in more points for the FHV logo. Now it looks a lot sharper:

    IMAG0052.jpg

    however there is still some flickering. Again the photo isnt as good as it looks to me, but you can see from the photo that there are patches where the laser isn't visible. In person these patches seem to move around each of the letters in a loop. Is it because the micro can't spit out the points fast enough?

    Maybe I should put a cro on the DAC output now to see how fast is redrawing the image.

    T.

  14. #14
    mixedgas's Avatar
    mixedgas is online now Infinitus Excellentia Ion Laser Dominatus
    Join Date
    May 2007
    Location
    A lab with some dripping water on the floor.
    Posts
    5,396

    Default

    move around each of the letters in a loop. Is it because the micro can't spit out the points fast enough?

    Maybe I should put a cro on the DAC output now to see how fast is redrawing the image.

    T.[/QUOTE]

    would need to see CRO traces, a easy trick is to use a spare IO pin as a scope trigger at the start of the frame.

    watch out for "C", it tends to add delays, compared to assembler.

    did the included viewer/editor work for you?

    Try its optimization feature.

    Your doin fine...

    Steve

  15. #15
    mixedgas's Avatar
    mixedgas is online now Infinitus Excellentia Ion Laser Dominatus
    Join Date
    May 2007
    Location
    A lab with some dripping water on the floor.
    Posts
    5,396

    Default

    move around each of the letters in a loop. Is it because the micro can't spit out the points fast enough?

    Maybe I should put a cro on the DAC output now to see how fast is redrawing the image.

    T.[/QUOTE]

    would need to see CRO traces, a easy trick is to use a spare IO pin as a scope trigger at the start of the frame.

    watch out for "C", it tends to add delays, compared to assembler. The grid needs some achor points.

    Your doin fine...

    Steve

  16. #16
    Join Date
    Oct 2009
    Posts
    15

    Default

    Quote Originally Posted by mixedgas View Post
    would need to see CRO traces, a easy trick is to use a spare IO pin as a scope trigger at the start of the frame.
    Am I just looking for the time it takes to draw each frame? I already have an LED flashing for a heartbeat, and I can its visibly flashing (although pretty fast), so I can just time that to see how much time a frame takes to draw.

  17. #17
    Join Date
    Oct 2006
    Location
    Cleveland, Ohio
    Posts
    2,144

    Default

    First off, are you sure your galvos are tuned optimally? Do you have a computer controlled DAC with which you can display the ilda test frame (or load it onto your micro).?

    After the scanners are tuned up, think about dwelling 150-250 microseconds at each hard corner and tweaking the timing on the straight lines to what looks good to you, and you'll be close to optimal.

  18. #18
    Join Date
    Feb 2009
    Location
    East Coast of Southern Virginia
    Posts
    193

    Default

    Are you just outputting the points in code.. with no timing except for cycle counting? If so you should really implement a timer (doesn't have to be an interrupt) to at least keep the point timing between points even. You can use a loop which just iterates through each point and delays until the timer expires. Setup the timer again and move to the next point. Store your points in an array in a header file .... or other type of include file...

    You are going to drive yourself buggy without a timer...

  19. #19
    Join Date
    Oct 2009
    Posts
    15

    Default

    Quote Originally Posted by drlava View Post
    First off, are you sure your galvos are tuned optimally? Do you have a computer controlled DAC with which you can display the ilda test frame (or load it onto your micro).?
    I really have no idea unfortunately. I bought them from Dave at Lasershowparts. I kind of assumed (bad idea come to think of it) they would be tuned pretty well, or they would be blatantly out of tune.

    No computer controlled DAC available i'm afraid. I did load a couple of test frames that Steve suggested onto the micro, there's a pic of the output a couple of posts back.

    I'm not running any timing either, however the loops are all exactly the same. Each point in each character is being sent to the DAC after the same number of clock cycles. I think the only variable in timing will be the latching time for the DAC - i.e. the DAC will latch earlier for a smaller voltage swing.
    Between the characters there will be a bit of a longer break however. I've attached the code below in case it helps anyone:

    Code:
    int maxt = maxDAC12;                        // the maximum number for the function variable used by the horiz. & vert. DACs
                                                // (should match the number of possible outputs of each DAC, to allow a 1:1 relation)
    unsigned short int tot_points1 = 190;
    unsigned short int tot_points2 = 243;
    unsigned short int tot_points3 = 182;
    unsigned short int tot_points4 = 393;
    unsigned short int point_num = 0;
    unsigned short int delay_time2 = 0;
    unsigned short int delay_time1 = 50;
    
    const unsigned short points1[190][2] = {
    // points go here
    };
    const unsigned short points2[243][2] = {
    // points go here
    };
    const unsigned short points3[182][2] = {
    // points go here
    };
    const unsigned short points4[393][2] = {
    // points go here
    };
    
    void main(void)
    {
          P5DIR |= 0x02;                               // Set P5.1 to output direction
          P6DIR |= 0x03;                              // set P6.1 & P6.2 to output
          P6OUT &= 0x0C;                              // Set P6.1 & P6.2 to low
        ADC12CTL0 = REF2_5V + REFON;              // Internal 2.5V ref on
        TACCR0 = 13600;                           // Delay to allow Ref to settle (delay of approx 13ms = 13600/SMCLK)
        TACCTL0 |= CCIE;                          // Compare-mode interrupt.
        TACTL = TACLR + MC_1 + TASSEL_2;          // up mode, SMCLK
        __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, enable interrupts
        DAC12_0CTL = DAC12IR + DAC12AMP_7 + DAC12ENC; // Int ref gain 1
        DAC12_1CTL = DAC12IR + DAC12AMP_7 + DAC12ENC; // Int ref gain 1
    
        DAC12_0DAT = 0x0000;
        DAC12_1DAT = 0x0000;
    
        while (1)
        {    
            P5OUT ^= 0x02;                                        // Toggle an LED (heartbeat)
            do{
                point_num++;
                DAC12_0DAT = points1[point_num - 1][0];
                DAC12_1DAT = points1[point_num - 1][1];
            }while(point_num != tot_points1);
            point_num = 0;
    
            do{
                point_num++;
                DAC12_0DAT = points2[point_num - 1][0];
                DAC12_1DAT = points2[point_num - 1][1];
            }while(point_num != tot_points2);
            point_num = 0;
            
            do{
                point_num++;
                DAC12_0DAT = points3[point_num - 1][0];
                DAC12_1DAT = points3[point_num - 1][1];
            }while(point_num != tot_points3);
            point_num = 0;
            
            do{
                point_num++;
                DAC12_0DAT = points4[point_num - 1][0];
                DAC12_1DAT = points4[point_num - 1][1];
            }while(point_num != tot_points4);
            point_num = 0;
         }
    }

  20. #20
    Join Date
    Feb 2009
    Location
    East Coast of Southern Virginia
    Posts
    193

    Default

    Wow... what is your clock rate? Is the MCU 1 clock ~ 1 inst. (for most instructions)?

    Also your DACs are not double buffered right? (from looking at the code).

    You may want to have it output a square wave and measure the point to point timing (point output rate) with your scope. From reading the earlier posts you say you are going really slow... however the code is just outputting as fast as the micro can go... which means with most modern micros and clock rates you probably are going way too fast.

    At the very least put a delay loop in between each point. Just make 1 variable that decremements from some value to 0 in a while loop. Then you will at least see some effect... good or bad.

    do{
    point_num++;
    DAC12_0DAT = points1[point_num - 1][0];
    DAC12_1DAT = points1[point_num - 1][1];
    unsigned int uiDelay = 1000; // assuming a 8 or 16 bit micro
    while (uiDelay) uiDelay--;
    }while(point_num != tot_points1);

    It would be really good though to do a square wave a measure the output rate though....

    You may want to adjust your output rate for around 12kpps ... most scanners can handle that rate quite well even with non-optimal point spacing and such.

  21. #21
    mixedgas's Avatar
    mixedgas is online now Infinitus Excellentia Ion Laser Dominatus
    Join Date
    May 2007
    Location
    A lab with some dripping water on the floor.
    Posts
    5,396

    Default

    Two 7476 JK counters wired as a ring counter generate a quadrature square wave, thats a start for a test.

    Steve

  22. #22
    Join Date
    Oct 2009
    Posts
    15

    Default

    Hi folks,

    Thanks for all the help. Last week I finished up the project and handed in my documentation. With any luck my supervisor won't need any revisions. Unfortunately I didn't get a chance to keep cracking with all your suggestions to perfect the output, but you can see below that we were getting closer:

    Final Output.JPG

    Thanks again for all the suggestions, I'm sure the student that continues the project next semester will be here to ask some more questions, and I'll be lurking around too

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •