I fought the Max31856 and I WON

Started by Rx7man, April 03, 2016, 10:27:34 PM

Rx7man

Well.. after about 2 days of frustration, I think I've got it licked... I'd still like to do some optimizing, but so far so good..

Read 4 thermocouples in 200 MICROseconds... Not bad I think :).. and no sample smoothing is really necessary, the Max31856 can average up to 16 samples all by itself.

As long as the different chips all use the same SPI mode, that time can only get better with optimizations, but if I have to start changing SPI modes I might run into some extra code switching between them.

I will be revisiting my stepper motor as well, don't know if I'll ever actually use it for something useful though..


Next thing to attack will be the CAN bus, I want to put all SPI devices into one library, and have them all read/write the same way, and eliminate stuff we don't use (alternate CAN modes, etc)
'94 dually,  67/67 HE351VE, NV5600, ~600hp
'93 ECLB 47RH, new toy truck, H pump project, 1000hp goal, 300K miles
93 XCLB auto, bone stock, 350K miles
93 XCLB 5spd, bone stock, 100K miles

Rx7man

OK, though untested, it does compile with the addition of the CAN bus.

I modified the library to include only the barebones of what we need to work with the Holset turbo, and I added some shortcuts..

It makes working with the turbo MUCH easier, especially for someone not used to all this stuff..


A little example?


#include "MySPIdevices"

ThermoPin = 22;
CANpin = 10;

MAX31856 Thermo1(ThermoPin);
HolsetCAN Turbo(CANpin, VGTaddress); //CAN address of the turbo


setup(){
   Serial.begin(115200);
   Thermo1.begin();
   Turbo.begin();
}

loop(){
   Serial.print("Thermocouple is at (C) ");
   Serial.println(Thermo1.readThermocoupleC);

   Turbo.move(960);
   delay(1000);
}


I'm actually going to contain all the turbo so that it's all behind the scenes.. so you can get the actual position, commanded position, commanded speed, and temperature all from that library, which will clean up my main code in a big way and make it more readable (I think).. far less scrolling![/code]
'94 dually,  67/67 HE351VE, NV5600, ~600hp
'93 ECLB 47RH, new toy truck, H pump project, 1000hp goal, 300K miles
93 XCLB auto, bone stock, 350K miles
93 XCLB 5spd, bone stock, 100K miles

65fpvmustang

well if you fought the max 31856 i'm screwed. lol

Rx7man

'94 dually,  67/67 HE351VE, NV5600, ~600hp
'93 ECLB 47RH, new toy truck, H pump project, 1000hp goal, 300K miles
93 XCLB auto, bone stock, 350K miles
93 XCLB 5spd, bone stock, 100K miles

65fpvmustang

plan is to can bus to ms3, and me being a newbie figure this will be a challenge.

Rx7man

I don't know much about MS, but I'll give a hand if I CAN
'94 dually,  67/67 HE351VE, NV5600, ~600hp
'93 ECLB 47RH, new toy truck, H pump project, 1000hp goal, 300K miles
93 XCLB auto, bone stock, 350K miles
93 XCLB 5spd, bone stock, 100K miles