rleto577

Member Since: February 7, 2010

Country: United States

  • Product DEV-10039 | about 3 years ago

    Save you hair. They have a tendancy to fall off on their own as time goes on… Anyway, I’m not sure what you mean by pastebin, I assume it’s the comments box at the top. I’ll put the code in there again assuming you have a way to reformat the code. Here it is: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    / Welcome to the ECU Reader project. This sketch uses the Canbus library. It requires the CAN-bus shield for the Arduino. This shield contains the MCP2515 CAN controller and the MCP2551 CAN-bus driver. A connector for an EM406 GPS receiver and an uSDcard holder with 3v level convertor for use in data logging applications. The output data can be displayed on a serial LCD. SK Pang Electronics www.skpang.co.uk v1.0 28-03-10 Modified by: R. Letourneau VE3MPV for the Arduino MEGA - Feb 18th, 2011 Pin assignment: CAB-BUS MEGA ——- —– RST Reset +3.3 3V3 +5V 5V GND GND 13 52 SCK/PB1 12 50 MISO/PB3 11 51 MOSI/PB2 10 53 SS/PB0 9 9 PH6 8 8 PH5 7 7 6 16 TX2 5 18 TX1 4 19 RX1 A4(18) 25 A3(17) 23 A2(16) 24 A1(15) 22 / // #include #include #define COMMAND 0xFE #define CLEAR 0x01 #define LINE0 0x80 #define LINE1 0xC0 #define sGPS Serial1 // NewSoftSerial mySerial = NewSoftSerial(4, 5); #define sLCD Serial2 // Repalces: NewSoftSerial sLCD = NewSoftSerial(3, 6) #define LED2 8 #define LED3 7 #define D9 9 #define UP 22 #define DOWN 23 #define LEFT 24 // Should be the RIGHT #define ENTER 25 #include #include #include #include #include #include #include #include #include FAT TestFile; char buffer[512]; int read_size=0; int count=0; #define COMMAND 0xFE #define GPSRATE 4800 #define BUFFSIZ 90 char parseptr; char buffidx; uint8_t hour, minute, second, year, month, date; uint32_t latitude, longitude; uint8_t groundspeed, trackangle; char latdir, longdir; char stat; void setup() { Serial.begin(9600); sGPS.begin(GPSRATE); sLCD.begin(9600); pinMode(LED2,OUTPUT); pinMode(LED3,OUTPUT); pinMode(UP,INPUT); pinMode(DOWN,INPUT); pinMode(LEFT,INPUT); pinMode(ENTER,INPUT); digitalWrite(UP,HIGH); digitalWrite(DOWN,HIGH); digitalWrite(LEFT,HIGH); digitalWrite(ENTER,HIGH); pinMode(D9,OUTPUT); // Used for SD_CS in file: sd_raw_config.h // macros: select_card() & unselect_card() // Canbus/defaults.h pin assigment changed for MEGA Serial.println(“ECU Reader”); sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); if (Canbus.init(CANSPEED_500)) { sLCD.print(“CAN Init ok”); } else { sLCD.print(“CAN Init Failed!”); while (1) ; } delay(1000); sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); sLCD.print(“Mode: CAN GPS SD”); sLCD.print(COMMAND,BYTE); sLCD.print(LINE1,BYTE); sLCD.print(“Push: Dwn Up Rt”); } void loop() { if (digitalRead(UP) == 0) { Serial.println(“GPS…”); sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); sLCD.print(“GPS…”); gps_test(); } if (digitalRead(LEFT) == 0) { sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); sLCD.print(“SD…”); Serial.println(“SD…”); sd_test(); } if (digitalRead(DOWN) == 0) { Serial.println(“CAN…”); sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); sLCD.print(“CAN…”); while(1) { Serial.print(‘.’); // Mind pacifier if(Canbus.ecu_req(ENGINE_RPM,buffer) == 1) { sLCD.print(COMMAND,BYTE); sLCD.print(LINE0,BYTE); sLCD.print(buffer); } digitalWrite(LED3, HIGH); if(Canbus.ecu_req(VEHICLE_SPEED,buffer) == 1) { sLCD.print(COMMAND,BYTE); sLCD.print(LINE0 + 9,BYTE); sLCD.print(buffer); } if(Canbus.ecu_req(ENGINE_COOLANT_TEMP,buffer) == 1) { sLCD.print(COMMAND,BYTE); sLCD.print(LINE1,BYTE); sLCD.print(buffer); } if(Canbus.ecu_req(THROTTLE,buffer) == 1) { sLCD.print(COMMAND,BYTE); sLCD.print(LINE1 + 9,BYTE); sLCD.print(buffer); } digitalWrite(LED3, LOW); delay(50); if (digitalRead(ENTER) == 0) break; } dispMsg(); } delay(1000); } void sd_test(void) { Serial.println(“ready…”); TestFile.initialize(); Serial.println(“Starting…”); TestFile.create_file(“rej7.txt”); TestFile.open(); while(1) { TestFile.write(“This is test data.”); TestFile.close(); while(1) { TestFile.open(); read_size=TestFile.read(buffer); Serial.println(read_size, DEC); for(int i=0; i ‘9’) || (str[0] < ‘0’)) return d; d = 10; d += str[0] - ‘0’; str++; } return d; } void dispMsg() { sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); sLCD.print(“Mode: CAN GPS SD”); sLCD.print(COMMAND,BYTE); sLCD.print(LINE1,BYTE); sLCD.print(“Push: Dwn Up Rt”);; Serial.println(“ECU Reader”); / For debug use / }

  • Product DEV-10039 | about 3 years ago

    I had no luck using the demo code with the duemilanove and the NSS library. So I ported the code to the MEGA board and my problems are solved, no more hang-ups ! As suspected, the NewSoftSerial library is causing the sketch to behave strangely and my level of expertise doesn’t allow me to delve into the library code to see what’s wrong with it. My guess is a problem with resources and/or interrupts. I added a copy of my code for your testing: >>>>>>>>>>>>>>>>>>>>>>>
    OOps, I appended my code here but the format looks awful. I have to find another way to add the code…

  • Product DEV-10039 | about 3 years ago

    After extensive testing, I found out that my microSD problem has nothing to do with the SPI configuration. In the following code from the can_shield_test.pde demo program, if I remove the else{…} section in the: if(Canbus.init(CANSPEED_500)) block, it works fine. Strange…??? So I suspect it has something to do with the NewSoftSerial object (nss). I searched the nss online and found similar lockup problems with the nss. I need to do more testing with the nss. Anyone experienced similar problems ?
    if(Canbus.init(CANSPEED_500)) / Initialise MCP2515 CAN controller at the specified speed /
    {
    sLCD.print(“CAN Init ok”);
    } else
    {
    sLCD.print(“Can’t init CAN”);
    }

  • Product DEV-10039 | about 3 years ago

    I have a canbus_shield dated: 8/31/10 and noticed that D10 (SPI/SS) is used to select the MCP2515 via the CAN_CS line. This causes SPI bus problems when both the CANBUS and microSD are used in the same sketch, i.e., demo code. Any suggestions on how I can get both the microSD & MCP2515 working via the common SPI bus without bus issues ?

No public wish lists :(