Author Topic: First Arduino experience.  (Read 759 times)

0 Members and 1 Guest are viewing this topic.

Online paulca

  • Frequent Contributor
  • **
  • Posts: 275
  • Country: gb
First Arduino experience.
« on: December 08, 2017, 09:05:58 AM »
Got my first Arduino this evening.  A £3 Nano "compatible".  Soldering the headers was easy, took all of 5 minutes.  Stuck it in a breadboard, powered it and it blinked at me.  Out of the box it worked.  £3.  Where's the fun in that?

Linux ... software installed and ran fine.  /dev/ttyACM* ... nothing.  Messed about recompiled my kernel a few times and after half an hour I rebooted to windows.

Windows 7... software took ages to download, I eventually caught Steam using all the Internet for whatever it wanted to do, large object over the head of Steam and...  The software installed and ran.  COM errors.  Apparently the software chooses COM1 first even though it's a dummy. COM3 worked.

Uploaded a modification of the blink program to morse code "SOS" and it worked.

Played about with reseting it, running it off breadboard or USB.  Resilient little thing.  Went to reprogramme it and "device error".  Windows would longer recognize it was plugged in, no matter how many times I plugged or unplugged it.

Rebooted.  Thing works fine on COM3 again.  (I hate windows)

The worry for me right now is... given it's ADC and DAC capabilities.... I can do so much more in software without having to deal with the complicated analogue electronics stuff, so I will run away from the later scared and do everything with an Arduino or a PI  and not bother learning analogue electronics. 

I gather that would be the appeal of the arduino.   Considerably lower level than the PI but as easy to get up and running.  PI and Python, high level, big OS, big power, LOTs of processing and LOTs of memory £30.  Arduinno, very little memory (Java (or pythong) programmers need not apply), very little power, no OS, but even more capable when it comes to things like ADC, DAC and almost as capable when it comes to interfacing with external sensors and gizmos £3 (or £15 for a branded 'original').

Arduino + Gizmo + Google = instant gratification.

But hey ,it gets people more interested in STEM, electronics, science, technology and engineering,  it works for me.

As a software guy I love it.  Now I can get values out of circuits and back into circuits from software. The horizon has widened.

Still have to get it working in Linux, but... My linux is a custom job, based on Gentoo, the fact it didn't have ACM drivers didn't help, so I'm maybe missing support for something else, like external/usb TTYs or something that I've never needed before, that normally are there in Ubuntu et. al. and I have never enabled.
"What could possibly go wrong?"
 

Online paulca

  • Frequent Contributor
  • **
  • Posts: 275
  • Country: gb
Re: First Arduino experience.
« Reply #1 on: December 08, 2017, 09:10:05 AM »
By the way..

Newbie to newbie

BLUTAK!

Thanks to Julian Ilett on youtube [1], but a lump of blutak makes things so much easier to solder.  For Americans it's like sticky clay used to put up posters on walls, but as a clay like thing you can poke headers into a lump of it, position the board on top, squeeze and mold the lump to get the shape you want and... only need to hold the solder and soldering iron.

[1] http://www.youtube.com/channel/UCmHvGf00GDuPYG9DZqQKd9A
"What could possibly go wrong?"
 

Offline John B

  • Regular Contributor
  • *
  • Posts: 81
  • Country: au
Re: First Arduino experience.
« Reply #2 on: December 08, 2017, 09:17:24 AM »
Just a tip, if you have trouble getting a nano compatible board to connect, look on the underside of the PCB and have a look at the USB chip. Many of them use a Win Chip Head IC, and I found it much more reliable to download the drivers directly from their website (in chinese if I remember, but I still found the drivers). The logo on the IC is WCH, but also looks like HDM upside down. In a few cases, windows couldn't automatically find a driver.
 

Offline ez24

  • Super Contributor
  • ***
  • Posts: 2632
  • Country: us
Re: First Arduino experience.
« Reply #3 on: December 08, 2017, 09:52:12 AM »
.... have a look at the USB chip.

My first experience with Arduino:

Got two real UNOs and carefully followed directions and they would not work.   Got on a forum and tried everything that I was told to do for 3 days.  There was another guy who just got one and it also did not work.  After 3 days the mystery was solved.  He and I got new developed boards from arduino.cc  vs arduino.org  and the new board had a different USB chip than the original and it required new drivers that were not available.  After 3 days new software was uploaded.  It took me year(s) to try Arduino again because I was so pissed that a real product had the wrong software.  Last week I got a clone (will not buy from Arduino anymore) Mega 2560 and it worked out of the box so I am starting to try C++ again.  It comes up on Com 6 (I do not know what 1-5 are).

Now .cc and .org have decided to work together.


Offline phil from seattle

  • Regular Contributor
  • *
  • Posts: 79
  • Country: us
Re: First Arduino experience.
« Reply #4 on: December 08, 2017, 09:56:42 AM »
Most nano v3 clones use the CH340 for USB. Older versions of Linux didn't have the driver. Recent Ubunus have it it though. Win 10 and Win 7 on my machines connect to it no problem.
« Last Edit: December 08, 2017, 09:58:41 AM by phil from seattle »
 

Offline chris_leyson

  • Frequent Contributor
  • **
  • Posts: 615
  • Country: wales
Re: First Arduino experience.
« Reply #5 on: December 08, 2017, 11:37:22 AM »
Hi paulca, glad to hear that everything went well.
Quote
As a software guy I love it.  Now I can get values out of circuits and back into circuits from software. The horizon has widened.
It's good, no bloatware and the hardware is really inexpensive.
My first Arduino experience was more frustration than anything else, I found that the code generated by the IDE was really slow, I think I was expecting far too much from it. To speed things up a bit I went for Pinguino and bare metal programming with MPLAB. But that's not the same as Arduino.
 

Offline Nusa

  • Frequent Contributor
  • **
  • Posts: 531
  • Country: us
Re: First Arduino experience.
« Reply #6 on: December 08, 2017, 12:06:33 PM »
Hi paulca, glad to hear that everything went well.
Quote
As a software guy I love it.  Now I can get values out of circuits and back into circuits from software. The horizon has widened.
It's good, no bloatware and the hardware is really inexpensive.
My first Arduino experience was more frustration than anything else, I found that the code generated by the IDE was really slow, I think I was expecting far too much from it. To speed things up a bit I went for Pinguino and bare metal programming with MPLAB. But that's not the same as Arduino.

The arduino library routines (digitalRead/digitalWrite) for port i/o are SLOW because of idiot checks and pin lookups, but they work for most projects because real performance is not required, especially during the learning phase. Those that really need speed can get large improvements by reading/writing the ports themselves. Of course, you need to have a few programming skills AND have an understanding of how the port registers work.
 

Offline phil from seattle

  • Regular Contributor
  • *
  • Posts: 79
  • Country: us
Re: First Arduino experience.
« Reply #7 on: December 08, 2017, 04:19:07 PM »
Hi paulca, glad to hear that everything went well.
Quote
As a software guy I love it.  Now I can get values out of circuits and back into circuits from software. The horizon has widened.
It's good, no bloatware and the hardware is really inexpensive.
My first Arduino experience was more frustration than anything else, I found that the code generated by the IDE was really slow, I think I was expecting far too much from it. To speed things up a bit I went for Pinguino and bare metal programming with MPLAB. But that's not the same as Arduino.

The arduino library routines (digitalRead/digitalWrite) for port i/o are SLOW because of idiot checks and pin lookups, but they work for most projects because real performance is not required, especially during the learning phase. Those that really need speed can get large improvements by reading/writing the ports themselves. Of course, you need to have a few programming skills AND have an understanding of how the port registers work.
And, you can still use the Arduino IDE/bootloader/libraries (like for displays, etc).
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 1269
  • Country: nz
Re: First Arduino experience.
« Reply #8 on: December 08, 2017, 05:29:24 PM »
I think the original poster with have more luck using /dev/ttyUSB0.

/dev/ACM* is an Linux-on-ARM thing.

Just do 'dmesg' after plugging in to see what device it has detected.
 

Online paulca

  • Frequent Contributor
  • **
  • Posts: 275
  • Country: gb
Re: First Arduino experience.
« Reply #9 on: December 08, 2017, 06:35:20 PM »
I think the original poster with have more luck using /dev/ttyUSB0.

/dev/ACM* is an Linux-on-ARM thing.

Just do 'dmesg' after plugging in to see what device it has detected.

Yea.  All I get is:

[  763.597289] usb 3-2: new full-speed USB device number 2 using xhci_hcd

Nothing more.  No device recognition, no driver loading, nothing.  The only ttys I have are /dev/ttyNN or /dev/ttyAA 325 of them.  0-99, aa-zf

Although, I do get this in "lsusb":

Bus 003 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

So lsusb can enumerate it.  This gives me a lead at least. I'll have a play later to see if I can find a driver for HL-340 or whatever that is.

The Linux tutorials are interesting because they jump straight past the Arduino software into building cross-compile tool chains  (GCC et. al) and (I assume) writing to the device yourself without the Arduino software.    I'll maybe pick that up later.

EDIT:
Ran
cd /usr/src/linux
make menuconfig

Searched with "/" for ch341 and found it straight away.
USB Winchiphead CH341 Single Port Serial Driver
Enabled it as a module.
make modules modules_install
modprobe ch341


Bingo:
[ 1552.197357] usb 3-2: new full-speed USB device number 8 using xhci_hcd
[ 1552.363153] ch341 3-2:1.0: ch341-uart converter detected
[ 1552.391232] usb 3-2: ch341-uart converter now attached to ttyUSB0

« Last Edit: December 08, 2017, 06:43:25 PM by paulca »
"What could possibly go wrong?"
 

Online Seekonk

  • Super Contributor
  • ***
  • Posts: 1578
  • Country: us
Re: First Arduino experience.
« Reply #10 on: December 08, 2017, 10:24:59 PM »
I hate the headers.  I don't know what they plate some of them with, but some of them don't flow solder very well even with flux.  Most of the dupont wires are crap. I just solder directly to the board for reliability and use the nano as a breadboard. For 40 years I twideled pots and subbed resistors.  It's nice just to enter a number.
« Last Edit: December 08, 2017, 10:27:26 PM by Seekonk »
 

Online paulca

  • Frequent Contributor
  • **
  • Posts: 275
  • Country: gb
Re: First Arduino experience.
« Reply #11 on: December 08, 2017, 10:28:09 PM »
Rant warning!!!

http://www.ladyada.net/learn/arduino/lesson4.html

I haven't even got to the good bit, but this tutorial has already made so many school boy errors it's irritating.

1.  It complains that hard disks use SI multiples for Kilo, Mega bytes.  It's ironic that the tutorial is about serial communications and it fails multiple times to realise that "hard disks don't care what your data is" because the data is treated as serial bits.  They only use "octets" to make things convenient.  "Bytes" are ONLY used in computers/micros because of bus width and data word lengths.  They can be 4 bits, 8, 16, 24, 32, 64, 128 bits wide.  Hard disks don't care.  It's not a marketing tactic it's a well established standard.  ALL data storage and data transfer specs are in SI units of bits or SI units of octets.  if they aren't and are written in powers of 2, "x 1024" they are wrong.

2.  println("Hello World!") ... without looking at the source code for this library function I can tell you it is NOT going to send 12 bytes.  It will be 13 or more likely 14 bytes.

Hello World!\n\0

They forgot the new line and the null terminator.  This is important because if you were to allocate a bit of memory for that string and assume it's 12 characters when you insert your Hello World\n\0 into it, it will over run by 2 bytes.  Your program will probably run fine, but might well blow up at some later time when something is using those 2 bytes for something else.

This is fundamental for C or assembly that you understand this or your code will randomly crash.

/rant.
"What could possibly go wrong?"
 

Offline Canis Dirus Leidy

  • Contributor
  • Posts: 26
  • Country: ru
Re: First Arduino experience.
« Reply #12 on: December 08, 2017, 10:31:12 PM »
Bingo:
[ 1552.197357] usb 3-2: new full-speed USB device number 8 using xhci_hcd
[ 1552.363153] ch341 3-2:1.0: ch341-uart converter detected
[ 1552.391232] usb 3-2: ch341-uart converter now attached to ttyUSB0
By the way. Which version of linux kernel is installed? Because in pre 4.10 versions CH341 was only partially supported (unless distro maintainers backported driver or added their own patches). As a result (I got it with Chinese RS232 dongle) adapter was simply non-working: system see CH341 but it was impossible to get any sane data from device due to data/parity/stop bits configuration mismatch.
 

Online paulca

  • Frequent Contributor
  • **
  • Posts: 275
  • Country: gb
Re: First Arduino experience.
« Reply #13 on: December 08, 2017, 10:43:17 PM »
Bingo:
[ 1552.197357] usb 3-2: new full-speed USB device number 8 using xhci_hcd
[ 1552.363153] ch341 3-2:1.0: ch341-uart converter detected
[ 1552.391232] usb 3-2: ch341-uart converter now attached to ttyUSB0
By the way. Which version of linux kernel is installed? Because in pre 4.10 versions CH341 was only partially supported (unless distro maintainers backported driver or added their own patches). As a result (I got it with Chinese RS232 dongle) adapter was simply non-working: system see CH341 but it was impossible to get any sane data from device due to data/parity/stop bits configuration mismatch.

I believe it's 4.4.2-gentoo but I can easily upgrade it in a few minutes.  The advantages of running a source based distro is that kernel upgrades are (usually) very easy.

zcat /proc/config.gz > .config
make menuconfig
EXIT and save
make -j 9 all modules modules_install install
(Check boot loader and symlinks)
reboot.
Pray.
"What could possibly go wrong?"
 

Online paulca

  • Frequent Contributor
  • **
  • Posts: 275
  • Country: gb
Re: First Arduino experience.
« Reply #14 on: December 08, 2017, 10:46:39 PM »
It seem it fully supports the rs232 serial, but not the i2c. 

The arduino uses the rs232 serial doesn't it?  So I would only run into problems if I try and use I2C over USB?
"What could possibly go wrong?"
 

Offline Buriedcode

  • Frequent Contributor
  • **
  • Posts: 685
  • Country: gb
Re: First Arduino experience.
« Reply #15 on: December 09, 2017, 01:12:01 AM »
The AVR in the Arduino does indeed use the UART (not really RS232 as its TTL levels) using one of the handshake lines on the CH341 to reset it.  I'm unsure how one would go about using the two-wire interface on the CH341.

Its a surprisingly quick and convenient way to prototype which is why after years of avoiding it (in favour of my own atmega328 board..) I know use it for prototyping for almost all small projects.
 

Offline Nusa

  • Frequent Contributor
  • **
  • Posts: 531
  • Country: us
Re: First Arduino experience.
« Reply #16 on: December 09, 2017, 01:12:36 AM »
It seem it fully supports the rs232 serial, but not the i2c. 

The arduino uses the rs232 serial doesn't it?  So I would only run into problems if I try and use I2C over USB?

If you're talking software, then basically yes, adequate support.

If you're talking hardware, then no. RS-232 is NOT the same thing as TTL UART at all, although some people incorrectly call it that. The most critical difference is voltage levels. TTL signals are between 0 and VCC. RS-232 signals may range from -15 and +15V, and the specs say up to +/- 25V must be tolerated.

I2C is a different animal. Arduino has hardware support for it on specific pins, but it's not enabled out of the box with any default bootloader I know of. You have to implement i2c yourself (there are libraries) if you want to use it.
 

Online paulca

  • Frequent Contributor
  • **
  • Posts: 275
  • Country: gb
Re: First Arduino experience.
« Reply #17 on: December 09, 2017, 01:47:24 AM »
I2C is a different animal. Arduino has hardware support for it on specific pins, but it's not enabled out of the box with any default bootloader I know of. You have to implement i2c yourself (there are libraries) if you want to use it.

What about SPI?

One of my go-to reasons for the ardie was I2C and SPI "maker modules" to play with.

But as you say, I can do I2C in software with libraries.
"What could possibly go wrong?"
 

Offline Buriedcode

  • Frequent Contributor
  • **
  • Posts: 685
  • Country: gb
Re: First Arduino experience.
« Reply #18 on: December 09, 2017, 02:43:48 AM »
I2C is a different animal. Arduino has hardware support for it on specific pins, but it's not enabled out of the box with any default bootloader I know of. You have to implement i2c yourself (there are libraries) if you want to use it.

What about SPI?

One of my go-to reasons for the ardie was I2C and SPI "maker modules" to play with.

But as you say, I can do I2C in software with libraries.

I'm not entirely sure what you're after.  Generally the Arduino nano and uno both use the atmega328, either at 3.3V or 5V, with clock options of 8MHz or 16MHz.  The atmega328 has a two-wire port, as well as an SPI port, the former fully supports I2C, so rather than try to modify a board and use the CH340 for I2C... why not just use the micro as a serial-I2C bridge?  I believe that's what most people do, and I'm guessing that's what you're doing.

You can also do 'I2C in software' but I don't see why when the AVR has hardware support for it (still requires a library, or some software fiddling to get it working).
 

Offline phil from seattle

  • Regular Contributor
  • *
  • Posts: 79
  • Country: us
Re: First Arduino experience.
« Reply #19 on: December 09, 2017, 03:14:16 AM »
I'm not sure I understand the "I2C not enabled" comment. You need to have code to use I2C but it only requires the usual initialization needed for the AVR 328.  Same for SPI. The arduino "system" doesn't require anything different from the underlying AVR micro. The arduino is just basically just an AVR breakout board. That's why I like the nano - minimal 'duino to get in the way. Plus, it's breadboard friendly. I buy them 5 at a time from China, $2 a piece or less, and use them for all sorts of simple projects.

By the way, UART isn't the protocol, it's the hardware implementation - https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter. Asynchronous Serial, or more commonly Async, is the name for the protocol.
 

Offline Nusa

  • Frequent Contributor
  • **
  • Posts: 531
  • Country: us
Re: First Arduino experience.
« Reply #20 on: December 09, 2017, 03:40:31 AM »
What they said about I2C. I responded to your "i2c over usb" comment, which made it sound like you wanted bootloader support for I2C. The bootloader is the (often pre-installed) program that allows you to load your program via serial pins (or attached usb connector).

Yes, there is full hardware support for both SPI and I2C on specific pins. You can also do it via software on other pins. Either way, you have to write code or use libraries to make use of it.
 

Online paulca

  • Frequent Contributor
  • **
  • Posts: 275
  • Country: gb
Re: First Arduino experience.
« Reply #21 on: December 09, 2017, 08:11:04 AM »
Well ... this didn't take long.



Unfortunately I forgot to unplug the USB power, with that out it reads circa 20mA.

Mickey mouse, but it's my first ever I2C read, my first graphical OLED.

Of course, most of the credit goes to Adafruit and whoever wrote the SSD1306 library. 

Still cool for a Friday evening tinker.
"What could possibly go wrong?"
 

Offline darrellg

  • Supporter
  • ****
  • Posts: 45
  • Country: us
Re: First Arduino experience.
« Reply #22 on: December 09, 2017, 08:22:21 AM »
Got my first Arduino this evening.  A £3 Nano "compatible".
[...]
The worry for me right now is... given it's ADC and DAC capabilities....
FYI, there is no DAC in a Nano, or any other '328 based board. What it calls "analogOut" is really PWM.
 

Offline Chris935

  • Contributor
  • Posts: 6
  • Country: gb
Re: First Arduino experience.
« Reply #23 on: December 09, 2017, 02:52:12 PM »
By the way..

BLUTAK!


Or if you want them perfectly straight, plug the headers into the breadboard, set Arduino on top, solder.  ;)

Chris
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2354
  • Country: us
Re: First Arduino experience.
« Reply #24 on: December 09, 2017, 03:23:02 PM »
Umm...  Your complaints about the tutorial are ... seriously tiny nits, for that level of tutorial.
Quote
println("Hello World!") ... without looking at the source code for this library function I can tell you it is NOT going to send 12 bytes.  It will be 13 or more likely 14 bytes.
>Hello World!\n\0
They forgot the new line and the null terminator.
The string stored in memory has a null terminator.  The string transmitted will have the newline (and perhaps \r\n) because println adds that, but does NOT include the null terminator.  Because it's the terminator...  Do you want to try to guess how much space the line takes as it sits somewhere in the serial monitor code on the host?  Me neither!  (also, it never says the string is 12 bytes, it just uses 12 bytes in the "problems."
Quote
  This is important because if you were to allocate a bit of memory for that string and assume it's 12 characters when you insert your Hello World\n\0 into it, it will over run by 2 bytes.
But "allocating a bit of memory" for the string would be essentially a different exercise than printing it.
Quote
It's not a marketing tactic it's a well established standard.  ALL data storage and data transfer specs are in SI units of bits or SI units of octets.  if they aren't and are written in powers of 2, "x 1024" they are wrong.
Yeah, memory chips, and the amount of flash and RAM inside the Arduino (all specified in KB, as multipliers of 1024) are technically wrong.  And hard disks might be interesting because 1 bit on the platter may not equal 1 bit of storage, and one byte on the serial port is actually 10 bits transmitted, and ... all sorts of stuff that really isn't appropriate for a beginner's tutorial.
See also https://www.cnet.com/news/gigabytes-vs-gibibytes-class-action-suit-nears-end/


Quote
Well ... this didn't take long.
... t's my first ever I2C read, my first graphical OLED
And that's the beauty of it all, isn't it?  Perhaps you feel a bit guilty about not having to have written your own functions to manipulate the I2C interface, because those Arduino libraries are bloated an inefficient?   Or perhaps not!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf