PDA

View Full Version : Shopbot Talking to Arduino



jsolos
10-03-2013, 08:33 PM
I have been playing around with an idea to attach a laser to the shopbot head for etching and cutting. In order to make controlling the laser (on/off/pulse width modulation) a little easier and more flexible, I am using an Arduino board set to receive commands from a serial port. So for example, if I send an "L100" command over the serial port to the Arduino (echo L100>com5) the laser turns on at 100%. That part is fine.

Now, being a newb at the whole shopbot control except for using the usual part files, here is the problem. How can I create a custom command and incorporate it into the G-code? How do I map that command to windows command/DOS command?

I read a bit on virtual tools.The programing guide says something about "TC, 1500, small, 2 " as a custom command but the virtual file looks more like "'VT = [&T]oolName, PathFile, autostart(1=yes), persist(1=yes)"

Is this the route I have to go or are there other ways to create custom commands? So if anyone can give me some guidance, it would be greatly appreciated. I`m running version 3.6.46.

I think if we get this working it will open up a whole bunch of other possibilities!

jsolos
10-03-2013, 09:38 PM
I read a bit on virtual tools.The programing guide says something about "TC, 1500, small, 2 " as a custom command but the virtual file looks more like "'VT = [&T]oolName, PathFile, autostart(1=yes), persist(1=yes)"


Sorry, by this I mean I`m not sure how to get from a TC command to a virtual tool. Or are they even related?

dana_swift
10-04-2013, 10:45 AM
Hi Eric-

The Arduino and Shopbot are two of my favorite toys! (Especially the ARM based Arduino's like the Due.)

Shopbot unfortunately does not provide a built-in interface to auxiliary controllers like an Arduino. That does not mean you cant outwit it and do it through the back door.

One way would be to implement a synchronous serial link using 2 of the TTL outputs. One for clock, one for data. Then a short subroutine in the SBP file can output commands over the cobbled up protocol link.

Another way is talk to an Arduino is to write a communications program that has to be run in parallel with the SB3 program. Shopbot does allow communication through the PC registry. That is also very klunky but its at least supported by the SB3 software directly. That is documented in the SB programming documentation. SB3 does not provide any mechanism to launch your program however, so do it the other way. Launch your program and have it launch SB3.

Its a real shame the "open SBP" format does not allow user defined functions, as that would allow convenient calling of your subroutine, but again you can simulate it by using a set of global variables to hold the calling parameters. (I have had to use this method for some of my "active" SBP files.)

Lastly there is the issue of changing the post processor(s) to call your laser controller for "cut" or "engrave" settings. Impliment any protocol you like on top of either of the above communications methods.

I have advocated using UDP communications between the host and ShopBot, that would allow any number of intelligent controllers, but no support has been provided. Arduino's love UDP (so does everything except shopbots), as the Wiznet 5100 chip they use implements network communications in hardware, including TCP/IP connections. If you tinker any at the low level, check out that chip, it makes life so easy and is hacker proof, since hackers cannot change the hardware! Get a network shield and see what they are doing.

That is probably information overload, but that might help get you going. Sounds like a cool project! Keep us up to date.

(A fair note of caution, using a Laser on a shopbot is risky, as there is no safety mechanisms appropriate for high powered lasers built-in. Between glints, toxic exhaust issues, and eye safety, among others.)

Hope that helped-

D

dana_swift
10-04-2013, 01:04 PM
I just re-read the programmers handbook "ProgHand.pdf" (under [H]elp:[P]rogramming and Developers Resources) section regarding using the PC registry for data exchange with external programs. Section "Windows Registry Interface…Controlling the ShopBot software from outside programs (b)", page 34 in my copy of the pdf.

My comments regarding getting data from the SB3 were mis-stated: you cannot get custom user information out of the SB3 program through the registry. You can send commands to the SB3 program that way. You can read the state of the shopbot, so appropriate commands can be generated (perhaps for the laser movement?)?

There is no provision for setting or reading global variables, or passing parameters to your program from within a toolpath command list.

The registry feature is something I have experimented with, but not recently. That neuron was taking a sigh-nap :)

Sorry for the mistake! The synchronous serial interface will certainly work, but will require some clever coding! It can be bi-directional as well with two output lines and one input line.

I fear that Arduinos were not a "twinkle in the eye" at the time of the SB3 program design, so the SB3 program is showing its age.

Wonder when SB4 will be out? Any hopes of support for communication with intelligent peripherals? Why not mount a handi-bot on the gantry.. and use it as "smart drill".. or an array of them? That would require a much more powerful control program than SB3.

Wouldn't it be cool if the SB4 toolpath "SBP" command language was dot-net based.. allowing compiled intelligent toolpaths! How could that help the average user? How about determining that the tool is cutting air, and speeding up? How about machine vision? Maybe allow the bot to do pick-and-place for assembly as well as cutting? When a 3D print-head finally arrives, the machine could switch from cutting to deposition mode dynamically. Or engrave serial numbers in parts automatically. Have the touch probe work during cutting operations so the tool would know it is about to encounter material instead of air. Or find Z0 dynamically!

So many ideas come to mind for a next generation "SB4" program. The possiblities for 4+ axes boggles the mind.

Hmm, enough day dreaming. Back to income producing- I may need an upgrade if some of these features every come to pass..

D

tomwillis
10-04-2013, 01:35 PM
Eric -I have a laser set up on my SB-but I use a different controller.
tom

paul_z
10-04-2013, 02:47 PM
A few years ago I looked at a shopbot to microcontroller interface using the shopbot discretes. I ran some tests using my PRT Alpha control box and discovered that I could change output discretes at 8,000 times per second. Including overhead, it looked like 2K bits per second were possible from the shopbot to the microcontroller. Might be able to get 1K bits per second in the reverse direction.

The results were too slow to move much data but fast enough to send commands and such. I wanted to move large amounts of data from the microcontroller to the shopbot so I dropped the effort.

Paul Z

srwtlc
10-04-2013, 05:07 PM
I don't know anything about Arduino, but could something like the way the spindle control works be applied to this situation? Instead of a TR,12000 command, sending out an equivalent L,100. Or for the lack of making a new SB command, cross referencing TR commands (TR,100 or something like that). Then it would just be a matter of making a custom post processor for it.

I read this last night and fell asleep thinking about it and my last thought was, Dana Swift. ;)

dana_swift
10-04-2013, 06:08 PM
Another thought that occurred to me, how about open COMx as a file, then use INPUT and WRITE statements to communicate with the Arduino? The Ardunio shows up as a COM port when it is plugged in via USB. That could make the communication issue trivial.

Something along the lines of:

OPEN "COM1:" FOR INPUT AS #1

then..

WRITE #1,"Command Text String"
INPUT #1,&AcknowledgeMessage

and finally:

CLOSE #1

The serial port would have to be configured elsewhere of course. The open could be done in the SBP header when the spindle/router is turned on. Close could be called when the spindle/router is turned off.

In the toolpath WRITE #1 commands can be used to send specific commands to the Arduino.

Just getting the rust out of the mental machinery..

Paul- that was the idea I was suggesting, but I have never tried it, its just clear that it would work.

Thomas- I would love to hear more about how you setup your laser.

D

Brady Watson
10-04-2013, 09:05 PM
Not to steer away from using an Arduino, but have you checked out the VH command in newer versions of SB3? It is made to interface with laser using PWM control.

-B

tomwillis
10-05-2013, 06:43 PM
Dana - not sure I can be much help...I had a tech guy integrate my laser. But certainly - if you have specific questions - I can try to answer them or post pics.

I believe it was Brady in a past thread that suggested it was not his preference to combine both laser with router/spindle - and I have to agree with that opinion. Although my setup has worked for me - it does require care to shield the laser from dust and debris when the router is running....so Eric if you're seriously entertaining this as an option....I may rethink that (depending upon your application - it was costly to integrate and may make more sense to simply purchase a stand alone laser machine.)

I think it was in 2007 that I looked into changing my PRT rails to round linear with pillow block and ball screw which would give much smoother action and reduce the vibration of the laser considerably, but could not afford it.

My limited understanding of some of the issues with integrating laser on the SB and controlling it - is when vector cutting - reducing the power of the laser as it comes into a corner to avoid burning. The controller has to do this smoothly and I believe has been one of the major obstacles....so I'm not sure if the Arduino setup can handle this.

One of the limitations of my controller - when raster cutting .bmp images is doing them one at a time. Ideally - I'd love to set up 50 small plaques on the table and be able to run all 50 at once. Instead, I have to set up a jig and run one at a time and continually replace as it completes.

On positive note - my controller does allow the adjustment of both power and feed rate to 'dial-in' a precise control - but it was not inexpensive. With the addition of PhotoGraV software for raster images has extended my capabilities and offerings to clients - which has been very helpful.

Tom

dana_swift
10-05-2013, 08:24 PM
Thomas- Thank you for the reply. I am sure more people on the forum than myself would love some photos of how you mounted the laser, optics, etc.

I am curious: how many watts your laser is running, and which tube you went with? Do you modulate the beam, or just change the cut speed? Do you engrave with it as well as cut?

As to getting burning in corners, did you handle that by turning ramping down to effectively off? Or did the burning in corners turn out to be a non-issue?

Have you built any kind of downdraft table to handle combustion fumes? Beam stop?

D

jsolos
10-07-2013, 11:30 AM
Another thought that occurred to me, how about open COMx as a file, then use INPUT and WRITE statements to communicate with the Arduino? The Ardunio shows up as a COM port when it is plugged in via USB. That could make the communication issue trivial.

Something along the lines of:

OPEN "COM1:" FOR INPUT AS #1

then..

WRITE #1,"Command Text String"
INPUT #1,&AcknowledgeMessage

and finally:

CLOSE #1

The serial port would have to be configured elsewhere of course. The open could be done in the SBP header when the spindle/router is turned on. Close could be called when the spindle/router is turned off.

In the toolpath WRITE #1 commands can be used to send specific commands to the Arduino.

Just getting the rust out of the mental machinery..

Paul- that was the idea I was suggesting, but I have never tried it, its just clear that it would work.

Thomas- I would love to hear more about how you setup your laser.

D

Yes, that's sort of where I was going with my design. I already have the Arduino talking to the COM port. So basically, anything that can send a string like "L100" to the port will work. I was looking at virtual tools because there are calls to external compiled programs and you can pass parameters to them. Any possibility of going down that path?

The beauty of this is that once you have that com link set up, you can pass any command to the Arduino to do pretty much whatever you can imagine. Even basic Aduino's could control several other servos, lasers, 3D print heads, etc. So your Shopbot takes care of the positioning and the Arduino handles the stuff that traditionally can't be handled by dedicated servo driver.

I love that computer vision idea someone posted. Just think if your shopbot was smart enough to know where the edges of a part were?

As for the laser, it's a 2 watt laser I will use for cutting mostly foam forms and plastic. So I'm not too concerned about it going rogue and slicing a corner of the shop bot off. ;) So total cost of laser + Arduino so far, $100!

How open are the guys at Shopbot about this sort of design input? Given the explosion of Arduino, Raspberry Pi, and other cheap micro-controllers, you would think they would jump at the idea of turning a shopbot into a customizable work platform.

Keep the ideas coming! I'm sure we can figure something out.

dana_swift
10-07-2013, 12:29 PM
Eric- glad your project is progressing, and my com idea helps!

Shopbot is far more open to unique applications than most companies, however there is nothing like talking to them directly. No need to fear calling tech support and asking them about a special application of the software/hardware.

Did you see that Arduino now is releasing an Intel based arduino?

http://arduino.cc/en/ArduinoCertified/IntelGalileo

This thing has a lot of horsepower! Thats a pentium class chip for an Arduino! Its a direct competitor to the raspberry pi, so the price for the entire computer will have to be in the order of $35.00. That's Thirty Five dollars in case somebody thinks I misstyped something! The sale price has not been set, but getting a CPU into an arduino opens up markets for chip manufacturers. There is a video of the CEO of Intel introducing this thing. Its a big deal and they know it.

Built in Ethernet! Remember my post about UDP? Built in. Shield not required. (in the Arduino world a "shield" is a daughter board, not an electrical conductor.)

Conceptually that is enough CPU power to run MS Windows! For now it runs Linux, or the RTOS of your choice.

It has JTAG access for debugging, which is a requirement of mine. The Arduino DUE has JTAG and the tools to use it are free from Atmel. Another thing Intel will have to compete with. The DUE runs something like 80mhz and the Galileo runs 400mhz. And the development software is all free!

If Microsoft decides to get off its rear end and get into the market this is a clear invitation to them. Their attempt to compete with Arduino with their Netduino, has gotten very little penetration. I have only heard of one person trying to use one. Microsoft needs to abandon proprietary languages (gulp) and embrace the gcc tool chain.

Another really cool CPU out there is the Beagle Bone Black.

This is a revolution in computing like the microprocessor itself. The big kids are changing direction rapidly. How about Shopbot?

CNC will be impacted. Cost reductions, and true dedicated control computers! Hmm.. the future is exciting! Glad I have gotten to participate :)

Its like when the iphone was introduced, or IBM decided they ought to offer a personal computer. Paradigm earthquake time.

AVR's are cute and cheap and all, but when you can have a high end 32bit or 64bit cpu instead of a little 16bitter, its like the invention of the bulldozer. The only limit is your imagination and skill. At these prices anybody can afford to experiment.

D

dana_swift
10-07-2013, 12:38 PM
Addendum-

Just after I posted the previous note I found where TI is trying to compete directly with Intel in the same market:

http://news.cnet.com/8301-11386_3-57606189-76/heads-up-intel-ti-chips-bring-arm-to-arduino-gadget-market/

As I said in my last post, the Arduino platform has become a launchpad for technology. Its also the best free advertising out there.

Intel is badly shaken by the success and penetration of ARM devices. Almost no cellphone uses an intel processor anymore. ARM designs rules the tablets and phones.

Just came across that.. how to take best advantage of this technology in a small shop is yet to settle out. But it will impact all of us.

D

khaos
10-07-2013, 03:34 PM
On the same train of thought.

Microsoft open source. :eek:

I know you are making a face. But its true, those words go together.

Microsoft .NET Gadgeteer is an open-source toolkit for building small electronic devices using the .NET Micro Framework and Visual Studio. (Love my VS2012 once I could fix the colors)

Check this out (http://research.microsoft.com/en-us/projects/gadgeteer/) and especially this (http://www.netmf.com/gadgeteer/).

I am making a computerized chair and I wanted to use wireless control via a tablet or phone. This is the direction I am leaning in. Pricing was really good and once the immediate economic constraints ease a little I will be diving in.

SomeSailor
10-07-2013, 04:23 PM
That's the biggest reason I have my laser (Pinnacle ZX 100W) in a different room from the ShopBot altogether. The dust is hard enough to keep off the mirrors a room away. I can't imagine having a spindle and a tube / light path on the same gantry.

Not to mention the fire hazard. You could burn up $50K-$75K of machine all from a few minutes of inattention. :(

ted
10-09-2013, 02:39 PM
Hi Guys,

Just to jump in with a bit more info ... or distraction.

On Laser Control: As mentioned by Brady, VH (with VN activation) can be used to control a laser using a standard PWM protocol (with a V204 or later board). It deals with modulating the laser during acceleration/deceleration. We've used it on a couple of tools here and have a couple of ShopBotters who use it. We are open to more input on how to refine the system, but it will certainly work in a basic way to run a laser. (VH also has a protocol to control 3D printer temperatures; but in practice, we've found the heaters produce enough electrical noise that it is more reliable to just run them with a standalone thermal control, and that is how our 3D head will work.) The use of VH is described in the current Command Reference. Note that pinouts for the Control Card can be found at: http://www.shopbottools.com/files/ShopBotControlCardConnections.pdf (http://www.shopbottools.com/files/ShopBotControlCardConnections.pdf)

On Arduino's: It does not make a lot of sense to me to try and serially communicate with an Arduino from the ShopBot Control Card or software -- just too big a hassle. But you can certainly interact with the Arduino by signaling to it using the an app that is monitoring the registry, a file, etc ... or better by reading a couple of ShopBot Outputs. On the new Handibot, we use an Arduino to control all the fancy LED blinking and coloring. We trigger the appropriate Arduino program by activating various combinations of Outputs (a very simple approach) which are decoded by Arduino inputs.

On Arudino's and Open Source more generally: I don't know if you have seen our planning for the next Control Card that is discussed in some of the Handibot documents as well as here: http://www.shopbottools.com/mApplications/developers.htm (http://www.shopbottools.com/mApplications/developers.htm). Basically the plan is to move towards the same uController that is used in the Arduino DUE. This would be a natural move in the sense of a upgrading to a more capable 32-bit ARM controller for ShopBot; it will initially run ShopBot firmware that will interact with our Control Software in the regular way. However, we are also working with a group that is developing a new, open-source, motion control system that will run on the same uC. This new system puts about 85% of what is normally done on the PC, on the uC and will offer an advanced motion control system that is under active development by a number of interested individuals and groups. With it, you will be able to run ShopBot from a much thinner application; making using a wide range of devices much more practical ... and making the whole environment for running a ShopBot much more open and expansive. We think it is pretty exciting. Just flash whatever firmware system you want on the tool -- run it as a current ShopBot, or with the new approach.

Ted Hall, ShopBot

gsnover
11-07-2013, 06:44 PM
Hey guys,

I am so glad I have found this thread. So I just found the j6 header on the controller and as Ted has described it can output PWM? From what I understand I can use a low pass filter to convert that to an analog signal and read that through Arduino's input pins? Ted, do have some example code on how to use VH? The pin out diagram you posted indicates there are also analog outputs, DAC 0, DAC1 - pins 18-20... 0-5v?. What command uses those?

what I need to do is use gcode get a 0-5v signal to the arduino which i will be output as a analog 0-10v signal to an air pressure controller. I am working on a ceramic paste extruder head for 3d printing. I want to use gcode to set and control air pressure and then modulate it with speed. The VH command sounds perfect, i am just not sure how to implement it.

Setting up the com port as dana described in confusing to me. How do I do that in gcode? from there i can probably figure out how to get arduino to listen.

any help would be really appreciated!

-Guy

dana_swift
11-08-2013, 12:18 PM
Guy- the GCode documentation for SB is:

http://shopbotwiki.com/index.php?title=GCodeMain

If what you want to do is there, you are in good shape. If not, consider learning more about the SBP command language. It is documented in depth in the programming handbook.

http://shopbottools.com/ShopBotDocs/files/SBG00314%20ProgHandWin%202013%2005%2001.pdf

As to reading the signals from the arduino, it depends a bit on which arduino you are using. I would suggest you avoid the analog conversion step, as that just discards all the accuracy and precision digital data offers. The signal Ted describes is digital in nature and fully arduino compatible. Look into using the counter/timers of the arduino to recover the values from the VH command.

richards
11-09-2013, 10:51 AM
An often overlooked feature of the Arduino is the SPI and I2C interfaces. In some of my projects, I have a bunch of microprocessors connected via the I2C interface. One is the "master" and the others are "slaves". The master sends parameters and "start" signals to the slaves. The slaves send status information to the master while performing their tasks.

By breaking up the entire task into several subtasks, a handful of little $3.00 microprocessors can be used to control feature-laden machines. For example, Kodak/Bremson sold an electronic retrofit controller based on the DEC LSI-11 cardcage for the S-Series of Professional photoprinters. The base price for that unit was $17,000, with a typical installed price about double that. My microcontroller version had more bells and whistles than the DEC model. Parts, including eight stepper motors, cost less than $2,000. I could sell my unit for half the price of the basic Kodak model and actually make more profit per unit than Kodak.

By breaking an application into its component parts, its easy to assign an Arduino or other microcontroller a specific task. For instance, a simple LCD controller usually uses seven pins, which eats up a log of the available I/O on that board. A bunch of analog input/outputs can use up all of the analog pins. Before long, all of the Arduino's pins are used. Add to that the requirement to closely control some signals (stepper pulse string, for example), and a single Arduino can bog down. By assigning a separate Arduino or microcontroller to each stepper motor, to the display, and to the other various inputs and outputs, everything can be handled in a timely fashion without spending a fortune, There are standard libraries already written that simplify connecting multiple Arduinos via I2C or SPI.

gsnover
11-12-2013, 11:32 PM
thanks dana. I found some tutorials using counter/timer as you suggested I will give them a shot.

jsolos
11-19-2013, 10:12 AM
HI, just wanted to post a quick update. Ted, from Shopbot came up with a brilliantly simple idea.

I can use the following command from a DOS prompt to send the commands to the Arduino. For example;
"ECHO L1>com5" (where com5 is the serial port the Arduino is listening to.)

So Ted's idea is just to do a SHELL command in my G-code and pass the commands that way. There's a utility somewhere on the website that lets you edit G-Code based on certain conditions. I used that to insert two commands in my code. I test for changes in the Z axis. Before Z moves up, I insert
SHELL, "ECHO L0>com5" into the G-Code. Before Z moves Down, I insert SHELL, "ECHO L1>com5" into the code.

So using this I can send commands to the Arduino to turn the laser on or off as the spindle moves up and down.

I'll try to test the whole thing this week and maybe post a few pictures of the Laser and 3D print heads mounted on the Shopbot.

gsnover
04-29-2014, 06:18 PM
HI, just wanted to post a quick update. Ted, from Shopbot came up with a brilliantly simple idea.

I can use the following command from a DOS prompt to send the commands to the Arduino. For example;
"ECHO L1>com5" (where com5 is the serial port the Arduino is listening to.)

So Ted's idea is just to do a SHELL command in my G-code and pass the commands that way. There's a utility somewhere on the website that lets you edit G-Code based on certain conditions. I used that to insert two commands in my code. I test for changes in the Z axis. Before Z moves up, I insert
SHELL, "ECHO L0>com5" into the G-Code. Before Z moves Down, I insert SHELL, "ECHO L1>com5" into the code.

So using this I can send commands to the Arduino to turn the laser on or off as the spindle moves up and down.

I'll try to test the whole thing this week and maybe post a few pictures of the Laser and 3D print heads mounted on the Shopbot.
Eric,

Trying to talk to an arduino. I tried running a sbp file with your command line SHELL, "ECHO L0>comX" with arduino listening to that specified com port. I got nothing. Can you share more of your code? Is ECHO a file location of another program as it states it in the command reference guide? I have no idea how your system is working. Your help would be very appreciated.

Go Habs!

thanks,

Guy

jsolos
04-29-2014, 09:11 PM
Hi Guy,

Although ECHO is a built in dos command, the shopbot interpreter had trouble with it. I had to find an external "echo" program that I could put in the shopbot software directory where the command interpreter for SHELL could find it.

I think I got it from here. http://www.paulsadowski.com/wsh/cmdprogs.htm or any other similar utility.

Once you have that, you can make sure the connection works by opening a DOS command window in the directory you put the new EXE and trying your command like "ECHO L1 0 >COMM1" or whatever comm port your arduino is listening on. Once you know that works, then try calling it from the shell command.

Hope that helps.

gsnover
05-01-2014, 02:10 PM
Eric,

I successfully sent data to the arduino from the command prompt using ECHO. I can use SHELL to open the cmd.exe in the same directory. Using a process monitor if I run SHELL, "ECHO" I can see that it finds echo. However, it doesn't like SHELL, "ECHO hi>com3".

Any ideas?
Thanks again for your help. So close.

Guy

jsolos
05-04-2014, 07:03 PM
can you see the message that the Shell command is sending back. That might give us a clue. Also, try to rename that exe to "R_ECHO.exe" or something and change the shell command to call that. That way you will know if you are getting your version of ECHO or the built in DOS one.

Let me know how it goes...