Using an Arduino Due as a mini-QC controller

My Nissan Leaf Forum

Help Support My Nissan Leaf Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

garygid

Well-known member
Joined
Apr 21, 2010
Messages
12,469
Location
Laguna Hills, Orange Co, CA
Presently, we have been using, and gotten a lot of "mileage"
out of the AVR-CAN board, which supports one CAN bus,
digital and some analog I/O, and a serial port.

However, as a 16 Mhz 8-bit uP, it is not the fastest kid
on the block. The whole Arduino lineup is nicely
supported, has many enthusiasts, but was also
a bit under-powered. Until recently...

The Arduino Due, with the form factor of the Arduino Mega 2560,
sports 84 Mhz and a 32 bit uP, with more I/O, 2 USB, 2 CAN, etc.
Downside, the libraries to support it are... evolving. The porting
of Sketches from the old Arduino architecture to the new Due
architecture seems to impact almost anything except blinking
one LED. Many of the new complexities are hidden by
new function Libraries, written or evolved to support the Due.

So, if you want to help us go down this path of discovery,
joining the "Arduino Due Forum", getting a Due from
one of the many sources, obtain a USB A to micro-B cable,
and download the IDE (Interactive Development Environment)
from Arduino (search Arduino Due Software Development),
version 1.5.4r2 (1.5.x is still a "Beta" version). The zip file is about
150 MB, and it unzips into a folder of about 350 MB. No need to
install, I just moved the folder (Arduino-1.5.3) to the root of
my D-drive, using Vista (but it should work on XP upward, I think).

So, relatively easy to "play", if you desire.
Post below if you are unterested.
Thanks, Gary
 
Getting Started Info:

Ordering an Arduino Due R3:

Sparkfun, Pololu, Amazon, eBay, and others carry the Arduino Due.
There are even clones, but the Due R3 is the latest genuine
board, as of 1 Sept 2013, and is typically found for about $50.

Some links:
http://www.mouser.com/ProductDetail/Arduino/A000062/?qs=%2fha2pyFaduiZABvG4cWGliztKnOI%252bnXJLcGrUqiduMw%3d" onclick="window.open(this.href);return false;
https://www.sparkfun.com/products/11589" onclick="window.open(this.href);return false; (lots in stock)
http://www.iorodeo.com/content/arduino-due-r3" onclick="window.open(this.href);return false;
http://www.amazon.com/Arduino-A000062-Due/dp/B00A6C3JN2" onclick="window.open(this.href);return false;

Ordering a USB cable for Programming the Due

A USB-A to micro-B cable is necessary for first use of the Due.
It powers the Due, allows the IDE to conveniently flash
the Due, and allows statements like Serial.print("Hello World") to show
text in the Serial Monitor window, which is a Tool included in the IDE.

Available from many places, and commonly found to charge phones and tablets.
Although local sources might be faster, or you might already have this
USB "micro" cable, it is not included with the Arduino Due.

links:
http://deepsurplus.com/Computer-Cables-Accessories_2/USB-Cables-A-Male-to-USB-Micro-B-Male_2" onclick="window.open(this.href);return false;

Ordering a Prototype Shield for the Due

Not necessary, but might be convenient if you need to add some circuitry
or connections (we do). I just ordered from NKC.

NOTE: If the shield is not the top shield, it should extended the 2x3 SPI connector
in the middle of the proto area. Somewhat inconveniently, this requires a long-pin
2x3 female header mounted upside down (the pin side up)!

links:
http://store.nkcelectronics.com/MEGAshield-KIT-for-Arduino-MEGA-2560-R3-and-Arduino-DUE_p_309.html" onclick="window.open(this.href);return false; (for Due, FL. 33326, I bought these.)

other links:
https://www.sparkfun.com/products/9346" onclick="window.open(this.href);return false; (for Mega 2560, and not the best)
http://www.adafruit.com/products/192?gclid=CLHo0b7NibcCFYPd4AodO3QAlA" onclick="window.open(this.href);return false; (for Due, much better)
http://togglebit.net/2013/06/11/protocanshield-for-the-due/" onclick="window.open(this.href);return false; (layout for two CAN ports)

A color TFT display, with Touch input, and a Display Shield:

I bought several display sizes from ColdTears Electronics, and their
display shield for the Due. All of these are with the "font chip".

The 5" (800x480) and the High-Resolution version of the 3.2" (480x320)
are best supported at the present time. However, as of
October 2013, I have added support for the 3.5" (480x320)
touch display, and the 4" and 7" displays (both 800x480).

So, all five sizes are candidates, depending upon
the requirements of the application.
I am using the CTE50 and CTE32HR for now, attempting
to make a controller and logger for the mini-QC device.
However, my software runs on all five sizes.

CTE32HR (480x320) for $30:
http://www.ebay.com/itm/3-2-inch-480x320-TFT-LCD-module-w-Font-IC-ILI9481-arduino-DUE-MEGA-2-8-3-5-/121097673674?pt=LH_DefaultDomain_0&hash=item1c31fbdbca" onclick="window.open(this.href);return false;

Display Shield for Arduino Due for $13:
http://www.ebay.com/itm/TFT-SD-Shield-for-Arduino-DUE-TFT-LCD-Module-SD-Card-Adapter-2-8-3-2-inch-Mega-/121057447668" onclick="window.open(this.href);return false;?

Yes, shipping take quite a while.

Getting the IDE from Arduino:

Download the latest version 1.5.? "Beta" Zip file (about 150 MB), free, from:
http://arduino.cc/en/main/software" onclick="window.open(this.href);return false;

You don't need the installer. The UnZip process will create a folder
with around 1700 files, about 350 MB in size, typically named
the "arduino-1.5.4" folder for this latest version.

This folder can be moved almost anywhere, but I usually put it at the
root of my D (or C, if there is no D) drive, primarily to minimize the
length of the path names. Others have "buried" the folder and
have had problems.

The arduino.exe file is easily found insde. Just double-click to run it.

Running your first Due Sketch

After starting the arduino.exe program, select Board in the Tools menu,
and select the "Arduino Due (Programming Port)". After you get an actual
Due board, you will also select a Serial Port. For now, without the board,
the best we can do is to select examples, or write new Sketches, and
see if they compile.

There is lots of good information and help at the
Arduino Due Forum
http://forum.arduino.cc/index.php?board=87.0" onclick="window.open(this.href);return false;
 
Usage Hints

Programming USB Port
Just connect the Programming USB Port to the PC, and
note which Comm Port number is assigned by the PC
after the driver installation.

Important hint:
The driver is found by browsing to the ...
/arduino-1.5.4/drivers/
folder.

I usually set the PC to use Comm Port 30 for
this special Programming Port.

Programming
Start with the Example Sketches (programs for Arduino)
that are included, and then try some of those that are
typically included with each library.

Note, not all the examples work on the Due.

Serial Monitor Tool
If the Sketch uses the convenient Serial functions, like
Serial.print("Hello World") ;
you can typically see that output using the IDE's
Serial Monitor window, which helps with debugging.

Native USB Port
This USB port is supported with firmware and circuitry
in the Due itself, and I use it to send Logging Data
to my CAN-Do program in the PC.

When connected to the PC, with the Due running,
this usually creates a Virtual Comm Port in the PC.
I typically set my PC to "create" Comm Port 10.

To do some debugging, you might use some
Dumb Terminal Program, but it is unusual for
one to work well with binary data instead of
the standard ASCII characters.

Use with CAN-Do:
Get my CAN-Do program (for Windows) and some log files at:
www. wwwsite. com/puzzles/cando/
 
Working Sketches

Examples, as supplied in the IDE

Basic Blink - works with 1.5.3

Constructed Stand-Alone Sketches

Sketches that requires Library Mods

---------
There is lots of goof information and help at the
Arduino Due Forum
http://forum.arduino.cc/index.php?board=87.0" onclick="window.open(this.href);return false;
 
Summary of Hardware and Software:
(as used for my mini-QC project Sketches)

(If anybody needs additional links, I will add them
to the thread's 2nd post, above.)

Hardwre:
1. Arduino Due R3, unmodified
2. Proto-board shield for the Due (not yet required)
3. ColdTears Electronics (CTE) display Shield for Due (not Mega)
4. A CTE touch-display (with font chip), see list below.
5. USB cable, A to micro B to fit the Due's Programming port.
6. Host computer (l use a Windows PC) to run the Arduino IDE
(Interactive Development Environment).
7. Host hardware to run my Windows CAN-Do program (NYR).
8. Another USB cable, like above, if programming and
using CAN-Do "at the same time", primarily to avoid
a lot of plugging and unplugging to the Due.

Software:
1. The latest IDE for the Due (now, 1.5.4r2) from Arduino
2. Three added Libraries, modified by me (UTFT, UTFT_CTE, and UTouch)
3. Other non-included Libraries (DueTC)
4. My Script for Mini-QC simulation (v35 is the current version)
5. My CAN-Do program, not required, for capturing and seeing log data.

Touch Display Boards:
CTE32HR or CTE35 are the most likely candidates,
because of their lower cost. Both are 480X320.
I have also used the larger 4", 5", and 7" displays, all 800x480.

At this point (v29), my Script seems to support all 5 of these
displays, by changing one line of the source code to specify
the display device, CTE32HR, CTE35, CTE40, CTE50, and CTE70.

CAUTION : This hardware and software is not yet suitable
or safe to use for controlling any real-time critical process, like
a power supply used as a charger for car batteries.

But, if you are interested in joining the project, welcome aboard.
Cheers, Gary
 
Sketches for Mini-QC functions

If you have, or have ordered, the necessary hardware,
you may PM me with your circumstances and email
address.

Or, email me (with "Mini-QC Sketch for Due" in the
Subject line, and request the Software.

Soon, I will add the latest software to my website,
use the link in my signature.
 
Interested indeed. :3 I've ported a few AVR-family programs to run on my Arduino, and a lot of the language is very flexible with just minor syntax changes from what I'd seen between models so far. I'd love to take a whack at this, but I first need to get my hands on one. I'll be on the back burner 'til I can find the opportunity to acquire one, but it sure sounds promising :D

edit:
"... based on the... ARM..."

Awh hell. They had to go and make everything complicated now, didn't they? *throws all the AVR assembly language off the desk* Bah! :lol:
 
I would be happy to help!

Given that the software for the Due is not well developed yet (which was something the "old" arduinos had going for them), did you consider other boards?

The beagle bone http://beagleboard.org" onclick="window.open(this.href);return false; comes with 2 can buses and has a lot more power and features than the Arduino due.
 
Good suggestion, and a powerful little beast. Thanks.

Solutions like the Beagle Board Black...
Generally the OS gets in the way of tight control of the I/O processes.
But, it depends upon how much special purpose hardware is included.

With the huge following that the Arduino has, we are hoping that
the libraries will be usable, and we will have tight control over the
operating code.

But, there are always surprises...
 
garygid said:
Good suggestion, and a powerful little beast. Thanks.

Solutions like the Beagle Board Black...
Generally the OS gets in the way of tight control of the I/O processes.
But, it depends upon how much special purpose hardware is included.

With the huge following that the Arduino has, we are hoping that
the libraries will be usable, and we will have tight control over the
operating code.

But, there are always surprises...

I think the beagle can be run with RTO (see http://www.youtube.com/watch?v=sdzUpcRdisw" onclick="window.open(this.href);return false;) but it would take some effort...

Anyway, I ordered an Arduino Due, should be here tomorrow.
Let me know what you want me to do with it.
 
Run the Blink example, and I will decide how to share my/our Scripts.

Get into the Arduino Due Forum.

I am working my way through as many Examples as I can.
I have completed the Basic group, and will post my versions.

We need good PWM, CAN, and... timers, interrupt handling,
and reliable, fast SerialUSB output on the Native USB port.
Apparently they are/were struggling with occasional lost bytes.

I have some touch color displays coming, that will use the
GUI library that is being developed on the Forum.
 
I can post Due-tested Scripts on my web Site, as zipped folders,
for others to download and try.

folks could email tested scripts to me, sending to plugin210,
without the 10, connected to a domain named mboxes with the
dot suffix of the last 3 characters of "sitcom".
Use a subject starting with "Due-Script" so I do not junk it.

Other suggestions?
 
With some basic scripts this should work, but in order to do specific things, more specific information would be necessary.
When I have my Due, I will play a little bit with it to get a feel for how it is different from the old Arduinos.

Is there any other hardware needed? For testing CAN related functions, e.g. with the LEAF, I assume some extra hardware is needed (i.e. the CAN transceiver), apart from the connector, to make the Due talk to the leaf?


It seems there is some library code available for CAN

http://forum.arduino.cc/index.php?topic=131096.0" onclick="window.open(this.href);return false; ?
 
garygid said:
folks could email tested scripts to me, sending to plugin210,
without the 10, connected to a domain named mboxes with the
dot suffix of the last 3 characters of "sitcom".

:lol: That's... art, right there. That's just art. :lol:

Should I post my existing Arduino GID-meter script here? I could just dump it in a code box for all to enjoy...
 
Got my Due today.
Run through some of the basic scripts, they seem to work pretty much like the old arduino scripts.
Everything is 3.3 v now, so some care has to be taken, but otherwise looks and feels like the old ones..

The native USB serial issues seem to have been resolved a while ago.
Testing the port, I found no missing data. Speed is ~ 233 kB/s, so not too bad, compared to the old arduino.
 
I put up a simple Web Page to allow downloading of the
Arduino Due R3 Sketches that I have used and tested on my Due.

Use the link in my signature below, and then a link there, or go to
http://www.wwwsite.com/puzzles/duesketch/" onclick="window.open(this.href);return false; :D

The zip of a Sketch unzips into a folder with the same name as
the sketch file (without the suffix) that it contains. You just move,
or copy, the Sketch folder into your favorite Sketch-holding folder.

Looks like I need to add some Libraries "zips" as well, which should
unzip into a folder that should go into the... /arduino-1.5.3/libraries/
folder along with the other library folders that are already there.

A simple library folder usually contains at least a ".h" and a ".cpp" file
(with the same name as the folder), and often an "examples" folder.
 
Back
Top