AVR to Arduino - VPW

Ecu Hardware Modifications
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: AVR to Arduino - VPW

Post by Tazzi »

Not a big fan of AVR studio right this second. Only because its not a simple "paste n go" situation. Looks like I have to read up on the ATmega baud registers and compare that to the ATmega8 so that I can edit and port the code to the ATmega328. Things such as:
UBRRH = DEFAULT_BAUD>>8; // set baud rate
UBRRL = DEFAULT_BAUD;
UCSRB =((1<<RXCIE)|(1<<RXEN)|(1<<TXEN)); // enable Rx & Tx, enable Rx interrupt
UCSRC =((1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0)); // config USART; 8N1

Need to be updated to the appropriate atmega328 version.
Unless anyone can think of something Im missing, this seems to be whats needed.


*Edit
Looks like theres a few examples using the ATmega328 and baud registers.. this makes life a whoooooole lot easier
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: AVR to Arduino - VPW

Post by Tazzi »

These definitions should set us on course :thumbup:

Code: Select all

//defines needed for Atmega328: 
#define    UCSRA    UCSR0A 
#define    UCSRB    UCSR0B 
#define    UCSRC    UCSR0C 
#define    UBRRH    UBRR0H 
#define    UBRRL    UBRR0L 
#define    UDRE    UDRE0 
#define    UDR    UDR0 
#define    RXC    RXC0 
#define    RXEN    RXEN0 
#define    TXEN    TXEN0 
#define    UCSZ1    UCSZ01 
#define    UCSZ0    UCSZ00 
#define output_high(port,pin) port |= (1<<pin) 
#define output_low(port,pin) port &= ~(1<<pin) 
#define set_output(portdir,pin) portdir |= (1<<pin) 

#ifndef F_CPU 
   #define F_CPU 16000000UL      
#endif 
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: AVR to Arduino - VPW

Post by Tazzi »

8-)

I guess all thats left is to flash file using avrdude and see how we go. The pins set to analog 0 and 3 (I think). Am going to pop round jaycar now to pick up the list of requirements at the obd end:

Code: Select all

78L05 (voltage regulator) 
R1 220ohms
D1 (LED Green)
C2 0.1u capacitor(i think)
C1 100u capacitor
R2 220ohms
D2 (LED yellow)
T1 BC548A
R3 15K
R4 2.2K
R5 47K
R6 47K
R7 10K
T2 BC548A
D3 1N4148
T3 BC548A
D4 ZPD8V2
R8 47omhs
R9 510ohms
T4 BC548A
R10 1K
Attachments
ArduinoVPW.rar
(1.47 KiB) Downloaded 398 times
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
ejukated
Posts: 443
Joined: Wed Mar 04, 2009 8:52 pm

Re: AVR to Arduino - VPW

Post by ejukated »

awesome work, be really keen to see how this turns out.
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: AVR to Arduino - VPW

Post by Tazzi »

Hopefully it does.. The coding changes have been made (which I imagine is the hardest bit) so all thats left is trial and error.

Ran out of time to pick up the gear. But I dont see why I couldnt try flashing the code to the arduino.. Wont be able to test the VPW communication, but will be able to check if its loaded properly as it should send the device name and info over serial port. *fingers crossed*
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: AVR to Arduino - VPW

Post by Tazzi »

Well I think it flashed successfully :)
Just gotta write some code up quickly to read whatever is sent from the arduino.
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
antus
Site Admin
Posts: 8237
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: AVR to Arduino - VPW

Post by antus »

This is a good quick reference to see if whatever speed your looking for is going to be achievable at your clock speed, and how close the speed will be. Within a couple of % is acceptible, but you can see some rates like 11.0592 Mhz or 18.432 Mhz lend themselves to serial data transmission at normal speeds better than others. I used it extensively when I was trying to build my vpw cable on AVR.

http://www.wormfood.net/avrbaudcalc.php
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: AVR to Arduino - VPW

Post by Tazzi »

Cheers Ant, funny enough I had that bookmarked already from research of baud rates and clockspeeds.

Only thing Im looking to understand better is adapting the prescaler to suit the 16Mhz chip.
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: AVR to Arduino - VPW

Post by Tazzi »

Was going over the schematic, added a few labels to see if there was any parts I can toss for the moment for simple test designs. It probably is a good idea to keep it as is since it would be nice to see when data is passing through, and when the device is powered up.

But, highlighted in the green square.. Im a little lost whats happening there? I thought this would be connected to 5v, since well.. its not really a constant 12v from the car, this can fluctuate from 10v to 14ish volts, any idea if this will be an issue?

Also, I not too experienced with Eagle or pcb designing software, really appreciate if someone could draft up the diagram below for an arduino shield of some sort. Just dont need the atmega8 chip or max232 chip. Board only needs to connect to the rx/tx pin, power and gnd.
Commented.png
Commented.png (55.29 KiB) Viewed 6402 times
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
VL400
Posts: 4991
Joined: Sun Mar 01, 2009 2:54 pm
cars: VL Calais and Toyota Landcruiser. Plus some toys :)
Location: Perth, WA
Contact:

Re: AVR to Arduino - VPW

Post by VL400 »

Its a buffer/driver that clamps the battery voltage using the zener (8.2V) and current limiting resistor. The forward volt drop of the diode D3 drops it another 0.7V or so to keep it within the VPW spec of (I think) a nominal 7V for a high.
Post Reply