algorithmic modeling for Rhino
Hi guys,
I'm communicating with a 3D printer via Grasshopper / Firefly (and eventually) Silkworm.
So far, I can quite happily send G-Code move commands to the printer - which is a Leapfrog Creatr, based on Arduino Mega / RAMPS electronics - via the generic Serial Write command.
I also want to get a return feed of information, which will basically tell me when the printhead has reached its destination (so normally sending the printer a code 'M114' will get it to return a string along the lines of :
X:100.00Y:15.00Z1.20E:0.00 Count X:100.00Y:15.00Z1.20E:0.00
ok
you can see this works in an arduino serial monitor window from the screenshot below.
Unfortunately I can't seem to get the generic "Serial Read" block to work for me in Grasshopper. (I do have the arduino serial monitor closed, and the "Hurray" message is displaying)
When I write a log file, the txt file does grow, but full of empty lines.
I'm stumped, really - there are lots of other people who have asked this question / had this problem, but unfortunately most of them never explained how they got it working when they did....
Thanks in advance
Fergal
Tags:
Hi Fergal,
Thanks for your question. To be honest... I think your issue is somewhat of a unique and new issue... but something I've been looking into recently. You see all of the Read/Write components (including the Generic versions) don't wait to receive a call back message from the Arduino... basically the Write components send the data whenever Grasshopper computes a new solution (whether that's from a timer upstream or someone moving a slider... it sends the latest message as soon as possible).
What you're describing is a way in which Grasshopper manages a list of instructions and waits for a call back from the Arduino before issuing the next command. I've recently been re-working the stepper component so that it incorporates this new functionality... and it seems to be working pretty well. I had to re-work the Stepper Firmata as well as the component itself... but I think in general it works well. However, currently the stepper component sends a specific string to work with the Stepper Firmata sketch... It isn't necessarily suited to send any generic message you want.
However, I've recently also been working with Erik Luhtala who is building his own CNC milling machine and he would like to be able to use Firefly to stream G-code directly to the Arduino in the same manner your describing (using the call back function once each command has been implemented). So, I'm thinking of modifying the stepper component to be able to send any generic list of string data (ie. g-code) using this call back communication method. I think this would work for what you're trying to do too. I'm not sure when this will be available, but hopefully soon.
-Andy
Hi Andy,
Thanks for such a quick reply!...
So that makes a little more sense now! - I spent a lot of the morning reading and trying to understand your thread on the Arduino forum where you were discussing the original VB code required to make the Firefly components function. Very interesting, though quite tricky by the end!
What I am still a little confused (and perhaps I'm missing something in your reply) about is why the Generic Read is constantly reading 'empty' when enabled or 'null' when not - even when data is certainly being sent down the usb line (Hyperterminal, Arduino Serial Mon and Pronterface all receive and read data back, for the same commands i send from firefly) For example, after any command the Leapfrog printer will reply 'ok', but I can't even get that to appear.
Earlier, after thinking that it may be a mutual exclusivity / duplex issue, where Firefly wasn't happy to have read and write happening at the same time, I set up the sketch as per the image attached, with a button component to enable write, which then ran through a NOT gate to enable read. A temporary push of the button would write all the commands down usb to the printers buffer, then switch 'Read' back on . I had put a 3 second 'pause' gcode command early on, to make sure it wasn't all executing too quickly, and I was missing the reading of the return data. Still, there wasn't a blip in the log.
I also tried a Playback function with some gcode in the txt file, set at 500ms, to see if that got a return, but alas no!..
..I cant help feel i'm missing a tiny crucial detail!
I'm really delighted that you're working on something similar with Erik. I've spent the last few days pondering how I'd get sequential commands to send, but only after a call back like you describe, so it's very exciting to know you're working on that. It will be very exciting when Grasshopper will be capable to output directly to a printer, with proper feedback / closed loop control!
Thanks again!
Fergal
Hi,
So I created a little hardware workaround that quite does the trick, it seems!
Basically, I connected a pair of wires to one of stepper drivers (which automatically 'step' between +24V and -24V (square wave), as the printhead moves with a G1 command.
I rectified this signal, and smoothed it with a capacitor, which gave me a constant +24V signal during an 'extrude' phase. I limited this signal to 5V (using a 7805 chip) and then limited the current to ~40mA (using an LM338 limiter). This then gives me a safe signal for a second Arduino to monitor, completely independent of printer and its firmware quirks.
The system can now self monitor itself, with the Arduino passing back line numbers back to Firefly as it counts them. It also allows me to control multiple extrude heads and tools on the fly!
So it's not uber elegant, as solutions go...but as a hack to get out of a hole, it works....
And maybe this could be of use to someone else
-Fergal
Cool. Nice solution. Would love to see a picture of your circuit.
-Andy
Hey Andy,
Sure. Here's a photo attached
I ended up having to add an opto-isolator just before the arduino input, as it there seemed to be a bit of a conflict with common ground across the system otherwise.
...Or more useful than a picture of a not very neat circuit, here's a schematic :
Hi Andy,
I have been searching all over the internet for a solution and finally found this thread!! Any updates on this? It would be a huge thing for the gcode folks. In my case, a 3d printer with marlin firmware.
Cheers!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 1 Comment 0 Likes
© 2024 Created by Scott Davidson. Powered by