[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 574: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 630: sizeof(): Parameter must be an array or an object that implements Countable
Build Your Own SLA/SLS • Create a mask with UV sensor
Page 1 of 5

Create a mask with UV sensor

Posted: Tue Aug 11, 2015 8:29 am
by nc42
I thought I'd start a new topic to make this easier to find. Plus it's a bit long winded. This will be a bit of hardware and a bit of software. It will be a few posts and I recommend you read through them all before charging in.

First off the hardware used:

Arduino Duemilanove or Uno, you could use another Arduino or Raspberry PI but the code I'll upload will work straight away with the Duemilanove or Uno or a knock-off of your choice.

SainSmart 16x2 LCD with Keypad shield, once again there are other ways to go about this but this is what I had so it if you want the easy plug and play this is the go. Also very cheap. Make sure you get one you can solder headers on to.

ML8511 UV sensor breakout board. Mine is a sparkfun but cheaper versions can be found if you can wait for it to come from china.

If you buy name brand you're looking at around $45 for these 3 pieces. If you go ebay knock off you can easily be waiting for your mail for under $20

On top of this you'll need some headers to solder on to the LCD shield and the ML8511 breakout and some jumper wires. There is on slightly (very) tricky bit of soldering the way I did it but this could be avoided with a small breadboard.

First step is to do a little bit of soldering. Solder the headers on to the breakout board. On the LCD shield you will need to solder a header on to the holes that correspond to pins A1, A2, the 3.3v source pin and a ground pin. I chose to solder 3 header pins on to the 3.3v output as you need to connect 3.3 volts to three things. If this seems a bit tricky for you, you can solder one then run a jumper to a breadboard then run the 3 wires from the bread board.

Now it's time to wire it up. You will run jumpers from the 3.3v pin on the LCD shield to pin A2, the 3.3v pin on the ML8511 and the EN pin on the ML8511. A jumper from ground on the LCD shield to ground on the ML8511 and finally a jumper from A1 to the OUT on the ML8511.

Next its time to load the sketch in to the Arduino. Open up the UV_Sensor sketch and plug you Arduino in to your computer. Make sure you have the right type of board and processor selected and the proper COM port under the tools and hit up load.

You should be ready to go. The Screen should read "Position 1 Press R to read" If you want to check that it works you can open the serial monitor in the Arduino IDE and press the "Right" (mine actually says "Rigth") button on the shield. The serial monitor should read 192,180,"Some reading" where some reading is the reading from the sensor. If you press the button again it should read 384,180,"Some reading" and on and on.

Attached code as Codebenders is shutting down

Re: Create a mask with UV sensor

Posted: Tue Aug 11, 2015 9:08 am
by nc42
Okay a couple of things before we continue. The code posted and the stl file are specifically for 1080 projectors. With a few small changes you could adapt it to other resolutions. To use my method you will also need Rhino. There are probably other ways to accomplish the same thing but I'm not going to try to figure them out at this point. Rhino is cheap for what it is but still expensive though they do offer a 90 day trial of the full software.

You will need to download a copy of Coolterm found at http://freeware.the-meiers.org/

Empty out your vat and give it a nice wipe. Then open the attached stl in Creation Workshop. Scale and move the stl to fit your build area. Under slicer settings make your bottom layer time absurdly high (I think I went 1300000) so you have all the time you could want to take your measurements. Slice the model.

Plug your Arduino in to your computer and start Coolterm. Match your settings you used in the Arduino IDE for loading the sketch into the connection options in Coolterm and hit connect.

Put your Z axis as high as possible to get it out of your way. Now hit start in Creation Workshop. The grid of dots should show up (the numbers will be backwards, deal with it). Take your sensor and put on dot 1 and press the "RIGHT" button on the LCD shield. In cool term you should have a reading pop up that reads "192,180,UV reading" with UV reading being the sensor reading. The LCD should change to "Position 2 Press R to read" if so all is good and take your 45 measurements.

After you take all the measurements go to Coolterm and select all the data. Copy it into notepad or the like and save it giving it a name like "UV No Mask 1.txt" Then go back into Coolterm and hit the clear data button and hit the RESET button on the LCD shield. I would recommend taking 3-5 sets of readings saving each one to it's own file.

After taking the readings import them into Excel or Open Office. Compare the 3rd row from each data set. The readings should be generally close but not exactly the same on each one. If you have one that has readings quite different from the rest throw it out. Average the readings from the left over data sets. Put this column of averaged data sets into a new spread sheet with the 1st and 2nd column from the data sets (the XY positions)

Now you have a choice. The X and Y coordinates that come from the Arduino are to large by a factor of 10 because Arduino doesn't like decimal places. You can either divide them all by 10 in your spreadsheet or later in Rhino you can use scale to fix it, up to you.

At this point you need to save the spread sheet with the X Y and Averages of your readings as a csv (comma separated value) file.

And you're ready for the next part

Re: Create a mask with UV sensor

Posted: Tue Aug 11, 2015 9:43 am
by nc42
Open Rhino and start a new project "Small Millimeters"

Under the File menu select import. Find you csv file with the averaged values and select it. When prompted select comma for the delimiter and hit ok. You should have a bunch of points pop up on the screen.

If you didn't divide all the X and Y values by 10 before making the csv file you probably wont see all the points as they will be spread out. If this is the case make sure they are all selected and go to the Transform menu and select Scale > Scale 2-d. It will prompt you for the origin point. In the "Top" view click on the origin (0,0) or put you cursor in the view and type 0 and hit enter. It will prompt you for the scale factor type 0.1 and hit enter. Your point cloud should be smaller now.

Make sure all the points are selected and type in "patch" (no quotes) it should bring up the Patch Surface Options window. Set "Stiffness" to 0.5 and hit okay. This should create a surface. You will need to extend to edges of the surface. Type ExtendSrf in to the command bar it will prompt you to "Select edge of Surface to extend" in the "Top" view select either the top or bottom edge of the surface it will the prompt you for "Extension Factor" enter 10 and hit enter.

The next step is to make a plane. type "Plane" into the command line. For the first corner select the origin in the "Top" view or place the cursor in the "Top" view and type 0 and hit enter. For the second corner type "192,108" and hit enter.

Next we need to trim the surface we made from the points. Select the surface and type "CutPlane" into the command line and hit enter. Make sure the box in the bottom left corner next to "End" is selected. If this box is grayed out click on the word "Osnap" on the bottom of the screen. Now the cursor should snap to the corners of the plane we made in the last step. Select a corner then select another corner on the same side as the first. Work your way around the plane creating 4 cutplanes. After you've done this hit ESC.

Now we will trim the excess from the surface we created. Select the 4 cutplanes you created in the previous set and type "Trim" in to the command line. now start clicking on the parts of the surface that are out side the planes. When done hit ESC. You should now have a surface that when viewed from the top is 192mm by 108mm.

Now we need to scale the surface to exaggerate the differences in UV readings. I'll tell you what I used but it took some trial and error so it might take a few tries to get it right. Select the surface from the UV readings and type "Scale1d" into the command line and hit enter. It will prompt you for the origin point. Select the origin in the "Right" view or put the cursor in the "Right" view and type 0 and hit enter. For the scale factor I used 5.
for the direction you want to go directly vertical from the origin. If you hold the shift key it will only allow the cursor to move vertically or horizontally. The curvature of your surface should be much greater.

Now we need to move the Plane we created earlier. Select it and move it so it is 10-12 mm above the highest point of the UV surface. Again this took some trial and error so you might want it closer or further away.

Select the points made at the beginning and hide or delete them.

Next change one of the views to "Bottom" by clicking on the down arrow by the view name and going to Set View > Bottom. Maximize the "Bottom" view by double clicking on the view name and click on the "zoom extents" button which is a magnifying glass with 4 arrows around it to fill the view. Next go to the "View" menu and select shaded.

The final set is to type "ShowZBuffer" into the command line and hit enter. You can change the range of the shading by moving the flat plane closer or further away from the UV surface.

Unfortunately I couldn't get the print image option to work properly so at this point I just took a screenshot

Re: Create a mask with UV sensor

Posted: Tue Aug 11, 2015 9:51 am
by nc42
Almost there! Open the screenshot in Photoshop or the editing software of your choice and stretch the part of the image that is your shaded surface until it fills up a RBG canvas that is 1920 pixels by 1080 pixels. I also adjusted the contrast increasing it by 50 in Photoshop. At this point save it as a .png

Next open up Creation Workshop and go to the machine settings and click the software mask check box. Then select your png file. Then click apply changes (I forgot this step the first time I tried!) You should be ready to go. I went ahead and took new readings at this point and they were much more similar to each other! See attached spreadsheet if you want to see the amazing data!

Re: Create a mask with UV sensor

Posted: Tue Aug 11, 2015 10:15 am
by sodium
interesting results! its amazing the variationg from the hotspot to the weakspot ( 5.39 vs 1.34 ) . i receive this morning my sensor and gonna take a diferent route. i will post results soon. good work!

Re: Create a mask with UV sensor

Posted: Tue Aug 11, 2015 3:33 pm
by cardin1
Wow !!! That's fantastic. I was getting ready to try and make a mask but was not too happy with having to use a camera. Thank you for sharing.

Re: Create a mask with UV sensor

Posted: Tue Aug 11, 2015 3:58 pm
by nc42
Seems to have worked quite well. Just finished my first print of 9 chess pieces and only one had a little delam on the bottom other than that mostly perfect!

Re: Create a mask with UV sensor

Posted: Tue Aug 11, 2015 6:15 pm
by jon_bondy
Would one of you please post one of the final PNG files?

Re: Create a mask with UV sensor

Posted: Tue Aug 11, 2015 6:33 pm
by nc42
Here you go

Re: Create a mask with UV sensor

Posted: Tue Aug 11, 2015 6:39 pm
by jon_bondy
I imagine that taking a picture using a camera would not work, because it would respond to non-UV light. I wonder if it would work with an appropriate filter.