Starting a new build

  • 114 Replies
  • 1624 Views
*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 990
  • Jack of all trades
    • '94 Dodge dually
Re: Starting a new build
« Reply #90 on: April 03, 2018, 10:06:32 AM »
another way to do it would be to imitate vehicle ECU's.. the display unit, or whatever requests a parameter and then the relevant computer responds.. I think it's explained in plain english here
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline hakcenter

  • developer
  • Hero Member
  • *****
  • 689
    • 1998 12v Ram
Re: Starting a new build
« Reply #91 on: April 04, 2018, 06:06:11 PM »
so simple gosh even a monkey could do it, lolol
AMP 2 Corinthians 8:21
For we take thought beforehand and aim to be honest and absolutely above suspicion, not only in the sight of the Lord but also in the sight of men.


*

Offline Chewy1576

  • Full Member
  • ***
  • 60
    • 1997 Chevy K3500 6.5
Re: Starting a new build
« Reply #92 on: April 09, 2018, 08:10:53 PM »
Took a long weekend to drive down to Nevada with some buddies for a golf trip. I ordered the 16 MHz crystal and some other parts before I left. They were delivered last Friday. Now that I’m back, I got the new crystal soldered in and changed the code on the LCD side to use the same lib as the VGT side and added the interrupt input and it seems to be working much better. No delay timers or anything, it just chews through them.

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 990
  • Jack of all trades
    • '94 Dodge dually
Re: Starting a new build
« Reply #93 on: April 10, 2018, 09:52:42 AM »
I think I might take a look at the current CAN library and see what can be changed to make the frequency selectable...  Using interrupts on both sides I was able to get ping rates under 1ms, and maybe better since this was with 8mhz crystals.. I do have some 16mhz crystals spare, but I'd rather find a software solution since I have so many of these boards with 8's on them
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline Chewy1576

  • Full Member
  • ***
  • 60
    • 1997 Chevy K3500 6.5
Re: Starting a new build
« Reply #94 on: April 10, 2018, 10:14:39 AM »
Here's the one I switched to. I like the frame formatting in this one. There was also a download link in that forum post I mentioned earlier that had a library with selectable mhz settings.

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 990
  • Jack of all trades
    • '94 Dodge dually
Re: Starting a new build
« Reply #95 on: April 10, 2018, 10:42:54 AM »
I was thinking of modifying the existing library so it wouldn't need any other changes to code except for the initializer.. I will keep that one in mind though, since there's a good chance the units I'll build that use these 8mhz modules will have totally different code anyhow
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline Chewy1576

  • Full Member
  • ***
  • 60
    • 1997 Chevy K3500 6.5
Re: Starting a new build
« Reply #96 on: April 17, 2018, 07:10:24 PM »
I haven't really had much time to work on this, but I've been trying to set up the message filtering on the LCD side and it's kicking my butt! It's receiving all of the messages, but I'm having trouble figuring out how to grab specific messages and copying the data into the variables for display on the LCD.

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 990
  • Jack of all trades
    • '94 Dodge dually
Re: Starting a new build
« Reply #97 on: April 17, 2018, 07:55:14 PM »
Are you trying to do it in hardware (the MCP chip has some mailboxes, filters, etc) or in software?
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline Chewy1576

  • Full Member
  • ***
  • 60
    • 1997 Chevy K3500 6.5
Re: Starting a new build
« Reply #98 on: April 17, 2018, 09:58:19 PM »
In the software, using if statements looking for the  specific message ID, then doing a memcpy into the fourbyte array. I started looking into masks and filters too, but haven’t gotten very far.

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 990
  • Jack of all trades
    • '94 Dodge dually
Re: Starting a new build
« Reply #99 on: April 18, 2018, 07:33:22 AM »
I'd start with setting up a bunch of #DEFINE statements that set up the messageID and what they're for, then use a CASE statement.. Can't remember the exact syntax for it, I think this is right?

Code: [Select]
#Define RPM_MID 345543 //I'm just using random numbers here
#Define EGT_MID 23432
#define TSS_MID 645555
.
.
.
.
.

void MessageHandler(CAN Message){
fourbyte value = GetFourbyteFromMessage(Message);

Select Message.ID{
   Case RPM_MID:
    RPM = value;
    break;
  Case EGT_MID;
    TSS = value;
    break;
  Case TSS_MID:
    TSS = value;
    break;
}
}

fourbyte GetFourbyteFromMessage(CAN Message){
//do your memcopy here, or just do it byte by byte
return value;
}

'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline Chewy1576

  • Full Member
  • ***
  • 60
    • 1997 Chevy K3500 6.5
Re: Starting a new build
« Reply #100 on: April 18, 2018, 09:36:40 AM »
I'll try to give it a shot tonight. Thanks!!!

*

Offline Chewy1576

  • Full Member
  • ***
  • 60
    • 1997 Chevy K3500 6.5
Re: Starting a new build
« Reply #101 on: April 18, 2018, 09:15:19 PM »
Here's my first attempt, no workie....

Code: [Select]
void MCP2515_ISR()
{
  data_rcvd = true;
}

void C_CANBUS()
{
  data_rcvd = false;
 
  if (CAN.available() == true)
    {
      rcv_data = CAN.read();
    };
 
  data_ready = true;
}

void copydata()
{
  data_ready = false;
  switch(rcv_data.id)
    {
      case turbo_speed_ID:
        memcpy(rcv_data.data,turbo_speed.b,4);
        break;

      case vane_pos_ID:
        memcpy(rcv_data.data,vane_pos.b,4);
        break;

      case boost_pressure_ID:
        memcpy(rcv_data.data,boost_pressure.b,4);
        break;

      case egt_ID:
        memcpy(rcv_data.data,egt.b,4);
        break;
    }
}

void loop()
{
  if (data_rcvd = true)
  {
    C_CANBUS();
  }

  if (data_ready = true)
  {
    copydata();
  }

  D_LCDWrite();

}

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 990
  • Jack of all trades
    • '94 Dodge dually
Re: Starting a new build
« Reply #102 on: April 18, 2018, 10:43:09 PM »
I'd start tossing in some serial prints in there and see what's going on..  Also pay attention to HEX and DECimal values with your message ID's

I'd start with putting one in the interrupt, then each CASE statement.. is it actually getting in there?

Also, it would make the program flow look smoother if instead of setting a flag that the copy is done, just go right to parsing that data out.   Also, global variables tend to be frowned upon when not absolutely necessary.. Pass directly to the function..
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline Chewy1576

  • Full Member
  • ***
  • 60
    • 1997 Chevy K3500 6.5
Re: Starting a new build
« Reply #103 on: May 21, 2018, 09:39:03 PM »
So I haven't given up... Been a busy month or so and I haven't had much time to tinker. I had some time tonight to work on moving the received data around, and figured out I had the destination and source in the MEMCPY backwards  ;D. Now it receives one message and the program seems to hang, it doesn't pull in any more messages.

Code: [Select]
void MCP2515_ISR()
{
  data_rcvd = true;
}

void C_CANBUS()
{
  data_rcvd = false;
 
  CAN_Frame rcv_data;

  if (CAN.available() == true)
    {
    rcv_data = CAN.read();
    }

  if (rcv_data.id == 300000000)
    {
    memcpy(turbo_speed.b,rcv_data.data,sizeof(rcv_data.data));
    }

  if (rcv_data.id == 305000000)
    {
    memcpy(vane_pos.b,rcv_data.data,sizeof(rcv_data.data));
    }

  if (rcv_data.id == 310000000)
    {
    memcpy(boost_pressure.b,rcv_data.data,sizeof(rcv_data.data));
    }

  if (rcv_data.id == 315000000)
    {
    memcpy(egt.b,rcv_data.data,sizeof(rcv_data.data));
    }
}

void D_LCDWrite()
{
  long disp_turbospeed = 0;
  int disp_egt = 0;

  disp_turbospeed = (long) turbo_speed.f;
  disp_egt = (int) egt.f;
 
    //lcd.setCursor(0,0);
    //lcd.("TurboSpd:          ");
   
    //lcd.setCursor(0,0);
    Serial.println(String("TurboSpd:") + String(disp_turbospeed) + String(" RPM"));
   
    //lcd.setCursor(0,1);
    //lcd.print("TurboPos:         ");
       
    //lcd.setCursor(0,1);
    Serial.println(String("VanePos:") + String(vane_pos.f,2) + String (" cm2"));

    //lcd.setCursor(0,3);
    //lcd.print("Boost:  ");
   
    //lcd.setCursor(0,3);
    Serial.println(String("Boost:") + String(boost_pressure.f,2));

    //lcd.setCursor(12,3);
    //lcd.print("EGT:    ");

    //lcd.setCursor(12,3);
    Serial.println(String("EGT:") + String(disp_egt));

    //delay(100);
}

void loop()
{
   
  if (data_rcvd = true)
  {
    C_CANBUS();
  }

  D_LCDWrite();
 
}

*

Offline Chewy1576

  • Full Member
  • ***
  • 60
    • 1997 Chevy K3500 6.5
Re: Starting a new build
« Reply #104 on: May 21, 2018, 09:46:23 PM »
K another dumb mistake...

As soon as I changed "sizeof(rcv_data.data))" in the MEMCPY to "rcv_data.length", it started working!