<p>I have been working on a printer project that basically is a 2D printer (dot matrix type). We are using solenoids as actuators to make impressions on the paper. We are now in the process of designing custom software. But a problem that we have encountered is that we have no idea how to design software as we are a bunch of beginners in this field.</p>

<p>An idea we are working on is based on position-acknowledge technique. In this technique the computer sends G-code to the controller. The controller after reaching the position defined in code sends an acknowledgement and the computer then sends the next signal. This is the model we are currently working on. </p>

<ul>
<li>Can anyone suggest any other ideas to make this work? </li>
<li>Is Our approach right? </li>
<li>Do 3D printers work using same technique?</li>
</ul>

[{'answer_id': 7944, 'author': 'Trish', 'author_id': 8884, 'author_profile': 'https://3dprinting.stackexchange.com/users/8884', 'pm_score': 2, 'selected': False, 'text': '<p>3D printer firmware use gcode that is derived from CNC and no acknowledgment. They send movement commands to the stepper motors like <code>G1 X10 Y10</code> to move the printhead 10 mm along the X and Y.</p>\n\n<p>You could use a ready 3D printer firmware like Marlin on a 3d printer board and use the X-axis or extruder output to couple to your solenoid, sending a <code>G1 Z0.1</code> or <code>G1 E0.1</code>, which will actuate it for a short time. You might even use E and Z on different solenoids.</p>\n'}, {'answer_id': 7946, 'author': '0scar', 'author_id': 5740, 'author_profile': 'https://3dprinting.stackexchange.com/users/5740', 'pm_score': 1, 'selected': False, 'text': '<p>Are you interested in receiving the instructions correctly, or interested in how the instructions are executed by the hardware? This answer doesn\'t go into the software communication between controller board and software that sends the instruction from another software/hardware platform  (see <a href="https://3dprinting.stackexchange.com/a/7947/">this answer</a>), this answer addresses the positioning/movement. </p>\n\n<p>Most of current 3D printers do not track the position of the print head. The software instructs the head to go somewhere, but it never checks if it actually arrives at that exact position. Problems like missing steps of the stepper or skipping notches on the belt are not detected and the printer will continue thinking it has reached the position.</p>\n\n<p>Skipping of belts is a mechanical issue and should not occur (nor can be detected unless there are stepper steps missed), but skipping of steps is something that can be detected by certain type of stepper drivers (trinamic). Steppers do not use a feedback loop to check the final position. Servos, opposed to steppers, use a feedback loop, and as such are able to reach the position as instructed, but this comes a an increased cost, servo\'s are more expensive and hence not found in most of the "cheaper" 3D printing machines.</p>\n\n<p>It is up to the designer of a 3D machine to choose the motors for the positioning system, if it is not highly loaded, you go for steppers without a feedback loop, or in higher loaded machines for servo\'s (basically steppers with some positioning electronics for the feedback). In case of a stepper you hope that it reaches the destination you tell it to go to, for a servo, you known that it reaches that exact position. </p>\n\n<p>To get back on topic of your question, there is no feedback on reaching the position (you call this acknowledgement), you just send the G-codes sequentially or in a buffer to the printer electronics which executes the statements one at the time (this is done by the firmware, this <a href="https://3dprinting.stackexchange.com/a/7947/5740">this answer</a> for replies of the machine on the code it receives). It is your choice of the hardware that actually determines whether this is executed like instructed. Do note that most machines are not highly loaded (the 3D printhead is not very heavy and <em>normally</em> does not hit any obstruction in its path as Z advances) justifying the use of steppers without the need for feedback. CNC machines, certainly the larger ones, that position a highly loaded cutting tool need such a feedback loop as the positioning needs to be very exact. You need to consider the forces at play in your paper punch machine, but from my point of view, your machine does not seem to be highly loaded. In such a case you are not in need for a more expensive positioning system, nor the need for the processing of a return/feedback signal in your custom software.</p>\n'}, {'answer_id': 7947, 'author': 'Sean Houlihane', 'author_id': 4927, 'author_profile': 'https://3dprinting.stackexchange.com/users/4927', 'pm_score': 2, 'selected': False, 'text': '<p>You appear to be asking about rate-limiting the stream of G-code provided by the computer, but some more context in your question will help if this is not the case.</p>\n\n<p>Printers tend to work in two ways.</p>\n\n<ol>\n<li><p>Read G-code from local storage as a text file. Here, the parser/control engine is in full control.</p></li>\n<li><p>Stream G-code over a serial port using an \'ack\' handshake.</p></li>\n</ol>\n\n<p>The reference for G-code used in 3D printing is the <a href="https://reprap.org/wiki/G-code#Replies_from_the_RepRap_machine_to_the_host_computer" rel="nofollow noreferrer">RepRap Wiki</a>. Here you will find responses such as <code>ok</code> <code>resend</code> and <code>fatal</code>, these indicate when a previous command is processed and something else can be sent, if the previous message was identified as corrupt, or if recovery is impossible.</p>\n\n<p>The basic rule for this style of handshake is that after every host to slave transaction, the host <strong>must</strong> wait for some response before sending another transaction. The slave could send either ACK responses, or other asynchronous transactions if you can design the system to avoid or not care about overrun in the slave to host direction.</p>\n\n<p>When designing a handshake like this, you can consider all possible ways for something to go wrong (assume the interface is imperfect). How can you handle a request being missed and no ACK ever? When there is a timeout, can you make a \'benign\' request to see if the printer is still connected, etc.</p>\n'}, {'answer_id': 13553, 'author': 'Adrian Maire', 'author_id': 12615, 'author_profile': 'https://3dprinting.stackexchange.com/users/12615', 'pm_score': 0, 'selected': False, 'text': '<p>The CNC system, and simplifying intentionally, is divided into several steps:</p>\n\n<ol>\n<li><strong>Acquisition of the g-code</strong>: This depends on the platform, whether is a file from an USB flash-memory, network or direct input from the operator. G-code operations needs to be buffered in a quantity enough to allow some "look-ahead" in the program.</li>\n<li><strong>Parsing of the g-code</strong>: Parsing of any formal language is based on "formal grammars" theory <a href="https://en.wikipedia.org/wiki/Formal_grammar" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Formal_grammar</a>. Fortunately, g-code is one of the simplest grammar of the Chomsky hierarchy. Language parsing is a full topic in itself, and it follows lexical, syntactical and semantical analysis.</li>\n<li><p><strong>Driving</strong>: It exists several different strategies:</p>\n\n<ul>\n<li><strong>Open-loop vs closed loop</strong>: In closed-loop CNC, sensors provide a feedback from the movement, allowing the driver to fix deviations (e.g. no step lots). Those systems are more expensive and usually not available in cheap 3D printers. In open-loop CNC, the driver send signals and "hope" the machine will follow, this is the case of most cheap 3D-printers, where if you block the head, it will lose steps.</li>\n<li><strong>Synchronous vs asynchronous</strong> (not sure about this naming): In synchronous systems, the driver send a single step for each axis each loop (one step forward, no step, or one step backward for each of the x, y, z, a... axis). In each iteration, the driver establish which steps need to be activated and send it; the speed of the movement depends on how fast this loop is performed. In Asynchronous driving, the loop run at a specific speed and apply steps as needed to correct the distance between the previous/detected position and the expected position.</li>\n</ul></li>\n</ol>\n\n<p>Acquisition and parsing of g-code can be performed in soft real-time, however the driving needs hard real-time, which precision determine the maximum speed that your CNC can manage.</p>\n\n<p>The servos/steppers usually cannot manage infinite acceleration, this is why the system needs to read g-code instructions ahead to anticipate closed angles or changes in direction. It should then reduce the indicated speed down to something which allows the next instruction.</p>\n\n<p>I hope this give a quick introduction to the topic, obviously, each aspect needs further reading.</p>\n'}]
['https://3dprinting.stackexchange.com/questions/7943', 'https://3dprinting.stackexchange.com', 'https://3dprinting.stackexchange.com/users/14172/']