I have developed software in C++, Java, PHP, .NET and now I am interesting to learn to program material things. I would like to program a system that could interact with IR, LCD and to be able to resuse old printer motors to use it, etc.
我用c++、Java、PHP、。net开发了软件,现在我很想学习编程。我想设计一个可以与IR, LCD交互的系统,并且能够重新使用旧的打印机马达,等等。
My problem is, where to start? I have searched the web and have found an open source board called Arduino but how to get other electronic components together? What book or tutorial should I do to be able to create a small project?
我的问题是,从哪里开始?我搜索了网络,找到了一个叫做Arduino的开源平台,但是如何将其他电子元件组装在一起呢?我应该做什么书或教程才能创建一个小项目?
14 个解决方案
#1
61
Parallax is notoriously overpriced. They get away with it because they sell their stuff to educational institutions who don't know any better.
视差是出了名的贵。他们之所以能侥幸成功,是因为他们把自己的东西卖给了不了解情况的教育机构。
The Arduino is a good start, go through a few of their examples (click 'Learning' on the Arduino site) and see what parts they require. My favorite hobby electronics online shop is sparkfun.com. They've got tons of parts designed to interface with things like the Arduino.
Arduino是一个很好的开始,看看他们的一些例子(点击Arduino站点上的“学习”),看看他们需要哪些部分。我最喜欢的电子在线商店是sparkfun.com。他们有很多设计用来与Arduino之类的东西交互的部件。
You can program them in C, C++, or AVR Assembly. Personally I'd say avoid the BASIC ones, they are way slower and if you're already into programming it's not worth the hassle.
您可以用C、c++或AVR程序集对它们进行编程。就我个人而言,我认为应该避免那些基本的问题,它们的速度要慢得多。
(FYI, the Arduino is basically a board and software library designed around the wonderful AVR microcontroller)
(顺便说一句,Arduino基本上是一个基于AVR单片机设计的板和软件库)
#2
31
I'd definitely second the Arduino suggestion. They are cheap, there are several suppliers since the hardware is open source (although the name isn't), the IDE is free, you program them in C, and they're easy to hook up to just about anything. The board has 12 digital I/O pins (two of which double as serial communication pins) and six 12-bit A/D converter I/O pins (which can also be configured as digital pins). It can handle pulse-width modulation (PWM) for motor and servo control, interrupts, I2C interfaces, and most boards can either run standalone or off the USB port. Communication to the computer is handled by an FTDI serial USB driver.
我绝对支持Arduino的建议。它们很便宜,因为硬件是开源的(虽然名称不是),IDE是免费的,您可以用C编程,它们很容易连接到任何东西。板上有12个数字I/O引脚(其中两个作为串行通信引脚)和6个12位A/D转换器I/O引脚(也可以配置为数字引脚)。它可以处理脉冲宽度调制(PWM)电机和伺服控制,中断,I2C接口,和大多数板子可以运行单独或离开USB端口。与计算机的通信由FTDI串行USB驱动程序处理。
In addition to Sparkfun.com, also check out www.adafruit.com for some cheap, small USB "Boarduino" boards and several nice prototyping shields for the full-sized Arduino.
除了Sparkfun.com,你还可以在www.adafruit.com网站上找到一些便宜的小型USB“Boarduino”板,以及几块尺寸齐全的Arduino原型机。
The main Arduino site (Arduino.cc) has pretty much every reference and tutorial you need to get started.
主要的Arduino站点(Arduino.cc)几乎包含了您需要入门的所有参考和教程。
Here is the "Hello, World!" of Arduino programming as an example of how easy it is. The program blinks an LED attached to digital pin 13:
下面是Arduino编程的“Hello, World!”,它是如何简单的一个例子。该程序将一个LED连接到数字pin 13上:
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
Basically every Arduino program has a setup() function that runs when the power is applied or the board is reset and a loop() function that runs forever. Of course, you also have timers and interrupt functions, or your can use the loop() for polling inputs and then call out to other functions. The Arduino IDE sits on top of GCC and uses the same libraries and includes that you would use if you were writing a barebones program for the Atmega microcontroller. This means that (a) it hides the hard parts as long as you want it to (bootloaders, fuses, etc.), (b) you can get to the internals of the program if you want to, and (c) you can utilize a large selection of libraries that are out there for this family of microcontrollers.
基本上,每个Arduino程序都有一个setup()函数,该函数在应用电源时运行,或者重新设置面板时运行,还有一个loop()函数,该函数将永远运行。当然,您也有计时器和中断函数,或者您可以使用loop()来轮询输入,然后调用其他函数。Arduino IDE位于GCC的顶部,使用与Atmega微控制器编写裸线程序时相同的库和包含的库。这意味着(a)隐藏了很难的部分,只要你想要(引导装载器、保险丝等),(b)你可以得到的内部程序,如果你想,和(c)你可以选择利用大量的库,这个家庭的微控制器。
#3
28
Well, the field of microcontrollers is quite big. You have several brands, each one sporting a full range of controllers, with varying degrees of capacity, complexity and ability.
微控制器的领域很大。你有好几个品牌,每一个都有各种各样的控制器,具有不同程度的容量、复杂性和能力。
That said, the way to start with most microcontrollers is by reading the manufacturers' manual. As opposed to "normal" programming, where most programmers go by standards and rules and best practices and frameworks, etc. microcontroller programming is still done pretty much as programming was done in the early 1980s: by reading a controller's manual, reproducing examples, and extending from there.
也就是说,从大多数微控制器开始的方法是阅读制造商的手册。与“常规”编程相反,在“常规”编程中,大多数程序员遵循标准、规则、最佳实践和框架等,微控制器编程仍然与上世纪80年代早期的编程差不多:通过阅读控制器手册、复制示例并从中进行扩展。
Microchip's manuals, for example, are excellent. They also have a very good community, and provide some libraries with "standard" functions you might like to use (like math, I/O, doing serial I/O using two pins, and so on). A lot of the people working with PICs is quite open and normally share their source code if they think it might be of use to someone else.
例如,Microchip公司的手册就非常优秀。它们也有一个非常好的社区,并且提供了一些您可能喜欢使用的“标准”函数库(比如math、I/O、使用两个大头针进行串行I/O等等)。很多使用PICs的人都是非常开放的,如果他们认为这可能对其他人有用,他们通常会分享他们的源代码。
There are some choices you have to make before beginning. The first one is what language are you going to use. You have three options:
在开始之前,你必须做出一些选择。第一个是你要用什么语言。你有三个选择:
- Assembly: Most manufacturers provide free or quite cheap development kits for their microcontrollers (MCUs for short). This is the most powerful option, and the one you should use if you feel comfortable. It also will teach you a lot about computers in general.
- 装配:大多数制造商为他们的微控制器提供免费或相当便宜的开发工具包(简称MCUs)。这是最强大的选择,如果你觉得舒服,你应该使用它。它也会教会你很多关于电脑的知识。
- Something else: If you'd rather use something like C, you'll have to pay quite a bit of money for the compiler (although there is at least one open source option for some of the device), and you have to consider the code produced by the high-level languages normally takes a lot of space/memory in the device. Also, depending on the standard library, you'll end up programming a fair amount of the functionality yourself anyway.
- 别的东西:如果你宁愿使用类似C,你得花不少钱的编译器(尽管至少有一个开源选项的一些设备),你必须考虑由高级语言的代码通常需要大量的空间/内存的设备。此外,根据标准库的不同,您最终将自己编写大量的功能。
- Basic/Pascal-like language: some MCUs come with an Basic/Pascal-like interpreter. These are great to start doing some "toy" projects, and getting the feeling of how this things work.
- 基本/类似于护照的语言:一些MCUs带有基本/类似于护照的解释器。这些都是很好的开始做一些“玩具”项目,并获得如何工作的感觉。
Then, you have to decide what kind of device you want to use. Prices per unit vary greatly depending on maker, whether it is PROM, EPROM, EEPROM, how much memory it has, how much storage it has, how many programmable pins, etc.
然后,你必须决定你想使用哪种设备。每个单元的价格取决于制造商,无论是PROM、EPROM、EEPROM,它有多少内存,它有多少存储空间,多少可编程引脚,等等。
My recommendation, for starters, would be:
首先,我的建议是:
- Try to find a free "burner" on the Internet if you want to experience the thrill of programming your MCUs using something you built. There are plenty available out there, just google for "simple PIC burner" or similar. If that's not a requirement, then you can buy a burner, but it will cost you a fair bit of money.
- 如果你想体验一下用你自己做的东西来编程的快感,试着在互联网上找一个免费的“燃烧器”。有很多可用的,只是谷歌为“简单的PIC燃烧器”或类似。如果这不是一个要求,那么你可以买一个燃烧器,但是它会花你一大笔钱。
- Get one EEPROM version of the MCU you think you are going to use the most. This will save you the problem of having to throw away a $5 piece of hardware just because you have a bug in your code.
- 得到一个你认为你会使用最多的单片机的EEPROM版本。这将使您不必仅仅因为代码中有错误就丢弃5美元的硬件。
- Buy a bunch of the PROM version of the MCU. They are cheap, and you'll need them. And once you get started, you'll want to put an MCU everywhere.
- 买一堆舞会版的MCU。它们很便宜,你需要它们。一旦你开始,你会想把一个单片机放在任何地方。
- Learn how to use The Emulator. Most SDKs come with an emulator you can use to test your ideas before committing them to PROM.
- 学习如何使用模拟器。大多数SDKs都带有一个模拟器,您可以在将它们提交到舞会之前使用它来测试您的想法。
- Find yourself some simple and interesting first project. I must emphasize the SIMPLE there. If you try to come up with a way to control your microwave oven using a remote control straight away, be ready for a long period of learning.
- 找一些简单有趣的第一个项目。我必须强调那里的简单。如果你想找到一种方法来控制你的微波炉使用一个遥控器,准备好长时间的学习。
Well, hope this helps you! If you want any more information, I'm around the corner, just whistle! :)
希望这对你有帮助!如果你想知道更多的信息,我马上就来,吹口哨!:)
#4
14
I recently started learning microcontroller programming using the Arduino. I purchased the Arduino Starter Pack from adafruit.com and walked through their introductory tutorials. Their kit comes with some basic electronics (LEDs, buttons, photoresistor) which give you some things to experiment right off the bat.
我最近开始使用Arduino学习微控制器编程。我从adafruit.com上购买了Arduino入门包,并浏览了他们的入门教程。他们的工具包里有一些基本的电子设备(发光二极管、按钮、光敏电阻),可以让你立刻体验到一些东西。
If you already know C/C++ you will be able to start creating useful and interesting projects within hours.
如果您已经了解C/ c++,您将能够在数小时内开始创建有用的、有趣的项目。
The Arduino is also great because once you get familiar with it you can expand to writing raw C on any of the Atmel AVR line of microcontrollers with ease.
Arduino也很棒,因为一旦你熟悉了它,你就可以轻松地在Atmel AVR系列的微控制器上写出原始的C。
I also recommend The Electronics Goldmine where you can purchase assortments of electronics for pretty cheap to get a good starter set to work with.
我也推荐电子金矿,在那里你可以购买各种各样的电子产品,相当便宜,以获得一个良好的入门组工作。
#5
4
The BASIC stamp series is very interesting. They have a lot of nice simple control boards to get you started and the programming is dirt simple. The controller actually executes BASIC. While that might not excite a lot of people, writing microcontroller code takes time to get the hang of it. This system is great to get your feet wet. Then when you have some nice cool (and simple) project running you can move on to other more challenging controllers. These will be most likely assembly or C programmed. Debugging will be your greatest challenge.
基本邮票系列非常有趣。他们有很多很好的简单的控制板让你开始,而且编程非常简单。控制器实际执行BASIC。虽然这可能不会让很多人兴奋,但是编写微控制器代码需要时间来掌握它。这个系统很适合你。然后,当您有一些很棒的(简单的)项目运行时,您可以转向其他更具挑战性的控制器。这将是最有可能的汇编或C程序。调试将是您最大的挑战。
视差基本邮票
#6
3
This is probably overkill for what you are trying to do, but programming an FPGA based system can be fun. The VHDL language is more like wiring up circuits than writing C-code. A Nexys-2 board can be bought for $130.
这对于您正在尝试做的事情来说可能有点过头了,但是编程一个基于FPGA的系统是很有趣的。VHDL语言更像是连接电路,而不是编写C-code。一个Nexys-2板可以花130美元买到。
#7
3
Everything you need for startup in Arduino and electronics can be found here: http://www.smileymicros.com. If I remember well, the book author has/had a column for Arduino newbies in one of electronic magazines. Besides that, in general you should learn I2C, SPI, 1wire and try to interface sensors with such interfaces. Read a lot of datasheets of such sensors and try to understand everything in them. Ask questions when stuck. Learn MODBUS (RTU/ASCII/TCP) or similar protocol that can open your device to the world once you embed it in the device. Learn general electronics and try to interface relays, triacs, step motors, servos, what is pull up and pull down, what is sourcing and sinking, how to draw schematics and connect basic drivers to your MCU.
你需要在Arduino和电子设备上启动的一切都可以在这里找到:http://www.smileymicros.com。如果我没记错的话,这本书的作者在一本电子杂志上为Arduino的新手写了一篇专栏文章。此外,一般来说,您应该学习I2C、SPI、1wire,并尝试与此类接口的传感器进行接口。阅读大量此类传感器的数据表,并尝试理解其中的一切。问问题的时候卡住了。学习MODBUS (RTU/ASCII/TCP)或类似的协议,一旦你将你的设备嵌入到设备中,它就可以打开你的设备。学习通用电子,并尝试接口继电器,triacs,步进电机,伺服,什么是拉和拉,什么是采购和沉没,如何绘制原理图和连接基本驱动到你的单片机。
#8
3
I also have the impression that you need to start from basic microcontroller architecture things. PIC is good to start with, because the basic models and earliest series can be very useful - they have not too much extra functionality so you will not be lost with extras concentrating on basics which is good.
我还认为您需要从基本的微控制器体系结构开始。PIC是很好的开始,因为最基本的模型和最早的系列非常有用——它们没有太多的额外功能,所以你不会迷失在基本的东西上,这是很好的。
After this you need to understand lots of things about memory organization and program execution in context of microcontroller life-cycle and timing models. After this you can go forward with starting analysis of basics assembler examples for a concrete microcontroller and moving forward with more advanced techniques. Then you can move to more advanced series of PIC with DAC and other modules which are the common for most of modern microcontrollers, but on the PIC you can get lots of basics without additional pain which will work pretty the same for all other chips.
在此之后,您需要了解许多关于内存组织和程序执行的内容,这些内容涉及到微控制器生命周期和计时模型。在此之后,您可以开始分析具体的微控制器的基本汇编示例,并使用更高级的技术。然后你可以使用DAC和其他模块的更高级的图片,这是大多数现代微控制器的共同之处,但是在PIC上你可以得到很多基本的东西,没有额外的痛苦,这对所有其他的芯片都是一样的。
#9
3
Every microcontroller is different. The BASIC stamp is very popular among hobbyists, because you can program it in a high-level language.
每个控制器都是不同的。基本的戳记在爱好者中非常流行,因为您可以用高级语言编写它。
For lower-level work, one extremely common choice is the PIC, a cheap (<$4) and fast (~20 MHz) chip with almost no onboard memory. You can find a list of development environments on Wikipedia.
对于较低级别的工作,一个非常常见的选择是PIC,一个便宜的(小于4美元)和快速的(~ 20mhz)芯片,几乎没有板载内存。您可以在Wikipedia上找到开发环境的列表。
If you need to buy electronic components to go with your microcontroller, DigiKey is an excellent place to start.
如果你需要购买电子元件来配合你的单片机,DigiKey是一个很好的起点。
#10
2
Check out Physical Computing by Dan O'Sullivan: http://itp.nyu.edu/~dbo3/physical/physical.html He also has links to Basic Stamp, BX24, Basic Atom, and PIC "Quick References".
请参阅Dan O'Sullivan的《物理计算》:http://itp.nyu.edu/~dbo3/ Physical /physical.html。
Arduino is a great platform with a large, supportive community. I recommend it.
Arduino是一个伟大的平台,拥有一个庞大的、支持的社区。我推荐它。
#11
2
Another vote for the Arduino which is very cool. With an Arduino board, a one-wire temperature sensor and Hyperterminal, you can start to record data about the world around you. Hook up Processing and you can log the data, graph it, analyse it in Excel, whatever. Neat.
另一个投票给Arduino,这很酷。通过一个Arduino板,一个单线温度传感器和超级终端,你可以开始记录你周围世界的数据。连接处理,你可以记录数据,作图,用Excel分析,等等。整洁。
#12
2
If you're a bit electronics enthusiast, you could build you own development system. It could be more complicated but it's a lot more fun.
See here a simple development system for PIC16F628A microncontrollers, including full schematics and PCB: http://www.bobtech.ro/proiecte/microcontrolere/1-bobdemo-sistem-pentru-dezvoltare-aplicatii-cu-microcontroler
Features:
如果你是一个电子爱好者,你可以建立自己的开发系统。它可能更复杂,但更有趣。这里有一个简单的开发系统,用于PIC16F628A微控制器,包括完整的示意图和PCB: http://www.bobtech.ro/proiecte/microcontrolere/1-bobdemo-sistem- pentruth -aplicatii- cuc -microcontroler特性:
- 12 I/O with pushbuttons for inputs and LEDs for outputs
- 输入和led输出按钮的I/O。
- RS232 serial port interface for PC
- RS232 PC串口接口
- infrared remote control sensor
- 红外遥控传感器
- on-board ICSP programming connector
- 车载ICSP编程连接器
- optional on-board 9V battery (for demo purposes)
- 可选车载9V电池(演示用)
- on-board +5V power supply for microcontroller and external peripherals
- 车载+5V电源,用于单片机和外部外设
For programming, you can use BobProg - ICSP PIC programmer
Follow the link for programmer schematics and PCB.
对于编程,您可以使用BobProg - ICSP PIC程序设计器来实现编程原理图和PCB。
Software:
软件:
- (free) MPLAB IDE from Microchip for development in C or ASM language
- (免费)来自微芯片的MPLAB IDE,用于C或ASM语言的开发
- (free) IC-Prog flash programming software to use for the ICSP programmer
- (免费)用于ICSP程序员的IC-Prog flash编程软件
#13
1
I have two suggestions.
我有两个建议。
-
Stamp microcontrollers are great introductory chips. You can pick up the kits on eBay cheap ( < $30 typically). I can also recommend the Stamp2 Communications and Control Projects book by Tom Petruzzellis http://www.amazon.com/STAMP-2-Communications-Control-Projects/dp/0071411976/ref=sr_11_1?ie=UTF8&qid=1221613350&sr=11-1
邮票微控制器是很好的入门芯片。你可以在eBay上买到便宜的套装(通常小于30美元)。我还可以推荐Tom Petruzzellis的Stamp2通信与控制项目书籍http://www.amazon.com/stamp -2通信控制项目/dp/0071411976/ref=sr_11_1?
-
Microchip (www.microship.com) makes the Stamp microcontroller. They also offer free samples from their web site including shipping. I picked up a couple micros with built in radios to do some two way RF communications (not WIFI). Another great microcontroller manufacturer is Dallas Semiconductor http://www.maxim-ic.com/ and they also ship out free samples too. Dallas/Maxim also has an Engineering Journal that they will mail free to your address and the journal has tons of sample implementations, using their chips of course, from which you can grok lots of good information from as well.
微晶片(www.microship.com)制造邮票微控制器。他们也提供免费样品从他们的网站包括航运。我买了几个内置无线电的微型电脑,做一些双向射频通信(不是WIFI)。另一个伟大的微控制器制造商是达拉斯半导体公司http://www.maxim-ic.com/,他们也提供免费样品。Dallas/Maxim也有一份工程杂志,他们会免费寄给你的地址,而该杂志也有大量的示例实现,当然是使用他们的芯片,你也可以从中获取大量的好信息。
#14
0
On a side note:
If you don't want to get your hands dirty soldering a lot of stuff or are not electrically inclined to do so (like me), try looking into PLC's.
They are industrial hardware controllers with modules for almost every task such as digital I/O's, analog I/O's, stepper motor controllers, serial I/O, Ethernet, etc. You can program them in different ways, assembler like, graphical and a text editor with code looking like a mix of Pascal and Basic. They have built-in multitasking and usually perform pretty well, but they are a bit more expensive than a regular microcontroller. I always recommend Wago and their 750-841 controller.
顺便说一句:如果你不想让你的手接触到很多东西,或者不像我一样倾向于这样做,那就去看看PLC吧。它们是工业硬件控制器,具有几乎所有任务的模块,如数字I/O、模拟I/O、步进电机控制器、串行I/O、以太网等。您可以以不同的方式对它们进行编程,如汇编程序、图形和文本编辑器,代码看起来像Pascal和Basic的混合体。它们有内置的多任务处理功能,通常表现得很好,但是它们比普通的微控制器要贵一些。我总是推荐Wago和他们的750-841控制器。
#1
61
Parallax is notoriously overpriced. They get away with it because they sell their stuff to educational institutions who don't know any better.
视差是出了名的贵。他们之所以能侥幸成功,是因为他们把自己的东西卖给了不了解情况的教育机构。
The Arduino is a good start, go through a few of their examples (click 'Learning' on the Arduino site) and see what parts they require. My favorite hobby electronics online shop is sparkfun.com. They've got tons of parts designed to interface with things like the Arduino.
Arduino是一个很好的开始,看看他们的一些例子(点击Arduino站点上的“学习”),看看他们需要哪些部分。我最喜欢的电子在线商店是sparkfun.com。他们有很多设计用来与Arduino之类的东西交互的部件。
You can program them in C, C++, or AVR Assembly. Personally I'd say avoid the BASIC ones, they are way slower and if you're already into programming it's not worth the hassle.
您可以用C、c++或AVR程序集对它们进行编程。就我个人而言,我认为应该避免那些基本的问题,它们的速度要慢得多。
(FYI, the Arduino is basically a board and software library designed around the wonderful AVR microcontroller)
(顺便说一句,Arduino基本上是一个基于AVR单片机设计的板和软件库)
#2
31
I'd definitely second the Arduino suggestion. They are cheap, there are several suppliers since the hardware is open source (although the name isn't), the IDE is free, you program them in C, and they're easy to hook up to just about anything. The board has 12 digital I/O pins (two of which double as serial communication pins) and six 12-bit A/D converter I/O pins (which can also be configured as digital pins). It can handle pulse-width modulation (PWM) for motor and servo control, interrupts, I2C interfaces, and most boards can either run standalone or off the USB port. Communication to the computer is handled by an FTDI serial USB driver.
我绝对支持Arduino的建议。它们很便宜,因为硬件是开源的(虽然名称不是),IDE是免费的,您可以用C编程,它们很容易连接到任何东西。板上有12个数字I/O引脚(其中两个作为串行通信引脚)和6个12位A/D转换器I/O引脚(也可以配置为数字引脚)。它可以处理脉冲宽度调制(PWM)电机和伺服控制,中断,I2C接口,和大多数板子可以运行单独或离开USB端口。与计算机的通信由FTDI串行USB驱动程序处理。
In addition to Sparkfun.com, also check out www.adafruit.com for some cheap, small USB "Boarduino" boards and several nice prototyping shields for the full-sized Arduino.
除了Sparkfun.com,你还可以在www.adafruit.com网站上找到一些便宜的小型USB“Boarduino”板,以及几块尺寸齐全的Arduino原型机。
The main Arduino site (Arduino.cc) has pretty much every reference and tutorial you need to get started.
主要的Arduino站点(Arduino.cc)几乎包含了您需要入门的所有参考和教程。
Here is the "Hello, World!" of Arduino programming as an example of how easy it is. The program blinks an LED attached to digital pin 13:
下面是Arduino编程的“Hello, World!”,它是如何简单的一个例子。该程序将一个LED连接到数字pin 13上:
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
Basically every Arduino program has a setup() function that runs when the power is applied or the board is reset and a loop() function that runs forever. Of course, you also have timers and interrupt functions, or your can use the loop() for polling inputs and then call out to other functions. The Arduino IDE sits on top of GCC and uses the same libraries and includes that you would use if you were writing a barebones program for the Atmega microcontroller. This means that (a) it hides the hard parts as long as you want it to (bootloaders, fuses, etc.), (b) you can get to the internals of the program if you want to, and (c) you can utilize a large selection of libraries that are out there for this family of microcontrollers.
基本上,每个Arduino程序都有一个setup()函数,该函数在应用电源时运行,或者重新设置面板时运行,还有一个loop()函数,该函数将永远运行。当然,您也有计时器和中断函数,或者您可以使用loop()来轮询输入,然后调用其他函数。Arduino IDE位于GCC的顶部,使用与Atmega微控制器编写裸线程序时相同的库和包含的库。这意味着(a)隐藏了很难的部分,只要你想要(引导装载器、保险丝等),(b)你可以得到的内部程序,如果你想,和(c)你可以选择利用大量的库,这个家庭的微控制器。
#3
28
Well, the field of microcontrollers is quite big. You have several brands, each one sporting a full range of controllers, with varying degrees of capacity, complexity and ability.
微控制器的领域很大。你有好几个品牌,每一个都有各种各样的控制器,具有不同程度的容量、复杂性和能力。
That said, the way to start with most microcontrollers is by reading the manufacturers' manual. As opposed to "normal" programming, where most programmers go by standards and rules and best practices and frameworks, etc. microcontroller programming is still done pretty much as programming was done in the early 1980s: by reading a controller's manual, reproducing examples, and extending from there.
也就是说,从大多数微控制器开始的方法是阅读制造商的手册。与“常规”编程相反,在“常规”编程中,大多数程序员遵循标准、规则、最佳实践和框架等,微控制器编程仍然与上世纪80年代早期的编程差不多:通过阅读控制器手册、复制示例并从中进行扩展。
Microchip's manuals, for example, are excellent. They also have a very good community, and provide some libraries with "standard" functions you might like to use (like math, I/O, doing serial I/O using two pins, and so on). A lot of the people working with PICs is quite open and normally share their source code if they think it might be of use to someone else.
例如,Microchip公司的手册就非常优秀。它们也有一个非常好的社区,并且提供了一些您可能喜欢使用的“标准”函数库(比如math、I/O、使用两个大头针进行串行I/O等等)。很多使用PICs的人都是非常开放的,如果他们认为这可能对其他人有用,他们通常会分享他们的源代码。
There are some choices you have to make before beginning. The first one is what language are you going to use. You have three options:
在开始之前,你必须做出一些选择。第一个是你要用什么语言。你有三个选择:
- Assembly: Most manufacturers provide free or quite cheap development kits for their microcontrollers (MCUs for short). This is the most powerful option, and the one you should use if you feel comfortable. It also will teach you a lot about computers in general.
- 装配:大多数制造商为他们的微控制器提供免费或相当便宜的开发工具包(简称MCUs)。这是最强大的选择,如果你觉得舒服,你应该使用它。它也会教会你很多关于电脑的知识。
- Something else: If you'd rather use something like C, you'll have to pay quite a bit of money for the compiler (although there is at least one open source option for some of the device), and you have to consider the code produced by the high-level languages normally takes a lot of space/memory in the device. Also, depending on the standard library, you'll end up programming a fair amount of the functionality yourself anyway.
- 别的东西:如果你宁愿使用类似C,你得花不少钱的编译器(尽管至少有一个开源选项的一些设备),你必须考虑由高级语言的代码通常需要大量的空间/内存的设备。此外,根据标准库的不同,您最终将自己编写大量的功能。
- Basic/Pascal-like language: some MCUs come with an Basic/Pascal-like interpreter. These are great to start doing some "toy" projects, and getting the feeling of how this things work.
- 基本/类似于护照的语言:一些MCUs带有基本/类似于护照的解释器。这些都是很好的开始做一些“玩具”项目,并获得如何工作的感觉。
Then, you have to decide what kind of device you want to use. Prices per unit vary greatly depending on maker, whether it is PROM, EPROM, EEPROM, how much memory it has, how much storage it has, how many programmable pins, etc.
然后,你必须决定你想使用哪种设备。每个单元的价格取决于制造商,无论是PROM、EPROM、EEPROM,它有多少内存,它有多少存储空间,多少可编程引脚,等等。
My recommendation, for starters, would be:
首先,我的建议是:
- Try to find a free "burner" on the Internet if you want to experience the thrill of programming your MCUs using something you built. There are plenty available out there, just google for "simple PIC burner" or similar. If that's not a requirement, then you can buy a burner, but it will cost you a fair bit of money.
- 如果你想体验一下用你自己做的东西来编程的快感,试着在互联网上找一个免费的“燃烧器”。有很多可用的,只是谷歌为“简单的PIC燃烧器”或类似。如果这不是一个要求,那么你可以买一个燃烧器,但是它会花你一大笔钱。
- Get one EEPROM version of the MCU you think you are going to use the most. This will save you the problem of having to throw away a $5 piece of hardware just because you have a bug in your code.
- 得到一个你认为你会使用最多的单片机的EEPROM版本。这将使您不必仅仅因为代码中有错误就丢弃5美元的硬件。
- Buy a bunch of the PROM version of the MCU. They are cheap, and you'll need them. And once you get started, you'll want to put an MCU everywhere.
- 买一堆舞会版的MCU。它们很便宜,你需要它们。一旦你开始,你会想把一个单片机放在任何地方。
- Learn how to use The Emulator. Most SDKs come with an emulator you can use to test your ideas before committing them to PROM.
- 学习如何使用模拟器。大多数SDKs都带有一个模拟器,您可以在将它们提交到舞会之前使用它来测试您的想法。
- Find yourself some simple and interesting first project. I must emphasize the SIMPLE there. If you try to come up with a way to control your microwave oven using a remote control straight away, be ready for a long period of learning.
- 找一些简单有趣的第一个项目。我必须强调那里的简单。如果你想找到一种方法来控制你的微波炉使用一个遥控器,准备好长时间的学习。
Well, hope this helps you! If you want any more information, I'm around the corner, just whistle! :)
希望这对你有帮助!如果你想知道更多的信息,我马上就来,吹口哨!:)
#4
14
I recently started learning microcontroller programming using the Arduino. I purchased the Arduino Starter Pack from adafruit.com and walked through their introductory tutorials. Their kit comes with some basic electronics (LEDs, buttons, photoresistor) which give you some things to experiment right off the bat.
我最近开始使用Arduino学习微控制器编程。我从adafruit.com上购买了Arduino入门包,并浏览了他们的入门教程。他们的工具包里有一些基本的电子设备(发光二极管、按钮、光敏电阻),可以让你立刻体验到一些东西。
If you already know C/C++ you will be able to start creating useful and interesting projects within hours.
如果您已经了解C/ c++,您将能够在数小时内开始创建有用的、有趣的项目。
The Arduino is also great because once you get familiar with it you can expand to writing raw C on any of the Atmel AVR line of microcontrollers with ease.
Arduino也很棒,因为一旦你熟悉了它,你就可以轻松地在Atmel AVR系列的微控制器上写出原始的C。
I also recommend The Electronics Goldmine where you can purchase assortments of electronics for pretty cheap to get a good starter set to work with.
我也推荐电子金矿,在那里你可以购买各种各样的电子产品,相当便宜,以获得一个良好的入门组工作。
#5
4
The BASIC stamp series is very interesting. They have a lot of nice simple control boards to get you started and the programming is dirt simple. The controller actually executes BASIC. While that might not excite a lot of people, writing microcontroller code takes time to get the hang of it. This system is great to get your feet wet. Then when you have some nice cool (and simple) project running you can move on to other more challenging controllers. These will be most likely assembly or C programmed. Debugging will be your greatest challenge.
基本邮票系列非常有趣。他们有很多很好的简单的控制板让你开始,而且编程非常简单。控制器实际执行BASIC。虽然这可能不会让很多人兴奋,但是编写微控制器代码需要时间来掌握它。这个系统很适合你。然后,当您有一些很棒的(简单的)项目运行时,您可以转向其他更具挑战性的控制器。这将是最有可能的汇编或C程序。调试将是您最大的挑战。
视差基本邮票
#6
3
This is probably overkill for what you are trying to do, but programming an FPGA based system can be fun. The VHDL language is more like wiring up circuits than writing C-code. A Nexys-2 board can be bought for $130.
这对于您正在尝试做的事情来说可能有点过头了,但是编程一个基于FPGA的系统是很有趣的。VHDL语言更像是连接电路,而不是编写C-code。一个Nexys-2板可以花130美元买到。
#7
3
Everything you need for startup in Arduino and electronics can be found here: http://www.smileymicros.com. If I remember well, the book author has/had a column for Arduino newbies in one of electronic magazines. Besides that, in general you should learn I2C, SPI, 1wire and try to interface sensors with such interfaces. Read a lot of datasheets of such sensors and try to understand everything in them. Ask questions when stuck. Learn MODBUS (RTU/ASCII/TCP) or similar protocol that can open your device to the world once you embed it in the device. Learn general electronics and try to interface relays, triacs, step motors, servos, what is pull up and pull down, what is sourcing and sinking, how to draw schematics and connect basic drivers to your MCU.
你需要在Arduino和电子设备上启动的一切都可以在这里找到:http://www.smileymicros.com。如果我没记错的话,这本书的作者在一本电子杂志上为Arduino的新手写了一篇专栏文章。此外,一般来说,您应该学习I2C、SPI、1wire,并尝试与此类接口的传感器进行接口。阅读大量此类传感器的数据表,并尝试理解其中的一切。问问题的时候卡住了。学习MODBUS (RTU/ASCII/TCP)或类似的协议,一旦你将你的设备嵌入到设备中,它就可以打开你的设备。学习通用电子,并尝试接口继电器,triacs,步进电机,伺服,什么是拉和拉,什么是采购和沉没,如何绘制原理图和连接基本驱动到你的单片机。
#8
3
I also have the impression that you need to start from basic microcontroller architecture things. PIC is good to start with, because the basic models and earliest series can be very useful - they have not too much extra functionality so you will not be lost with extras concentrating on basics which is good.
我还认为您需要从基本的微控制器体系结构开始。PIC是很好的开始,因为最基本的模型和最早的系列非常有用——它们没有太多的额外功能,所以你不会迷失在基本的东西上,这是很好的。
After this you need to understand lots of things about memory organization and program execution in context of microcontroller life-cycle and timing models. After this you can go forward with starting analysis of basics assembler examples for a concrete microcontroller and moving forward with more advanced techniques. Then you can move to more advanced series of PIC with DAC and other modules which are the common for most of modern microcontrollers, but on the PIC you can get lots of basics without additional pain which will work pretty the same for all other chips.
在此之后,您需要了解许多关于内存组织和程序执行的内容,这些内容涉及到微控制器生命周期和计时模型。在此之后,您可以开始分析具体的微控制器的基本汇编示例,并使用更高级的技术。然后你可以使用DAC和其他模块的更高级的图片,这是大多数现代微控制器的共同之处,但是在PIC上你可以得到很多基本的东西,没有额外的痛苦,这对所有其他的芯片都是一样的。
#9
3
Every microcontroller is different. The BASIC stamp is very popular among hobbyists, because you can program it in a high-level language.
每个控制器都是不同的。基本的戳记在爱好者中非常流行,因为您可以用高级语言编写它。
For lower-level work, one extremely common choice is the PIC, a cheap (<$4) and fast (~20 MHz) chip with almost no onboard memory. You can find a list of development environments on Wikipedia.
对于较低级别的工作,一个非常常见的选择是PIC,一个便宜的(小于4美元)和快速的(~ 20mhz)芯片,几乎没有板载内存。您可以在Wikipedia上找到开发环境的列表。
If you need to buy electronic components to go with your microcontroller, DigiKey is an excellent place to start.
如果你需要购买电子元件来配合你的单片机,DigiKey是一个很好的起点。
#10
2
Check out Physical Computing by Dan O'Sullivan: http://itp.nyu.edu/~dbo3/physical/physical.html He also has links to Basic Stamp, BX24, Basic Atom, and PIC "Quick References".
请参阅Dan O'Sullivan的《物理计算》:http://itp.nyu.edu/~dbo3/ Physical /physical.html。
Arduino is a great platform with a large, supportive community. I recommend it.
Arduino是一个伟大的平台,拥有一个庞大的、支持的社区。我推荐它。
#11
2
Another vote for the Arduino which is very cool. With an Arduino board, a one-wire temperature sensor and Hyperterminal, you can start to record data about the world around you. Hook up Processing and you can log the data, graph it, analyse it in Excel, whatever. Neat.
另一个投票给Arduino,这很酷。通过一个Arduino板,一个单线温度传感器和超级终端,你可以开始记录你周围世界的数据。连接处理,你可以记录数据,作图,用Excel分析,等等。整洁。
#12
2
If you're a bit electronics enthusiast, you could build you own development system. It could be more complicated but it's a lot more fun.
See here a simple development system for PIC16F628A microncontrollers, including full schematics and PCB: http://www.bobtech.ro/proiecte/microcontrolere/1-bobdemo-sistem-pentru-dezvoltare-aplicatii-cu-microcontroler
Features:
如果你是一个电子爱好者,你可以建立自己的开发系统。它可能更复杂,但更有趣。这里有一个简单的开发系统,用于PIC16F628A微控制器,包括完整的示意图和PCB: http://www.bobtech.ro/proiecte/microcontrolere/1-bobdemo-sistem- pentruth -aplicatii- cuc -microcontroler特性:
- 12 I/O with pushbuttons for inputs and LEDs for outputs
- 输入和led输出按钮的I/O。
- RS232 serial port interface for PC
- RS232 PC串口接口
- infrared remote control sensor
- 红外遥控传感器
- on-board ICSP programming connector
- 车载ICSP编程连接器
- optional on-board 9V battery (for demo purposes)
- 可选车载9V电池(演示用)
- on-board +5V power supply for microcontroller and external peripherals
- 车载+5V电源,用于单片机和外部外设
For programming, you can use BobProg - ICSP PIC programmer
Follow the link for programmer schematics and PCB.
对于编程,您可以使用BobProg - ICSP PIC程序设计器来实现编程原理图和PCB。
Software:
软件:
- (free) MPLAB IDE from Microchip for development in C or ASM language
- (免费)来自微芯片的MPLAB IDE,用于C或ASM语言的开发
- (free) IC-Prog flash programming software to use for the ICSP programmer
- (免费)用于ICSP程序员的IC-Prog flash编程软件
#13
1
I have two suggestions.
我有两个建议。
-
Stamp microcontrollers are great introductory chips. You can pick up the kits on eBay cheap ( < $30 typically). I can also recommend the Stamp2 Communications and Control Projects book by Tom Petruzzellis http://www.amazon.com/STAMP-2-Communications-Control-Projects/dp/0071411976/ref=sr_11_1?ie=UTF8&qid=1221613350&sr=11-1
邮票微控制器是很好的入门芯片。你可以在eBay上买到便宜的套装(通常小于30美元)。我还可以推荐Tom Petruzzellis的Stamp2通信与控制项目书籍http://www.amazon.com/stamp -2通信控制项目/dp/0071411976/ref=sr_11_1?
-
Microchip (www.microship.com) makes the Stamp microcontroller. They also offer free samples from their web site including shipping. I picked up a couple micros with built in radios to do some two way RF communications (not WIFI). Another great microcontroller manufacturer is Dallas Semiconductor http://www.maxim-ic.com/ and they also ship out free samples too. Dallas/Maxim also has an Engineering Journal that they will mail free to your address and the journal has tons of sample implementations, using their chips of course, from which you can grok lots of good information from as well.
微晶片(www.microship.com)制造邮票微控制器。他们也提供免费样品从他们的网站包括航运。我买了几个内置无线电的微型电脑,做一些双向射频通信(不是WIFI)。另一个伟大的微控制器制造商是达拉斯半导体公司http://www.maxim-ic.com/,他们也提供免费样品。Dallas/Maxim也有一份工程杂志,他们会免费寄给你的地址,而该杂志也有大量的示例实现,当然是使用他们的芯片,你也可以从中获取大量的好信息。
#14
0
On a side note:
If you don't want to get your hands dirty soldering a lot of stuff or are not electrically inclined to do so (like me), try looking into PLC's.
They are industrial hardware controllers with modules for almost every task such as digital I/O's, analog I/O's, stepper motor controllers, serial I/O, Ethernet, etc. You can program them in different ways, assembler like, graphical and a text editor with code looking like a mix of Pascal and Basic. They have built-in multitasking and usually perform pretty well, but they are a bit more expensive than a regular microcontroller. I always recommend Wago and their 750-841 controller.
顺便说一句:如果你不想让你的手接触到很多东西,或者不像我一样倾向于这样做,那就去看看PLC吧。它们是工业硬件控制器,具有几乎所有任务的模块,如数字I/O、模拟I/O、步进电机控制器、串行I/O、以太网等。您可以以不同的方式对它们进行编程,如汇编程序、图形和文本编辑器,代码看起来像Pascal和Basic的混合体。它们有内置的多任务处理功能,通常表现得很好,但是它们比普通的微控制器要贵一些。我总是推荐Wago和他们的750-841控制器。