Author Topic: Microcontroller alternative to Arduino  (Read 13680 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: 12860
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: 4078
  • 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: 9890
  • 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: 12860
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: 12860
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: 12860
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: 12860
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
 

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #25 on: June 14, 2016, 12:39:46 am »
I see a lot talking of microcontrollers but no mention of alternatives to Arduino. So I suppose it comes down to C, C++, and C#, I do recall seeing some drag and drop programming. My understanding is C is best since it's closer to machine language.
 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: Microcontroller alternative to Arduino
« Reply #26 on: June 14, 2016, 12:47:04 am »

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.
Still not fully explained. Where is this 16 bit PWM coming from, and in what way is it related to 0~5V?

 

Offline sporadic

  • Regular Contributor
  • *
  • Posts: 72
  • Country: us
    • forkineye.com
Re: Microcontroller alternative to Arduino
« Reply #27 on: June 14, 2016, 12:56:34 am »
I see a lot talking of microcontrollers but no mention of alternatives to Arduino. So I suppose it comes down to C, C++, and C#, I do recall seeing some drag and drop programming. My understanding is C is best since it's closer to machine language.
Arduino is about as dumbed down as it gets.  Not sure what you're looking for as your problem wasn't arduino the related. Maybe moving to native AVR development and a debug capable programmer like an Atmel ICE would give you a better understanding of what's going on at a lower level.
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: Microcontroller alternative to Arduino
« Reply #28 on: June 14, 2016, 12:58:47 am »
Pwm = Pulse Width Modulation , The output will be always s 0 or 5 V ( theoretically) But the key is how long , Duty cycle is how much % they will on on state and off state, foe example 10% duty cicle is turned on 10 % of the oscilanting time and 90% will be off



 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: Microcontroller alternative to Arduino
« Reply #29 on: June 14, 2016, 01:02:04 am »
"I see a lot talking of microcontrollers but no mention of alternatives to Arduino. So I suppose it comes down to C, C++, and C#, I do recall seeing some drag and drop programming. My understanding is C is best since it's closer to machine language."

Not necessarily

Check this links

https://www.hackster.io/rayburne/4-dollar-90-mips-32-bit-72-mhz-arm-arduino-f6e5c9

http://www.pinguino.cc/



 

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #30 on: June 14, 2016, 03:03:07 am »

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.
Still not fully explained. Where is this 16 bit PWM coming from, and in what way is it related to 0~5V?

I have figured out my problem and posted my solution which is that I was dividing an integer into another that was larger thus giving a 0. i just made it float ---> 65536.0 problem solved for now.

Yes I can clean it up and make it more lean but I will do that later when I learn more, I just got this Arduino a month ago, and spend maybe 2 weeks working on the coding if you want to call it that.

thanks for the reponses.

I have everything I need at the moment but thanks for your responses.
 

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #31 on: June 14, 2016, 03:06:27 am »
"I see a lot talking of microcontrollers but no mention of alternatives to Arduino. So I suppose it comes down to C, C++, and C#, I do recall seeing some drag and drop programming. My understanding is C is best since it's closer to machine language."

Not necessarily

Check this links

https://www.hackster.io/rayburne/4-dollar-90-mips-32-bit-72-mhz-arm-arduino-f6e5c9


http://www.pinguino.cc/

LOL pinguino, the pic alternative to atmega.

thanks
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3024
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Microcontroller alternative to Arduino
« Reply #32 on: June 14, 2016, 06:14:09 am »
I see a lot talking of microcontrollers but no mention of alternatives to Arduino. So I suppose it comes down to C, C++, and C#,

Unless I misunderstand your statement there, you seem to be thinking of "Arduino" as a language.  It's not.  You are writing in C/C++, the IDE does some gruntwork for you in doing the compilation, and there are some libraries and functions provided to you through that, but it's all C/C++ at the end of the day.
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: Microcontroller alternative to Arduino
« Reply #33 on: June 14, 2016, 08:27:55 am »
Arduino is a set of libraries but is C running on the  root of the things
 

Offline obiwanjacobi

  • Frequent Contributor
  • **
  • Posts: 988
  • Country: nl
  • What's this yippee-yayoh pin you talk about!?
    • Marctronix Blog
Re: Microcontroller alternative to Arduino
« Reply #34 on: June 14, 2016, 09:54:45 am »
...Or he means the Arduino IDE..?

In that case look at Visual Micro (for Visual Studio) or Atmel Studio (7)... (Windows only)
Arduino Template Library | Zalt Z80 Computer
Wrong code should not compile!
 

Offline retrolefty

  • Super Contributor
  • ***
  • Posts: 1648
  • Country: us
  • measurement changes behavior
Re: Microcontroller alternative to Arduino
« Reply #35 on: June 14, 2016, 11:01:40 am »
Arduino is a set of libraries but is C running on the  root of the things

Root? There is no root.

 All code running an arduino 'sketch' is compiled C/C++.
« Last Edit: June 14, 2016, 11:05:11 am by retrolefty »
 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: Microcontroller alternative to Arduino
« Reply #36 on: June 14, 2016, 12:10:28 pm »
All code running an arduino 'sketch' is compiled C/C++.
And that's the problem. If only the Arduino used a true high level language such as BASIC, then newbies wouldn't have to worry about the size of an integer or how to show a percentage, because all calculations would be floating point already.  And they wouldn't struggle with a syntax that was designed to save typing but makes it too easy to create hard-to-see bugs.
 
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Microcontroller alternative to Arduino
« Reply #37 on: June 14, 2016, 01:09:07 pm »
"And that's the problem"
And the enduring appeall of c. It is a powerful language because of those options it provides.

Precisely because of that lack of constraints, it puts a great burden on the programmer to know she or he is doing. This very threads serves as an example of suug consequences when the programmer has no idea about what she or her is doing.

Your approach, a potentially valid one for beginners, is highly restrictive andd costly. It amounts to a permanently mounted training wheel on a race bike.
================================
https://dannyelectronics.wordpress.com/
 

Offline asgard20032

  • Regular Contributor
  • *
  • Posts: 184
Re: Microcontroller alternative to Arduino
« Reply #38 on: June 14, 2016, 01:26:12 pm »
Are you kidding? BASIC, easy syntax :-DD :-DD :-DD :-DD? Not at all. Learning C, no problem. Learning Verilog, no problem. VHDL, syntax get a little bit crank up. But Basic, and the like (Visual basic), the syntax is weird. C only got a very few keyword (including char, int and the other type, if, else, while, for, switch, void, return, and the other keyword more rarely used). For the semi-colon, you just put one at the end of each statement. The hardest thing to understand in C is the pointer concept. But even that is not that hard. If we compare Basic with that, it has the same complexity : lot of keyword to remember, where do we put the $ sign, before of after? I see both : https://en.wikipedia.org/wiki/BASIC , i also see weird semi-colon placement, and lastly, I see some strange keyword that doesn't exist in other more structured language, like the left keyword. Oh, and I see goto most everywhere in most Basic stuff... Basic teach bad habit. Even if we can write structured Basic, most of the literature is tainted with goto. Visual Basic is almost even worse (strange keyword, strange structure, strange data type). Is C harder than Basic or visual basic, I strongly say no. Personally I find it easier than most other language, but this is a personal taste, but it is definitely not harder. It all come to one important sentence : pick your poison.

Code: [Select]
10 INPUT "What is your name: "; U$
20 PRINT "Hello "; U$
30 INPUT "How many stars do you want: "; N
40 S$ = ""
50 FOR I = 1 TO N
60 S$ = S$ + "*"
70 NEXT I
80 PRINT S$
90 INPUT "Do you want more stars? "; A$
100 IF LEN(A$) = 0 THEN GOTO 90
110 A$ = LEFT$(A$, 1)
120 IF A$ = "Y" OR A$ = "y" THEN GOTO 30
130 PRINT "Goodbye "; U$
140 END

Oh, and the point that given birth to this reply is the guy that talked about basic and datatype, everything float and ... Well, knowing your datatype is very important. If you exchange information between 2 device, you need to know how the information will be stored at each end, or else, it won't work as expected.
 

Offline System Error Message

  • Frequent Contributor
  • **
  • Posts: 473
  • Country: gb
Re: Microcontroller alternative to Arduino
« Reply #39 on: June 14, 2016, 01:33:13 pm »
There are many alternatives, you can always contact a company that makes them and order some chips. The reason why you dont see much mention of alternatives is because arduino covers a wide range of commonly used general purpose controllers in a convenient way including the IDE and compiler. You can even use java for it.

You can also use FPGAs too.

There are many many controllers/chips but they dont usually come on a board with all the IO and stuff ready with an IDE like arduino has. Udoo for example doesnt actually use arduino, it uses arduino compatible chips as the chips they use arent exactly the same.
 

Offline BloodyCactus

  • Frequent Contributor
  • **
  • Posts: 482
  • Country: us
    • KrÃ¥ketær
Re: Microcontroller alternative to Arduino
« Reply #40 on: June 14, 2016, 03:56:47 pm »
ugh so many confused concepts in here. dividing signed integers by 65536, now shifting them by 16 (go undefined behaviour!) conversion to doubles. on an 8bit mcu that does floating point in software. ugh.

Marty, find a good C beginner tutorial on types and their sizes and try and understand what exactly you are doing.
-- Aussie living in the USA --
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: Microcontroller alternative to Arduino
« Reply #41 on: June 14, 2016, 06:01:52 pm »
ugh so many confused concepts in here. dividing signed integers by 65536, now shifting them by 16 (go undefined behaviour!)

The suggested code had a right shift on a signed integer, so it is implementation-defined behaviour rather than undefined.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Microcontroller alternative to Arduino
« Reply #42 on: June 14, 2016, 06:39:42 pm »
Why would you suspect the O.P's pwmstep which he's using for the duty cycle of a 16 bit PWM, to be signed?  That would be idiosyncratic in the extreme.  As long as pwmstep is unsigned, multiplying by an unsigned long constant will promote to unsigned long, so the right shift will have a well defined result as long as the platform uses 32 bit or larger longs.  Sizeof(long) is 4 under AVR GCC, unless the non-ANSI compilant switch -mint8 is used.
« Last Edit: June 14, 2016, 06:44:03 pm by Ian.M »
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6190
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #43 on: June 14, 2016, 06:51:59 pm »

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

5*Step/65535 = voltage

step/65535*100 = Duty cycle


These looks like basic linear scalings. Have you look at this Arduino function?

https://www.arduino.cc/en/Reference/Map
 

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #44 on: June 14, 2016, 08:11:01 pm »
I see a lot talking of microcontrollers but no mention of alternatives to Arduino. So I suppose it comes down to C, C++, and C#,

Unless I misunderstand your statement there, you seem to be thinking of "Arduino" as a language.  It's not.  You are writing in C/C++, the IDE does some gruntwork for you in doing the compilation, and there are some libraries and functions provided to you through that, but it's all C/C++ at the end of the day.

Arduino is a software brand, just using it's name on hardware.
 

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #45 on: June 14, 2016, 08:12:46 pm »
Are you kidding? BASIC, easy syntax :-DD :-DD :-DD :-DD? Not at all. Learning C, no problem. Learning Verilog, no problem. VHDL, syntax get a little bit crank up. But Basic, and the like (Visual basic), the syntax is weird. C only got a very few keyword (including char, int and the other type, if, else, while, for, switch, void, return, and the other keyword more rarely used). For the semi-colon, you just put one at the end of each statement. The hardest thing to understand in C is the pointer concept. But even that is not that hard. If we compare Basic with that, it has the same complexity : lot of keyword to remember, where do we put the $ sign, before of after? I see both : https://en.wikipedia.org/wiki/BASIC , i also see weird semi-colon placement, and lastly, I see some strange keyword that doesn't exist in other more structured language, like the left keyword. Oh, and I see goto most everywhere in most Basic stuff... Basic teach bad habit. Even if we can write structured Basic, most of the literature is tainted with goto. Visual Basic is almost even worse (strange keyword, strange structure, strange data type). Is C harder than Basic or visual basic, I strongly say no. Personally I find it easier than most other language, but this is a personal taste, but it is definitely not harder. It all come to one important sentence : pick your poison.

Code: [Select]
10 INPUT "What is your name: "; U$
20 PRINT "Hello "; U$
30 INPUT "How many stars do you want: "; N
40 S$ = ""
50 FOR I = 1 TO N
60 S$ = S$ + "*"
70 NEXT I
80 PRINT S$
90 INPUT "Do you want more stars? "; A$
100 IF LEN(A$) = 0 THEN GOTO 90
110 A$ = LEFT$(A$, 1)
120 IF A$ = "Y" OR A$ = "y" THEN GOTO 30
130 PRINT "Goodbye "; U$
140 END

Oh, and the point that given birth to this reply is the guy that talked about basic and datatype, everything float and ... Well, knowing your datatype is very important. If you exchange information between 2 device, you need to know how the information will be stored at each end, or else, it won't work as expected.

you realize I used to program that way in 1983.. nice simple and this fourm would actually be more like RBBS
 

Offline richardman

  • Frequent Contributor
  • **
  • Posts: 427
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #46 on: June 14, 2016, 08:50:29 pm »
This is like the worst thread possible in the number of answers ;-)
// 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 NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: Microcontroller alternative to Arduino
« Reply #47 on: June 14, 2016, 09:20:18 pm »
This is like the worst thread possible in the number of answers ;-)
|O This thread is the worst ever. It started because the OP can't write code in C  :palm:.  It has nothing to do with Arduino  :scared:.
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: Microcontroller alternative to Arduino
« Reply #48 on: June 14, 2016, 10:00:03 pm »
All code running an arduino 'sketch' is compiled C/C++.
And that's the problem. If only the Arduino used a true high level language such as BASIC, then newbies wouldn't have to worry about the size of an integer or how to show a percentage, because all calculations would be floating point already.  And they wouldn't struggle with a syntax that was designed to save typing but makes it too easy to create hard-to-see bugs.
 

Have a play with Scratch (http://scratch.mit.edu), if only for a few minutes. No, really just do it.  Scratch for Arduino is what is really needed for newbies.

Oh, and I Google for 5 seconds... http://s4a.cat/

S4A is a Scratch modification that allows for simple programming of the Arduino open source hardware platform. It provides new blocks for managing sensors and actuators connected to Arduino.

(I teach Scratch it at a local CodeClub)
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 ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: Microcontroller alternative to Arduino
« Reply #49 on: June 15, 2016, 03:44:04 am »
Also have another option more on graphic side instead of hard C code

http://www.mitov.com/products/visuino#overview

I personally prefer C, but not everybody is the same taste
 

Offline CatalinaWOW

  • Super Contributor
  • ***
  • Posts: 5231
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #50 on: June 15, 2016, 04:23:00 am »
The OP may have nailed the Arduino problem when he described the responses he got on Arduino bulletin boards.  The problem is not the microcontroller, or the language.  The problem is that the ease of use of Arduino has allowed a lot of people who don't really know what they are doing to accomplish things, thus validating themselves as "experts".  Just about any other platform (with the possible exception of Stamp) would be better in this sense.

That said, I like Arduino.  Easy to get fast prototypes slapped together to evaluate user response, learn what you didn't know about the environment and requirements and so on.  And it is so cheap that it doesn't even make sense to clean it up unless you are building quite a few.  Just recognize that there is a lot of clunker advice and bad examples out there in the Arduino universe.
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: Microcontroller alternative to Arduino
« Reply #51 on: June 15, 2016, 04:56:34 am »
It's interesting.

I'm from the famous 80C31 time, and I prefer to use Atmel IDE than arduino, because the arduino Layer make things easier on one side, but make blinded developers on the other one, I still prefer to stay in ASM, C or even pascal with Microe compiler, arduino  only to CRTL C CTRL  V internet projects. Actually all my eyes in on Psoc or FPGA everything else decrease value for me
 

Offline autobot

  • Regular Contributor
  • *
  • Posts: 66
Re: Microcontroller alternative to Arduino
« Reply #52 on: June 15, 2016, 09:02:14 am »
The OP may have nailed the Arduino problem when he described the responses he got on Arduino bulletin boards.  The problem is not the microcontroller, or the language.  The problem is that the ease of use of Arduino has allowed a lot of people who don't really know what they are doing to accomplish things, thus validating themselves as "experts".  Just about any other platform (with the possible exception of Stamp) would be better in this sense.

That said, I like Arduino.  Easy to get fast prototypes slapped together to evaluate user response, learn what you didn't know about the environment and requirements and so on.  And it is so cheap that it doesn't even make sense to clean it up unless you are building quite a few.  Just recognize that there is a lot of clunker advice and bad examples out there in the Arduino universe.

That's true.

I actually think the mbed walks the fine line pretty well here: On the other hand, it's more complex than the Arduino so that deters the Arduino crowd, but once you pass the learning barrier(which isn't that big ), you get to prototype probably as fast as the arduino(and maybe even faster for some things, like power management) , and yet get to have a platform that could take you to production in many cases.
« Last Edit: June 15, 2016, 09:05:21 am by autobot »
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1611
  • Country: gb
Re: Microcontroller alternative to Arduino
« Reply #53 on: June 15, 2016, 11:21:56 am »
As with many disciplines there are almost always gaps in knowledge, and as CatalinaWOW pointed out, writing a few lines of code that use prebuilt libraries does gives some the sense they are 'good at coding for microcontrollers'  - with all manner of cool things happening, but with very little 'logic' being written.  I see it quite often with those with IT backgrounds starting to do embedded stuff - easily tripped up by things they take for granted on larger CPU's with seemingly endless resources.   Those are then countered by what some have called the 'bare metal zealots' who go as far as to say you should code in assembly... 

To the op.  If you're a software guy I'm sure you're used to writing down exactly what you want to do in flow chart format, and used to using equations.  What I think has tripped you up here is that you're dealing with an 8-bit device which has limitations, and therefore can require a different approach to how you do things, to achieve the desired effect. 

I was surprised when you said you had realised that right shifting a value (unsigned long) by 16 divides it by 65536 (similarlly left shifting multiples it). The same reason that left shifting a decmial number by 1 multiplies it by 10.  Because its an 8-bit device, it stores a 32-bit number in 4 locations, so it doesn't even need to shift any bits for that - it just takes the top two bytes and discards the bottom two. And this is where I believe quite a few people get stuck... bytes, chars, ints, words, longs etc.. are of course finite, whilst I'm sure many software people are aware of this, for micro's, often one needs more than just 'awareness' of logical functions and how the mathematical operations are actually performed on hardware.   You may not need it to be fast, and higher level languages give you the option of using floats, dealing with very precise numbers, but what if you're trying to make something use less power? or perform that calculation a thousand times a second?  It seems a common approach these days is to 'use a bigger chip'.

That is often why multiplications and divisions for things like averaging, are done to the power of two - to make it much easier for a chip without dedicated division hardware to divide a number.  It simply becomes a case of barrel shifting.

As for your project, it would help if you explained in your first post, what it is you're trying to achieve, and what you have tried so far.  We've all been 'peeved' when the software we've written doesn't do as we expected, but in every single case - it was my mistake and lack of understanding. (with the possible exception of a tiny bug in MikroC PRO that caused an if statement to always execute..).
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #54 on: June 15, 2016, 10:10:21 pm »
Quote
If only the Arduino used a true high level language such as BASIC, then newbies wouldn't have to worry about the size of an integer or how to show a percentage, because all calculations would be floating point already.
That is
  • quite uncertain.  Not all BASIC implementations implement floating point, and some require explicit declarations of floats vs integers/
  • Running floating point "all the time" on an 8bit CPU is not a great recipe for "product success."  You can tell from all the BASIC52 based boards that are still widely used (not!)  There are significant size and speed issues.
  • Ditto for a bunch of the other "higher level" languages.
OTOH, if the original code had been written on an ARM variant of "something", the OP might never have noticed assorted integer length issues, since they would have been 32bits instead of 16...   The whole "expressions involving constants may be computed using 16bit integers" is one of the biggest traps that catches "somewhat experienced" programmers on Arduino, and it's not Arduino's "fault"   (it doesn't happen in the vast majority of C-like environments, because ... 32bit ints.)

 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Microcontroller alternative to Arduino
« Reply #55 on: June 15, 2016, 11:19:30 pm »
The whole "expressions involving constants may be computed using 16bit integers" is one of the biggest traps that catches "somewhat experienced" programmers on Arduino, and it's not Arduino's "fault"   (it doesn't happen in the vast majority of C-like environments, because ... 32bit ints.)
^*THIS*^
To not be caught out by the standard compliant minimum integer length trap, you need to either be *much* smarter than the average bear, or to have a background in programming 8 or 16 bit embedded systems in C, or to have been a C programmer long enough to have welcomed in the ANSI C89 standard!   One more generation, and there will be very few people left from the K&R C era still coding . . . . . .
 

Offline System Error Message

  • Frequent Contributor
  • **
  • Posts: 473
  • Country: gb
Re: Microcontroller alternative to Arduino
« Reply #56 on: June 16, 2016, 12:55:08 am »

Just some things you can do with microcontrollers.
 

Offline martyTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #57 on: June 20, 2016, 10:08:43 pm »
Just remember this is an entry point platform..

We must first roll,crawl,walk, and run in due time.

Seeing a post on an Arduino question shouldn't get a PhD response.
 

Offline nikodean1

  • Newbie
  • Posts: 8
  • Country: jm
    • Kompulsa
Re: Microcontroller alternative to Arduino
« Reply #58 on: June 27, 2016, 01:56:42 pm »
Texas Instruments has some models that offer lots of processing power and flash memory for the price, but Arduino appears to have a much larger community to support it (and you're going to appreciate the abundance of tutorials and code samples available for them. Although, to be fair to TI, the Hercules models can be used with HALCoGen, which provides great libraries and a GUI which can save you some work (for example, you can generate a PWM signal with just a few clicks), and typing basically one line of code.
Sincerely,

Nicholas Brown. My engineering resources: https://www.kompulsa.com/engineering-resources/
 

Offline ez24

  • Super Contributor
  • ***
  • Posts: 3082
  • Country: us
  • L.D.A.
Re: Microcontroller alternative to Arduino
« Reply #59 on: June 28, 2016, 04:49:47 am »
Just remember this is an entry point platform..

We must first roll,crawl,walk, and run in due time.

Seeing a post on an Arduino question shouldn't get a PhD response.

Don't worry - this is normal on this forum.   :-+   I think there are a lot of PhDs here.
YouTube and Website Electronic Resources ------>  https://www.eevblog.com/forum/other-blog-specific/a/msg1341166/#msg1341166
 

Offline stj

  • Super Contributor
  • ***
  • Posts: 2155
  • Country: gb
Re: Microcontroller alternative to Arduino
« Reply #60 on: June 29, 2016, 01:57:49 am »
i say get a Nucleo board.
the 64pin ones are cheaper than arduino with onboard usb programmer and debug unit.

the best 144pin F767zi board is 200MHz and has hardware double-precision floating point math hardware and 2meg of flash.
and still only costs about $20
 

Offline ez24

  • Super Contributor
  • ***
  • Posts: 3082
  • Country: us
  • L.D.A.
Re: Microcontroller alternative to Arduino
« Reply #61 on: June 29, 2016, 02:20:58 am »
i say get a Nucleo board.
the 64pin ones are cheaper than arduino with onboard usb programmer and debug unit.

the best 144pin F767zi board is 200MHz and has hardware double-precision floating point math hardware and 2meg of flash.
and still only costs about $20

There is a 500+ page book written by a forum member who uses the Nucleo-64 as the tool used in the book.

https://leanpub.com/mastering-stm32

There are some sample pages available

YouTube and Website Electronic Resources ------>  https://www.eevblog.com/forum/other-blog-specific/a/msg1341166/#msg1341166
 
The following users thanked this post: stj

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Microcontroller alternative to Arduino
« Reply #62 on: June 29, 2016, 08:09:53 am »
Quote
https://leanpub.com/mastering-stm32
Are there similar books for any other vendors' ARM chips?
https://www.amazon.com/Embedded-Systems-Introduction-Cortex-Microcontrollers/dp/1477508996/ Might work for the TI Tiva chips?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf