I'm back. I used the checksum 0xFD. It seemed to partially work. The ECM sent back a 64 byte code instead of the 10 byte error that I was getting before. I was able to concatenate the multi-byte numbers and read them in real time. The problem I had though was every value seemed to be double what it should be. For example, I was getting 25 volts from the battery and 120 degrees from the engine temperature (engine off). It is a step in the right direction but only having 64 of the first 107 offsets isn't enough. I don't know why I am missing so much data and why the data I do have is doubled.
It says it's sending a total of 107 bytes ("length" byte is 0x64 (100), plus 7 bytes of header info), and the one thing I checked based on your earlier comment was the battery voltage: Two bytes at offset 28, 0x04C4 = 12.20V
I'd take a look at the serial receive side of things. Is there a buffer that you have to set up somewhere? Is it only set to 100 bytes? Is there some other hard-set maximum set up somewhere else?
My guess is that the ECM is indeed sending everything out, but for whatever reason, your serial routine/buffer isn't catching it all.
I think I might know what is causing it. The The header is saying the length of the response is supposed to be 100 bytes. I think I remember reading somewhere that the Arduino Uno Serial buffer size is 62 bytes. This might be an issue with the Arduino that I need to look up how to get around.
Let me know if you have any ideas how to get around the buffer limit.
Also, did you combine it as 29, then 28? That was opposite of what I though it was supposed to do.
I tried combining them using Value = Array[28] << 8 | Array[29]
How should I concatenate them?
(Message edited by Blaylock1988 on March 12, 2012)
Do a google search for "big-endian" versus "little-endian". That's what describes the byte order for values larger than one byte.
In this case, use the same instruction you're using, but swap "28" and "29". I didn't remember the "endian-ness" off the top of my head, so I checked both ways, and 12.20V (0x04C4) sure made a lot more sense than 501.80V (0xC404)
As far as the built-in serial buffer size being 62 bytes, I've never used an arduino, so unfortunately, I have no clue, other than rolling your own.
Ok, the buffer size is 64 bytes, I am not sure why I am getting 62.
I think my problem was that I was writing the entire buffer to outArray, instead of writing the first byte of the buffer to the outArray[i] for i=0 to i=107 as the stream came in.
I will have to wait until Thursday night when I go home to see if this works.
I messed with it a bit today. I got it to concatenate correctly and read temperature perfectly.
I discovered that my buffer is overflowing. The limit is 64 bytes. I rearranged my code and got it to read 67 bytes, which is a little better, but I think I am reading the information to slowly now and the buffer fills up faster than I can read it. I wish I knew more people that had experience with Arduinos.
Also, I need to get mass air flow from the bike, but I don't have the money for a wideband O2 sensor, and I don't know how to install a MAF sensor into my intake manifold. I already have injector pulsewidth so I can calculate how much fuel I am using.
Does anyone have any other suggestions for getting either A/F or mass air flow?
(Message edited by Blaylock1988 on March 16, 2012)
I hope you keep at it, and document what you do here. I for one, have been watching this tread with great interest. That Arduino platform is pretty neat.
This post has me seriously intrigued to start working with Arduinos.
I found this comic, which I thought did a great job of explaining the basics.
Now I really want to find a basic arduino kit to get started. The author of the comic had a site in her links that had a basic starter kit: http://www.adafruit.com/products/170
What do you guys think of this to get started? Is there a better "starter" kit out there?
I should add that I have a BS in Computer Science, so I don't think the programming portion will be too difficult to pick up. I really love tinkering with mechanical things, and would love to be able to combine my computer skills and mechanical skills to create some interesting electronics for the Buell...
(Sorry if I'm hijacking this post, but I figured you guys would be the right people to ask about getting started with Arduinos)
If programming is not going to be an issue then you should probably start with and AVR development system and just program in raw C for AVR. All tool chain applications are free, just need a programmer if the dev. board doesn't include one. STK600 or STK500 would be logical places to start though you might want to go with the cheaper Butterfly: http://www.smileymicros.com/index.php?module=pagem aster&PAGE_user_op=view_page&PAGE_id=41
Greg - do you do any of this programming or have an electrical background? I'd love to find someone local who I could talk to about this stuff. I really did pick the wrong career field - I should have gone Mech E or Comp E instead of Comp Sci!
I've always wanted to learn this stuff, but have very limited background with electrical, except for wiring motorcycles. I'm thinking of picking up the Arduino kit just to get my feet wet with this, and using the Buell as a test bed... similar to what Blaylock1988 has been doing.
At the other end of the spectrum, you can get started with this stuff for about $8 worth of parts and some soldering / time with a breadboard.
I went that way, because my goal was a dirt cheap way to do anything anywhere. So a $25 Aurduino board was too expensive. I got the PIC's and figured out how to program them in C (nice tools available), played around with different schematics, and have a design now that can control current or blink an LED based on analog inputs for about $8 worth of hardware. Add $8 to $15 if you want a 16x2 character LCD included.
If you want to go that route, let me know, and I can give you my schematic and some source code. You can use MPLab and a couple of different C compilers to program them (and they work great).
I think the $99 Butterfly kit would do more for you in the long run. I have it but haven't had a lot of time to devote to learning C. The $99 kit gives you the entire learning lab with jumper wires, bread board, motor, LEDs, etc. It's a good starter kit that covers a lot of fundamentals.
AVRFreaks is the forum of choice for the bare AVR dev. kits (and other AVR stuff), not sure what is out there for Arduino but I'm sure there is a large community on the web.
I guess I have some more research to do in determining which route would be best.
This stuff is all new to me, so I don't know if the "start from scratch" routine would work. I haven't played with a breadboard since I was a kid and had one of those Radioshack Electronic Learning Kits... but it was fun building motion sensor alarms and scaring my siblings.
I didn't get that butterfly kit, I got the kit that was the next step down from adafruit. I also saw that Radioshack carries arduinos and some arduino shields for the same price as at adafruit.
The nice thing with arduino is that it is open source and a HUGE arduino forum that is very active. If you can't figure something out, there are tons of people out there that can help through the forum, or youtube, or project sites because the arduino following is so big.
I am heading home today so I can work on my bike some more, I am getting very close to reading all 107 bytes. Then I will be able to start writing the meat of the code.
I finally got the Arduino to read all 107 bytes of data. My question now is does the ECM keep sending this stream of data or do I get one stream per request?
Msamuels0, could I possibly take a look at your code that you used? I am having a hard time figuring out how to write the program to request and read the data from the ECM continuously while still performing other operations.
(Message edited by Blaylock1988 on March 28, 2012)
I finally got the arduino to read all 107 bytes of data in real-time. No delays, no stops, no cutting off data, it works like a dream. Check out the video:
Michael - that's awesome. What you'be been posting here has inspired me to pick an an arduino when I get home from this deployment. I've been reading up on them for a couple weeks now and I'm convinced that it would be a fun gadget to play with, and the Buell is a good test-bed for projects!
I might also pick up a Raspberry Pi when they're available again - plenty of uses for that as well!
Thanks, I have been searching through my engines notes from the past 2 semesters for equations I can use (piece together) to calculate power. I am going to add case structures to the code so I can tab through different information to display on the LCD. Eventually I will make a shift indicator on it too. During the summer I will pick up a big touch screen like Msamuels0 has on his and make a custom interface for everything.
Greg - I saw that it was also waiting CE certification as well. They weren't selling it as an assembled product, so they didn't think they needed it there. Plenty of time though - I won't be home from Afghanistan until August, and in the mean time I can brush up on basic electronics with the Arduino.
Michael - please keep posting your progress. I'd like to help out if I could, but can't do much 7000 miles away from home!
Not to take this too far off, but the pi is much too assembled to be called a kit, so it must be certified before they can risk selling it. If not and it turns out that the FCC buys one, and it doesn't pass, then Newark will be on the hook for the fines and may need to buy back each device sold or face higher fines of $10,000 per unit sold. It probably wouldn't go that high and I doubt it would happen, but they could still be hit for a small fine or a cease and desist since it has not been certified. I'm fairly confident that the board will pass the most basic tests needed to sell it here, just that time and money are involved. And yes I would like to get at least one for my self and play with it.
This Arduino stuff is very interesting, would be great to get to the point of having full diagnostics, data logging, fuel map correction and upload, etc. Wish I could help more but I'm not very experienced and stuffed with other things I need to do. If you get down to a schematic of what you need, I can probably help by designing the circuit boards and point ot a board making service.
You might have enough for his middle volume orders that go our about once a month. http://dementeddiode.org/blog/2011/03/a-medium-run -service-for-open-source-hardware/ Boards are good quality and made in USA if that matters at all, I know to some of the guys doing low volume it does matter. I have several different designs that I've run through the service and for the above it should come out perfect.
Man that design could be shrunk to half the size with surface mount components, might almost double the time to assemble though unless you build an oven or maybe temp. controlled hot plate, or preheater and low volume hot air. What's the TO-220 device? Looks like some kind of high current driver.