Author Topic: Microcontroller alternative to Arduino  (Read 13508 times)

0 Members and 1 Guest are viewing this topic.

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Microcontroller alternative to Arduino
« on: June 12, 2016, 07:39:38 am »
I will probably post the problem I have with Arduino coding later, but right now little peeved with the Arduino brand (would say Atmel fanboys but since Micro bought them kind of a little pointless), so what alternatives would you suggest?
 

Offline f1rmb

  • Regular Contributor
  • *
  • Posts: 180
  • Country: fr
Re: Microcontroller alternative to Arduino
« Reply #1 on: June 12, 2016, 07:47:28 am »
I will probably post the problem I have with Arduino coding later, but right now little peeved with the Arduino brand (would say Atmel fanboys but since Micro bought them kind of a little pointless), so what alternatives would you suggest?
Hi,

   STM32 ;-)

Cheers.
---
Daniel
 

Offline Fred27

  • Supporter
  • ****
  • Posts: 726
  • Country: gb
    • Fred's blog
Re: Microcontroller alternative to Arduino
« Reply #2 on: June 12, 2016, 07:47:36 am »
Anything. Anything is better than an Arduino.

It's there anything particular you want out of it? Low power? Limited to thorough hole? 32 bit just for the hell of it?
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: Microcontroller alternative to Arduino
« Reply #3 on: June 12, 2016, 07:56:04 am »
Without knowing what you are peeved with, how can we suggest anything better?
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12805
Re: Microcontroller alternative to Arduino
« Reply #4 on: June 12, 2016, 08:02:12 am »
That's about as useful a question as "I want a vehicle, what do you recommend?"
You may need the microcontroller equivalent of a 50cc moped, or of an Aussie 680HP triple trailer road train.   Post your problems with Arduino, and explain what you need the MCU to do and you'll get better suggestions. 
 

Offline richardman

  • Frequent Contributor
  • **
  • Posts: 427
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #5 on: June 12, 2016, 08:48:38 am »
It depends on whether you are p*ssed off with the hardware or the software or both :-)

If p*ssed at hardware, then there are plenty "Arduino compatible" Cortex-M and other MCU based boards that use the Arduino software environment. Of course not all shields or libraries are 100% compatible.

If software, then you can just use any boards, and program in C/C++ :-) Lots of choices there.
// richard http://imagecraft.com/
JumpStart C++ for Cortex (compiler/IDE/debugger): the fastest easiest way to get productive on Cortex-M.
Smart.IO: phone App for embedded systems with no app or wireless coding
 

Offline CM800

  • Frequent Contributor
  • **
  • Posts: 882
  • Country: 00
Re: Microcontroller alternative to Arduino
« Reply #6 on: June 12, 2016, 10:48:34 am »
I still use the AVRs standalone myself, programmed with Atmel Studio. I just work with the datasheet and registers directly, Often I don't need anything of serious power and honestly it's kinda convenient to use the arduino baseboards as a breakout.

I've poked around STM32 and they look like quite a nice option, however I think the software really has something to be desired. I would suggest having a look at the Texas Instruments ARM chips and the NXP Kinetis series, they seem to be quite popular in industry, though it really depends what you are doing.

Nothing beats a bit of this:

Code: [Select]
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdbool.h>
#include <util/delay.h>

#define F_CPU 16000000UL

int main (void) {
//ADC SET UP
ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);
ADMUX |= (1 << REFS0);
ADMUX |= (1 << ADLAR);
ADCSRA |= (1 << ADEN);
ADCSRA |= (1 << ADSC);
ADCSRA |= (1 << ADATE);

//PWM SET UP
DDRB |= _BV(PB1) | _BV(PB2);
TCCR1A = _BV(COM1A1) | _BV(COM1B0) | _BV(COM1B1) | _BV(WGM10);
TCCR1B = _BV(CS20);

for(;;)
{
OCR1A = ADCH*0.47;
OCR1B = 0xff - ADCH*0.47;
}
}
« Last Edit: June 12, 2016, 11:27:41 am by TCWilliamson »
 

Offline sporadic

  • Regular Contributor
  • *
  • Posts: 72
  • Country: us
    • forkineye.com
Re: Microcontroller alternative to Arduino
« Reply #7 on: June 12, 2016, 12:43:05 pm »
By "arduino coding", I assume you mean the arduino abstraction? Just use the vendor's native programmer and tools, Atmel Studio in the case of an AVR.

Sent from my XT1094 using Tapatalk

 

Offline autobot

  • Regular Contributor
  • *
  • Posts: 66
Re: Microcontroller alternative to Arduino
« Reply #8 on: June 12, 2016, 12:56:50 pm »
maybe you would like the mbed.

 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4067
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Microcontroller alternative to Arduino
« Reply #9 on: June 12, 2016, 02:44:21 pm »
Mbed offers similar hardware boards and software abstraction. Is also has a somewhat usefull online ide.
But because mbed runs on more complicated and diverse hardware, reading the actual reference manual is unavoidable.

https://developer.mbed.org
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9886
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #10 on: June 12, 2016, 04:48:17 pm »
I really like the 'stamp' format of the mbed.  I also like their online compiler but I can still pull the code down and compile it with something else.  All of the code including the libraries.

One of my projects required a high speed SPI slave, interrupt driven.  I just wrote my own code and ignored the library code.  When it came time to deal with the NVIC, I wrote my  own 3 lines of code.  There was no requirement to use anything from the libraries.  But when I needed TCP/IP, I just used what was available in the libraries.  Recreating that code would be too much effort.

I don't do a lot of JTAG debugging but it's pretty easy to pull the entire code package into Rowley Crossworks and do the compilation and debugging locally.

I have only used the LPC 1768 incantation of the mbed.


 

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #11 on: June 12, 2016, 09:35:00 pm »
Didn't want to go into much detail until I chilled out..

It's more of a I don't understand how the math works out and what I needed to do, so I posted on the Arduino forum and got things like links to Wikipedia and some other rather random less then helpful posts.

For some reason I can't get my head around what I need to do to fix the math problem, I believe what I need to do is shift bits but I probably don't have the code right either.

I need to get volts and percentages for Duty Cycle..

5*Step/65535 = voltage

step/65535*100 = Duty cycle

Seems simple enough..

But I think what is happening is I go beyond the 16bits and it Zero's thus I get 0 on the lcd display.

When I really want to get say for duty cycle 0.001% to 100% and 7.62951E-05 to 5 volts for Voltage

 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Microcontroller alternative to Arduino
« Reply #12 on: June 12, 2016, 09:44:51 pm »
Quote
It's more of a I don't understand how the math works out and what I needed to do, ...

Seems to be unfair to blame that on arduino, or any chip: you will have those issues no matter what chip you use.

================================
https://dannyelectronics.wordpress.com/
 

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #13 on: June 12, 2016, 10:07:17 pm »
Quote
It's more of a I don't understand how the math works out and what I needed to do, ...

Seems to be unfair to blame that on arduino, or any chip: you will have those issues no matter what chip you use.

Arduino isn't a chip mfg it's a brand that uses the Atmel chip <sigh>
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12805
Re: Microcontroller alternative to Arduino
« Reply #14 on: June 12, 2016, 10:31:55 pm »
Divide *anything* by 65535 in C using normal (16 bit) unsigned integer maths and the result will be 0 or 1, and it can only be 1 if the input value was exactly 65535.  If you need a meaningful result, the expression would need to be carefully written to use long integer (32 bit) maths, and the expression would probably need to be rearranged so that intermediate values didn't overflow or underflow.

Dividing by 65535 is also very slow - it it vastly preferable to divide by 65536 which the compiler will implement by discarding the two low bytes (assuming you are using >16 bit maths).   You might say why not simply use floats or doubles?  Well, what was slow before (32 bit integer division by a non-power-of-two), becomes painfully slow, and the accuracy tends to be even worse for the same variable size as some of the bits that were being used for the actual number are now used for the exponent.

Fixed point integer maths is vastly preferable for small embedded systems, but you do have to plan each operation of each calculation to avoid overflows or loosing too much accuracy due to bits dropped at the LSB end, shifting the intermediate value up or down as required.   Often the implementation looks nothing like the theoretical calculation . . . .

The distinction between Arduino and Atmel ATmega328P isn't particularly useful for this problem as the Arduino toolchain uses GCC, which you are likely to be using anyway for AVRs (unless you've dropped lots of $$$$ on the Keil compiler) and the behaviour of integer maths in C is set by the ANSI C89 standard and its successor ANSI/ISO standards for C and C++., which have generally retained backward compatible behaviour with the C89 standard.
 
The following users thanked this post: marty

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #15 on: June 12, 2016, 10:48:41 pm »
Divide *anything* by 65535 in C using normal (16 bit) unsigned integer maths and the result will be 0 or 1, and it can only be 1 if the input value was exactly 65535.  If you need a meaningful result, the expression would need to be carefully written to use long integer (32 bit) maths, and the expression would probably need to be rearranged so that intermediate values didn't overflow or underflow.

Dividing by 65535 is also very slow - it it vastly preferable to divide by 65536 which the compiler will implement by discarding the two low bytes (assuming you are using >16 bit maths).   You might say why not simply use floats or doubles?  Well, what was slow before (32 bit integer division by a non-power-of-two), becomes painfully slow, and the accuracy tends to be even worse for the same variable size as some of the bits that were being used for the actual number are now used for the exponent.

Fixed point integer maths is vastly preferable for small embedded systems, but you do have to plan each operation of each calculation to avoid overflows or loosing too much accuracy due to bits dropped at the LSB end, shifting the intermediate value up or down as required.   Often the implementation looks nothing like the theoretical calculation . . . .

The distinction between Arduino and Atmel ATmega328P isn't particularly useful for this problem as the Arduino toolchain uses GCC, which you are likely to be using anyway for AVRs (unless you've dropped lots of $$$$ on the Keil compiler) and the behaviour of integer maths in C is set by the ANSI C89 standard and its successor ANSI/ISO standards for C and C++., which have generally retained backward compatible behaviour with the C89 standard.

So looks like fixed point math is where I need to focus my learning on then. oops yep 65536 forgot 0 is first step. doh
« Last Edit: June 12, 2016, 10:51:26 pm by marty »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12805
Re: Microcontroller alternative to Arduino
« Reply #16 on: June 12, 2016, 11:31:12 pm »
I should mention that a C compiler is not *required* to use 16 bit integer maths, but an ANSI compliant compiler will have an integer size >=16 bits.   A default integer type longer than 16 bits is likely on 32 or 64 bit processors with architectures and instruction sets that penalise 16 bit operations and/or misaligned access to read/store 16 bit values.   If you are porting fixed point algorithms, to a processor with a different word size using C's usual integer types, you always need to know the sizes of the types used on both platforms.  Its generally advisable to explicitly use the C99 fixed width integer types so porting your fixed point algorithm doesn't break it.
 

Offline JoeO

  • Frequent Contributor
  • **
  • Posts: 527
  • Country: us
  • I admit to being deplorable
Re: Microcontroller alternative to Arduino
« Reply #17 on: June 13, 2016, 09:16:47 am »
Arduino is not YOUR problem.
The day Al Gore was born there were 7,000 polar bears on Earth.
Today, only 26,000 remain.
 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: Microcontroller alternative to Arduino
« Reply #18 on: June 13, 2016, 09:31:56 pm »
I need to get volts and percentages for Duty Cycle...
I really want to get say for duty cycle 0.001% to 100% and 7.62951E-05 to 5 volts for Voltage
What exactly are you trying to do?
 

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #19 on: June 13, 2016, 09:40:45 pm »
I need to get volts and percentages for Duty Cycle...
I really want to get say for duty cycle 0.001% to 100% and 7.62951E-05 to 5 volts for Voltage
What exactly are you trying to do?

Just trying to get Duty Cycle %, I'm a lot closer now at least I'm not getting 0 for results. Just like to get 2 decimal places now and it'll be golden.

dcperc = ((pwmstep *100) >> 16);

Learned >> 16 << 16 both can be used to divide and multiply by 65536



 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12805
Re: Microcontroller alternative to Arduino
« Reply #20 on: June 13, 2016, 10:05:18 pm »
If pwmstep isn't a long, you'll have problems.  Try:
Code: [Select]
dcperc = ((pwmstep *100UL) >> 16);which forces the calculation to use long maths (32 bit on most platforms)
 
The following users thanked this post: marty

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #21 on: June 13, 2016, 10:31:44 pm »
FFS finally I got it... Here's the damn problem

When both types are of type int, it does integer divison, which gets truncated to the nearest int value. In this case, dividing one int by another that is larger will result in a value of zero. The conversion to type double only occurs when you assign the computed value to the variable percentage.

dcperc = (pwmstep /65536.0) *100;
« Last Edit: June 13, 2016, 10:41:44 pm by marty »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12805
Re: Microcontroller alternative to Arduino
« Reply #22 on: June 13, 2016, 11:24:21 pm »
Yep, but now you are doing floating point maths which is *S*L*O*W* and takes a lot of code space.   That *MAY* be acceptable, but if you are trying to update this value often or are short of code space you'll probably need to use fixed point maths.


I gather the aim is to get the 16 bit PWM duty cycle as a percentage 00.00% to 99.99%
If so a fixed point approach would be:
Code: [Select]
dcperc100 = ((pwmstep *10000UL) >> 16);will get a number in the range 0000 to 9999, a hundred times bigger than the desired percentage, then convert it to a string using itoa() and insert the '.' as you print it, or break it up with /100 and %100 into integer and fractional parts and print them with '.' in between.
 
The following users thanked this post: marty

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #23 on: June 13, 2016, 11:54:00 pm »
Yep, but now you are doing floating point maths which is *S*L*O*W* and takes a lot of code space.   That *MAY* be acceptable, but if you are trying to update this value often or are short of code space you'll probably need to use fixed point maths.


I gather the aim is to get the 16 bit PWM duty cycle as a percentage 00.00% to 99.99%
If so a fixed point approach would be:
Code: [Select]
dcperc100 = ((pwmstep *10000UL) >> 16);will get a number in the range 0000 to 9999, a hundred times bigger than the desired percentage, then convert it to a string using itoa() and insert the '.' as you print it, or break it up with /100 and %100 into integer and fractional parts and print them with '.' in between.

It's working for now but I will continue to improve it as I go I've spent 3 days on this now and I have to move on.  I believe I tried that too Ian and it (me) failed which is why I was having so many problems.
« Last Edit: June 13, 2016, 11:58:53 pm by marty »
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: Microcontroller alternative to Arduino
« Reply #24 on: June 14, 2016, 12:04:18 am »
Cypress Psoc and STM32 and if want something really real time Xmos
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf