User avatar
garygid
Gold Member
Posts: 12469
Joined: Wed Apr 21, 2010 8:10 am
Delivery Date: 29 Mar 2011
Leaf Number: 000855
Location: Laguna Hills, Orange Co, CA

Flashing the AVR-CAN board

Sun Jun 26, 2011 12:09 pm

-------------- Software --------------
The two main (free) software choices are:

1. AVR Studio 5 from http://www.Atmel.com" onclick="window.open(this.href);return false; (you need to Register to download it).
I have installed this, but not yet figured out how to use it to flash anything.

2. WinAVR (an open source project, I believe) that contains AVRdude for flashing the ".hex" file. I am using this, and it sems to work well.

------------- mini USB AVR-JTAG -------------
This seems to be a good (maybe even a "better") solution.
Usually available on eBay, mostly from Hong Kong or China.

I bought from this seller "seller25812", and just got and tested this one:
http://www.ebay.com/itm/260853683073" onclick="window.open(this.href);return false; ... bid $5 (plus $10 S&H)
or, a Buy-it-Now at
http://www.ebay.com/itm/250597883758" onclick="window.open(this.href);return false; .. for $17 (free S&H)

However, there appears to be one source in the USA, in CA. They are a bit more expensive (maybe $26 instead of $17), but their delivery is usually a lot quicker. I also bought from them.

This programmer attaches directly to a USB port, and it POWERS the board being programmed.

------------- SparkFun PGM-00012 -------------
From http://www.SparkFun.com" onclick="window.open(this.href);return false; for about $60, this JTAG programmer is connected via a USB A to B cable (not included). I have not tried it, but another member has ordered it, and will try it on the AVR-CAN board. This appears to have the right specs, so it SHOULD work, I think.

------------- AVR-Dragon --------------
I bought an AVR-Dragon (as I recall, for around $60 from http://www.Atmel.com" onclick="window.open(this.href);return false;) and found that it works well in its JTAG mode with the AVRdude software in Windows. However, it apparently REQUIRES use/help of the "libusb" software before AVRdude will recognize it.

In using AVRdude (AFTER connecting AVR-Dragon to a USB port, letting Windows find and install a driver for it, AND using libusb), the command-line parm "dragon-jtag" is used to identify the device, and "usb" is used for the port. Works well.

------------- AVR-JTAG-ICE -----------------
The other programmer I bought (from ebay) is supposed to be an AVR-JTAG-ICE "clone/copy/compatible" device, connected to a serial Comm Port.
Even a USB to RS232 adapter is supposed to work, using a virtual Comm Port.

However, it turns out that not all USB-to-RS232 adapters are suitable.
With the "worse" adapter, AVRdude could not establish communication/sync
with this "jtag1" device. :(

However, using two different brands of "better" adapter, it works flawlessly. :D

------------- USB-to-RS232 ------------------
Guess which USB-to-RS232 adapter I have ten of! :lol:

Fortunately, these adapters seem to work OK when connected to the AVR-CAN
to do CAN-Capture into the PC. I will experiment more when I have time.

I will order more adapters from a different source to try and get a current
source of "better" adapters. More on that later when they arrive and I test them.
Last edited by garygid on Tue Sep 13, 2011 6:38 pm, edited 3 times in total.
See SOC/GID-Meter and CAN-Do Info
2010 Prius
2011 LEAF, 2014 Tesla S85
2018 & 2019 Tesla Model 3
PU: SDG&E
Solar PV: 33 x 225W -> 7 kW max AC
Craigslist: Xm5000Li Electric Motorcycle

User avatar
evnow
Moderator
Posts: 11480
Joined: Thu Apr 22, 2010 11:41 am
Delivery Date: 25 Feb 2011
Leaf Number: 303
Location: Seattle, WA

Re: Flashing the AVR-CAN board

Sun Jun 26, 2011 2:17 pm

Here is an option for programmin that I posted in another thread.

PGM-09825
Pocket AVR Programmer
$14.95

http://www.sparkfun.com/products/9825
This new version uses an SMD 5x2 header. This is a simple to use USB AVR programmer. It is low cost, easy to use, works great with AVRDude, and is tested extensively on a Windows desktop.


Image
1st Leaf : 2/28/2011 to 5/6/2013
2nd Leaf : 5/4/2013 to 3/21/2017
Volt : 3/25/2017 to 5/25/2018
Model 3 : 5/10/2018 to ?

User avatar
garygid
Gold Member
Posts: 12469
Joined: Wed Apr 21, 2010 8:10 am
Delivery Date: 29 Mar 2011
Leaf Number: 000855
Location: Laguna Hills, Orange Co, CA

Re: Flashing the AVR-CAN board

Sun Jun 26, 2011 10:07 pm

I will order this programmer and try it with the AVR-CAN.

Just ordered from SparkFun.
Last edited by garygid on Sun Jun 26, 2011 11:28 pm, edited 1 time in total.
See SOC/GID-Meter and CAN-Do Info
2010 Prius
2011 LEAF, 2014 Tesla S85
2018 & 2019 Tesla Model 3
PU: SDG&E
Solar PV: 33 x 225W -> 7 kW max AC
Craigslist: Xm5000Li Electric Motorcycle

User avatar
evnow
Moderator
Posts: 11480
Joined: Thu Apr 22, 2010 11:41 am
Delivery Date: 25 Feb 2011
Leaf Number: 303
Location: Seattle, WA

Re: Flashing the AVR-CAN board

Sun Jun 26, 2011 11:02 pm

What is the firmware you are using ? I'm assuming it is a modified version of some open source ...?
1st Leaf : 2/28/2011 to 5/6/2013
2nd Leaf : 5/4/2013 to 3/21/2017
Volt : 3/25/2017 to 5/25/2018
Model 3 : 5/10/2018 to ?

User avatar
garygid
Gold Member
Posts: 12469
Joined: Wed Apr 21, 2010 8:10 am
Delivery Date: 29 Mar 2011
Leaf Number: 000855
Location: Laguna Hills, Orange Co, CA

Re: Flashing the AVR-CAN board

Sun Jun 26, 2011 11:59 pm

The Spy.c program apparently started as
main_can_spy_echo_example.c

It appears to be a 2007 Amtel example program that would read the CAN bus using their AT90CAN128 chip.

At least two others changed it to the form I first saw, where it would output fast binary-formatted CAN messages, with a sync-byte added, via the RS232 port. This was a very short program, and I have not actually seen the original "sample" code.

I re-wrote some, added comments, and added the watch-for-SOC raw data. I then format and display the raw or percentage SOC for the 7-segment serial-input display from SparkFun.

We are still evolving the firmware, but I will probably consider this "version 4.09" to be my first Beta-release version for the LEAF SOC-Meter project.

So far, it appears to be working OK, but no guarantee or warranties. Use entirely at your own risk.

I compile, asm, and link with WinAVR, and use AVRdude (currently through AVR-Dragon) to flash the AVR-CAN.
See SOC/GID-Meter and CAN-Do Info
2010 Prius
2011 LEAF, 2014 Tesla S85
2018 & 2019 Tesla Model 3
PU: SDG&E
Solar PV: 33 x 225W -> 7 kW max AC
Craigslist: Xm5000Li Electric Motorcycle

lincomatic
Posts: 316
Joined: Fri Jun 10, 2011 10:01 am
Delivery Date: 06 Apr 2011
Leaf Number: 3819

Re: Flashing the AVR-CAN board

Mon Jun 27, 2011 7:33 am

Adafruit's USBtinyISP is also a cheap and reliable AVR programmer. http://www.adafruit.com/products/46
For those on a tight budget, cheap knockoffs can easily be found on eBay.

User avatar
garygid
Gold Member
Posts: 12469
Joined: Wed Apr 21, 2010 8:10 am
Delivery Date: 29 Mar 2011
Leaf Number: 000855
Location: Laguna Hills, Orange Co, CA

Re: Flashing the AVR-CAN board

Mon Jun 27, 2011 8:23 am

Good suggestion, but apparently this Adafruit's USBtinyISP
cannot program via the JTAG port that the AVR-CAN uses.
See SOC/GID-Meter and CAN-Do Info
2010 Prius
2011 LEAF, 2014 Tesla S85
2018 & 2019 Tesla Model 3
PU: SDG&E
Solar PV: 33 x 225W -> 7 kW max AC
Craigslist: Xm5000Li Electric Motorcycle

User avatar
evnow
Moderator
Posts: 11480
Joined: Thu Apr 22, 2010 11:41 am
Delivery Date: 25 Feb 2011
Leaf Number: 303
Location: Seattle, WA

Re: Flashing the AVR-CAN board

Mon Jun 27, 2011 8:27 am

garygid wrote:Good suggestion, but apparently this Adafruit's USBtinyISP
cannot program via the JTAG port that the AVR-CAN uses.
Are you sure ? The Pocket programmer I posted above is based on the tiny usb - and avrdude should work with that. We need to use the correct avr-can parameter for the avrdude.

I've ordered the parts from sparkfun - once I get it we'll know for sure.
1st Leaf : 2/28/2011 to 5/6/2013
2nd Leaf : 5/4/2013 to 3/21/2017
Volt : 3/25/2017 to 5/25/2018
Model 3 : 5/10/2018 to ?

User avatar
garygid
Gold Member
Posts: 12469
Joined: Wed Apr 21, 2010 8:10 am
Delivery Date: 29 Mar 2011
Leaf Number: 000855
Location: Laguna Hills, Orange Co, CA

Re: Flashing the AVR-CAN board

Mon Jun 27, 2011 9:27 am

Not "sure", but that is what it says in the description
paragraphs right below the picture: no JTAG.

I have ordered the other USB to JTAG mentioned above,
and one from EBAY that has an RS232 interface to the PC.

I need a 9v dc power supply (maybe 12v will do) so
that I do not have to go out into the car to power the
AVR-CAN ... whose 5v also powers the EBAY JTAG card.

The USB to JTAG card gets power from the USB port, but
I still need power for the AVR-CAN before I can actually flash.
See SOC/GID-Meter and CAN-Do Info
2010 Prius
2011 LEAF, 2014 Tesla S85
2018 & 2019 Tesla Model 3
PU: SDG&E
Solar PV: 33 x 225W -> 7 kW max AC
Craigslist: Xm5000Li Electric Motorcycle

User avatar
evnow
Moderator
Posts: 11480
Joined: Thu Apr 22, 2010 11:41 am
Delivery Date: 25 Feb 2011
Leaf Number: 303
Location: Seattle, WA

Re: Flashing the AVR-CAN board

Mon Jun 27, 2011 7:41 pm

garygid wrote:I need a 9v dc power supply (maybe 12v will do) so
that I do not have to go out into the car to power the
AVR-CAN ... whose 5v also powers the EBAY JTAG card.

The USB to JTAG card gets power from the USB port, but
I still need power for the AVR-CAN before I can actually flash.
Oh no - I never thought of that. So, we need to add a suitable power supply to the list.

edit :

http://www.ioffer.com/i/avr-can-atmel-a ... -150548801
POWER SUPPLY CIRCUIT :
Power should be applied to power supply connector. AVR-CAN could be powered by applying up to 9VDC (5 to 9 VDC) to EXT1-1 and EXT1-2 and GND to EXT1-3 and EXT1-4 or if you supply 5 to 9 VDC to central pin of POWER SUPPLY connector and GND to external pin of this connector
The consumption of AVR-CAN is about 40-50 mA.
So, just need any ordinary small power supply. May be you can try an old cell phone / cordless phone charger.
1st Leaf : 2/28/2011 to 5/6/2013
2nd Leaf : 5/4/2013 to 3/21/2017
Volt : 3/25/2017 to 5/25/2018
Model 3 : 5/10/2018 to ?

Return to “LEAF CANBus”