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 »

Yeah thats what Iv understood so far. It uses the defined microsecond values.. converts them to defined values based on crystal size then uses this value to compare with the timer count to determine if it has reached it. (well, thats what Iv taken from the code)

Its the whole defining prescaler as 8,16,32,64 ect thats throwing me off. From my googling.. I meant to define this prescaler in which timer? (I think.. I dont quite understand this yet)

At least the crystals are nice and cheap if worse comes to worse! $1 gets ten 4mhz crystals.


*Edit, alright so it is this line of code that needs editing that we were looking at before:
#define us2cnt(us) ((unsigned char)((unsigned long)(us) / (1000000L / (float)((unsigned long)MCU_XTAL / 1L))))
Where our MCU_XTAL will be our mhz speed and the 1L is what we need to change, so our next closest prescaler is 8 or 64.. which will more then likely require modifying the timing values slightly.

Just some quick maths... 4mhz is 4,000,000 / 1 = 4,00,000Hz
Timer period then: 1/4,000,000 = 0.00000025s = 0.25us per tick (I think?)

Therefore, 16,000,000 / 8 = 2,000,000Hz
Timer period then: 1/2,000,000 = 0.00000050s = 0.5us per tick

So, our tick rate would take twice as long. I would want to half the vpw timing values to correspond to the same as the 4mhz values right?

Ahhhh I dont know... might have to just try values out and see how it goes? Bit of trial and error never hurt I guess.
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 »

megawoking.PNG
megawoking.PNG (1.72 KiB) Viewed 9499 times
It successfully programs to the mega, and prints out correctly :thumbup:
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 »

Having a little bit of trouble with the interrupts(I think) seems some sort of buffer overflow or something causing the device to reset after sending a couple AT commands... Hmmmm
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 »

Might be worth starting with a simple program that can just echo characters back from a terminal program. Then work back up to the AT commands to see what causes it to fail. Might be stuck in an unrelated loop somewhere.
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, will give that a go.

Iv found a coupl threads online talking about the Arduino mega2560 and issues with interrupts that didnt have a handler causing the device to reset.

Alternatively if interrupts are the issues, will just switch that out for a simple global var that gets checked constantly for if there are any bytes available to read
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: 8238
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 »

I think you will need interupts or you will miss events. They should work fine if you do it by the book. Harder to debug crashes than pc apps under a debugger though.
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 »

antus wrote:I think you will need interupts or you will miss events. They should work fine if you do it by the book. Harder to debug crashes than pc apps under a debugger though.
Well majority of the code doesnt actually use interrupts. The only interrupt there is for when we send a command to the device, but yeah it is better if it immediately dealt with it then doing it once it hits a check point.

Just trying to work through it line by line to find the culprit. Although the mega's formatting is slightly different to the Atmega8, the mega utilizes the interrupt format for the receive buffer differently.. so Im not sure if my conversion there is the problem.. although its whats used in examples and other forums.

Could be a completely unrelated error to this anyways. So might take a little while :thumbdown:
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 »

Good reliable source informed me this is possible using the arduino IDE and arduino code formatting if all the header files and source files are compressed into one and modified accordingly.
Id much prefer not having to desolder the 16mhz crystal and replace with a different size, so I might be needing an oscilloscope to actually see whats going on "timing" wise with the arduino and adjust EOF,SOF values accordingly. But first up is the proper conversion into arduino formatting and using the arduinos serial ports.
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 »

After some lengthy talks with some arduino gurus, they believe that if I port the code over properly to arduino standards and use the 16mhz as is, it should all work. Sooo.. we will continue doing this. Now that all the coding has been commented to know what happening, should be easy enough to make the arduino equivalent.

I attempted to utilize the buspirate as an oscilloscope, but failed as it seems all java applications screw up on this damn laptop!
So in foreseeing the need for an oscilloscope, anyone have recommendations on what to get?
Currently I am looking at a few on sparkfun:
DSO Nano V3 - Pocket-Sized Digital Oscilloscope - $99.95
USB Oscilloscope - MSO-19 - $250
DSO Quad - Pocket Digital Oscilloscope -$225

Im obviously more keen on grabbing the cheapest one.. but I have no idea on what the main difference between these are and how powerful this unit needs to be to record for a good period of time.
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 »

When going through the VPW documentation. It displays that a "High" is 7v.. I dont recall measuring that using the ELM cables.. they output roughly 5v. I cant imagine the arduinos 5v signal lines are going to be very happy with 7v. And even then, how will I output 7v back in for writing frames! *sigh*.. more researching. Might just try it out and see what happens.

If I can get the ELM to correctly read the frames form the arduino.. then I guess it doesnt really matter.
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
Post Reply