i found them on aliexpress, was tough!
I endend up finding some on eBay, they still come via Chinese Tugboat, but it's better than FOB from Alibaba.
i found them on aliexpress, was tough!
Maybe I should clarify selling, if I'm lucky I might recoup a $1 or $2 per board after components, solder, time, and shipping, I would hardly call it a commercial enterprise selling 1000/week. Just as you contributed your design to the community, I'm offering an easy option for those that can't (or don't) want to hunt down components and solder SMD parts; buying bare boards isn't within everybody's wheel house. If you don't want me to offer them thats fine, however, I'm not the only member whose offered to assemble boards for people (@onehorse)
There is only one rule and it is very clear - as long as you or anybody else is making ANY profit of it (and I know exactly what's the cost of components to build these boards), you are violating the 'license' under which this design has been made available. You didn't even bother to contact me before offering these for sale so you shouldn't be surprised that I'm not happy about your 'offer'.
Has anyone looked at an interrupt routine in the code that gets serviced when one of the RX filters matches?
That would be pretty slick!
#include <FlexCAN.h>
int ledPin = 13;
FlexCAN CANbus(250000);
static CAN_message_t rxmsg, txmsg;
String msg;
bool pinState;
// -------------------------------------------------------------
void setup(void)
{
Serial.begin(38400);
CANbus.begin();
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, 1);
delay(1000);
Serial.println(F("Hello Teensy 3.1 CAN Test."));
}
// -------------------------------------------------------------
void loop(void)
{
String Smsg;
while (!CANbus.available()){
toggle(ledPin);
delay(25);
}
if (CANbus.read(rxmsg) )
printCanMsg(rxmsg);
delay(1000);
toggle(ledPin);
}
void toggle(int pinNum) {
// set the LED pin using the pinState variable:
digitalWrite(pinNum, pinState);
// if pinState = 0, set it to 1, and vice versa:
pinState = !pinState;
}
void printCanMsg(CAN_message_t m){
String a = "";
for (int i=0; i<m.len ; i++)
a += (char)m.buf[i];
Serial.println(a);
}
void serialEvent(){
char inChar;
while (Serial.available()){
inChar = (char)Serial.read();
switch (inChar){
case 'a':
sendmsg1();
break;
case 'b':
sendmsg2();
break;
default :
sendmsg();
}
}
}
void sendmsg(){
String a="abcdefgh";
txmsg.id=0x0001;
txmsg.len=8;
for (int i=0; i< txmsg.len; i++)
txmsg.buf[i]=a[i];
CANbus.write(txmsg);
}
void sendmsg1(){
String a="12345678";
txmsg.id=0x0001;
txmsg.len=8;
for (int i=0; i< txmsg.len; i++)
txmsg.buf[i]=a[i];
CANbus.write(txmsg);
}
void sendmsg2(){
String a="A1B2C3D4";
txmsg.id=0x0001;
txmsg.len=8;
for (int i=0; i< txmsg.len; i++)
txmsg.buf[i]=a[i];
CANbus.write(txmsg);
}
Hi guys
Could you help me on this?
I appreciate it.
CAN bus requires an interface chip that you seem to be lacking in your picture. It's basically an open collector bus. Your tx pins are not expecting to be tied together and that may damage the chips.
Maybe check out this project to help you on your way.
https://oshpark.com/shared_projects/VeJFD9qA
It may be possible to simulate it with resistors and diodes for a board level application like your demo, but I haven't really considered it before.
That might helpI've tried to understand how to do it using resistors and diodes as you said, but couldn't understand how, can you point me on something?
16.2.5 Configuration of Rx FIFO ID filter table elements
The Rx FIFO ID tables or ID filter table elements are used as message acceptance filters
whose ID fields function as acceptance ID code. It is necessary to configure the Rx FIFO
ID filter table elements in freeze mode.
Kinetis supports up to 40 ID tables — therefore CTRL2[RFFN] = 4 at maximum.
/* Rx FIFO ID Filter Table Element 0 to 127 */
#define FLEXCAN0_IDFLT_TAB0 (*(vuint32_t*)(FLEXCAN0_BASE+0xE0))
#define FLEXCAN0_IDFLT_TAB(n) (*(vuint32_t*)(FLEXCAN0_BASE+0xE0+(n*4)))
//#define FLEXCAN0_IDFLT_TAB(n) (*(vuint32_t*)(FLEXCAN0_BASE+0xE0+(n<<2)))
void FlexCAN::setFilter(const CAN_filter_t &filter, uint8_t n)
{
if ( 8 > n ) {
if (filter.ext) {
FLEXCAN0_IDFLT_TAB(n) = ((filter.rtr?1:0) << 31) | ((filter.ext?1:0) << 30) | ((filter.id & FLEXCAN_MB_ID_EXT_MASK) << 1);
} else {
FLEXCAN0_IDFLT_TAB(n) = ((filter.rtr?1:0) << 31) | ((filter.ext?1:0) << 30) | (FLEXCAN_MB_ID_IDSTD(filter.id) << 1);
}
}
}
There is only one rule and it is very clear - as long as you or anybody else is making ANY profit of it (and I know exactly what's the cost of components to build these boards), you are violating the 'license' under which this design has been made available. You didn't even bother to contact me before offering these for sale so you shouldn't be surprised that I'm not happy about your 'offer'.
MrCanBus
send an eight byte packet with message ID 0x0500
0x6C,0x00,0x00,0x21,0x00,0x00,0x00,0x00
Oil service and/or Desmo service reset for your model.
With the reflash of the ECU I add extra CAN messages with the data needed to tune the bike.
The ECU on the MTS1200 uses less than half the CAN mailbox slots.
If you want to test sending CAN messages you can send the 0x80 message to test sending messages on the bus.
The ECU sends the 0x80 message and it does not care if other 0x80 messages are on the bus.
Send a message with RPM and you should see the dash show RPM and the headlight should turn on.
The 0x80 message is sent at 5 m/s intervals, You could wait until you get the 0x80 message then send 0x80, this will mean your message is the one the dash will use.
typedef struct CAN_message_t {
uint32_t id; // can identifier
uint8_t ext; // identifier is extended
uint8_t rtr; // RTR bit
uint8_t len; // length of data
uint16_t timeout; // milliseconds, zero will disable waiting
uint8_t buf[8];
} CAN_message_t;
// get identifier and dlc
msg.len = FLEXCAN_get_length(FLEXCAN0_MBn_CS(rxb));
msg.ext = (FLEXCAN0_MBn_CS(rxb) & FLEXCAN_MB_CS_IDE)? 1:0;
msg.rtr = (FLEXCAN0_MBn_CS(rxb) & FLEXCAN_MB_CS_RTR)? 1:0;
msg.id = (FLEXCAN0_MBn_ID(rxb) & FLEXCAN_MB_ID_EXT_MASK);
if(msg.ext) {
if(msg.rtr) {
FLEXCAN0_MBn_CS(buffer) = FLEXCAN_MB_CS_CODE(FLEXCAN_MB_CODE_TX_ONCE)
| FLEXCAN_MB_CS_LENGTH(msg.len) | FLEXCAN_MB_CS_SRR | FLEXCAN_MB_CS_IDE | FLEXCAN_MB_CS_RTR;
} else {
FLEXCAN0_MBn_CS(buffer) = FLEXCAN_MB_CS_CODE(FLEXCAN_MB_CODE_TX_ONCE)
| FLEXCAN_MB_CS_LENGTH(msg.len) | FLEXCAN_MB_CS_SRR | FLEXCAN_MB_CS_IDE;
}
} else {
if(msg.rtr){
FLEXCAN0_MBn_CS(buffer) = FLEXCAN_MB_CS_CODE(FLEXCAN_MB_CODE_TX_ONCE)
| FLEXCAN_MB_CS_LENGTH(msg.len)| FLEXCAN_MB_CS_RTR;
} else {
FLEXCAN0_MBn_CS(buffer) = FLEXCAN_MB_CS_CODE(FLEXCAN_MB_CODE_TX_ONCE)
| FLEXCAN_MB_CS_LENGTH(msg.len);
}
}
EagleUp + Maxwell rendererwhat software did you use to create this image?
#include <FlexCAN.h>
#include <kinetis_flexcan.h>
const int baudRate = 50000;
const int ledPin = 13;
const int delayTime = 1000;
int count = 0;
FlexCAN myCAN(baudRate);
CAN_message_t message;
CAN_message_t rxmsg;
void setup(){
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
digitalWrite(ledPin,HIGH);
myCAN.begin();
Serial.println("CAN PROTOCOL - INIT ... WAIT...");
digitalWrite(ledPin,LOW);
delay(5000);
digitalWrite(ledPin,HIGH);
Serial.println("Master ON - READY");
}
void loop(){
Serial.print("MY CAN data: ");
//Serial.println(myCAN.available());
if(myCAN.available()){
myCAN.read(rxmsg);
Serial.println(rxmsg.buf[0]);
if(rxmsg.buf[0] == 49){
Serial.println("Message Sent");
message.buf[0] = count;
message.buf[1] = count + 1;
message.len = 2 ;
message.id = 0x2;
myCAN.write(message);
count++;
}
}
//Serial.print("Data buf[0]: ");
//Serial.println(rxmsg.buf[0]);
delay(delayTime);
}
#include <FlexCAN.h>
#include <kinetis_flexcan.h>
const int baudRate = 50000;
const int ledPin = 13;
const int delayTime = 50;
FlexCAN myCAN(baudRate);
CAN_message_t message;
CAN_message_t rxmsg;
void setup(){
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
myCAN.begin();
Serial.println("CAN PROTOCOL - INIT ... WAIT...");
digitalWrite(ledPin,LOW);
delay(5000);
digitalWrite(ledPin,HIGH);
Serial.println("SLAVE ON - READY");
}
void loop(){
for(int i = 1 ; i < 50 ; i++){
message.buf[0] = i;
message.id = 0x1;
myCAN.write(message);
Serial.print("Message: ");
Serial.println(message.buf[0]);
digitalWrite(ledPin,HIGH);
delay(delayTime);
digitalWrite(ledPin,LOW);
delay(delayTime);
}
if (myCAN.available()){
Serial.println("Message Recived");
myCAN.read(rxmsg);
Serial.println(rxmsg.buf[0]);
Serial.println(rxmsg.buf[1]);
}
}
Code:const int baudRate = 50000;
You are not setting the message length when sending from the second Teensy, so (buf[0] == 49) will always be false.any ideas?