Author Topic: Best way to start moving away from Arduino?  (Read 11374 times)

0 Members and 1 Guest are viewing this topic.

Offline MLXXXp

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: ca
Re: Best way to start moving away from Arduino?
« Reply #25 on: October 25, 2017, 11:38:40 pm »
Hell, never return from setup()! Either will work.

Hell, just write your own main() and don't include setup() or loop(). This sketch will compile and run using the Arduino IDE:

Code: [Select]
int main() {
  return 0;
}
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
Re: Best way to start moving away from Arduino?
« Reply #26 on: October 26, 2017, 12:50:03 am »
What's the point in going to discrete MCUs only to go back to pre-made boards (unless you're good enough at RF design to design the board for ESP32)?
The point is that you can migrate to a new MCU, learn high-level program, and then low-level coding. And THEN when comfortable with the new platform, dump the Arduino IDE in favor of a more "bare-metal" IDE.  And THEN be familiar enough with software and hardware to dump the pre-made boards and roll your own. 

I didn't get the impression that the OP wanted to dump everything at once and start over from scratch.  I was trying to propose a more gradual, step-by-step approach.  One equation, one unknown (at least one at a time).
 

Offline daybyter

  • Frequent Contributor
  • **
  • Posts: 397
  • Country: de
Re: Best way to start moving away from Arduino?
« Reply #27 on: October 26, 2017, 02:12:30 am »
Buy a stm32f103 blue pill and use stm32duino.

Then move away from the libs step by step.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Best way to start moving away from Arduino?
« Reply #28 on: October 26, 2017, 02:19:02 am »
How to avoid the quirks of the IDE sketch file pre-preprocessing - writing 'vanilla' C/C++ programs under the Arduino IDE, with a normal main() function.  Nick Gammon's explanation is not entirely complete - in addition to accepting C++ .cpp source files it also accepts ANSI C .c source files.
As the Atmel Studio toolchain for AVRs also uses GCC with the same low-level headers and libraries, most AVR sample code will build under the Arduino IDE with minimal or no changes.

N.B. You *CANNOT* have a .c or .cpp source file called main - it clashes with one the IDE auto-adds.  Also the Arduino environment grabs the Timer 0 rollover interrupt vector (which it uses for various stuff including millis(), micros(), and delay(), so you cant write your own ISR for that interrupt.  Lastly it links with the normal Arduino libraries, so take care to avoid conflicts with Arduino keywords etc.
« Last Edit: October 26, 2017, 02:38:02 am by Ian.M »
 
The following users thanked this post: I wanted a rude username

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Best way to start moving away from Arduino?
« Reply #29 on: October 26, 2017, 02:28:11 am »
Quote
the things that assembler and machine code programming will teach you.
Perhaps.   But you don't need to jump there right away.
I'd claim that you never really need "machine code" (and a lot of modern CPU machine code, even the AVR, is pretty awful), except peripherals are complex enough these days that configuring them can be a lot like "machine code."
You do probably want to notice at some point that something like:Code: [Select]    add xoffset[r1+],shiftval[r2]  ;; vaguely like a possible MSP430 instructionis going to be slower thanCode: [Select]    add r1, r2(which is sort-of machine language)
(less so on RISC cpus where you won't HAVE the first sort!)


Quote
You *CANNOT* have a .c or .cpp source file called main - it clashes with one the IDE auto-adds
Are you sure about that?  recent versions of the IDE have separate build directories for the user files and internal files, and I think that name conflicts no longer cause problems.  A quick test seems to confirm this.
 
The following users thanked this post: Ian.M, newbrain

Offline cdev

  • Super Contributor
  • ***
  • !
  • Posts: 7350
  • Country: 00
Re: Best way to start moving away from Arduino?
« Reply #30 on: October 26, 2017, 03:09:01 am »
Just "try not to look like prey",    (Joke)

and when you move away, do it slowly and calmly always keeping your eyes on them.

(advice given to hikers on how to survive an encounter with a mountain lion)
"What the large print giveth, the small print taketh away."
 

Offline RES

  • Regular Contributor
  • *
  • Posts: 109
  • Country: 00
Re: Best way to start moving away from Arduino?
« Reply #31 on: October 26, 2017, 10:41:28 am »
What's the best way for me to start getting familiar with utilizing other microcontrollers, and/or getting a feel for what I can and can't do without a microcontroller?

Stay on the AVR micro (ASM, BASIC or C), begin with the ATtiny series DIP8 package, ATtiny13 or ATiny25. Begin to design combined CMOS/TLL + micro circuits, for example a simple 4-digit 7-segment clock or up/down counter, debounce buttons, etc.(straight forward code).
After a few years practice (assembler takes more time to learn) you can create the more complex designs and programs. Or. Moving from micros to CMOS/TTL+ discretes can be fun too (logic algebra, truth tables), no need for programming and lots of people can build your designs, but more cheap components means larger pcb, more complex circuits.

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Best way to start moving away from Arduino?
« Reply #32 on: October 26, 2017, 01:43:46 pm »
take ucKeil, a ULINK cable, some ARM-boards from Olimex
and you will be ready
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4028
  • Country: nz
Re: Best way to start moving away from Arduino?
« Reply #33 on: October 26, 2017, 07:04:52 pm »
I'd claim that you never really need "machine code" (and a lot of modern CPU machine code, even the AVR, is pretty awful)

This is true. The encodings can be pretty unfriendly to human decoding.

Unlike, say, the 6502.

A couple of weeks ago I was at dinner with a bunch of people from a RISC-V conference. One of the others there said he started out on the Apple ][. I said "What does this do? A9 C1 20 ED FD 4C D0 03"

He knew. Immediately.

(it prints an "A" on the screen and then exits to AppleSoft BASIC.)

Everyone who learned low level programming on those machines in those days seems to remember that A9 is "LDA immediate", 20 is JSR (and 60 is RTS), 4C is JMP. $FDED is the address of the COUT function. And you get to the monitor with "CALL -151" and get back with "3D0G" (Go at $03D0)

Most of the time the first hex digit tells you the operation and the second one tells you the addressing mode. Simple. Memorable 35-40 years later.
 
The following users thanked this post: I wanted a rude username

Offline woody

  • Frequent Contributor
  • **
  • Posts: 291
  • Country: nl
Re: Best way to start moving away from Arduino?
« Reply #34 on: October 26, 2017, 07:33:21 pm »
IIRC the 6502 had a LOT (13?) of addressing possibilities that were not always very clear to me. Direct or indirect, indexed or not indexed, absolute, relative and what not. 

I found the 6800/02/08 a lot simpler in that respect.
 

Offline Mr. Scram

  • Super Contributor
  • ***
  • Posts: 9810
  • Country: 00
  • Display aficionado
Re: Best way to start moving away from Arduino?
« Reply #35 on: October 26, 2017, 07:49:50 pm »
Like many other beginners, I currently use an Arduino as the core in most of my projects, but I know I'm sacrificing efficiency, price, and flexibility for ease of use with this approach. Apart from those shortcomings, it's just not as fun to hook up some stuff to an arduino and write some basic code to accomplish most tasks, it just feels like cheating sometimes. I'd like to shift to using microcontrollers other than the Arduino (the hardware and the software), or to not using any microcontroller at all and just discrete components when that is possible.

What's the best way for me to start getting familiar with utilizing other microcontrollers, and/or getting a feel for what I can and can't do without a microcontroller? I ask both in terms of the hardware and knowledge I would need to acquire for both of these tasks, particularly for other microcontrollers since there's just so many options and no definitive "best" answer like the Arduino is the best answer for the most easy to use hardware.

Any advice or tips appreciated.

Thanks,
Liam
Have you tried making your own board with an ATmega328p, programming an Arduino board using Amtel Studio or tried working with another member of the AVR family? Those are excellent first ventures into non Arduino territory. You'll learn to use a "real" IDE, read datasheets and find out about registers and the requirements of a specific chip. After that, crossing over to another chip family won't be scary, since it's basically the same thing with another flavour.

Start pulling away the curtains and you'll start building skills that are applicable to pretty much any microprocessor family.
 

Offline apelly

  • Supporter
  • ****
  • Posts: 1061
  • Country: nz
  • Probe
Re: Best way to start moving away from Arduino?
« Reply #36 on: October 26, 2017, 08:16:06 pm »
Just "try not to look like prey",    (Joke)
Totally off topic, but you reminded me of advice for intrepid explorers:
When venturing onto the savannah wear bells and carry pepper spray. Stay alert for lion sign. Juvenile lion sign contains fur and pieces of bone. Adult lion sign has bells in it and smells like pepper.

There's a lot of good advice in this thread. Mainly, the MCU doesn't matter. Dive in with some plain asm/c/c++ and get your blinky going on bare metal on an Arduino board.

I'd suggest investing some time learning how to use a decent IDE. And git. This will take effort. Others will tell you what a dick I am for suggesting you skill up here instead of just getting better at code. In my opinion they are the two most beneficial productivity tools on a coders bench. These skills will go a long way. The Arduino IDE is... Well... Simple and easy to use. My rule of thumb for software: Simple always means limited. The easier it is to use, the less flexible it is and the less it can do.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5317
  • Country: gb
Re: Best way to start moving away from Arduino?
« Reply #37 on: October 26, 2017, 08:42:13 pm »
Although my PIC experience is several orders of magnitude greater than my AVR and Arduino experience, if you’re trying to move to more bare metal, I don’t see why you wouldn’t stick with AVR to begin with.

I have no clue how to program an Arduino board at bare metal level from the Sketch UI, until this thread I didn’t know you could do that, but I found programming Arduino boards from Atmel Studio with a hardware debugger to be far, far simpler than I expected, it was a matter of a few minutes to get a blinky working. As an aside, I find the Atmel Studio experience including the edit/compile/program/debug/run cycle is slicker and astonishingly fast compared to MPLAB X/PIC too. Atmel Studio is Windows only though I believe.
 

Offline Mr. Scram

  • Super Contributor
  • ***
  • Posts: 9810
  • Country: 00
  • Display aficionado
Re: Best way to start moving away from Arduino?
« Reply #38 on: October 26, 2017, 08:53:08 pm »
Totally off topic, but you reminded me of advice for intrepid explorers:
When venturing onto the savannah wear bells and carry pepper spray. Stay alert for lion sign. Juvenile lion sign contains fur and pieces of bone. Adult lion sign has bells in it and smells like pepper.

There's a lot of good advice in this thread. Mainly, the MCU doesn't matter. Dive in with some plain asm/c/c++ and get your blinky going on bare metal on an Arduino board.

I'd suggest investing some time learning how to use a decent IDE. And git. This will take effort. Others will tell you what a dick I am for suggesting you skill up here instead of just getting better at code. In my opinion they are the two most beneficial productivity tools on a coders bench. These skills will go a long way. The Arduino IDE is... Well... Simple and easy to use. My rule of thumb for software: Simple always means limited. The easier it is to use, the less flexible it is and the less it can do.
Do you mean GitHub or actual Git?
 

Offline Mr. Scram

  • Super Contributor
  • ***
  • Posts: 9810
  • Country: 00
  • Display aficionado
Re: Best way to start moving away from Arduino?
« Reply #39 on: October 26, 2017, 08:58:49 pm »
Although my PIC experience is several orders of magnitude greater than my AVR and Arduino experience, if you’re trying to move to more bare metal, I don’t see why you wouldn’t stick with AVR to begin with.

I have no clue how to program an Arduino board at bare metal level from the Sketch UI, until this thread I didn’t know you could do that, but I found programming Arduino boards from Atmel Studio with a hardware debugger to be far, far simpler than I expected, it was a matter of a few minutes to get a blinky working. As an aside, I find the Atmel Studio experience including the edit/compile/program/debug/run cycle is slicker and astonishingly fast compared to MPLAB X/PIC too. Atmel Studio is Windows only though I believe.
Too bad the programmer is so expensive compared to pretty much any other. Even though you generally pay in time many times what you pay in money, asking 2 to 10 times more than competitors isn't smart, especially if you want to attract people migrating from Arduino to something more serious.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4028
  • Country: nz
Re: Best way to start moving away from Arduino?
« Reply #40 on: October 26, 2017, 10:14:18 pm »
Do you mean GitHub or actual Git?

git certainly.

It's very hard to experiment with changes to your program without a good way to go back to previous versions. Commit early, commit often, learn to use branches, merging, rebasing.

Even if you're the only person working on it and it never leaves your PC got is immensely valuable.

Plus, yes, you can trivially back up your whole history to another PC or the cloud or collaborate. You can use github for that, but you don't need to. ssh is plenty.
 

Offline stj

  • Super Contributor
  • ***
  • Posts: 2155
  • Country: gb
Re: Best way to start moving away from Arduino?
« Reply #41 on: October 26, 2017, 11:05:26 pm »
ARM is the way to go,
this is the best "bang for your buck" at the moment.
144pins, built in programmer, 400MHz < yes you read that correct!!!!
http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-h743zi.html

so new you cant get them easily though!!
 

Offline Mr. Scram

  • Super Contributor
  • ***
  • Posts: 9810
  • Country: 00
  • Display aficionado
Re: Best way to start moving away from Arduino?
« Reply #42 on: October 26, 2017, 11:18:53 pm »
ARM is the way to go,
this is the best "bang for your buck" at the moment.
144pins, built in programmer, 400MHz < yes you read that correct!!!!
http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-h743zi.html

so new you cant get them easily though!!
Where's the fun in having that many resources at your disposal?
 

Offline MT

  • Super Contributor
  • ***
  • Posts: 1616
  • Country: aq
Re: Best way to start moving away from Arduino?
« Reply #43 on: October 27, 2017, 12:03:19 am »
Like many other beginners, I currently use an Arduino as the core in most of my projects, but I know I'm sacrificing efficiency, price, and flexibility for ease of use with this approach. Apart from those shortcomings, it's just not as fun to hook up some stuff to an arduino and write some basic code to accomplish most tasks, it just feels like cheating sometimes. I'd like to shift to using microcontrollers other than the Arduino (the hardware and the software), or to not using any microcontroller at all and just discrete components when that is possible.

What's the best way for me to start getting familiar with utilizing other microcontrollers, and/or getting a feel for what I can and can't do without a microcontroller? I ask both in terms of the hardware and knowledge I would need to acquire for both of these tasks, particularly for other microcontrollers since there's just so many options and no definitive "best" answer like the Arduino is the best answer for the most easy to use hardware.

Any advice or tips appreciated.

Thanks,
Liam

ARM for obvious reasons and because everybody "says so", then 5 years later you start to seek for other manufacturers because your feed up with the partly retarded STM32, because everybody "says so" and because its true, the reason people use STM32 was because they where cheap and you got gazillion peripherals now when you found out all the dumbarse design implementations ST have done on all families (besides HAL, CubeMX,LL, on and on) you hate them and start cringe. So 7 years passed, now all ARM MCU manufacturers makes you cringe for various reasons except NXP. 10 years passed, now your quite an expert on ARM and all your time is spent on EEVblog arguing with other "disappoints" about various ARM MCU vendors who have made you cringe (except NXP, because they say so) over the years and wish it was 1980 and happy 6502 assembler days!

Happy bare metalling, i wish you the best cringes.. :popcorn:
 
The following users thanked this post: laseralex, CJay

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5317
  • Country: gb
Re: Best way to start moving away from Arduino?
« Reply #44 on: October 27, 2017, 06:45:31 am »
Although my PIC experience is several orders of magnitude greater than my AVR and Arduino experience, if you’re trying to move to more bare metal, I don’t see why you wouldn’t stick with AVR to begin with.

I have no clue how to program an Arduino board at bare metal level from the Sketch UI, until this thread I didn’t know you could do that, but I found programming Arduino boards from Atmel Studio with a hardware debugger to be far, far simpler than I expected, it was a matter of a few minutes to get a blinky working. As an aside, I find the Atmel Studio experience including the edit/compile/program/debug/run cycle is slicker and astonishingly fast compared to MPLAB X/PIC too. Atmel Studio is Windows only though I believe.
Too bad the programmer is so expensive compared to pretty much any other. Even though you generally pay in time many times what you pay in money, asking 2 to 10 times more than competitors isn't smart, especially if you want to attract people migrating from Arduino to something more serious.

If you're only after a programmer, you can use AVRDude directly with Atmel Studio and Arduino boards, zero cost. I do agree that the debugger options for AVR are not the cheapest. Having said that, regarding any tool cost, you have to weigh up your own cost of time against the convenience of having a seamless out of box experience, I can only say that against many other vendors' toolchains, I have been very pleasantly surprised with the whole Atmel experience.

Regarding several folks' suggestions of going straight to ARM, may I respectfully suggest that that in itself is a can of worms. Before the OP writes a line of code, just trying to understand the ARM market and the enormous number of options out there is a time sapping experience.

I also think that if the OP is after getting an understanding of bare metal programming then personally my experience tells me that ARM is not the easiest of places to start. Sure, some may have on-chip USB programmer/bootloaders, and the hardware development tools may be cheap as chips, but $ alone is not the only cost, there are a great many complexities for ARM hidden away that pretty soon you'll have to know about and figure out how the vendor has swept it under the carpet in their specific toolchain implementation.

The benefit of going for a more rudimentary device like the ATmega328 is that you don't get sidetracked unnecessarily into rabbit holes by these details because to a large extent they're simply not there.

Considering the tools and devices that the OP already has, they could start right now, and not have the hassle of analysis paralysis over which ARM to buy.
 
The following users thanked this post: NivagSwerdna

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Best way to start moving away from Arduino?
« Reply #45 on: October 27, 2017, 07:52:57 am »
One could do a lot worse than Atmel's ATmega328P Xplained Mini board.  Onboard debugger, Arduino compatible footprints for headers and the same MCU as an Arduino Uno.
 
The following users thanked this post: Howardlong

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: Best way to start moving away from Arduino?
« Reply #46 on: October 27, 2017, 08:41:54 am »
Unless you really have a long term plan you want to follow (e.g. I want to be an expert in X), you can't go too wrong if you just try something different for your next project:

- Stick to the Arduino environment, and dig into the lower levels - you can even experiment with inline assember if you like

- Pick a sensor of protocol that nobody else uses and build an Arduino library for it. Add to the community.

- Get an H/W debugger, switch to AVR studio, and read the datasheets if you want to really power up your AVR skills and knowledge

- Go to the really minimal tiny MCUs if you like logic puzzles and learning assembler. I fondly remember the PIC16F84 days...

- Prototype on Arduino, then move your to custom PCBs if you like the smell of solder

- Go for something like a Ti TM4C123 LaunchPad dev board  if you just want to try something different, but with a 'professional' edge to it (simulator, debugger, Keil)- you can even do the EdEx course from University of Texas if you feel the need: https://www.edx.org/course/embedded-systems-shape-world-utaustinx-ut-6-10x

- Go for an ESP32 in Arduino if you want Wifi and to feel like bashing your head against a wall due to the lack of examples

- Go for the Pi Zero and stick with I2C sensors if you are more interested in the application than the lower levels, and Python along the way

Plenty of options - each one you will learn something different, none of them a waste of time.

Which calls to mind my current tinkering project - a few WiFi modules for monitoring the temperature/humidity around the house.

- I could use a Arduino Library and an off the shelf Temp module and a WiFi shield, but that would cost big $$$, and can't be battery powered

- I could use a Raspberry Pi Zero, and an I2C sensor, but where is the fun in "reading "/dev/i2c/" from a web page,it would be cheaper then the Arduino project made using parts from the local hobby shop.

- I could use a bare AVR, design a PCB and reflow it, and put 433MHz RF modules on it, but really? who has the time to design, build and bring up a board for a one off weekend project.

- I chose to go with ESP32 - can use low power modes to save battery, has on board Wifi, can be battery powered (approx 150mA @ 5V when Wifi is active,way less than 1mA when sleeping). Total project cost about $7, including sensor.

It has been interesting so far. The DHT11 sensor's protocol works in a time scale that is tricky to work in, as it needs timing of 10us to 100us pulses (see image).

The ESP32 is still quite new, and a quick review showed that the first-hit GitHub library for the ESP32+DHT11 suck. For example:
Code: [Select]
/*-------------------------------------------------------------------------------
;
; get next state
;
; I don't like this logic. It needs some interrupt blocking / priority
; to ensure it runs in realtime.
;
;--------------------------------------------------------------------------------*/
int getSignalLevel( int usTimeOut, bool state )
{
int uSec = 0;
while( gpio_get_level(DHTgpio)==state ) {
if( uSec > usTimeOut )
return -1;
++uSec;
ets_delay_us(1); // uSec delay
}
return uSec;
}

Writing by somebody who is still thinking in a low end micro mindset, and is relatively clueless about how to do things when you grow into bigger, more complex environments where interrupts may be pinging off - but to their credit, at least they realize it!

It appears that the ESP32 has a 'RMT' peripheral that is perfect for this. Originally designed for using with IR remote controls it counts the length of high/low pulses and stores them in RAM, until it times out. I now have an interesting and somewhat useful < $10 weekend mostly software project where I might learn something that will be handy.
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline woody

  • Frequent Contributor
  • **
  • Posts: 291
  • Country: nl
Re: Best way to start moving away from Arduino?
« Reply #47 on: October 27, 2017, 10:09:22 am »

- I could use a Raspberry Pi Zero, and an I2C sensor, but where is the fun in "reading "/dev/i2c/" from a web page,it would be cheaper then the Arduino project made using parts from the local hobby shop.

Don't know about the Zero, but with a standard Pi it looks like this  :D
 

Offline ElektroQuark

  • Supporter
  • ****
  • Posts: 1244
  • Country: es
    • ElektroQuark
Re: Best way to start moving away from Arduino?
« Reply #48 on: October 27, 2017, 10:16:37 am »
Are you afraid that the OP is out of the discussion?

Offline zeqing

  • Regular Contributor
  • *
  • !
  • Posts: 84
  • Country: de
Re: Best way to start moving away from Arduino?
« Reply #49 on: October 27, 2017, 10:37:43 am »
i am absolutely different with you , i used the ARM7/ARM11, and FPGA, and STM32 when was in school and the first years as work, and then i found the Arduino, after 5 years' usage of Arduino, now i can not remember anything about  the other controllers..... :palm:
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf