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

Fri Jul 01, 2011 9:09 pm

tomsax wrote:I tried, that's not the problem. The erase always happens when you write flash, if you don't ask for it avrdude warns you it's doing it anyway, and you always get a message while the erase is happening. There's definitely something wrong with the JTAG ICE Mark I and the AT90CAN128 (or perhaps the AVR-CAN board).
avrfreaks guys may know something.
Really I just posted to let people know it can be programmed from an ISP programmer since I saw that a number of people bought an ISP programmer.
Hmmm ... I could try that.
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

Sat Jul 02, 2011 2:47 pm

The AVR-JTAG-ICE ("clone"?) board off ebay ($13 + $5 shipping for Q1) has an RS232 interface and the JTAG interface works well on all nine AVR-CAN boards that we have tried so far. It does REQUIRE a "good" USB-to-RS232 adapter cable.

I have also used AVR-Dragon (more expensive) in JTAG mode, both programmers with AVRdude.

What command line are you using to start AVRdude?
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
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

Sat Jul 02, 2011 3:02 pm

#Reset is EXT1-7
Gnd is EXT1-3 and -4
+5v is EXT1-5 and -6

only the "SCK" is on EXT2-33

However, if the AT90CAN128 chip is really using p2 and p3 (instead of p13 and p12) for MISO and MOSI, they might also be using another pin for SCK (instead of p11)?
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

Thu Jul 07, 2011 8:10 am

Gary, have you published your firmware (source & compiled) ? If you don't want to publish it now, can you send it to me in PM ...
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

Thu Jul 07, 2011 5:35 pm

Do you have the hardware for the CAN-Capture, ... or for the SOC-Meter, ... or both?

The Capture can do 1, 2, or 3 channels (takes 1, 2, or 3 AVR-CAN boards), and CAN-Do reads the binary info, adds time stamps, and stores up to 20 million CAN-messages in memory. The stored messages can be written to a CAN-Log file for later viewing and analysis.

The Meter function requires a display to see anything useful.

What flashing software & hardware do you have?

Will you write the hex file (via JTAG) to the AT90CAN128 uP on the AVR-CAN board?

The source is in transition, mostly for the SOC-Meter, but includes both Capture and Meter functions simultaneously. PM me your email address and I can send the .hex, and my "main" .c if you wish. But, at this point, please consider it to be for your personal use only.

However, I am open to suggestions.
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

Sat Jul 09, 2011 9:17 am

garygid wrote:Will you write the hex file (via JTAG) to the AT90CAN128 uP on the AVR-CAN board?

The source is in transition, mostly for the SOC-Meter, but includes both Capture and Meter functions simultaneously. PM me your email address and I can send the .hex, and my "main" .c if you wish. But, at this point, please consider it to be for your personal use only.
See my PM to you.

I bought Olimax AVR-USB-JTAG programmer on e-bay. So, now I'm all set to flash AVR-CAN.
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 Jul 10, 2011 6:45 pm

What eBay "auction" for the USB AVR JTAG Programmer, please?

I will email the hex file to you, at this point for your use only, please.

A. Powering the board:

About 8v is good for the board.
12v is high, and 14v is worse, and the on-board 5v regulator gets very hot, especially when also powering the LED display.

So:
1. For testing and programming, I connect ground and 8v DC to the white 2-pin Power-In header.

2. For real use in the car, I connect a 5v 1watt zener diode between the OBD 12v (always ON 12v is on OBD pin 16, or "switched" 12v, ON during Ready mode or Acc2 mode, is on OBD pin 8) and the AVR-CAN board's Power-In on the "D" pin 9. Optionally, one can add an On-Off-On SPDT sub-mini toggle switch to chose between the always-on 12v and the switched 12v.

3. Ground is OBD pin 5 and pin 4 is "shield". I connect one to "D" pin 3 and the other to pin 6 (as I recall), which are both grounds. Or, I might have connected OBD 4 and 5 both to "D" pin 3.

B. Connecting the CAN buss:

1. This is not necessary for programming or testing, but one finds EV-CAN "high" on OBD 13 and "low" on OBD pin 12.

2. Optionally, one can choose to wire a DPDT sub-mini toggle switch (can be On-On or On-Off-On) to select between the EV and the "Car" CAN buss. The Car-CAN has its high on OBD pin 6 and low on pin 14.

3. The (selected) CAN-high input goes to "D" pin 7, and the low goes to "D" pin 2.


C. Connecting the LED serial Display:

1. Ground (GND on the Display card) goes to EXT2 pin 8. I use a 1x4 or 2x4 header-connector (0.1" centers) for the connection, a black wire for Ground. A 1x2 connector could be used instead, but one is less likely to make a mistake plugging in the 4x2 connector.

2. The 5v power (VCC on the Display card) connects to EXT2 pin 6, right next to the black Ground wire (#1 above), using a red "Power" wire.

3. The Serial Data Input to control the Display. The "RX" connection hole is at the other end of the 8-hole "interface" on the Display card. It connects to EXT2 pin 23, and I use a green wire to a 1x6 header-connector (but a 1x1 connector would be sufficient).


D. If the programming is successful:

1. The board's LED should come on for 2 seconds. Then, after a few seconds OFF, start to flash fast (10x per sec) while the board waits for a CAN-buss signal.

2. If the Display is attached, it will display "junk" because its default is only 9600 baud and the AVR-CAN is using 57600 baud. Unfortunately we cannot detect the Display's speed, but the SOC-Meter can try every speed to "set" the Display to 57600 baud.

3. In THIS version of the firmware (might change) ... To force this one-time setting of the display, have the "BUT" button (on the AVR-CAN board), held down (ON) at the 2-second mark after Reset/Reboot, and the LED will flash quickly 3 times, and the Display will "twich" while 6 baud rates are tried, issuing the "Set Baud Rate to 57600" command at each speed. After the one-time setting, this Display-Init should not be needed again.

4. Then, at any power-on or reset/reboot, one should see the firmware version number briefly (currently as "F1.05"), and the Display should show "----" while waiting for the CAN buss. Then it will show " GO " (or possibly "999.9") while waiting for the first "SOC" message.

5. For now, one sees the "SOC Percentage", for example " 98.9" might appear after a full charge.

NOTE: We are exploring the workings of the car, and this MIGHT NOT be an accurate SOC. It is just a number (I chose 281 as 100%) that the LEAF generates. It seems to go up when we charge (over 6 hours), and down when we drive. BUT, just because it indicates 21.3% ond the "Guess-O-Meter" ESTIMATES hat you MIGHT have 15 miles remaining (IF you keep driving as you have done in the "recent" past, does NOT mean that you actually have ANY guaranteed miles left. USE AT YOUR OWN RISK.

Right now I use it to gather data, and understand the LEAF's behavior better.

We believe that the "Low Battery Warning" usually comes at about 17%, and the "Very Low Battery Warning" at ... maybe ??? 10 to 8%? ... and that Turtle may occur around 5%, MAYBE. Some have experienced "very few miles" after the Warnings, and a VERY short Turtle mode (100 yards compared to other's perhaps 1 mile experience).

SO, DO NOT DEPEND on much mileage after the "VERY LOW" Battery Warning. It is not fun to wait for a tow ... and it "looks bad" for all LEAFs (and EVs) to see them on the backs of tow trucks!
Last edited by garygid on Tue Jul 19, 2011 1:17 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 Jul 10, 2011 6:53 pm

Good write up Gary, thanks for all your help in getting this going. BTW, guessing this is what you send in the "instructions" of the kit ?

I got the cable yesterday - so I can start on the SOC meter, after getting some crimp pins etc.

BTW, the ebay was a one-off slightly-used piece someone was selling for a good price. It is the same one sparkfun sells for $57.

http://www.sparkfun.com/products/12
I will email the hex file to you, at this point for your use only, please.
Will wait for that, and yes it will remain with me. Also do send me the source so I can figure out what is happening and start working on enhancements.
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 Jul 10, 2011 7:03 pm

I realize that I need to put the above instructions in the SOC-Meter thread.

Also, I need to add the instructions for wiring the two "User-Input" buttons (Red left, Black right), but I will probably change how they were connected in my experimental version 1.05 of the Firmware.

Another Note: The SAME firmware SHOULD support CAN-Capture at this point, though it has not been sufficiently tested since I added the SOC-Meter parts of the code.

Assuming it works, just add an RS232 connection (115200 baud) to a the PC that is running ny CAN-Do program.

The CAN-message comes in 11-byte binary records from the AVR-CAN to the PC.
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 Jul 18, 2011 11:46 pm

2. The 5v power (VCC on the Display card) connects to EXT2 pin 8, right next to the black Ground wire, using a red "Power" wire.
That should be EXT2-6 for VCC.
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”