Recent Posts

Pages: [1] 2 3 ... 10
1
" If you made a board adapter and managed to insert it in breadboard without breaking it, it'll probably never come back out."
Not true.
I also offer 2560 system on a board in DIP format
2
I'm not an OOP programmer, so the below might be considered a workaround,

Declare the object in a function, call the function. When you leave the function, the object is destroyed. But I guess that you have considered that and it does not suite you.

Second option: using a statemachine approach, instantiate the object in the first state, destroy the object in the final state.
3
Shouldn't be a difficult task. Do you have a motor driver chosen yet, or are you controlling the motors directly from the relays right now?

Very often I suggest a completely different hardware configuration since starting with what the project builder already has is suboptimal. In this case, hardware choices would depend very much on how powerful the motors are, the speed and loads required and the application. e.g., does it need Emergency Stop capability? What motion limits are needed, etc.

I've spent most of my career doing various forms of motion control and it's amazing how complex even the simplest-looking applications really are.

Send me a PM and we'll talk.
4
Hello boylesg.

Unfortunately I could not find another library. I am using the Arduino IDE and use Xcode to view/edit the library files.

Based on the error code I got do you have any ideas on what the error may be. I may be in a little over my head with the level of coding used in libraries.
5
Project Guidance / Can bus shield ODB2
Last post by scarygood536 - Today at 04:09 am
Hello all! I'm new to the forums but a few years tinker'er. For the last several years I've been slowly working on a project to create my own tailgate light bar for my truck. I was originally going to pull the 12volt signal off the 7 pin trailer connector and step it down to a safer voltage and isolated with opticouplers to interface my lights with the truck signals. Then I learned about can-bus which would cut down on the wires I have to run. I have a canbus shield and a db9 to odbII port cable. I'm able to see can "data" when I run a default can receiver from any can bus library. My trouble is i cant see specific data. I cannot communicate with the canbus to send me specific data such as RPM,Speed, gear, signals etc... I reduced the canbus speed to 33kbps (not all libraries allow this) and on first run of arduino my truck will show me errors either 4wd needs service or tcs needs service basically interference.

my canbus shield uses mcp2515 mcp255 chips. I have a gmc sierra 1500. I have cut the CANH jumper as if i left it intact i couldn't receive any data (too many can devices) the code im trying to use is



Code: [Select]
#include <Canbus.h>
char UserInput;
int data;
char buffer[456];  //Data will be temporarily stored to this buffer before being written to the file

//********************************Setup Loop*********************************//

void setup(){
Serial.begin(9600);
Serial.println("CAN-Bus Demo");

if(Canbus.init(CANSPEED_125))  /* Initialise MCP2515 CAN controller at the specified speed */
  {
    Serial.println("CAN Init ok");
  } else
  {
    Serial.println("Can't init CAN");
  }
   
  delay(1000);

Serial.println("Please choose a menu option.");
Serial.println("1.Speed");
Serial.println("2.RPM");
Serial.println("3.Throttle");
Serial.println("4.Coolant Temperature");
Serial.println("5.O2 Voltage");
Serial.println("6.MAF Sensor");

}



//********************************Main Loop*********************************//

void loop(){

while(Serial.available()){
   UserInput = Serial.read();

if (UserInput=='1'){
 Canbus.ecu_req(VEHICLE_SPEED, buffer);
 Serial.print("Vehicle Speed: ");
 Serial.println(buffer);
 delay(500);
}
else if (UserInput=='2'){
 Canbus.ecu_req(ENGINE_RPM, buffer);
 Serial.print("Engine RPM: ");
 Serial.println(buffer);
 delay(500);

}
else if (UserInput=='3'){
 Canbus.ecu_req(THROTTLE, buffer);
 Serial.print("Throttle: ");
 Serial.println(buffer);
 delay(500);

}
else if (UserInput=='4'){
 Canbus.ecu_req(ENGINE_COOLANT_TEMP, buffer);
 Serial.print("Engine Coolant Temp: ");
 Serial.println(buffer);
 delay(500);

}
else if (UserInput=='5'){
 Canbus.ecu_req(O2_VOLTAGE, buffer);
 Serial.print("O2 Voltage: ");
 Serial.println(buffer);
 delay(500);

}
else if (UserInput=='6'){
 Canbus.ecu_req(MAF_SENSOR, buffer);
 Serial.print("MAF Sensor: ");
 Serial.println(buffer);
 delay(500);

}
else
{
  Serial.println(UserInput);
  Serial.println("Not a valid input.");
  Serial.println("Please enter a valid option.");
}

}
}


also

Code: [Select]

#include <SPI.h>
#include <CAN.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);

  Serial.println("CAN Receiver");

  // start the CAN bus at 500 kbps
  if (!CAN.begin(500E3)) {
    Serial.println("Starting CAN failed!");
    while (1);
  }
}

void loop() {
  // try to parse packet
  int packetSize = CAN.parsePacket();

  if (packetSize) {
    // received a packet
    Serial.print("Received ");

    if (CAN.packetExtended()) {
      Serial.print("extended ");
    }

    if (CAN.packetRtr()) {
      // Remote transmission request, packet contains no data
      Serial.print("RTR ");
    }

    Serial.print("packet with id 0x");
    Serial.print(CAN.packetId(), HEX);

    if (CAN.packetRtr()) {
      Serial.print(" and requested length ");
      Serial.println(CAN.packetDlc());
    } else {
      Serial.print(" and length ");
      Serial.println(packetSize);

      // only print packet data for non-RTR packets
      while (CAN.available()) {
        Serial.print((char)CAN.read());
      }
      Serial.println();
    }

    Serial.println();
  }
}


to receive specific data based on hex address


Code: [Select]
#include <SPI.h>
#include "mcp_can.h"

// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;

MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin

#define PID_ENGIN_PRM       0x0C
#define PID_VEHICLE_SPEED   0x0D
#define PID_COOLANT_TEMP    0x05

#define CAN_ID_PID          0x7DF

unsigned char PID_INPUT;
unsigned char getPid    = 0;

void set_mask_filt()
{
    /*
     * set mask, set both the mask to 0x3ff
     */
    CAN.init_Mask(0, 0, 0x7FC);
    CAN.init_Mask(1, 0, 0x7FC);

    /*
     * set filter, we can receive id from 0x04 ~ 0x09
     */
    CAN.init_Filt(0, 0, 0x7E8);                 
    CAN.init_Filt(1, 0, 0x7E8);

    CAN.init_Filt(2, 0, 0x7E8);
    CAN.init_Filt(3, 0, 0x7E8);
    CAN.init_Filt(4, 0, 0x7E8);
    CAN.init_Filt(5, 0, 0x7E8);
}

void sendPid(unsigned char __pid)
{
    unsigned char tmp[8] = {0x02, 0x01, __pid, 0, 0, 0, 0, 0};
    Serial.print("SEND PID: 0x");
    Serial.println(__pid, HEX);
    CAN.sendMsgBuf(CAN_ID_PID, 0, 8, tmp);
}

void setup()
{
    Serial.begin(115200);
    while (CAN_OK != CAN.begin(CAN_500KBPS))    // init can bus : baudrate = 500k
    {
        Serial.println("CAN BUS Shield init fail");
        Serial.println(" Init CAN BUS Shield again");
        delay(100);
    }
    Serial.println("CAN BUS Shield init ok!");
    set_mask_filt();
}


void loop()
{
    taskCanRecv();
    taskDbg();
   
    if(getPid)          // GET A PID
    {
        getPid = 0;
        sendPid(PID_INPUT);
        PID_INPUT = 0;
    }
}

void taskCanRecv()
{
    unsigned char len = 0;
    unsigned char buf[8];

    if(CAN_MSGAVAIL == CAN.checkReceive())                   // check if get data
    {
        CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf

        Serial.println("\r\n------------------------------------------------------------------");
        Serial.print("Get Data From id: ");
        Serial.println(CAN.getCanId(), HEX);
        for(int i = 0; i<len; i++)    // print the data
        {
            Serial.print("0x");
            Serial.print(buf[i], HEX);
            Serial.print("\t");
        }
        Serial.println();
    }
}

void taskDbg()
{
    while(Serial.available())
    {
        char c = Serial.read();
       
        if(c>='0' && c<='9')
        {
            PID_INPUT *= 0x10;
            PID_INPUT += c-'0';
           
        }
        else if(c>='A' && c<='F')
        {
            PID_INPUT *= 0x10;
            PID_INPUT += 10+c-'A';
        }
        else if(c>='a' && c<='f')
        {
            PID_INPUT *= 0x10;
            PID_INPUT += 10+c-'a';
        }
        else if(c == '\n')      // END
        {
            getPid = 1;
        }
    }
}



No data is ever retrieved.

I'm lost on how i can get the data i want to spit out. Any tips or help is appreciated thanks! 
6
Displays / Re: What should I expect in I2...
Last post by PeterPan321 - Today at 04:09 am
If you are going that route, then you may want to take a look at my hd44780 library.
It can offer a "plug and play" solution for that type of LCD h/w as it can auto locate the i2c address and auto configure the pin mappings used on the PCF8574 backpack.
It is available in the IDE library manager. (don't install it using a zip file)
See the github page for more information: https://github.com/duinoWitchery/hd44780
Also, see the wiki there for some additional information.

--- bill
Thanks! I've ordered a few from Aliexpress, so by the time the slow boat from China delivers it, I should have some test code set up and ready to go.
7
Programming Questions / Re: PID Library doubts
Last post by arduino_new - Today at 04:05 am
This solution is based on what I understand of your project:

You would need to calculate the rate of change of the temperature. Then, calculate the cut-off value based on the rate of change and turn on/off the system at this value.
8
Audio / Re: Change MIDIUSB Device Name...
Last post by musinou - Today at 04:03 am
Code: [Select]
So, after reading a few threads I decided to make a how-to, hoping it can help someone. Here you go:

[url=http://liveelectronics.musinou.net/MIDIdeviceName.php]http://liveelectronics.musinou.net/MIDIdeviceName.php[/url]
9
Arduino Yún / Yún retired?
Last post by AgroMeInc - Today at 04:02 am
So what will replace it?
Will the Yun Shield still exist ? Link is broken from products page.
10
There should be an example sketch, that comes with the library you are using for the shield.

Why don't you get your device working with the unmodified example sketch first and then slowly modify the example sketch according to your needs.
Pages: [1] 2 3 ... 10