Author Topic: Arduino: To(o) cheap or not to(o) cheap?  (Read 8002 times)

0 Members and 1 Guest are viewing this topic.

Offline RyanTTopic starter

  • Contributor
  • Posts: 31
  • Country: ca
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #25 on: March 20, 2018, 06:40:05 pm »
Update!

On the advice of several of you, I've gone ahead and ordered a couple of $4 Uno 3 clones (socketed uC). I also tagged a couple of extra ATmega328Ps for my next Digi-Key order, for bits and giggles.

I by no means want to discourage further conversation, though. The kind of information you've all shared will be invaluable for future projects, too.

Thanks again.
 
The following users thanked this post: imidis

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #26 on: March 20, 2018, 07:37:39 pm »
socketed uC
Hot air is like removing from a socket for the SMD equivalent.  But each to their own. DIPs are so last century.  :)
 

Offline metrologist

  • Super Contributor
  • ***
  • Posts: 2213
  • Country: 00
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #27 on: March 20, 2018, 08:02:20 pm »
Well, I like the nano form factor. Most of my solderless breadboards have a nano on them.
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 12298
  • Country: au
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #28 on: March 21, 2018, 12:58:25 am »
I like the nano FF as well.  In my last serious project, the board could fit inside the existing case even using the mini USB socket with a creative cabling solution, which allowed for a field replaceable USB cable.

Although having limited on board I/O there's still a lot you can do.  This project used everything except the TX/RX pins and digital pin 13 (but that last one is tagged for an additional option).

The only problems I've had were:
 * At the very beginning, realising I needed the CH340 driver.  I was expecting FTDI, but once I worked this out I actually felt a whole lot more comfortable knowing I didn't have the FTDI Sword of Damacles to worry about.
 * Not being able to find some of the library components in the IDE (that is seriously impossible to follow for a casual user).  A fresh download and install of the complete IDE fixed that.
 * Incorrect testing technique (a.k.a. my own stupidity) blowing out an I/O pin or two.  The processor still works and if I ever get around to it, I could identify the dud pins and maybe use it for some simple project.
 * Bricking a couple through my own less-than-brilliant efforts.  It's probably just the bootloader I've stuffed and maybe I'll get around to reflashing that at some point.

I have a couple of MEGA 2560 and MEGA ADK boards as well as UNO, but I buy the NANO in lots of 5.  At circa $3 a pop, why wouldn't you?


And, yes, there are certainly "better" chips and platforms out there - but they aren't necessary for the type of stuff I generally do today.  Arduino does it.  If I ever step into an area where that's inadequate, then I will examine the options at that time.  Doing that now might turn out to be an exercise in studying history.
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #29 on: March 21, 2018, 03:39:58 am »
Well, I like the nano form factor. Most of my solderless breadboards have a nano on them.

I like the ProMini myself, since once a project is encased I no longer need a USB interface. They are so cheap from China it's unbelievable.

The easiest person to fool is yourself. -- Richard Feynman
 

Online paulca

  • Super Contributor
  • ***
  • Posts: 4053
  • Country: gb
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #30 on: March 21, 2018, 07:44:15 am »
My 2 cents...

Uno clones are grand.  They come in a variety of honesty though.  A "good" clone will have a socketed DIP ATMega chip and a 16u2 USB interface.... ie. it will look exactly like the original.  They can be found for under $5 on ebay.  The cheaper clones use a surface mount ATMega and usually a CH380 USB chip.  The later can have some driver issues in Window's I'm told, but it's solvable with google.  The CH380 is much more robust, the genuine Arduino USB chip is prone to getting fried if you do anything nasty with the power rails.

Don't aim for STM, Arm, et. al. as there is nowhere near as much support when getting started.

Nano clones are potentially better as they slot into a breadboard limiting the amount of stuff on the desk and make it easy to just embed one into a project long term, or even solder it into a strip board.  Nano clones can be got for as little as $3.

You won't need a programmer straight off as both the Uno and and Nano are capable of being a decent ISP programmer if you choose to go "chip only" on a breadboard.  The sketch you need comes with the Arduino IDE "Arduino as ISP" and the only other thing you need are 5 breadboard jumper leads.  I have found the other cheap ISP programmers less reliable.  Genuine AVR programmers are far more expensive.

"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline bd139

  • Super Contributor
  • ***
  • Posts: 23024
  • Country: gb
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #31 on: March 21, 2018, 09:33:01 am »
Actually who needs an arduino? Here's what I'm using for AVR dev. As simple as it gets. If you're on windows use the arduino toolchain to build it:

Schematic:



Hardware:



Program:

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

int main()
{
// Set port D as output
DDRD = 0xFF;

while (1)
{
// Set PD0
PORTD |= (1 << PD0);

// Sleep a bit
_delay_ms(500);

// Unset PD0
PORTD &= ~(1 << PD0);

// Sleep a bit
_delay_ms(500);
}
}

Makefile:

Code: [Select]
# Project name
PROJECT=avrhelloworld

# Space separated list of all source files
SOURCES=main.c

# Set the target
MCU=atmega328p

# Clock speed of the AVR in Hz
SPEED=1000000

# AVRDUDE microcontroller type
MCUDUDE=m328p

# AVRDUDE programmer type
PROGRAMMER=usbasp

# not target specific. Don't need to change anything below
CC=avr-gcc
OBJCOPY=avr-objcopy
CFLAGS=-c -Os -Wall -DF_CPU=$(SPEED)UL
LDFLAGS=-mmcu=$(MCU)
ELF=$(PROJECT).elf
HEX=$(PROJECT).hex
OBJECTS=$(SOURCES:.c=.o)

all: $(SOURCES) $(ELF) $(HEX)

$(ELF): $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS)

$(HEX): $(ELF)
$(OBJCOPY) -j .text -j .data -O ihex $(ELF) $(HEX)

.c.o:
$(CC) $(LDFLAGS) $(CFLAGS) $< -o $@

clean:
rm $(OBJECTS) $(HEX) $(ELF)

burn:
avrdude -c $(PROGRAMMER) -p $(MCUDUDE) -u -U flash:w:$(HEX)

Packages required:

make
avr-libc
avr-gcc
avrdude

go go go :)

USBasp from ebay/bitsbox/china/wherever. Make sure you stick it in 5V mode first.
 
The following users thanked this post: RyanT

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #32 on: March 21, 2018, 09:53:54 am »
Another reason to get the genuine Uno or a 100% compatible clone with the ATmega16U2 USB interface is you can actually load custom code into the 16U2. 

Here's how to use the 16U2 to emulate a AVRISP mkII and program a blank '328P in its usual socket.  Minimal soldering required - just to populate the header JP2, then its just a matter of connecting four short F-F jumper wires and using Atmel's FLIP tool to reload the 16U2 in DFU mode.
https://make.kosakalab.com/make/electronic-work/burn_bootloader_uno_en/

If you are feeling somewhat braver (and have a spare Arduino or AVR ISP programmer handy in case you brick the 16U2, or want to revert it to the DFU bootloader), you can install Hoodloader2
https://github.com/NicoHood/HoodLoader2
which lets you run sketches on the 16U2, turning the Uno into a multi-processor board equivalent to a cut-down Arduino Micro (only 10 I/Os available with 3 used for comms to the other AVR) with a serial interface to the standard Uno 328P,
 

Online paulca

  • Super Contributor
  • ***
  • Posts: 4053
  • Country: gb
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #33 on: March 21, 2018, 10:54:13 am »
Actually who needs an arduino? Here's what I'm using for AVR dev. As simple as it gets. If you're on windows use the arduino toolchain to build it:

Who needs a bakery or supermarket!  Here's what I am using for bread:


No, not really.  I go to Tesco's.  :)

Where the non-arduino AVR stuff come into play is when you:

a) Want to put your arduino-ified breadboard onto a PCB and... not solder a Nano or Mini in there.
b) Want or need to decouple yourself from the nursing libraries provided by Arduino.  Usually this is because the Arduino libraries come at a cost in software terms and aren't always as efficient as you would hope for.  digitalWrite() probably the most used function is actually really slow in comparison to a single bit set operation on an IO port.

But... until you care about those, the Arduino, to me, is like using a DMM instead of having to build a voltage divider and panel meter for each voltage measurement.  I can plug it in, write a few lines of code and hit Upload, then pull it back out of the project and throw it into another one. 

When I come to bulding a PCB, then... I pull out the minimal schematics for the ATTiny85 or ATMega328.  I still use the Arduino libs as I have yet to find them detrimental to my project.  I have as a learning project created Blinky-sans-Arduino just for fun and a challenge though.

To go from sitting down the bench to blinky with an arduino, I'd estimate 5 minutes.
To go from sitting down at the bench and building an ATMega328P on a breadboard and creating blinky with AVR-Gcc et. al.  More like an hour.
To getting something like an oLED clock with a temp sensor and LDR running with avr-gcc, not including the time to port the libraries away from Arduino functions... a day.
« Last Edit: March 21, 2018, 10:57:57 am by paulca »
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline bd139

  • Super Contributor
  • ***
  • Posts: 23024
  • Country: gb
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #34 on: March 21, 2018, 11:00:26 am »
Who needs a bakery or supermarket!  Here's what I am using for bread:

I make my own bread!

 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #35 on: March 21, 2018, 11:21:21 am »
Random thoughts...
  • Instead of the 16U2 variant for USB HID devices there are lots of alternatives... e.g. Teensy (I have been meaning to update my TM22 joystick for ages) or PICs...
  • All the NHduino clones I have use CH340G and work fine with Windows 10.
  • I bought an AVR dragon (it was very cheap at the time) but have never actually used it on Uno.... but this does remind me that Arduino development on the whole tends to be printf or pin toggle debugging rather than proper breakpoints. (However when timing gets involved breakpoints have limited use... YMMV)
« Last Edit: March 21, 2018, 11:23:53 am by NivagSwerdna »
 

Offline RationalRoot

  • Newbie
  • Posts: 1
  • Country: ie
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #36 on: March 24, 2018, 09:44:58 am »
Some Arduino clones need a separate driver download. Don't let this trouble you. The generally provide a link. I've used elegoo if you want a brand to try. Cheap as chips. Works just fine. https://www.amazon.com/Arduino-Elegoo-ATmega328P-without-compatible/dp/B0713XK923
Hard to go wrong. You just download & install the CH340 driver. I think I got it from https://www.elegoo.com/tutorial/CH340%20Driver.zip
« Last Edit: March 24, 2018, 09:49:37 am by RationalRoot »
 

Online paulca

  • Super Contributor
  • ***
  • Posts: 4053
  • Country: gb
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #37 on: March 24, 2018, 05:43:02 pm »
The clones are usually fine.

Just as a small aside, I got one smoking the other night.  Literally smoking.  Supplying +5V to it's ground pin and connecting it's 5V line to earth ground via another USB device apparently didn't kill it.  I had clicked "Upload" and wondered why it wasn't working, so a good 20 seconds had passed until I noticed the smoke rising from it.

Wired the circuit correctly and the Aruino UNO clone still works fine.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline josip

  • Regular Contributor
  • *
  • Posts: 152
  • Country: hr
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #38 on: March 25, 2018, 07:17:13 am »
.... but this does remind me that Arduino development on the whole tends to be printf or pin toggle debugging rather than proper breakpoints. (However when timing gets involved breakpoints have limited use... YMMV)[/li][/list]

Totally agree with this. I never use breakpoint debugging with micros.

BTW, MSP430 CPUxV2 devices are with mailbox system, that can be used for log by SBW / JTAG, without any extra connection or hardware peripheral. Target device is in free running mode, during exchanging data with SBW / JTAG master.

 

Offline RyanTTopic starter

  • Contributor
  • Posts: 31
  • Country: ca
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #39 on: March 25, 2018, 11:08:38 am »
I'm not going to lie, debugging a uC with printf() is going to feel like cheating compared to the embedded work I'm used to, but I think I'll manage to sufficiently assuage my guilt. :P
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #40 on: March 25, 2018, 11:58:28 am »
In Arduinoland, printf() is borked.  It isn't connected to the UART I/O streams that communicate via the on-board USB chip to a terminal on your PC.

Attempts to connect it either conflict with the Arduino's proprietary 'standard' Serial library, or have massive overheads, so get used to using their Serial.print() (or Serial.println()) methods that will only print a single variable at a time with default formatting that can only be changed between DEC HEX and OCT for integers.

If you thought printf() debugging was ugly, wait till you see Serial.print() debugging! :(
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 12298
  • Country: au
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #41 on: March 25, 2018, 12:02:59 pm »
If you thought printf() debugging was ugly, wait till you see Serial.print() debugging! :(
Yeah ... it's not glamorous.
 

Online paulca

  • Super Contributor
  • ***
  • Posts: 4053
  • Country: gb
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #42 on: March 25, 2018, 12:17:20 pm »
A handy tip for debug and error reporting on Arduino when you don't have a serial connection is to blink an LED.

This becomes more important when you put an AVR chip into a PCB and realise you have no Rx/Tx test/debug pins available.  I'm sure you could use the ISP header (if you have one of those), but the LED method will still be available when your circuit is away from the apron strings of the PC.

As an example on my solar charge controller WiFi monitor device - which uses an ESP8266 but the concept is the same - I use the built in LED as diagnostics.

At power up I turn the LED on.
When waiting on the Wifi to connect I toggle the LED repeatedly with a 100ms delay.  (Rapid flashing).
When the WiFi connects I flash the IP address 4th octet, eg, if it gets 192.168.0.8, then I flash the LED 8 times.  If it gets 252 I flash the LED twice, wait, flash it 5 times, wait, flash it twice.

The LED then goes out.

When in it's main operational loop, a single 100ms pulse signifies a successful operation.  3 flashes denotes a failed operation.  Constant rapid flashing indicates a terminal condition it cannot recover from and should probably force a reset.

So without plugging it in or poking at it with the Wifi and checking logs on the thing that receives data from it, I can look at it and wait 5 seconds for a loop to complete, if it pulses once, it's fine.  When I turn it on I can see the rapid flashing as it connects to the Wifi and known when it stops everything is fine, if it doesn't stop it's borked.

Consider this if you ever put a power LED into an AVR circuit.  Instead run the power LED off a uC pin and use it not just for power, but for diagnostics.  If you have more complex output, just use more LEDs.

(Aside:  Of course as mine is an ESP8266 which is substancially more powerful than an Arduino and has built in Wifi I could probably construct SysLog UDP packets and send them to a SysLog server to actually create a log file.)
https://github.com/arcao/Syslog
« Last Edit: March 25, 2018, 12:22:17 pm by paulca »
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #43 on: March 25, 2018, 12:32:57 pm »
I suggest to not confuse together learning with building. The best learning tool is not always best building tool. I usually suggest to start learning with Arduino, yet I do not suggest to build anything with it. Depending on your personal learning curve steepness after Arduino you can move to next level sooner or later. Some just buy everything - arduino, bluepill and what not, from very beginning, check everything to see which one is the best for them.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #44 on: March 26, 2018, 09:14:03 am »
Quote
In Arduinoland, printf() is borked.  It isn't connected to the UART I/O streams that communicate via the on-board USB chip to a terminal on your PC.
Attempts to connect it either conflict with the Arduino's proprietary 'standard' Serial library, or have massive overheads

Nonsense.   Adding printf() support to an AVR Arduino is relatively trivial, and has no more overhead than most printf() implementations (significantly less than the average newlib-based printf(), in fact.)
Code: [Select]
#include <stdio.h>

int fput(char c, FILE* f) {
  Serial.write( c);
  return 0;
}

void setup() {
  Serial.begin(9600);
  stdout = fdevopen(fput, NULL);
}


Quote
Why on earth would anyone exclude any chip?
Well, I'd suggest excluding things like the ATtiny13, or ATmega48 just to for "playing", even if it does save several dimes per chip.  That kind of optimization is for ... later.  In theory, the ARM vs AVR decision is similar.  In practice, it's not - an ATmega328 Arduino had plenty of headroom in both performance and memory space for most "applications."


Quote
Another reason to get the genuine Uno or a 100% compatible clone with the ATmega16U2 USB interface is you can actually load custom code into the 16U2.
This seems to be underdeveloped, and used a lot less frequently than might have originally be intended.   One reason is that Arduino (and competitors) with actual native USB support started showing up, and they're generally a better solution if you want to speak directly to USB.
(Teensy, Arduino Micro, Leonardo, ...)
« Last Edit: March 26, 2018, 09:25:04 am by westfw »
 

Offline igendel

  • Frequent Contributor
  • **
  • Posts: 359
  • Country: il
    • It's Every Bit For Itself (Programming & MCU blog)
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #45 on: March 26, 2018, 09:54:57 am »
Joining the discussion a bit too late  :)

I have seen many cheap Arduino clones with issues. Some from my own collection, some brought to me for repair by local makers. The problems can be anywhere - from fake/wrong ICs to missing bootloaders to faulty soldering at the hardest-to-reach places.

For the price of a genuine Arduino board, one can buy 5-6 clones and most of them will be ok (assuming not all are bought from the same seller of course :) ). However, having to troubleshoot a bad board is really hard, annoying and discouraging for beginners. So at least in countries where $30 is not that much, my advice is to get one genuine board to begin with. When you know your way a little around the Arduino you can risk clones.

Maker projects, tutorials etc. on my Youtube channel: https://www.youtube.com/user/idogendel/
 

Offline Mr. Scram

  • Super Contributor
  • ***
  • Posts: 9810
  • Country: 00
  • Display aficionado
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #46 on: March 26, 2018, 10:54:26 am »
Joining the discussion a bit too late  :)

I have seen many cheap Arduino clones with issues. Some from my own collection, some brought to me for repair by local makers. The problems can be anywhere - from fake/wrong ICs to missing bootloaders to faulty soldering at the hardest-to-reach places.

For the price of a genuine Arduino board, one can buy 5-6 clones and most of them will be ok (assuming not all are bought from the same seller of course :) ). However, having to troubleshoot a bad board is really hard, annoying and discouraging for beginners. So at least in countries where $30 is not that much, my advice is to get one genuine board to begin with. When you know your way a little around the Arduino you can risk clones.
Another way of dealing with that would be to use the numbers to your advantage. Buy two variants. In the unlikely case one has issues, the other should be fine.
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #47 on: March 26, 2018, 12:31:27 pm »
I have seen many cheap Arduino clones with issues.
100% of mine have worked. Guess I have been lucky. I tend to stick to the "NHduino" variants which have a CPU XTAL as well as the USB XTAL.   https://www.mikrocontroller.net/attachment/258727/CH340G_UNO_ArduinoBoard_3.pdf
e.g. eBay auction: #142051313005 or eBay auction: #141676813121
 
« Last Edit: March 26, 2018, 12:38:18 pm by NivagSwerdna »
 

Offline igendel

  • Frequent Contributor
  • **
  • Posts: 359
  • Country: il
    • It's Every Bit For Itself (Programming & MCU blog)
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #48 on: March 26, 2018, 01:14:02 pm »
I have seen many cheap Arduino clones with issues.
100% of mine have worked. Guess I have been lucky. I tend to stick to the "NHduino" variants which have a CPU XTAL as well as the USB XTAL.   https://www.mikrocontroller.net/attachment/258727/CH340G_UNO_ArduinoBoard_3.pdf
e.g. eBay auction: #142051313005 or eBay auction: #141676813121

But... all Uno-type boards have that, don't they? I think only the old Duemilanove models with the FTDI chips didn't have a cyrstal for the USB. Or perhaps I should say "FTDI"  ;D
Maker projects, tutorials etc. on my Youtube channel: https://www.youtube.com/user/idogendel/
 

Offline Bassman59

  • Super Contributor
  • ***
  • Posts: 2501
  • Country: us
  • Yes, I do this for a living
Re: Arduino: To(o) cheap or not to(o) cheap?
« Reply #49 on: March 27, 2018, 03:39:02 am »
A handy tip for debug and error reporting on Arduino when you don't have a serial connection is to blink an LED.

This becomes more important when you put an AVR chip into a PCB and realise you have no Rx/Tx test/debug pins available.  I'm sure you could use the ISP header (if you have one of those), but the LED method will still be available when your circuit is away from the apron strings of the PC.

Instead of blinking an LED, you could monitor an otherwise-unused GPIO pin (or two, or more) with an oscilloscope. This is very handy for checking to see how often an interrupt occurs, for example. Set the pin when you enter the ISR, clear it when leaving. Or just toggle it on entry. You’ll never see that change on an LED, but it’s quite obvious on a ‘scope.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf