开源改变世界!!

将代码移植到 Arduino #2

推推 grbl 2年前 (2023-01-21) 331次浏览

关闭
Highlander01 开启了这个问题 2010 年 3 月 21 日 · 31条评论
 Closed

Porting code to Arduino#2

Highlander01 opened this issue on Mar 21, 2010 · 31 comments

注释

将代码移植到 Arduino #2

寻找一些建议,

我应该使用不同的编译器、上传器吗?你在用什么?它是否需要与 Arduino Mega 附带的不同的硬件上的其他类型的基本固件。

我有程序员记事本 [WinAVR] 来查看代码,但它似乎无法编译和加载到硬件。

所以,我目前正在将 Grbl 代码复制到 Arduino 软件中,然后将其加载到我的 Arduino Mega 硬件中并运行它。为了让它运行,我不得不禁用某些代码行。Arduino 似乎带有 wiring.h 文件。它似乎与以下内容冲突:#include “wiring_serial.h”、beginSerial 等…函数。我四处乱逛,看看是否可以禁用它。

我想我可能还需要做一些其他调整,因为我在 ATMega1280 上运行。我认为您的代码适用于 ATMega168。我想我可以弄清楚这一点。只是一些与序列相关的不同标签。

将代码移植到 Arduino #2
作者

我对复制到 Arduino 中的代码做了一些调整。我在串行程序的末尾添加了数字 2,其中大部分都有效。这让我了解了我无法理解的 Arduino 库。我现在面临的唯一挑战是“SIGNAL(SIG_USART_RECV)”中断似乎在 Arduino 中不起作用。我要么调整了某些东西,要么它与某个地方隐藏的 Arduino 库中可能发生的中断程序冲突。我将对其进行更多修改,并提供更新。

将代码移植到 Arduino #2
作者

以下禁用 Arduino 中 Arduino 的串行功能,以便 Grbl 串行工作。
(虽然仍然有一个中断挑战。我将尝试一个最小的串行程序来尝试解决这个问题)

// 定义 HardwareSerial_h 以抑制 Arduino 标准串行类的加载
#define HardwareSerial_h

将代码移植到 Arduino #2
作者

我做了最简单的程序,并弄清楚了为什么我无法在 Arduino Mega 上获得中断“SIGNAL(SIG_USART_RECV)”。我不得不给它加一个0。“信号(SIG_USART0_RECV)”有效!

将代码移植到 Arduino #2
作者

更新!!!!成功的第一步。我已经使用 Grbl 在我的 x 轴上做了我的第一步。我已经成功地左右移动了它。

在 Arduino 中:我发现手动输入命令有问题。它不会发送回车字符“r/n/”来触发要运行的 gcode 行。所以我临时在一行 gcode 触发器运行的末尾创建了“*”条目。

现在我已经掌握了运行的基础知识,我正在考虑创建一个图形用户界面。您目前使用什么?

我开始学习 python、tcl/tk 和 opengl,以便我可以使用 Linux EMC2 Axis GUI 界面并修改它以发送串行代码行。

将代码移植到 Arduino #2
作者

更新进度

我已经学习了一些 Python 教程,并且正在拼凑一个我自己的简单 USB 轴版本,它可以将数据发送到 Simen grbl / Arduino 板。不过还有很多东西要学。

使用 python 我已经想出了如何:

  • 对来自 Arduino 板的数据进行串行 USB 读取。写应该不难理解。
  • 做 OpenGL 3D 图形程序,我可以在其中绘制和旋转东西
  • 做文本编辑器,我可以在其中打开编辑和保存文件。

I think I now have the basic components figured out. Next I need to put the parts together and do some text string processing on files.

(I am not using much from the emc axis code yet. It is pretty big and I had a hard time finding my way around last time I looked at it. Maybe later.)

将代码移植到 Arduino #2
Member

I’m sorry I haven’t responded before. Need to get github to mail me updates on issues. Didn’t notice until now.

Personally I use the ruby-scripts in the ./scripts-folder of this repository. console uses socat to provide an interactive shell to grbl. stream is a small ruby-program to stream a gcode-file to Grbl. It works quite well, and I have successfully completed a number of milling job using this basic setup – yet a proper desktop client would of course be much, much better.

将代码移植到 Arduino #2

Hello Highlander,
did you get grbl running on a Arduino Mega?
I have no success with the serial communication…

将代码移植到 Arduino #2
Member

I have ported a different variant of Grbl to mega and c++. See
https://github.com/simen/twister. It is not a gantry CNC driver so you can’t
use it as-is (it uses a scara arm and is adapted for 3D deposition
printing), but handles the serial comms and everything using the C++ libs
distributed with Arduino and works well.

Sorry for the late response. We suddenly found our dream home and bought it.
Grbl-development is on hiatus until june.

On Tue, Mar 22, 2011 at 12:39 AM, buddhafragt <
reply@reply.github.com>wrote:

Hello Highlander,
did you get grbl running on a Arduino Mega?
I have no success with the serial communication…

Reply to this email directly or view it on GitHub:
https://github.com/simen/grbl/issues/2#comment_900863

将代码移植到 Arduino #2

Hello Simen,
Thanks for your response,
I make some modifications to run the code in the Arduino DIE, but at least I
take a compiler error message I dont understand:

/Applications/Arduino.app/Contents/Resources/Java/libraries/inc/stepper.c:
In function ‘st_init’:
/Applications/Arduino.app/Contents/Resources/Java/libraries/inc/stepper.c:22
8: error: ‘TCCR2A’ undeclared (first use in this function)
/Applications/Arduino.app/Contents/Resources/Java/libraries/inc/stepper.c:22
8: error: (Each undeclared identifier is reported only once
/Applications/Arduino.app/Contents/Resources/Java/libraries/inc/stepper.c:22
8: error: for each function it appears in.)
/Applications/Arduino.app/Contents/Resources/Java/libraries/inc/stepper.c:22
9: error: ‘TCCR2B’ undeclared (first use in this function)
/Applications/Arduino.app/Contents/Resources/Java/libraries/inc/stepper.c:22
9: error: ‘CS21’ undeclared (first use in this function)
/Applications/Arduino.app/Contents/Resources/Java/libraries/inc/stepper.c:23
0: error: ‘TIMSK2’ undeclared (first use in this function)
/Applications/Arduino.app/Contents/Resources/Java/libraries/inc/stepper.c:23
0: error: ‘TOIE2’ undeclared (first use in this function)

The stepper.c is not declared in the code…. ??

Regards
Michael

Am 08.04.2011 20:51 Uhr schrieb “simen” unter
reply@reply.github.com:

I have ported a different variant of Grbl to mega and c++. See
https://github.com/simen/twister. It is not a gantry CNC driver so you can’t
use it as-is (it uses a scara arm and is adapted for 3D deposition
printing), but handles the serial comms and everything using the C++ libs
distributed with Arduino and works well.

Sorry for the late response. We suddenly found our dream home and bought it.
Grbl-development is on hiatus until june.

On Tue, Mar 22, 2011 at 12:39 AM, buddhafragt <
reply@reply.github.com>wrote:

Hello Highlander,
did you get grbl running on a Arduino Mega?
I have no success with the serial communication…

Reply to this email directly or view it on GitHub:
https://github.com/simen/grbl/issues/2#comment_900863

将代码移植到 Arduino #2

I forgotten to say I try TWISTER….
sure it is not the right place here asking questions about twister…

将代码移植到 Arduino #2
Author

Hello,

Sorry for the late reply. I did not directly get grbl running on mine. It has been a while… but what I did was to modify it some/minor changes/plus some preferences added in and I made a version that was slightly different. I hate to stray from the base but I did.

Date: Mon, 21 Mar 2011 16:39:41 -0700
From: reply@reply.github.com
To: gooder01@hotmail.com
Subject: Re: [GitHub] Porting code to Arduino [simen/grbl GH-2]

Hello Highlander,
did you get grbl running on a Arduino Mega?
I have no success with the serial communication…

Reply to this email directly or view it on GitHub:
https://github.com/simen/grbl/issues/2#comment_900863

将代码移植到 Arduino #2
Author

copy of my modified version of grbl on an Arduino Mega with some additional changes is at: https://github.com/Highlander01/Highlander01HMI
It is mostly the same as grbl but it is different. It may also be a couple versions behind Simens grbl. I have not done any additions lately.

Date: Mon, 21 Mar 2011 16:39:41 -0700
From: reply@reply.github.com
To: gooder01@hotmail.com
Subject: Re: [GitHub] Porting code to Arduino [simen/grbl GH-2]

Hello Highlander,
did you get grbl running on a Arduino Mega?
I have no success with the serial communication…

Reply to this email directly or view it on GitHub:
https://github.com/simen/grbl/issues/2#comment_900863

将代码移植到 Arduino #2

Hello Highlander,

Thank you for sharing your modifications!
I try it today!

Best regards
Michael

Am 28.04.2011 5:25 Uhr schrieb “Highlander01” unter
reply@reply.github.com:

copy of my modified version of grbl on an Arduino Mega with some additional
changes is at: https://github.com/Highlander01/Highlander01HMI
It is mostly the same as grbl but it is different. It may also be a couple
versions behind Simens grbl. I have not done any additions lately.

Date: Mon, 21 Mar 2011 16:39:41 -0700
From: reply@reply.github.com
To: gooder01@hotmail.com
Subject: Re: [GitHub] Porting code to Arduino [simen/grbl GH-2]

Hello Highlander,
did you get grbl running on a Arduino Mega?
I have no success with the serial communication…

Reply to this email directly or view it on GitHub:
https://github.com/simen/grbl/issues/2#comment_900863

将代码移植到 Arduino #2

Hello Simen!

I try out Twister I have downloaded from github.

Bit I take a error message from the compiler:

serial_protocol.cc: In function ‘void sp_process()’:
serial_protocol.cc:84: error: ‘char_counter’ was not declared in this scope
serial_protocol.cc:86: error: ‘printByte’ was not declared in this scope
serial_protocol.cc:87: error: ‘printString’ was not declared in this scope

It seems there is a library missing, right?

Btw. I use AVR Studio 4.1

Best regards

Michael Zigan

将代码移植到 Arduino #2
Member

Sorry, Twister is build with AVR-GCC, a whole different tool-chain. I use
the one that is supplied within the Arduino application bundle.

On Sun, Oct 21, 2012 at 12:41 PM, Michael notifications@github.com wrote:

Hello Simen!

I try out Twister I have downloaded from github.

Bit I take a error message from the compiler:

serial_protocol.cc: In function ‘void sp_process()’:
serial_protocol.cc:84: error: ‘char_counter’ was not declared in this scope
serial_protocol.cc:86: error: ‘printByte’ was not declared in this scope
serial_protocol.cc:87: error: ‘printString’ was not declared in this scope

It seems there is a library missing, right?

Btw. I use AVR Studio 4.1

Best regards

Michael Zigan


Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-9641477.

将代码移植到 Arduino #2

simen> AVR Studio uses WinAVR which is, in fact, avr-gcc compiled for Windows :-) Also, the error reported is most probably a typo in said file: it should probably read line_counter instead of char_counter. The other two errors are caused by incomplete refactoring for Arduino: usage of print*() instead of Serial.print().

将代码移植到 Arduino #2
Member

I guess you are right, @csdexter. This project is not really meant for public comsumption (you’d probably need to know a lot about the configuration of motors to get any immediate use out of it), and as it turns out I hadn’t pushed the very latest changes. I just did, and it compiles just fine now. I’m really sorry @buddhafragt!

将代码移植到 Arduino #2 simen reopened this 2012 年 10 月 22 日
将代码移植到 Arduino #2
Member

Just so we are clear on this @buddhafragt: Twister is not a port of Grbl to the Mega. It is a fork from an early version of Grbl meant to drive two stepper motors that have been joined at the hips in a scara arm configuration as a ultra-cheap XY-table replacement. I have sucessfully used it to build a part using an early makerbot print head, but it is very, very experimental!

将代码移植到 Arduino #2

I try to compile it in AVR Studio and Arduino 0.23 too, but exactly the same compiler error.
The solution @csdexter offer dont solve the problem…
I think the prolem is ‘char_counter’ ‘printByte’ and ‘printString’ is really anywhere declared, so I thought simply a library is missing.
@simen, what kind og IDE/compiler you used for GRBL?
AVR Studio works for me, but I try to port it to the Arduino IDE with some modifications, it compiles, but the compiled program have some unexpected errors (EEPROM writing).

将代码移植到 Arduino #2

@simen,
I know Twister is not ready to use, but I try to add a c++ library to grbl with a lot of trouble and no success.
So I thought I can learn from your twister coding how to make it!

将代码移植到 Arduino #2
Member

@buddhafragt Did you see my comment about the missing patch? Try pulling the newest version and recompile!

将代码移植到 Arduino #2

thank you, compiling :-) with Arduino IDE!

将代码移植到 Arduino #2

I see grbl is compiling “out of the box” with Arduino IDE and Arduino MEGA, how comes?
Is grbl now compatible with the Mega?? I dont test the program in real right now.
Taken only a warnig:
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld: Warning: size of symbol `rx_buffer’ changed from 128 in serial.c.o to 132 in core.a(HardwareSerial.cpp.o)

Is the buffer size critical?

And funny, with the UNO I take a compiler error:
core.a(HardwareSerial.cpp.o): In function __vector_18': /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp:81: multiple definition of__vector_18′
serial.c.o:serial.c:157: first defined here

将代码移植到 Arduino #2

Like I said previously, grbl does not use Arduino. Since Arduino uses some AVR resources unknown to the user (Timer0 comes to mind now) and defines some functionality which grbl already has (UART), compilation within Arduino IDE and/or linking are expected to fail — and even if they do not, the resulting binary should be unusable.

I am unaware if the Arduino developers actually implemented a detection algorithm for source code that does not use the Arduino API (i.e. the empty .ino use case, like for Teacup) so that all Arduino parts are automatically disabled and the resulting binary is correct.

将代码移植到 Arduino #2
Member

If the Twister or Grbl compiles under the Arduino IDE, I did not know that! I think it includes libraries that we are not using. It’s supposed to be built using the makefile in the project.

将代码移植到 Arduino #2
Contributor

Hi there, I have created an Arduino Library of GRBL. It basically just encapsulates the current setup but makes it compatible/up-loadable with the Arduino IDE.

My idea with this port, is to leverage the Arduino’s hardware range and make GRBL work on a larger range of boards.

At the moment the Library has two examples. One for the UNO and one for the Duemilanove. The are configured the same at the moment but have different names defined that can be used to change the config settings per board.

https://github.com/Protoneer/GRBL-Arduino-Library

将代码移植到 Arduino #2
Member

@Protoneer : Great work! What did you need to do to get the IDE working as a library? Any drastic changes or minor ones? I think this would be a great infusion into the main repo, as a simpler way to upload the firmware.

将代码移植到 Arduino #2
Contributor

Like all hard thinks in life. It’s only hard till you crack it and then its easy looking back. :)

The pull requests I made over the last few days were most of the changes.

The thing that took the longest to solve was the linking issues I kept getting. It might sound silly now but who knew that the file names needed to be renamed CPP to work in the ARDUINO IDE?!?!?!? 👎

将代码移植到 Arduino #2

@Protoneer it says in the documentation: Arduino IDE only deals with C++ with a few quirks such as the absence of prototypes in the sketch (because the IDE injects them automatically). Libraries must be comprised of .cpp and .h files with one .h/.cpp file pair named exactly like the folder (and exactly like the library).

That folder may contain two special folders and one special file: “examples”, “utility” and “keywords.txt”. The second may contain any combination of .cpp and .c files, whose type will be obeyed when compiling (i.e. avr-g++ for .cpp and avr-gcc for .c).

I’ll stop here, no need to spam the thread with quotes from the Arduino documentation ;-)

将代码移植到 Arduino #2
Contributor

Hahaha… RTFM comes to mind. :)

Well the dots have been connected so lets make more cool stuff…

将代码移植到 Arduino #2

And, of course, if compiling a file with C++ and intending to link to it from C code, you need the good old extern "C" { thing.

喜欢 (0)