Grayscale Image Pixel Values (For Milling Machine)

Post your NXJ projects, project ideas, etc here!

Moderators: roger, 99jonathan, imaqine

Grayscale Image Pixel Values (For Milling Machine)

Postby 2DLuis » Wed Jan 04, 2012 10:33 pm

Hello,

I'm currently in the planning stages for a 3D milling machine, laying out all the java necessary before I actually build the robot. I plan on making it carve the models according to the process below (open to suggestions):


* Generate model in 3D CG Software (Maya, Blender, Autocad, etc.)
* Take a screenshot of model against black bg with a light in the scene to highlight model
* Crop image to a reasonably small image (whatever the NXT can hold in its limited memory, still researching that component)
* Place image on NXT memory
* Read image, pixel by pixel in JAVA (and move plotter in a similar way), and get the "shade" of each pixel
* According to this shade, adjust the Z axis of the drillbit. (white = less carving, black = max carving)

Hence, my questions are:
1) Does LEJOS only support xbm? Can it support a grayscale bitmap?
2) If grayscale is accepted, is there a way to get how intense of a shade the current pixel is? (So that I could loop through the image with getPixel())

--

My previous idea was to code a parser into the NXT to handle a language similar to G-Code, outputting files similar to:
Code: Select all
X2 Y3 Z4
X3 Y3 Z3
//these values being in nm


But I realized the readLine() function has been depreciated, and therefore used a stringBuffer to append file data at the byte level. I'd also like to know which of the two methods you'd recommend if possible (the image approach vs the G-Code approach)

Thanks!
2DLuis
New User
 
Posts: 3
Joined: Sat Dec 10, 2011 4:18 pm

Re: Grayscale Image Pixel Values (For Milling Machine)

Postby 2DLuis » Wed Jan 18, 2012 8:55 pm

After a couple of days of Google searches, I came up with a free Polish/English program that allows you to do this.

http://www.inf-el.com/cnc/cnc.htm

It's an excellent program, no overhead, simple and easy to use. I'll attempt and post the results of my milling machine quest for those of you interested soon.

My goal is to make a 3D milling machine from only a single NXT retail kit, but I may resort to using additional technic pieces besides the additional 4rth motor which must always be powered on for the drill bit. I will also attempt and provide full and accurate documentation when I complete the project.
2DLuis
New User
 
Posts: 3
Joined: Sat Dec 10, 2011 4:18 pm

Re: Grayscale Image Pixel Values (For Milling Machine)

Postby Aswin » Thu Jan 19, 2012 8:22 am

As I understand it you want the image file to serve as a source of the 3d model. The info in this file will be used not only to display the image but also to drive the milling process.

I think it would be a better idea to define a source file that is inedependent to both the display and the milling functions. It should just describe the model accurately enough for both. This file is still a source for both processes but it requires a function to translate into an image and one to translate into milling instructions.

The advantage of such an approach is that you do not loose essential model information because of the limitations of the image format (because it is black and white only, or because it has a max size of 100x70).

You could make the discription of the model grid/pixel based instead of vector based as CAD models are. You can do so because both the image and the milling instructions are grid/pixel based I suppose.
My NXT blog: http://nxttime.wordpress.com/
Aswin
Active User
 
Posts: 122
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands

Re: Grayscale Image Pixel Values (For Milling Machine)

Postby gloomyandy » Thu Jan 19, 2012 9:41 am

Hi Aswin/Folks,
I don't think that the image was intended to be limited to the size or capability of the NXT screen. It is quite common to use use images as the input for a milling process, though often they are converted to g-code to drive the actual machine. However in this case I suspect that a greyscale image may well be the more compact format (g-code files created from images can end up being very large). So if the plan is to hold everything in the NXT memory this may be the best option. Reading the original post it looks like the poster intends to have a format that is independent of the format used for milling (some form of 3d model), but will use a manual process to turn this into a bitmap, which will then be used to drive the milling process.

I played around with cnc stuff a few years ago and milled a few things from images. There are no examples of this work, but you may find the general cnc stuff of interest:
http://www.gloomy-place.com/cnc.htm
I upload the rather old video of the machine in action to youtube to make it easier to watch...
http://www.youtube.com/watch?v=oto2LzqJbkI

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Grayscale Image Pixel Values (For Milling Machine)

Postby 2DLuis » Thu Jan 19, 2012 6:09 pm

Thanks for the input.

What I plan to do is to take an 8bit grayscale .bmp file and convert it with the program above to gcode (rendering a bmp from the 3d view window, white being the highest z value, black the lowest). Once it is converted to gcode, it outputs a ~20kb .din file which I plan on storing in the NXT's memory. I have tested the gcode output with CncSimulator, and it outputs decent quality. I'll then read the file line by line and adjust the head to the given x,y,z. I had no intentions of showing a preview image on the NXT screen, because I don't think the LCD handles shading, right?

(Currently using the conversion factor of 1px = 0.2mm, any suggestions on what "resolution" to use?)

I planned on originally housing all gcode files on a pc, and using the usb connection library functions to transmit line by line to the milling machine, but figured this would only slow down the milling process and make it dependent upon another interface.

I do have another question though: what is the maximum memory we have access to in the NXT? Currently, I reinstalled the official LEGO firmware 1.31, but heard that project files once downloaded to the brick, are colossal, and was wondering how much of a memory increase the use of LEJOS has over the other firmware. I suspect that the largest gcode file on the nxt at any given time would be ~100kb..

Thanks again, and thanks for the link to the video.
2DLuis
New User
 
Posts: 3
Joined: Sat Dec 10, 2011 4:18 pm


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff