Constructing Janus, by Dirk

Post your build logs here

Re: Constructing Janus, by Dirk

Postby BenJackson » Sun Oct 23, 2011 6:46 pm

The AVR can count in hardware.
BenJackson
 
Posts: 494
Joined: Fri Apr 15, 2011 6:13 pm

Re: Constructing Janus, by Dirk

Postby dirktheeng » Sun Oct 23, 2011 9:59 pm

I'm not sure how to do that... the only way I know how to do this is to set a pin as a hardware interrupt which then calls a function that will increment/decrement. The problem with this approach is that if you have other things going on in the chip (say dealig with another interrupt or talking on a serial line) and the time it takes to deal with that is longer than the period between pulses, then you will miss that count. The forum's that I looked at said that about 20khz is about the most you can expect to be able to count without getting errors or jitter... with 1/16 microstepping, that is only 127 mm/sec... i may loose count in a jog. Plus, I want to use this to keep an absolute count for engraving in which I hope to really push the speed say to 200khz. I know that the smooth stepper and the xaxis can do that because I've tried it already. Unless you know how to hardware count that fast, it isn't much good.

That said, i'm no arduino/ARM expert by any means, so if you know a way to do this reliably with an ARM, please let me know. Also, the form information could be just wrong. If that is the case, set me strait with some good info. If you have a method different than what I explained above, please detail it a bit so I can figure it out and understand it.
dirktheeng
 
Posts: 616
Joined: Thu Sep 09, 2010 4:49 pm

Re: Constructing Janus, by Dirk

Postby BenJackson » Mon Oct 24, 2011 1:04 am

Are you confusing Arduino with AVR? I don't know if Arduino has a library function, but the AVR can certainly count in hardware. It would be hard to miss the fact that the timers are named "Timer/Counter0", "Timer/Counter1" and so on. The TCCR register has CS (clock select) bits and options include rising/falling edge of a particular pin (per counter). They go through a synchronizer so I think they count up to 1/2 FCPU.

I still think you could count at Mach3/EMC2 speeds just fine with any IRQ pin. The AVR will latch the rising (or falling) edge for you and you just have to service it before the next pulse. Even at <50kHz on an 8MHz AVR you have 160 instructions to take the interrupt and count it. You could probably write an interrupt handler to inc/dec a 32 bit counter (depending on DIR pin) in ~20 instructions.
BenJackson
 
Posts: 494
Joined: Fri Apr 15, 2011 6:13 pm

Re: Constructing Janus, by Dirk

Postby dirktheeng » Tue Oct 25, 2011 12:11 am

Ben,

Is't an arduino, at heart, an AVR? That's why I called it that.

Secondly, I think that the chip is too slow because 50kz is pretty low for my system.

A typical engrave move will be about 800mm/sec. my sep resolution is 157.4744 steps/mm (this is 16x microstepping). so that means my step frequency is 120khz. At 8Mhz, that only gives me 66 clock cycles between pulses. Further, rapids could be as high as 12700 mm/sec which is 2Mhz (I can do this because of the smooth stepper) and I have run it that fast. I only have cycles then.

The counters can count up to 10Mhz without loosing a step. That's why I chose this.

Anyhow. I decided to use a left over arduino mega which has more io than I need for this and I can read all 33 pins at once.
dirktheeng
 
Posts: 616
Joined: Thu Sep 09, 2010 4:49 pm

Re: Constructing Janus, by Dirk

Postby lasersafe1 » Tue Oct 25, 2011 2:15 pm

I'm barely following this discussion, but if you are wanting to track counts to a stepper, U.S. Digital makes a chip specifically for counting. It is usually used on their encoders, but the input source could also be the step and direction bits. They have chips to read quadrature and/or count and dirction. No coding necessary. I've always been amazed at how I can't fool my digital caliper no matter how fast I move it. This chip is why.

Scroll near bottom of this page.
http://www.usdigital.com/products
lasersafe1
 
Posts: 599
Joined: Fri Nov 27, 2009 8:23 pm

Re: Constructing Janus, by Dirk

Postby awesomenesser » Tue Oct 25, 2011 3:15 pm

Yes the chip in an arduino is an AVR. The part that makes it an arduino is the software which is put on an AVR. The arduino software is basically made for people that can't program or are too lazy to really program. It gets what you want done if you don't mind huge libraries and lots of overhead. Your code will be much faster if you just write it for the AVR itself. Another note is that in order to program an AVR you will need an ISP programmer. The Arduino uses a bootloader (more overhead) to allow hobbyists to go without programmers.

dirktheeng wrote:Ben,

Is't an arduino, at heart, an AVR? That's why I called it that.

Secondly, I think that the chip is too slow because 50kz is pretty low for my system.

A typical engrave move will be about 800mm/sec. my sep resolution is 157.4744 steps/mm (this is 16x microstepping). so that means my step frequency is 120khz. At 8Mhz, that only gives me 66 clock cycles between pulses. Further, rapids could be as high as 12700 mm/sec which is 2Mhz (I can do this because of the smooth stepper) and I have run it that fast. I only have cycles then.

The counters can count up to 10Mhz without loosing a step. That's why I chose this.

Anyhow. I decided to use a left over arduino mega which has more io than I need for this and I can read all 33 pins at once.
awesomenesser
 
Posts: 110
Joined: Wed Mar 02, 2011 4:07 pm

Re: Constructing Janus, by Dirk

Postby dirktheeng » Wed Oct 26, 2011 10:39 pm

I've decided that I am going to use a set of counters that I will connect to an old arduino MEGA I have laying around via a 34 pin ribbon cable the MEGA will set the laser on/off. I am also going to attempt to use the MEGA to do engraving.

The engraving strategy looks like this:

1) prepare the image via a Python Script. The python script will take an image, convert it to greyscale, and then dither it to the resolution and size needed.
2) write this informatin to an SD Card through the MEGA (I have an SD card shield)
3) Move the laser head to the position of the upper left corner of the engraving
4) give Mach3 the macro code (say M199) which is the macro that will handle the rastering through Mach3
a. the macro will send a code throught he modbus (arduino uno) that will set the mega to engrave mode
b. the mega will send back the dimensions of the raster, feed rate, and other information
c. the macro will ask the modbus for the dimensions and feed rate
d. the macro will move the head to start position and request permission to start a raster line
e. the mega will load the first line of data (which contains the position information in steps when the laser should be swiched)
f. when the mega is ready, it sets a ready pin that is read by the Uno which then sends the ready signal to Mach3
g. mach moves the head at the right speed to a given position
h. once the MEGA detects motion, it sets the ready pin to low
i. as the head moves, the MEGA tracks the position via the counters and turns the laser pin on and off as specified
j. once past the end of the data in a line, Mega loads the next line and will set the ready pin to high again when done
k. rince wash repeat until done

Hopefully this will work ok because at 30IPS and 1000 DPI, the head will pass pixels at the rate of 30kHz. This means that I will have 533 instruction cycles to read the position, compare it to a given value, set the laser pin, and load the compare value. This is also prety much the limit of how fast we can the laser on and off. Supposedly, the laser takes about 15 microseconds to turn on and off (each), so it takes about 30 microseconds to turn on and off once and there is 33.3 microseconds that the head is over a pixel.

If 533 instruction are not enough, I will replace the MEGA with an Duo (when it comes out) or a Maple which run at 96mhz. That will give me 3200 instructions. I think the key to making this reliable is not having to wast a lot of resources on the board to count the signal.

Who knows, maybe we will get a general high speed vector/engraving solution for under $100.
dirktheeng
 
Posts: 616
Joined: Thu Sep 09, 2010 4:49 pm

Re: Constructing Janus, by Dirk

Postby TLHarrell » Wed Oct 26, 2011 10:45 pm

What are the possibilities of adding greyscaling to this? Maybe 8 color variations, instead of something like 256?
40w Full Spectrum Engineering 5th Gen Hobby 20"x12" w/ Rotary Engraver
South San Francisco Bay Area - Sales and Support Representative for Full Spectrum Engineering
408-47-LASER - Skype: whitelightlaser-thomas - Facebook: White Light Laser
TLHarrell
 
Posts: 373
Joined: Thu Jul 28, 2011 11:30 pm
Location: Morgan Hill, CA

Re: Constructing Janus, by Dirk

Postby dirktheeng » Wed Oct 26, 2011 10:53 pm

I don't think it would be a problem for a Maple/Duo to do this as they are faster, but a Mega may struggle because now I have to keep track and step through 2 vectors one for on and off, the other for power, and it isn't just writing a simple on/off, but now I have to use an analog write statement which will definatly take more instruction cycles. I don't even know if this will work at the high feed rates with a MEGA and a simple on/off vector yet. I'm going to give it a try though. If I can't make it work, I'll try with a faster controller. At that level, I would expect that it would be ok.

That said, I don't know how fast I can get the laser to respond with a digital resistor pot in place of the hand pot. It would have to be on the same speed as the on/off to work well. If the digital resistor idea works well, then there is no reason why we can't do 256 bit greyscale.
dirktheeng
 
Posts: 616
Joined: Thu Sep 09, 2010 4:49 pm

Re: Constructing Janus, by Dirk

Postby dirktheeng » Sun Oct 30, 2011 9:30 pm

decided to make some changes to make it easier and cheaper. went to using ribbon cables and IDC connectors. This is significantly easier and made the board layout much simpler. the smoth stepper already has a ribbon cable to go from the board to the DB25... a simple IDC connector will allow me to listen in on the signals. Ordered all the parts from digikey... came to $29.

Dropped the i2c expanders in favor of doing a direct 34 pin connectioin to the mega/maple/duo.

Here's a view of the circuit diagram:

CircuitDiagram.png
Diagram


Tentative board layout:

BoardLayout.png
Layout
dirktheeng
 
Posts: 616
Joined: Thu Sep 09, 2010 4:49 pm

PreviousNext

Return to Build Logs

Who is online

Users browsing this forum: No registered users and 1 guest