Results 1 to 15 of 40

Thread: Looking for asistance with ALDL project...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

  2. #2

  3. #3

  4. #4
    Fuel Injected! Quaraxkad's Avatar
    Join Date
    May 2019
    Posts
    37
    I've ordered an Arduino Uno, it will be here tomorrow. I believe it's C++, not C. First step is basically just the example code shown here: https://www.arduino.cc/reference/en/.../serial/write/. Except I'll swap the hello string for the 0A 58 40 0D AC byte sequence and the proper 8192 baud rate. If I've done my math correctly and it works, that should give me a tach reading of 3500.

  5. #5
    LT1 specialist steveo's Avatar
    Join Date
    Aug 2013
    Posts
    4,056
    right on

    here's a general function to generate a checksum byte with c or c++, just run it against the array

    Code:
    char checksum_generate(char *buf, int len) {
      int x = 0;
      unsigned int sum = 0;
      for(x=0;x<len;x++) sum += buf[x];
      return ( 256 - ( sum % 256 ) );
    }
    here's a function to test an incoming checksum (not that you should have to for this program)

    Code:
    bool checksum_test(char *buf, int len) {
      int x = 0;
      unsigned int sum = 0;
      for(x=0;x<len;x++) sum += buf[x];
      if((sum & 0xFF) == 0) {
        return true;
      } else {
        return false;
      }
    }

  6. #6
    Fuel Injected! Quaraxkad's Avatar
    Join Date
    May 2019
    Posts
    37
    Ah yes, I had completely forgotten about the checksum! Adding in your checksum function, this is pretty much the entirety of the initial test! I'm leaving out all of the other bytes because I expect they are uneccessary. I'm assuming the gauge cluster will only look at the 5 bytes after 0x0A.

    Code:
    void setup() {
      Serial.begin(8192);
    }
    
    void loop() {
      if (Serial.availableForWrite() > 5) {
        byte b[5] = {0x0A, 0x58, 0x40, 0x0D, 0xAC};
    
        unsigned int x, sum = 0;
        for (x = 0; x < sizeof(b); x++) sum += b[x];
        byte cs = ( 256 - ( sum % 256 ) );
    
        Serial.write(b, 5);
        Serial.write(cs);
      }
    }
    It compiles without errors or warnings, but that doesn't mean my logic is sound!

  7. #7
    Fuel Injected! Quaraxkad's Avatar
    Join Date
    May 2019
    Posts
    37
    Adding a little math to convert an integer RPM into MSB and LSB...

    Code:
    void setup() {
      Serial.begin(8192);
    }
    
    void loop() {
      if (Serial.availableForWrite() > 5) {
        int rpm = 3200;
        byte msb = floor(rpm / 256);
        byte lsb = rpm % 256;
        
        byte b[5] = {0x0A, 0x58, 0x40, msb, lsb};
    
        unsigned int x = 0, sum = 0;
        for (x = 0; x < sizeof(b); x++) sum += b[x];
        byte cs = ( 256 - ( sum % 256 ) );
    
        Serial.write(b, 5);
        Serial.write(cs);
      }
    }
    Now if that works, I will add a potentiometer and read that for input to convert to an rpm reading, and I should be able to control my tachometer in real time!

Similar Threads

  1. New guy old project
    By The Stickman in forum Introductions
    Replies: 1
    Last Post: 04-24-2015, 05:26 AM
  2. Need help on new project
    By SuperHbody in forum GM EFI Systems
    Replies: 0
    Last Post: 01-05-2015, 06:45 AM
  3. new here...odd project and need help
    By travisr1988 in forum GM EFI Systems
    Replies: 5
    Last Post: 04-19-2014, 06:30 PM
  4. Another TPI Project..
    By ezobens in forum GM EFI Systems
    Replies: 16
    Last Post: 01-20-2014, 05:49 PM
  5. 85 k5 project?
    By mjc in forum GM EFI Systems
    Replies: 0
    Last Post: 12-24-2013, 01:50 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •