Arduino enviroment: I'm converted. - Page 1
Forum section: electronics / general

author: Buriedcode
author_rank: Super Contributor
timestamp: May 31, 2016, 05:43:11 pm
content: Well, some might have seen me mention using an Arduino as being a way for software people, to use hardware, without knowing too much about hardware. And after years on forums seeing posts about these things, and the (relatively few) folks who get quite defensive with 'its clearly something wrong with the hardware, not my knowledge of microcontrollers! it put me off using an Arduino for anything more than quick knock-up tests, so my old Arduino has been gathering dust because it couldn't do anything more than going the 'standard' way. I've been coding AVR's and PIC's in C for years, often for things that micros are designed for - very low level timing measurements, RF/IR control comms, and small 'converters'.Well, decided to use the Arduino IDE for the ESP8266, and of course the original (and my own Atmega328 board) to get back into it and see whats changed over the past few years. Pains me to admit it, but, as almost everyone probably realises - except me - it has blossomed into a ridiculously convenient way to not only do 'quick knock-ups', but downright complicated and extremely useful projects.The word 'convert' implies religion, and I know there will always be those who get defensive over their preferred hardware, so I'm not getting all wet over it... Just that in 3-4 years, the added boards, libraries, ease of porting projects and endless open source projects out there has changed my mind completely. Almost ashamed I didn't get back into it sooner, probably could have saved my self many many hours writing my own libraries for projects. Makes me feel old! (and dumb for being stubborn).Development with the ESP8266 would have been a long winded process if I had just use the native SDK (which I'm sure is just fine). I just spent an afternoon playing with websockets, LED's, and writing code to control (and recieve) the many 433Mhz control/sensor devices I have about the house - something I have been meaning to do for a while - and it took.. 4 hours. Thats 4 hours to have PC/phone access to *almost* anything. Whilst I probably won't use most of it, the novelty is still real.So, if there is anyone left alive who still hasn't used the Arduino IDE/language yet - the standard Arduino board (just an Atmega) is fine and all that, but it really shines for the ESP8266. Put them together, along with the library to flash the AVR over WIFI (via a webpage) and it really is a breeze to control lighting, read sensors etc.. all the bread and butter of 8-bit machines but with some horsepower available.I'm waiting for the 'well.. where have you been?' replies.BC

author: fmaimon
author_rank: Unknown
timestamp: May 31, 2016, 06:05:11 pm
content: If you are using Windows, try using MS Visual Studio and it's Arduino plugin from Visual Micro (www.visualmicro.com). It is much better than the Arduino IDE.

author: rstofer
author_rank: Super Contributor
timestamp: May 31, 2016, 07:15:01 pm
content: Quote from: fmaimon on May 31, 2016, 06:05:11 pmThanks for posting this! For years I have made only limited use of the Arduino because I HATE the IDE. With the VisualMicro add-in, I can use a full featured IDE with a pretty nice hardware gadget.

author: andre_teprom
author_rank: Regular Contributor
timestamp: May 31, 2016, 07:15:28 pm
content: I am of the same opinion as you, and not only with the Arduino trend, but with a lot of other knowledge areas which nowadays became almost useless. The most significant merit we owe to the Arduino conception is the standardizing of either hardware design ( shields ) but also firmware design. Anyway, for critical designs our experience still makes difference, although most designs I got were simple, and I noticed the value of my job reduced by the competition with these guys.

author: gildasd
author_rank: Frequent Contributor
timestamp: May 31, 2016, 07:33:38 pm
content: Same here, but I've gone the way of "Micro". And am now designing boards where the Arduino lives on a socket, super convenient.As good as the 328 is, if you need analogue inputs, it's full of limitationshttps://www.arduino.cc/en/Main/ArduinoBoardMicro

author: krzychb
author_rank: Contributor
timestamp: May 31, 2016, 08:02:05 pm
content: I also love the abundance of s/w libraries for almost any problem and platform so you can hardly develop something new on your ownQuote from: fmaimon on May 31, 2016, 06:05:11 pmBesidesVisual Microthere are two other players -PlatormIOandArduinoEclipsePlugin V3.They are all great tools to chose from depending on your skill level, set of features, preffered O/S, etc.I believe Arduino IDE is is the mother of all of them and unites the whole ecosystem with Library Manager and Platform Manager

author: macboy
author_rank: Super Contributor
timestamp: June 01, 2016, 04:13:08 pm
content: I like Arduino.I am a low-level software engineer by profession (drivers, bootloaders, interrupt handlers, that kind of thing) and EE by training so I understand all the guts underneath the Arduino. There is a lot of stuff going on to make it so easy to use. Some of it gets in the way of what people want to do, then things get not so easy any longer. And there is some convenient but just miserably inefficient code to deal with (digitalWrite, etc.). Despite those limitations I still like it.I like it a lot.Maybe I don't mind those things that irk other people, because I understand the low level stuff well enough to very easily find and work around performance bottlenecks and other issues. When it doesn't do what I want I just poke at registers and make it happen. The fact is: you can do a lot of amazing stuff very easily on Arduino. The ESP8266 support is awesome. A 160 MHz 32 bit CPU with tons of FLASH, plus WiFi for a couple bucks? Wow.Yes, the IDE sucks big time. You can use external editors and compile in the IDE. You can use Microsoft's VS if you are into that. I'm not. You can use Eclipse if you are into that. I am.

author: zapta
author_rank: Super Contributor
timestamp: June 01, 2016, 04:24:52 pm
content: I love Arduino. A single package install that runs on all three major OSs and tons of cheap off the shelf compatible peripherals.In one example I needed to tweak the Marlin firmware of my old RepRap 3D printer. Installing the tool chain, making the changes, and uploading to the printer was a breeze. My current printer uses the Sailfish firmware which uses the avrgcc tool chain directly and installing the software to make changes was much more tedious.BTW, there are many misconceptions about Arduino, for example that it uses a proprietary language (it uses C/C++) or that you must use the standard libraries to do I/O (you can access the registers directly if you choose).

author: JPortici
author_rank: Super Contributor
timestamp: June 01, 2016, 05:13:17 pm
content: it's not that i don't like the idea per sethe language and syntax pisses me offthe ide pisses me off immenselythe "Maker" (with capital M) community around it disgusts me

author: rrinker
author_rank: Super Contributor
timestamp: June 01, 2016, 05:35:28 pm
content: Visual Micro is my new best friend. One of the big projects I have in mind will utilize a PC communicating with multiple Arduino nodes out on my model railroad. My preferred platform for PC programming is Visual Studio, so leveraging that for the Arduino side is just awesome.

author: macboy
author_rank: Super Contributor
timestamp: June 01, 2016, 06:27:22 pm
content: Quote from: JPortici on June 01, 2016, 05:13:17 pmIt's C++. There is absolutely no Arduino-unique syntax. The compiler that compiles the code is unmodified avr-gcc. Almost every microcontroller in the world is programmed exclusively in C/C++, unless you choose asm. Maybe you'd prefer to use aBASIC Stamp?Quote from: JPortici on June 01, 2016, 05:13:17 pmI get this. I really do.Quote from: JPortici on June 01, 2016, 05:13:17 pmThat's a strongly negative sentiment with no justification given. Would you care to elaborate?

author: JPortici
author_rank: Super Contributor
timestamp: June 01, 2016, 06:53:25 pm
content: Yes! About the language, i was referring to the arduino language.. digital write and the likes. all that useless abstracion for putting a byte in a register... no control over the hardware layer...About the 'makers'... this is more about personal experiences. I have yet to meet one person that refer himself as a Maker that has tried to create something by himself instead of just copying other people's projects.. or that has a vague idea of what he's doing.To me Maker has become just another buzzwordhm. please take this as a rant

author: Karel
author_rank: Super Contributor
timestamp: June 01, 2016, 07:03:31 pm
content: Quote from: JPortici on June 01, 2016, 06:53:25 pmHai ragione.

author: retrolefty
author_rank: Super Contributor
timestamp: June 01, 2016, 07:41:07 pm
content: QuoteGet over yourself already. That is not a language, just predefined functions to use or not use as you desire. You with your obvious experience should be able to manipulate directly to the hardware even inside an 'Arduino sketch', because as already stated it's just C++.

author: JPortici
author_rank: Super Contributor
timestamp: June 02, 2016, 06:10:15 am
content: I know, i know. Please forgive that ranting. i had an abe simpson momenthttp://i.imgur.com/91sn32Q.jpgstill, around here i have people that did something with an arduino...and i have they who call themselves the Makers"so what did you do with it?""oh i built this kit and that project""ok but what did YOU do?""what do you mean?"if you can understand

author: dannyf
author_rank: Super Contributor
timestamp: June 02, 2016, 10:26:58 am
content: QuoteI'm not a fan of Arduino - i often call it "designed by liberal arts students for liberal arts students".But that statement captures its biggest appeal and value-add: it dumbs down a complex thing to a level so low that (practically) anyone can use a mcu. That's no different from any technology advances, notably computers - what you did for weeks on a PDP11 can be done today on my smart phone in seconds, or hours. The learning curve is flattened, the hurdle is lowered so everyone can come in and play the same game that was until recently reserved for a few.That in my view is a great thing. and it doesn't take a rocket scientist to see that.I often see elitists comments looking down on the Arduino crowd. I think those people should be reminded that what matters isn't how you do it but what you do with it.

author: gildasd
author_rank: Frequent Contributor
timestamp: June 02, 2016, 07:18:09 pm
content: Quote from: dannyf on June 02, 2016, 10:26:58 amIt's a gateway drug.

author: zapta
author_rank: Super Contributor
timestamp: June 03, 2016, 02:20:24 am
content: Quote from: JPortici on June 01, 2016, 05:13:17 pmC/C++ is not for everyone. Try Basic, you may find it easier.

author: Red Squirrel
author_rank: Super Contributor
timestamp: June 03, 2016, 02:42:03 am
content: Arduino is actually what got me interested in electronics. I was looking into a way to monitor if my power goes out, battery voltage and other environmental stuff and wanted to know how to interface the physical world with a computer so I can write a progam to read the data, then I found out about this relay board and used that for the temperature and hvac control, then later on found out about arduino, and eventually the concept of micro controllers. I'm experimented with programming atmega chips directly but found it hard to find tutorials on the code/syntax, but there is tons of tutorials for arduino, so I just stick to using the arduino code but on the MCU directly. I use the actual arduino to prototype stuff or play around.I also like that it uses C/C++. I feel that's a great language since it's standard and not really owned or controlled by any one company. I'm not a fan of stuff like .net because it's so proprietary, so it's nice to know that must MCUs do in fact use C/C++. Assembly also sounds kinda interesting too, I want to actually play around with that some day. It's a great way to get a deeper understanding of the system you're coding on.As a side note because arduino has become so popular it makes it easier to google stuff, like say I want to know how to interface a certain chip with a MCU, I can just google "how to use xyz chip with arduino" and I'll probably find something. Even if I'm not using arduino the info might still be useful.

author: retrolefty
author_rank: Super Contributor
timestamp: June 03, 2016, 02:55:50 am
content: Quote from: zapta on June 03, 2016, 02:20:24 am

author: hasithvm
author_rank: Contributor
timestamp: June 03, 2016, 08:36:27 am
content: Eh, I liked it while I was dabbling around in basic microcontroller use...but I ran into its limitations quite fast.Still, nothing really matches it for a beginners' level. mbed is such a horrible inconsistent mess (87 lines of code for a blinky? no thank you).

author: janoc
author_rank: Super Contributor
timestamp: June 03, 2016, 12:43:55 pm
content: Quote from: JPortici on June 01, 2016, 05:13:17 pmThe "language" and syntax is just normal C++ with a few wrappers - like a hidden main() calling your setup() and loop() functions. Not sure what can be pissing you off there - it uses the same gcc as the STM32 you are using normally. The quality of the libraries varies and is a different issue, of course.And the rest ... well, nobody forces you to use it, but a bit of tolerance is never bad. Live and let live ...Quote from: JPortici on June 01, 2016, 05:13:17 pmYoudo haveaccess and control to the hardware, all the normal ATMega registers are available and accessible. It is normal AVR GCC, with all the standard headers and libs. The Arduino stuff are only convenience libraries on top. So if you want to do register programming, you certainly can - the tutorials showing that are even in the official documentation because they recognize stuff like digitalWrite() is too slow for many things. It is meant to be easy to use for beginners and portable between boards, not necessarily fast.Don't know how it is on some of the newer ARM Arduinos, though.Quote from: JPortici on June 01, 2016, 05:13:17 pmSorry, but "Maker" != inventor/design engineer. You are looking at it from a completely wrong angle. The point of the "Make" movement was to get people build stuff as opposed to walking into a Walmart and buying everything. The second goal was to teach young people how this stuff works and hopefully get them interested in technology. In that aspect it has been immensely succesful, IMHO.So kit building is just fine in that context - it can be perfectly educational and useful. And yes, it does make the person a "maker", because they have made something, even if it was just assembling a kit as opposed to designing something from scratch. Some will graduate to that, most won't, but that is not the point.And not knowing what they are doing? Well, everyone learns differently - when I was starting to play with batteries and lightbulbs as a kid, I didn't have a university degree neither. I still remember how I have discovered what a "short circuit" was when I have managed to wire a switch in parallel with a battery (I was maybe 7 years old). There is nothing wrong with not knowing - they are not applying for your job!And yeah, "Maker" certainly is a buzzword.

author: dannyf
author_rank: Super Contributor
timestamp: June 03, 2016, 01:02:19 pm
content: "87 lines of code for a blinky? no thank you)."That'S probably not the fault of the tool but that of the person using the tool.

author: janoc
author_rank: Super Contributor
timestamp: June 03, 2016, 01:12:43 pm
content: Quote from: dannyf on June 03, 2016, 01:02:19 pmIt is a bit of a hyperbole, but my experience with mBed was pretty similar. Inconsistent support for libraries between supposedly supported boards, mess of a documentation, elementary stuff like timers not actually provided by the libs leaving you to have to use the vendor libraries (when then bother with mBed in the first place?), etc.Compared to the "batteries included" experience you get with Arduino, even with the horrible default Processing-based "IDE", it is a day and night difference.My feeling is that mBed wanted to be ARM's alternative to Arduino for the ARM ecosystem, but it is not really there. And it is more likely that Arduino will take that space now, with the Arduino supported ARM boards being released and tools like PlatformIO.org providing out of the box ARM support.

author: zapta
author_rank: Super Contributor
timestamp: June 03, 2016, 03:54:20 pm
content: Quote from: dannyf on June 03, 2016, 01:02:19 pmCode:#include "mbed.h"DigitalOut led(LED1);int main() {for(;;) {led = !led;wait_ms(100);}}

author: hasithvm
author_rank: Contributor
timestamp: June 03, 2016, 07:04:09 pm
content: Quote from: zapta on June 03, 2016, 03:54:20 pmHuh, could've sworn it was mbed. My mistake, it's actually LPCWare, or a version thereof. This was directly from the projects linked from the "Getting Started" card distributed with the LPC11x kits.I was helping someone getting setup with trying out the LPC devkits, and saw....this monstrosity.I think I associated the sample with mbed because the kits came in a massive box from ARM with ARM/mbed branding on the sides. Good to see mbed is doing better!

author: dannyf
author_rank: Super Contributor
timestamp: June 03, 2016, 08:03:55 pm
content: The example you quoted isn't a typical blinky: it is considerably complex, with setting and resetting of the LED done in two separate isrs. Implementing a blinky on the lpc is quite simple, especially if you do so without lpcware.As to the particular chip, lpc11xx, it is nxps equivalent of stm32f103 in terms of its popularity and value / performance compromise. It reminds me off the 2106 a lot.

author: hasithvm
author_rank: Contributor
timestamp: June 03, 2016, 09:10:27 pm
content: That's my gripe with that example- it was way too complex for a getting started project. I should notneedto know what a NVIC is/does to blink a single LED. The perceived barrier to entry is incredibly important in this field - Arduino does a good job of lowering that bar, warts and all.TI's Stellaris/Tiva libs and examples are somewhat nicer, but still in no way ready for 101-level projects.

author: Dubbie
author_rank: Unknown
timestamp: June 03, 2016, 09:24:12 pm
content: I got started with electronics with an arduino. I was super excited that I could control a stepper after literally 1 hour of getting my first arduino. That led me down a long path to now where I am happy designing circuits and making pcbs from scratch using a huge variety of micro controller chips and peripheral ics. I learnt a bit about analog circuit design too to support what I needed to do. It's been a couple of years at least since I last used an Arduino.Anyway, I can assure you that without the Arduino to give me a kick start, there is no way I would have picked up this hobby to the level I am at.I think it is just plain snobbery to look down at people messing around with arduinos. Even if they have no idea what they are doing and just blindly following instructions, (like I was) that doesn't mean it won't spark an interest to move beyond that stage.Sent from my phone using Tapatalk

author: dannyf
author_rank: Super Contributor
timestamp: June 03, 2016, 10:19:29 pm
content: QuoteThat's because it shows a lot more than just blinking an led.Here is one for the LPC1114 LPCXpersso board.Code:#include <lpc11xx.h>//we use lpc11xx//hardware configuration#define LED_PORTGPIO0#define LED_DDRGPIO0#define LED(1<<7)//led on gpio0.7#define LED_DLY1000000//waste some cycles//end hardware configuration//global defines#define GPIO0LPC_GPIO0#define IO_OUT(gpio, pins)gpio->DIR |= (pins)#define IO_IN(gpio, pins)gpio->DIR &=~(pins)#define IO_SET(gpio, pins)gpio->DATA|= (pins)#define IO_CLR(gpio, pins)gpio->DATA&=~(pins)#define IO_FLP(gpio, pins)gpio->DATA^= (pins)#define IO_GET(gpio, pins)((gpio->PIN) & (pins))//#define FIO_SET(gpio, pins)gpio->SET = (pins)//#define FIO_CLR(gpio, pins)gpio->CLR = (pins)#define FIO_SET(gpio, pins)gpio->MASKED_ACCESS[(pins) & 0b11111111111] = ((pins) & 0b11111111111)#define FIO_CLR(gpio, pins)gpio->MASKED_ACCESS[(pins) & 0b11111111111] = 0#define FIO_FLP(gpio, pins)IO_FLP(gpio, pins)#define FIO_GET(gpio, pins)((gpio->DATA) & (pins))//global variables//waste timevoid delay(int dly) {while (dly--) continue;}//initialize the mcuvoid mcu_init(void) {SystemCoreClockUpdate();//update systemcoreclockLPC_SYSCON->SYSAHBCLKCTRL |= 1<<6;//6: enable clock to gpio}int main() {mcu_init();//reset the mcuIO_OUT(LED_PORT, LED);//led as outputwhile (1) {IO_FLP(LED_PORT, LED);//flip the led//FIO_FLP(LED_PORT, LED);//flip the leddelay(LED_DLY);//waste some time}return 0;}If you were to trim off the stuff that could have been put away in a different set of files, you get precisely what you would see in an Arduino.Again, the point is that the fault isn't the tool. The fault is with the user of the tool.

author: Buriedcode
author_rank: Super Contributor
timestamp: June 11, 2016, 12:40:39 pm
content: Not trying to resurrect this thread, but just adding a bit more... since I (like to think..) I am a seasoned microcontroller engineer, but in many ways a noob with the 'arduino'.I decided to set myself a few projects that would normally be reserved for 8-bit micro's using a PIC and mikroC (free version). These include:- a learning remote receiver for cheap 433Mhz remotes. Along with the ability to transmit.- same as above but for IR using a bog standard TSOP1738- WS2812B controller- A 'peripheral controller' that adds extra low level functionality to the ESP8266 - which can do a hell of a lot on its own, but lacks IO's for more complicated projects.It quickly became clear that by far the best route, and one I'm sure everyone uses, is to use the libraries 'as and when' you need them, as well as more bare metal programming for more specific routines.All the above has libraries already written for them, RCswitch, IRremote, and 'Neopixel' libraries. These work remarkably well, but with their limitations, which are well documented. I wonder how many Arduino users delve into using the AVR's peripherals directly? Even using basic AVR-GCC using the timers for capture, periodic interrupts etc.. is pretty simple. I ended up writing a rather large sketch that does all three of the above projects in one, using two timers, all interrupt driven. I am toying with the idea of releasing another library for 433Mhz devices that is a tad more versatile.Also the 'digitalwrite' is nice and simple for developing for multiple devices but rather slow for bit banging, so I fell back on some macro's I had used for AVR's many years ago - they still work just find in the arduino IDE, eg:Code:// define ports and pins (port number) for connections#define RFinputPORT PINB#define RFinputDDR DDRB#define RFinputPIN 0#define RFoutputPORT PORTB#define RFoutputDDR DDRB#define RFoutputPIN 3// Bit macro definitions#define BIT(x) (1 << (x))#define SETBITS(x,y) ((x) |= (y))#define CLEARBITS(x,y) ((x) &= (~(y)))#define SETBIT(x,y) SETBITS((x), (BIT((y))))#define CLEARBIT(x,y) CLEARBITS((x), (BIT((y))))#define BITSET(x,y) ((x) & (BIT(y)))#define BITCLEAR(x,y) !BITSET((x), (y))// the following should compile to a couple of instructions.#define RFoutHIGH SETBIT(RFoutputPORT, RFoutputPIN)#define RFoutLOW CLEARBIT(RFoutputPORT, RFoutputPIN)The downside being the code becomes less readable, and ties one into a particular device. But still, makes using old remotes, and interfacing to security systems an absolute breeze.So really I've settled to using it instead of AVR studio - at least for the devices arduino supports, purely for the extra libraries and the simplicity of a built in serial monitor, and flashing. Honestly think I'll start using these for professional contracts

author: dannyf
author_rank: Super Contributor
timestamp: June 11, 2016, 01:38:44 pm
content: QuoteIt is actually the opposite: the code becomes easier to read and more portable. Whenever you see SETBIT(), you know that bits are being set, regardless of which platform you are on.What I do is to put such macros / functions in a separate file (gpio.h/gpio.c for me), and that forms the basis of my other routines. For example, my HC595 files would reference gpio.h and uses the definitions / routines implemented in gpio.h/gpio.c to perform its own functions. When I move to a different chip, I just need to implement a different set of gpio.h/gpio.c and all my routines that reference to gpio.h/gpio.c will work.