python 3d打印机

by Nikolay Khabarov

通过尼古拉·哈巴罗夫(Nikolay Khabarov)

如何使用Python构建自己的CNC控制器和3D打印机 (How you can use Python to build your own CNC controller and 3D printer)

This article discusses the process I used to build the first ever CNC machine controller implementation on pure Python.

本文讨论了我用来在纯Python上构建第一个CNC机床控制器实现的过程。

Computer numerical control (CNC) machine controllers are typically implemented using the C or C++ programming language. They run on OS-less or real-time operating systems with simple microcontrollers.

计算机数控(CNC)机器控制器通常使用C或C ++编程语言来实现。 它们在无操作系统或具有简单微控制器的实时操作系统上运行。

In this article, I’ll describe how to build a CNC controller — a 3D printer in particular — using modern ARM boards (Raspberry Pi) with a modern high level language (Python).

在本文中,我将介绍如何使用具有现代高级语言(Python)的现代ARM板(树莓派)来构建CNC控制器(尤其是3D打印机)。

Such a modern approach opens a wide range of integration options with other cutting edge technologies, solutions, and infrastructures. This makes the whole project developer-friendly.

这种现代方法为与其他前沿技术,解决方案和基础架构的集成提供了广泛的选择。 这使整个项目对开发人员友好。

关于该项目 (About the Project)

Modern ARM boards typically use Linux as a reference operating system. This gives us access to the entire Linux infrastructure with all the Linux software packages. We can host a web server on a board, use Bluetooth connectivity, use OpenCV for image recognition, and build a cluster of boards, among other things.

现代ARM板通常使用Linux作为参考操作系统。 这使我们可以使用所有Linux软件包访问整个Linux基础结构。 我们可以在板上托管Web服务器,使用蓝牙连接,使用OpenCV进行图像识别以及构建板集群等。

These are well-known tasks that can be implemented on ARM boards, and they can be really useful for custom CNC machines. For example, auto-positioning using compuvision can be very handy for some machines.

这些是可以在ARM板上执行的众所周知的任务,它们对于自定义CNC机器非常有用。 例如,对于某些机器,使用compupvision自动定位可能非常方便。

Linux is not a real-time operating system. This means we can’t generate pulses with the required timings to control stepper motors directly from the board pins with running software, even as a kernel module. So, how can we use steppers and high-level Linux features? We can use two chips — one microcontroller with a classic CNC implementation, and an ARM board connected to this microcontroller via UART (universal asynchronous receiver-transmitter).

Linux不是实时操作系统。 这意味着我们无法使用运行软件(甚至是内核模块)从具有所需时序的脉冲直接从板针直接控制步进电机。 那么,我们如何使用步进器和高级Linux功能? 我们可以使用两块芯片-一个具有经典CNC实现的微控制器,以及一个通过UART(通用异步收发器)连接到该微控制器的ARM板。

What if there are no suitable firmware features for this microcontroller? What if we need to control additional axes that are not implemented in the microcontroller? Any modifications to the existing C/C++ firmware will require plenty of development time and efforts. Let’s see if we can make it easier and even save money on microcontrollers by simply removing them.

如果该微控制器没有合适的固件功能怎么办? 如果我们需要控制微控制器中未实现的其他轴怎么办? 对现有C / C ++固件的任何修改都将需要大量的开发时间和精力。 让我们看看是否可以通过简单地删除微控制器来使它变得更容易甚至省钱。

氯化萘 (PyCNC)

PyCNC is a free open-source high-performance G-code interpreter and CNC/3D-printer controller. It can run on various Linux-powered, ARM-based boards, such as Raspberry Pi, Odroid, Beaglebone, and others. This gives you the flexibility to pick any board and use everything that Linux offers. And you can keep the entire G-code runtime on one board without the need for a separate microcontroller for real-time operation.

PyCNC是一个免费的开源高性能G代码解释器和CNC / 3D打印机控制器。 它可以在各种基于Linux的基于ARM的板上运行,例如Raspberry Pi,Odroid,Beaglebone等。 这使您可以灵活地选择任何板并使用Linux提供的所有功能。 而且,您可以将整个G代码运行时保持在一块板上,而无需单独的微控制器进行实时操作。

Choosing Python as the main programming language significantly reduces the code base compared to C/C++ projects. It also reduces the boilerplate and microcontroller-specific code, and makes the project accessible to a wider audience.

与C / C ++项目相比,选择Python作为主要编程语言会大大减少代码库。 它还减少了样板代码和微控制器特定的代码,并使该项目可供更广泛的受众使用。

这个怎么运作 (How it works)

The project uses DMA (Direct Memory Access) on the chip hardware module. It simply copies the GPIO (General Purpose Input Output) states buffer allocated in RAM to the actual GPIO registers. This copying process is synchronized by the system clock and works completely independently from the CPU cores. Thus, a sequence of pulses for the stepper motor’s axis is generated in memory and then the DMA precisely sends them out.

该项目在芯片硬件模块上使用DMA(直接内存访问)。 它仅将RAM中分配的GPIO(通用输入输出)状态缓冲区复制到实际的GPIO寄存器。 该复制过程由系统时钟同步,并且完全独立于CPU内核而工作。 因此,在内存中生成了一个用于步进电机轴的脉冲序列,然后DMA精确地将其发送出去。

Let’s dig deeper into the code to understand the basics and how to access hardware modules from Python.

让我们深入研究代码以了解基础知识以及如何从Python访问硬件模块。

通用输入输出 (GPIO)

A General Purpose Input Output module controls pin states. Each pin can have low or high state. When we program the micro-controller, we usually use SDK (software development kit) defined variables to write to that pin. For example, to enable a high state for pins 1 and 3:

通用输入输出模块控制引脚状态。 每个引脚可以具有低电平或高电平状态。 对微控制器进行编程时,通常使用SDK(软件开发套件)定义的变量来写入该引脚。 例如,要使引脚1和3处于高电平状态:

PORTA = (1 << PIN1) | (1 << PIN3)

If you look in the SDK, you will find the declaration of this variable, and it will look similar to:

如果查看SDK,则会发现此变量的声明,它的外观类似于:

#define PORTA (*(volatile uint8_t *)(0x12345678))

It’s just a pointer. It doesn’t point to the location in RAM, but to the address of the physical processor. The actual GPIO module is located at this address.

这只是一个指针。 它不是指向RAM中的位置,而是指向物理处理器的地址。 实际的GPIO模块位于此地址。

To manage pins, we can write and read data. Raspberry Pi’s ARM processor is not an exception, and it has the same module. To control pins, we can write/read data. We can find the addresses and data structures in the official documentation for processor peripherals.

要管理引脚,我们可以写入和读取数据。 Raspberry Pi的ARM处理器也不例外,它具有相同的模块。 为了控制引脚,我们可以写入/读取数据。 我们可以在处理器外围设备的官方文档中找到地址和数据结构。

When we run a process in the user’s runtime, the process starts in the virtual address space. The actual peripheral is accessible directly. But we can still access real physical addresses with ‘/dev/mem’ device.

当我们在用户的运行时中运行一个进程时,该进程在虚拟地址空间中启动。 实际的外围设备可直接访问。 但是我们仍然可以使用'/dev/mem'设备访问真实的物理地址。

Here is some simple code in Python that controls a pin’s state using this approach:

这是Python中的一些简单代码,可以使用这种方法控制引脚的状态:

Let’s break it down line by line:

让我们逐行将其分解:

Lines 1–6: headers, imports.

第1至6行 :标头,导入。

Line 7: open ‘/dev/mem’ device access to the physical address.

第7行 :打开'/dev/mem'设备访问物理地址。

Line 8: we use the mmap system call to map a file (though in our case, this file represents physical memory) into the process’s virtual memory. We specify the length and offset of the map area. For the length, we take the page size. And the offset is 0x3F200000.

第8行 :我们使用mmap系统调用将文件(尽管在本例中,该文件代表物理内存)映射到进程的虚拟内存中。 我们指定地图区域的长度和偏移量。 对于长度,我们采用页面大小。 偏移量为0x3F200000

The documentation says that the bus address 0x7E200000 contains GPIO registers, and we need to specify the physical address. The documentation says (page 6, paragraph 1.2.3) that the 0x7E000000 bus address is mapped to the 0x20000000 physical address, but this documentation is for Raspberry 1. Please note that all module bus addresses are the same for Raspberry Pi 1–3, but this map was changed to 0x3F000000 for RPi 2 and 3. So, the address here is 0x3F200000. For Raspberry Pi 1, change it to 0x20200000.

该文档说总线地址0x7E200000包含GPIO寄存器,我们需要指定物理地址。 文档说(第6页,第1.2.3节), 0x7E000000总线地址已映射到0x20000000物理地址,但是本文档适用于Raspberry1。请注意,Raspberry Pi 1-3的所有模块总线地址均相同,但是对于RPi 2和3,此映射已更改为0x3F000000 。因此,此处的地址为0x3F200000 。 对于Raspberry Pi 1,将其更改为0x20200000

After this, we can write to our process’s virtual memory, but it actually writes to the GPIO module.

此后,我们可以写入进程的虚拟内存,但实际上是写入GPIO模块。

Line 9: close the file handle, since we don’t need to store it.

第9行 :关闭文件句柄,因为我们不需要存储它。

Lines 11–14: we read and write to our map with the 0x08 offset. According to the documentation, it is the GPFSEL2 GPIO Function Select 2 register. And this register controls pin functions.

第11至14行 :我们以0x08偏移量读写地图。 根据文档,它是GPFSEL2 GPIO功能选择2寄存器。 该寄存器控制引脚功能。

We set (clear all, then set with the OR operator) 3 bits with the 3rd bit set to 001. This value means that the pin works as an output. There are many pins and possible modes for them. This is why the register for modes is divided into several registers, where each contains the modes for 10 pins.

我们设置(清除所有,然后用OR运算符设置)3位,并将第3位设置为001 。 该值表示该引脚用作输出。 有许多引脚和可能的模式。 这就是为什么模式寄存器分为几个寄存器,每个寄存器包含10个引脚的模式的原因。

Lines 16 and 22: set up the ‘Ctrl+C’ interruption handler.

第16和22行 :设置“ Ctrl + C”中断处理程序。

Line 17: infinite loop.

第17行 :无限循环。

Line 18: set the pin to the high state by writing to the GPSET0 register.

第18行 :通过写入GPSET0寄存器将引脚设置为高电平状态。

Please note, Raspberry Pi doesn’t have registers like PORTA (AVR microcontrollers) have. We can’t write the whole GPIO state of all pins. There are just set and clear registers which are used to set and clear specified with bitwise mask pins.

请注意,Raspberry Pi没有像PORTA(AVR微控制器)那样的寄存器。 我们不能写所有引脚的整个GPIO状态。 仅有设置清除寄存器,用于设置和清除按位屏蔽引脚指定的寄存器。

Lines 19 and 21: delay

第19和21行 :延迟

Line 20: set pin to low state with the GPCLR0 register.

第20行 :使用GPCLR0寄存器将引脚设置为低电平状态。

Lines 25 and 26: switch pin to default, input state. Close the memory map.

第25和26行 :将引脚切换为默认输入状态。 关闭内存映射。

This code should be run with superuser privileges. Name the file ‘gpio.py’ and run it with ‘sudo python gpio.py’. If you have a LED connected to pin 21, it will blink.

该代码应以超级用户权限运行。 将文件命名为'gpio.py'并使用'sudo python gpio.py'运行它。 如果您有一个LED连接到引脚21,它将闪烁。

DMA (DMA)

Direct Memory Access is a special module that is designed to copy memory blocks from one area to another. We will copy data from the memory buffer to the GPIO module. First of all, we need a solid area in physical RAM that will be copied.

直接内存访问是一个特殊的模块,旨在将内存块从一个区域复制到另一个区域。 我们将数据从内存缓冲区复制到GPIO模块。 首先,我们需要将要复制的物理RAM中的固定区域。

There are few possible solutions:

可能的解决方案很少:

  1. We can create a simple kernel driver that will allocate, lock, and report to us the address of this memory.
    我们可以创建一个简单的内核驱动程序,它将分配,锁定并向我们报告该内存的地址。
  2. In some implementations, virtual memory is allocated and uses ‘/proc/self/pagemap’ to convert the address to the physical one. I wouldn't recommend this approach, especially when we need to allocate big area. Any virtually allocated memory (even locked, see the kernel documentation) can be moved to the physical area.

    在某些实现中,虚拟内存被分配并使用'/proc/self/pagemap'将地址转换为物理地址。 我不推荐这种方法,特别是当我们需要分配大面积的时候。 任何虚拟分配的内存(即使已锁定,也请参阅内核文档 )都可以移至物理区域。

  3. All Raspberry Pi have a ‘/dev/vcio’ device, which is a part of the graphic driver and can allocate physical memory for us. An official example shows how to do it. And we can use it instead of creating our own.

    所有的Raspberry Pi都有一个'/dev/vcio'设备,该设备是图形驱动程序的一部分,可以为我们分配物理内存。 一个官方示例显示了如何执行此操作。 而且我们可以使用它而不是创建我们自己的。

The DMA module itself is just a set of registers that are located somewhere at a physical address. We can control this module via these registers. Basically, there are source, destination, and control registers. Let’s check some simple code that shows how to use the DMA modules to manage the GPIO.

DMA模块本身就是一组位于物理地址某处的寄存器。 我们可以通过这些寄存器控制此模块。 基本上,有源,目标和控制寄存器。 让我们检查一些简单的代码,这些代码显示了如何使用DMA模块来管理GPIO。

Since additional code is required to allocate physical memory with ‘/dev/vcio’, we will use a file with an existing CMA PhysicalMemory class implementation. We will also use the PhysicalMemory class, which performs the trick with memap from the previous sample.

由于额外的代码需要分配物理内存'/dev/vcio' ,我们将使用一个文件与现有的CMA PhysicalMemory类实现。 我们还将使用PhysicalMemory类,该类使用上一个示例中的memap执行技巧。

Let’s break it down line by line:

让我们逐行将其分解:

Lines 1–3: headers, imports.

第1至3行 :标头,导入。

Lines 5–6: constants with the channel DMA number and GPIO pin that we will use.

第5-6行 :常量,我们将使用通道DMA编号和GPIO引脚。

Lines 8–15: initialize the specified GPIO pin as an output, and light it up for a half second for visual control. In fact, it’s the same thing we did in the previous example, written in a more pythonic way.

第8-15行 :将指定的GPIO引脚初始化为输出,并点亮半秒以进行可视控制。 实际上,这与我们在前面的示例中所做的相同,只是使用了更多的Python语言。

Line 17: allocates 64 bytes in physical memory.

第17行 :在物理内存中分配64个字节。

Line 18: creates special structures — control blocks for the DMA module. The following lines break the structure of this block. Each field has a length of 32 bit.

第18行 :创建特殊结构-DMA模块的控制块。 以下几行中断了此块的结构。 每个字段的长度为32位。

Line 19: transfers information flags. You can find a full description of each flag on page 50 of the official documentation.

第19行 :传输信息标志。 您可以在官方文档的第50页上找到每个标志的完整说明。

Line 20: source address. This address must be a bus address, so we call get_bus_address(). The DMA control block must be aligned by 32 bytes, but the size of this block is 24 bytes. So we have 8 bytes, which we use as storage.

第20行 :源地址。 该地址必须是总线地址,因此我们调用get_bus_address() 。 DMA控制块必须对齐32个字节,但是此块的大小为24个字节。 因此,我们有8个字节,用作存储空间。

Line 21: destination address. In our case, it’s the address of the SET register of the GPIO module.

第21行 :目标地址。 在我们的例子中,它是GPIO模块的SET寄存器的地址。

Line 22: transmission length — 4 bytes.

第22行 :传输长度4个字节。

Line 23: stride. We do not use this feature, set 0.

第23行 :大步向前。 我们不使用此功能,设置为0

Line 24: address of the next control block, in our case, next 32 bytes.

第24行 :下一个控制块的地址,在本例中为下一个32字节。

Line 25: padding. But since we used this address as a data source, put a bit, which should trigger GPIO.

第25行 :填充。 但是,由于我们将此地址用作数据源,因此请放置一点,这将触发GPIO。

Line 26: padding.

第26行 :填充。

Lines 28–37: fill in the second DMA control block. The difference is that we write to CLEAR GPIO register and set our first block as a next control block to loop the transmission.

第28–37行 :填写第二个DMA控制块。 区别在于我们写入CLEAR GPIO寄存器,并将我们的第一个块设置为循环传输的下一个控制块。

Lines 38–39: write control blocks to physical memory.

第38–39行 :将控制块写入物理内存。

Line 41: get the DMA module object with the selected channel.

第41行 :获取具有所选通道的DMA模块对象。

Lines 42–43: reset the DMA module.

第42–43行 :重置DMA模块。

Line 44: specify the address of the first block.

第44行 :指定第一个块的地址。

Line 45: run the DMA module.

第45行 :运行DMA模块。

Lines 49–52: clean up. Stop the DMA module and switch the GPIO pin to the default state.

第49–52行 :清理。 停止DMA模块,并将GPIO引脚切换为默认状态。

Let’s connect the oscilloscope to the specified pin and run this application (do not forget about sudo privileges). We will observe ~1.5 MHz square pulses:

让我们将示波器连接到指定的引脚并运行该应用程序(不要忘记sudo特权)。 我们将观察到约1.5 MHz的方波:

DMA挑战 (DMA challenges)

There are several things that you should take into consideration before building a real CNC machine.

在构建真正的CNC机床之前,您需要考虑几件事。

First, the size of the DMA buffer can be hundreds of megabytes.

首先,DMA缓冲区的大小可以为数百兆字节。

Second, the DMA module is designed for a fast data copying. If several DMA channels are working, we can go beyond the memory bandwidth, and buffer will be copied with delays that can cause jitters in the output pulses. So, it’s better to have some synchronization mechanism.

其次,DMA模块设计用于快速数据复制。 如果几个DMA通道正在工作,我们将超出内存带宽,缓冲区将被复制,延迟会导致输出脉冲抖动。 因此,最好具有一些同步机制。

To overcome this, I created a special design for control blocks:

为了克服这个问题,我为控制块创建了一个特殊的设计:

The oscillogram at the top of the image shows the desired GPIO states. The blocks below represent the DMA control blocks that generate this waveform. “Delay 1” specifies the pulse length, and “Delay 2” is the pause length between pulses. With this approach, the buffer size depends only on the number of pulses.

图像顶部的波形图显示了所需的GPIO状态。 下面的块表示产生此波形的DMA控制块。 “延迟1”指定脉冲长度,“延迟2”是脉冲之间的暂停长度。 使用这种方法,缓冲区大小仅取决于脉冲数。

For example, for a machine with 200mm travel length and 400 pulses per mm, each pulse would take 128 bytes (4 control blocks per 32 bytes), and the total size will be ~9.8MB. We would have more than one axis, but most of the pulses would occur at the same time. And it would be dozens of megabytes, not hundreds.

例如,对于行程长度为200mm的机器和每毫米400个脉冲的机器,每个脉冲将占用128字节(每32字节4个控制块),总大小约为9.8MB。 我们将有多个轴,但大多数脉冲将同时发生。 它将是几十兆字节,而不是数百兆字节。

I solved the second challenge, related to synchronization, by introducing temporary delays through the control blocks. The DMA module has a special feature: it can wait for a special ready signal from the module where it writes data. The most suitable module for us is the PWM (pulse width modulation) module, which will also help us with synchronization.

我通过在控制块中引入了临时延迟来解决了与同步有关的第二个挑战。 DMA模块具有一个特殊功能:它可以等待来自其写入数据的模块的特殊就绪信号。 最适合我们的模块是PWM(脉冲宽度调制)模块,它也将帮助我们进行同步。

The PWM module can serialize the data and send it with fixed speed. In this mode, it generates a ready signal for the FIFO (first in, first out) buffer of the PWM module. So, let’s write data to the PWM module and use it only for synchronization.

PWM模块可以序列化数据并以固定速度发送。 在这种模式下,它将为PWM模块的FIFO(先进先出)缓冲器生成就绪信号。 因此,让我们将数据写入PWM模块,并将其仅用于同步。

Basically, we would need to enable a special flag in the perceptual mapping of the transfer information flag, and then run the PWM module with the desired frequency. The implementation is quite long — you can study it yourself.

基本上,我们需要在传输信息标志的感知映射中启用特殊标志,然后以所需的频率运行PWM模块。 实现时间很长-您可以自己研究 。

Instead, let’s create some simple code that can use the existing module to generate precise pulses.

相反,让我们创建一些简单的代码,可以使用现有模块生成精确的脉冲。

import rpgpio
PIN=21PINMASK = 1 << PINPULSE_LENGTH_US = 1000PULSE_DELAY_US = 1000DELAY_US = 2000 g = rpgpio.GPIO()g.init(PIN, rpgpio.GPIO.MODE_OUTPUT) dma = rpgpio.DMAGPIO()for i in range(1, 6): for i in range(0, i): dma.add_pulse(PINMASK, PULSE_LENGTH_US) dma.add_delay(PULSE_DELAY_US) dma.add_delay(DELAY_US)dma.run(True) raw_input(“Press Enter to stop”)dma.stop()g.init(PIN, rpgpio.GPIO.MODE_INPUT_NOPULL)

The code is pretty simple, and there is no need to break it down. If you run this code and connect an oscilloscope, you will see:

代码很简单,不需要分解。 如果运行此代码并连接示波器,则会看到:

And now we can create real G-code interpreter and control stepper motors. But wait! It is already implemented here. You can use this project, as it’s distributed under the MIT license.

现在,我们可以创建真正的G代码解释器并控制步进电机。 可是等等! 它已经在这里实现。 您可以使用此项目,因为它是根据MIT许可证分发的。

硬件 (Hardware)

The Python project can be adopted for your purposes. But in order to inspire you, I will describe the original hardware implementation of this project — a 3D printer. It basically contains the following components:

可以根据需要使用Python项目。 但是为了激发您的灵感,我将介绍该项目的原始硬件实现-3D打印机。 它基本上包含以下组件:

  1. Raspberry Pi 3
    树莓派3
  2. RAMPSv1.4 board

    RAMPSv1.4板

  3. 4 A4988 or DRV8825 module
    4个A4988或DRV8825模块
  4. RepRap Prusa i3 frame with equipment (end-stops, motors, heaters, and sensors)
    RepRap Prusa i3框架,带设备(终端挡块,电机,加热器和传感器)
  5. 12V 15A power supply unit
    12V 15A电源单元
  6. LM2596S DC-DC step down converter module
    LM2596S DC-DC降压转换器模块
  7. MAX4420 chip
    MAX4420芯片
  8. ADS1115 analog to digital converter module
    ADS1115模数转换器模块
  9. UDMA133 IDE ribbon cable
    UDMA133 IDE带状电缆
  10. Acrylic glass
    亚克力玻璃
  11. PCB stands
    PCB支架
  12. Set of connectors with 2.54mm step
    一组2.54mm台阶的连接器

The 40-pin IDE ribbon cable is suitable for the Raspberry Pi 40 pins connector, but the opposite end requires some work. Cut off the existing connector from the opposite end and crimp connectors to the cable wires.

40针IDE带状电缆适用于Raspberry Pi 40针连接器,但另一端需要做一些工作。 从相反的一端切断现有的连接器,然后将连接器压接到电缆上。

The RAMPSv1.4 board was originally designed for connection to the Arduino Mega connector, so there is no easy way to connect this board to the Raspberry Pi. The following method allows you to simplify the boards connection. You will need to connect less than 40 wires.

RAMPSv1.4开发板最初是为连接Arduino Mega连接器而设计的,因此没有简便的方法将该开发板连接至Raspberry Pi。 以下方法可以简化电路板的连接。 您将需要连接少于40根电线。

I hope this connection diagram is fairly simple and easily duplicated. It’s better to connect some pins (2nd extruder, servos) for future use, even if they are not currently needed.

我希望此连接图相当简单并且易于复制。 最好连接一些引脚(第二个挤出机,伺服器)以备将来使用,即使当前不需要它们也是如此。

You might be wondering — why do we need the MAX4420 chip? The Raspberry Pi pins provide 3.3V for the GPIO outputs, and the pins can provide very small current. It’s not enough to switch the MOSFET (Metal Oxide Semiconductor Field Effect Transistor) gate. In addition, one of the MOSFETs works under the 10A load of a bed heater. As a result, with a direct connection to a Raspberry Pi, this transistor will overheat. Therefore, it is better to connect a special MOSFET driver between the highly loaded MOSFET and Raspberry Pi. It can switch the MOSFET in a an efficient way and reduce its heating.

您可能想知道-为什么我们需要MAX4420芯片? Raspberry Pi引脚为GPIO输出提供3.3V,并且这些引脚可以提供非常小的电流。 仅切换MOSFET(金属氧化物半导体场效应晶体管)栅极是不够的。 此外,其中一个MOSFET在床加热器的10A负载下工作。 结果,直接连接到Raspberry Pi时,该晶体管将过热。 因此,最好在高负载MOSFET和Raspberry Pi之间连接一个特殊的MOSFET驱动器。 它可以有效地切换MOSFET并减少发热。

The ADS1115 is an Analog to Digital Converter (ADC). Since Raspberry Pi doesn’t have an embedded ADC module, I used an external one to measure the temperature from the 100k Ohm thermistors. The RAMPSv1.4 module already has a voltage divider for the thermistors. The LM2596S step down converter must be adjusted to a 5V output, and it is used to power the Raspberry Pi board itself.

ADS1115是模数转换器(ADC)。 由于Raspberry Pi没有嵌入式ADC模块,因此我使用了一个外部模块来测量100k欧姆热敏电阻的温度。 RAMPSv1.4模块已经具有用于热敏电阻的分压器。 LM2596S降压转换器必须调节至5V输出,并且用于为Raspberry Pi板本身供电。

Now it can be mounted on the 3D printer frame and the RAMPSv1.4 board should be connected to the equipped frame.

现在可以将其安装在3D打印机框架上,并将RAMPSv1.4板连接到配备的框架上。

That’s it. The 3D printer is assembled, and you can copy the source code to the Raspberry Pi and run it. sudo ./pycnc will run it in an interactive G-Code shell. sudo ./pycnc filename.gcode will run a G Code file. Check the ready config for Slic3r.

而已。 3D打印机已组装完毕,您可以将源代码复制到Raspberry Pi并运行它。 sudo ./pycnc将在交互式G代码shell中运行它。 sudo ./pycnc filename.gcode将运行一个G代码文件。 检查Slic3r的准备配置 。

And in this video, you can see how it actually works.

在此视频中 ,您可以看到其实际工作原理。

If you found this article useful, please give me some claps so more people see it. Thanks!

如果您觉得这篇文章有用,请给我一些鼓掌,以便更多的人看到。 谢谢!

IoT is all about prototyping ideas quickly. To make it possible we developed DeviceHive, an open source IoT/M2M platform. DeviceHive provides a solid foundation and building blocks to create any IoT/M2M solution, bridging the gap between embedded development, cloud platforms, big data & client apps.

物联网就是关于快速构思想法的一切。 为了使其成为可能,我们开发了DeviceHive ,这是一个开源的IoT / M2M平台。 DeviceHive为创建任何IoT / M2M解决方案提供了坚实的基础和构建块,弥合了嵌入式开发,云平台,大数据和客户端应用之间的差距。

翻译自: https://www.freecodecamp.org/news/how-to-build-a-3-d-printer-using-cnc-controller-in-python-bd3cd5e28516/

python 3d打印机

python 3d打印机_如何使用Python构建自己的CNC控制器和3D打印机相关推荐

  1. python len函数_知识清单Python必备的69个函数,你掌握了吗?

    本文纲要 Python 作为一门高级编程语言,为我们提供了许多方便易用的内置函数,节省了不少开发应用的时间.目前,Python 3.7 共有 69 个内置函数,一些是我们耳熟能详的函数,另一些却不是很 ...

  2. python求加速度_如何利用Python 为自然语言处理加速度

    自去年发布 Python 的指代消解包(coreference resolution package)之后,很多用户开始用它来构建许多应用程序,而这些应用与我们最初的对话应用完全不同. 利用 spaC ...

  3. python优化网站_[练习] 用PYTHON来优化网站中的图片

    我到公司以来,第一次加班,哇,加一晚上加一上午,现在还没下班的迹象,555,困. 对于网站中的一些关键的页面,多重缓存.静态化.程序代码优化--之外,为了提高用户打开页面的速度,图片是必须要优化的. ...

  4. python打印表格_怎么使用python脚本实现表格打印?

    大家在办公学习中,有没有被打印机的功能所惊叹?可能大部分小伙伴并没有在意打印机的实现原理,只知道它是可以复印东西的,当小编提出这个问题的时候,那大家有没有考虑过呢?有些小伙伴可能会说这个和我们Pyth ...

  5. python框架漏洞_注意!Python中的10个常见安全漏洞及修复方法

    编写安全的代码很困难,当你学习一门编程语言.一个模块或框架时,你会学习其使用方法.在考虑安全性时,你需要考虑如何避免代码被滥用,Python也不例外,即使在标准库中,也存在着许多糟糕的实例.然而,许多 ...

  6. python递归函数例题_递归案例python

    广告关闭 腾讯云11.11云上盛惠 ,精选热门产品助力上云,云服务器首年88元起,买的越多返的越多,最高返5000元! 而对应的中文翻译 "递归" 却表达了两个意思:"递 ...

  7. python开发中级_针对中级Python开发人员的13个项目构想

    python开发中级 Learning the basics of Python is a wonderful experience. But the euphoria of just learnin ...

  8. 网易图灵学院python公开课_图灵学院 Python全系列教程全栈工程师 python视频教程下载...

    大家怎么说? 老师很好,我认为,若想学好python,应该多练.多想.多看.学习资料不能仅限于老师给定的这些内容,这些毕竟是入门资料 老师讲的真不错,对于我们这种小白来说 也比较容易懂,虽然有些时候自 ...

  9. 高等数学与python高级应用_高等数学——基于Python的实现

    商品详情 书名:高等数学--基于Python的实现 定价:45.8 ISBN:9787121382437 作者:官金兰 版次:第1版 出版时间:2020-07 内容提要: 本书旨在用通俗易懂的语言介绍 ...

最新文章

  1. Centos7+Mysql5.7实现主从复制
  2. SQL优化常用方法41
  3. ECsoop 商品列表页属性筛选区品牌以LOGO形式显示
  4. Boost.MultiIndex 使用 multi_index_container::ctor_args_list 的示例
  5. MySQL高级 - 案例 - 系统性能优化 - 数据源配置
  6. Python开发一个股票类库
  7. 半径为r的均匀带电球体_一半径为R的均匀带电球体,其电荷的体密度为ρ.求(1)球外任一点的电势;(2)球表面上的电势;(3...
  8. 电脑常用音频剪辑软件_5款好用的音频剪辑软件推荐
  9. 关于Java中的对象的哈希值何时相等
  10. spring jdbc_Spring JDBC示例
  11. 遥感图像几何校正 matlab,利用多项式实现图像几何校正(Matlab实现)
  12. 迅为IMX6ULL开发板Linux下电容触摸屏实验-实验程序编写
  13. “Chart“ 图表控件基本操作
  14. oracle 建表 varchar,一个完整的Oracle建表的例子
  15. 阿里云|无影云桌面之初体验,只有一句真滴New Beer
  16. 《领导力与沟通艺术》
  17. IT科技行业发展现状,未来发展方向有哪些?
  18. 从iass向pass转型
  19. 2018 年,WEB前端开发人员应该关注哪些新晋技术?
  20. 建立您的初创企业:通过URL邀请他人

热门文章

  1. 编译原理实验 -- 文法分析
  2. 拉格朗日插值、分段线性插值、三次样条插值
  3. 二分图/二部图(bipartite graph)
  4. AF BAF tuning <5>
  5. 《 Python List 列表全实例详解系列(八)》__随机列表元素
  6. 服务器安装嵌入式系统,嵌入式设备连接云服务器
  7. html dw map,DW制作地图之map标签
  8. 数据结构(从概念到C++实现)
  9. commit your changes or stash them before you can merge 解决方法
  10. log4,log4net,Log4配置,log4net使用实例,.net中使用LOG4输出日志,LOG4纪录日志