PDA

View Full Version : CAN Bus Library for Teensy 3.1



chadder_all
11-16-2013, 03:24 AM
Moderator Edit: I've merged the many CAN bus threads and made this topic stick to the top of the Suggestions forum.

Current CAN Bus Status (June 2014): Teachop's FlexCAN library (https://github.com/teachop/FlexCAN_Library) works on Teensy 3.1. :)

Please use this thread to discuss CAN bus for Teensy 3.1.


-------------------------------


Is it possible to use a teensy 3.0 for a CAN bus controller? A few other classmates and myself are trying to develop a supervisory computer to monitor all onboard sensors. We are thinking of using CAN for a few reasons; error detection, message priority, increased immunity to noise, etc.
If teensy doesnt support CAN, are there any other suggestions? Perhaps I can convince some people to use I2C instead.

PaulStoffregen
11-16-2013, 09:31 AM
Moderator Edit: This old message was written before Teensy 3.1 was released, in January 2014.

------------------------------------------

Currently none of the Teensy boards supports CAN bus.

This CAN bus shield library (http://www.seeedstudio.com/wiki/CAN-BUS_Shield) will probably work on Teensy 3.0. It uses the SPI library to talk to the MCP2515 chip. I just checked the code and it compiles ok (on Linux, there's a lowercase filename that needs to be edited, but a trivial thing to fix, and it doesn't matter on Mac and Windows). Of course, you'll need that shield with those 2 chips.

I do have a quick question though. If I were to look into trying that shield, or just those 2 chips somehow, what CAN devices would I use for testing?

chadder_all
11-16-2013, 10:28 PM
Thanks for the link! Just to clarify, the shield allows communication between an Arduino and the 2515 controller with SPI interface and the 2551 transceiver? Please bare with me as I am very new to CAN. For each CAN device (sensors, actuators, etc.) there is a host processor that will send out (or receive) messages to the CAN transceiver. The transceiver manipulates the message so that the CAN controller can understand it. Then does the controller put the received message on the CAN bus so it is available to be used by the host processor (i.e. the Arduino/Teensy)? The CAN controller also has the ability to decide which message/node has priority.

As for the test CAN devices, would two photoreceptors attached to analog pins work? So the message being sent would be based on the value being read at the pins? I dont think I understand this

PaulStoffregen
11-17-2013, 03:28 AM
Let me rephrase that question...

Suppose you magically had a Teensy with MCP2515 and tranceiver chip and 9 pin connector. What would you plug into that 9 pin connector? What other CAN stuff would you have communicate with Teensy?

chadder_all
11-17-2013, 04:03 AM
Ok now I understand. There are going to be quite a few inputs and outputs but here are a few: throttle sensor, brake sensor, traction control system, BMS error, Emergency kill switch, ready indicator, battery temperature sensor. Those are the more important ones of a long list. Pretty much the supervisory computer has to indicate whether any of the systems fail and if they do the battery has to be disconnected immediately.

chadder_all
11-17-2013, 04:44 AM
Paul,

Would my next step be to purchase the MCP 2515 and 2551 along with the shield? Then setup a basic network to see if the teensy supports CAN? I am really excited to work on this project

PaulStoffregen
11-17-2013, 04:40 PM
Maybe this?

http://www.mikroe.com/click/can-spi-3.3v/

chadder_all
11-19-2013, 01:31 AM
Thanks Paul. I will look into that but I think I may just go with another controller with CAN built in

chadder_all
01-15-2014, 09:28 PM
Hi Paul,

I just noticed the 3.1 is CAN enabled. Ive done my research and understand more or less how a CAN network operates. With the CAN controller integrated into teensy, all I would need is a transceiver like the MCP2551/2561 to take the differential signals from the CAN bus and transmit a 1 (recessive) or 0 (dominant) to the CAN controller to then be processed by the teensy. In my case, we have these nodes that are putting data on the CAN bus to be processed by the supervisory computer. I assume the data being put on the bus from the nodes contains message ID, message length, message, etc. otherwise we would have now way of telling which node is trying to "speak".

Anyways, what I am trying to get at is what does the CAN controller do? Does it just make it easier for the teensy to do its thing? I have read it has built in error handling functions.

Also, is the CAN controller hardware that needs to be programmed to handle these errors? Is that what a CAN library would do?

Many thanks!

chadder_all
01-15-2014, 09:42 PM
Additionally,

What would have to be done to make a CAN library?

PaulStoffregen
01-15-2014, 09:45 PM
What would have to be done to make a CAN library?

Only programming, merely pressing buttons on a keyboard in the right order...

Headroom
01-15-2014, 09:57 PM
ROTFLMAO. If it would just be that easy ......

chadder_all
01-16-2014, 01:24 AM
say you want to put a message on the CAN bus, does the controller automatically frame the message or do you have to write functions/libraries to do so?

dpharris
01-28-2014, 07:16 AM
The driver chip just handles the electrical driving on the bus.
The controller handles sending a frame, which consists of lead bits, header, control-bits, data-length, data, checksum, and follow bits; and also does bit-stuffing and error detection and correction.
CAN was invented by Bosch for cars and trucks, and there is a lot of info on the net, e.g. http://en.wikipedia.org/wiki/CAN_bus and the original spec at http://www.bosch-semiconductors.de/media/pdf_1/canliteratur/can2spec.pdf
CAN controllers differ quite a lot. The MCP2515 is quite basic. The built in CAN controller in the Teensy 3.1 is more sophisticated, and has a number of 'mail-boxes', each of which can be used to receive particular messages, or to send messages. The messages can be filtered on the header field. and matched messages can cause automatic replies.
BTW, you have to have two CAN nodes on a bus to get it to work, otherwise the CAN controller will hang.

dpharris
01-29-2014, 01:54 AM
Hi All -

If there is no CAN support for the FLEXCAN in Teensy 3.1, then I will take a stab at a very basic library.

I am thinking:
Can_setup( id, rate)
Where id is channel number, rate is an enum(125000,...),
And returns 0=fail, 1=success
Can_send( type, header, length, &data)
Where type is enum(standard, extended), header is 11 or 29-bit, length is number of data bytes,
And returns 0=fail, 1=success
Can_receive( type, header, length, &data)
Where type is enum(standard, extended), header is 11 or 29-bit, length is number of data bytes,
And returns 0=fail, 1=success

Filtering and other stuff on request.

David

pkropf
02-08-2014, 06:40 PM
It looks like Teensy 3.1 includes support for CAN bus though it doesn't look like there's any library or other documentation that supports it. Any idea on when there's be support for the CAN bus?

Thanks!

- Peter

stevech
02-08-2014, 11:47 PM
It looks like Teensy 3.1 includes support for CAN bus though it doesn't look like there's any library or other documentation that supports it. Any idea on when there's be support for the CAN bus?

Thanks!

- Peter Paul posted a few days ago that a CAN library for T3 is in the TODO list - a few weeks out.

pkropf
02-09-2014, 12:11 AM
Paul posted a few days ago that a CAN library for T3 is in the TODO list - a few weeks out.

Excellent, thanks for the info!

BTW, I had done a search for CAN bus but the forum engine returned nothing. Seems a bit strange to me.

stevech
02-09-2014, 12:15 AM
there is Arduino (AVR) code for the CAN bus... in the model railroad world. I found some with Google's help.

PaulStoffregen
02-11-2014, 04:19 PM
I merged the many CAN bus threads.

Please use this threads to discuss CAN bus. If you see people start new threads on CAN bus, please direct them to post and subscribe on this thread.

Having it all in 1 thread will really help in a few weeks when I start actually working on the CAN library.

pawelsky
02-11-2014, 05:15 PM
If there is no CAN support for the FLEXCAN in Teensy 3.1, then I will take a stab at a very basic library.

In the Arduino Due CAN API thread (http://forum.arduino.cc/index.php?topic=131096.msg1472486#msg1472486) Paul provided a link to mbed's CAN API which looks very nice, clean and simple (and also very Arduino-like).

http://mbed.org/handbook/CAN#api

Maybe that is something you could aim for?

teachop
03-18-2014, 05:25 PM
There is an up-and-running Teensy3.1 CAN driver here. It will undoubtedly need to gain more features, but if interested please go ahead and take a look:
https://github.com/teachop/FlexCAN_Library

dpharris
03-19-2014, 01:01 AM
Teachop's code looks like a good start :-). Thanks for coalescing the various CAN threads.

allen
03-19-2014, 07:56 AM
Hello Everyone,

I am newbie to CAN Bus, I have done some google on it, but i want some clarification.

1.If am having CAN controller inbuilt on my Microcontroller(say STM32), it is having CAN_H and CAN_L. Can i connect these CAN_H and CAN_L lines to other CAN device to form a CAN network. Is CAN tranceiver is needed? or can i connect One CAN device CAN_H to other CAN device CAN_H and same for CAN_L also.

2. If i want to send some message to CAN bus, how and where can i send, since there is two lines CAN_H and CAN_L. and through which pin will receive data from the BUS. is there any transmitter and receiver Pin as in UART

3. What is the difference between CAN and CANopen. Normally CAN data rate is max 1Mbps, is CANopen also has same datarate

teachop
03-19-2014, 11:32 AM
I am newbie to CAN Bus, I have done some google on it, but i want some clarification
1. Yes you need a CAN transceiver, it won't work to just connect between parts CAN-TX and RX directly. Also include termination (resistors).
2. CAN is different from a UART. The UART has TX and RX that can operate at the same time, called full duplex. The CAN uses a single pair of wires in differential mode for noise immunity (some sort of ground reference is still needed too). The CAN bus can transfer information both ways but can only talk in one direction at a time, called half duplex.
3. CANopen is an additional protocol layer on top of the CAN bus. It can run at different rates, and 1Mbps is one of them.

Edit: Fixed TX/Rx oops thanks pawelsky for pointing it out!

pawelsky
03-19-2014, 09:34 PM
1. Yes you need a CAN transceiver, it won't work to just connect between parts CAN_H and _L directly. Also include termination (resistors).

BTW I don't think CAN terminals of the microcontroller would be called CAN_H/L, I would expect CAN_RX/TX or similar. CAN_L/H is what you get from the transceiver (which as teachop mentioned is necessary)

teachop
03-19-2014, 10:06 PM
CAN_H/L
Oops thanks, fixed.

Otmar
06-17-2014, 02:21 AM
I was trying to get the Teensy 3.1 reading CAN today and discovered that the teachop library (Many thanks for that!) seems to use pins 5 & 6 on the Teensy 3.1 board as teachop states in the readme. I was initially confused since the very pretty pinout card that comes with the Teensy 3.1 shows CAN on pins 3 & 4 and I, being the "hardware guy", was not looking at libraries when I wired it up.

I have not yet sent any packets, but did successfully and accurately read some packets on the powertrain bus of a Model S.

I am using a SN65HVD235D CAN transceiver chip with a 10K slope control resistor to ground on RS and 1K safety series resistors in both RX and TX connections to the Teensy. At this time it is not in listen only mode, though that's why I selected this chip to have that option.

Not wanting to derail the conversation (meaning if you want to talk more about this application, lets find another thread) for general entertainment here's a picture of a Teensy in a Tesla, it's mounted on top of an Adafruit motor driver board. I verified packet accuracy by comparing data read on the Teensy to the Phytec CAN dongle.

2228

duff
06-17-2014, 02:36 AM
i don't know about CAN bus but it looks like you need to vacuum your floor. hehe :cool:

mcneight
06-19-2014, 08:14 AM
Starting with a suggestion from Paul, and with big thanks going to teachop, I've incorporated the FlexCAN library into a "unified" CAN library. One simple API gets you functionality for three different types of CAN controller; Microchip MCP2515, Atmel SAM3X (Due), and Freescale K2x (Teensy 3.1). It's not quite finished yet, but if you are interested in using it, take a look at https://github.com/McNeight/CAN-Library/

Comments and patches are more than welcome.

-Neil

PaulStoffregen
06-19-2014, 12:32 PM
Neil, any chance you might restructure this library? With all the .cpp and .h files in the "src" directory, it can only work with Arduino 1.5.6. Currently, Teensy 3.1 only supports Arduino 1.0.5. Many people using the MCP2515 are probably also on Arduino 1.0.5, since 1.5.x is still considered beta test.

mcneight
06-19-2014, 02:58 PM
Paul,

I went with the 1.5.x library layout for two reasons:
1) This was originally meant to be just between the MCP2515 and the Due, which only uses the 1.5.x series
2) The 1.5.x library format is the way Arduino libraries are going for the foreseeable future

One of the things I discovered is that the new library format is very particular about how files are laid out and formatted. If the library.properties file doesn't parse correctly, the library is unavailable to the IDE. Also, if you cut and paste the library.properties file from another library, forgetting to change the name of the library effectively makes it disappear. The "legacy" library format is much simpler. For my testing with the Teensy, I simply took the contents of the src directory and copied them into the top level library directory, and then copied over the examples directory.

Would it be helpful if I created a 1.0.x branch in the repository to push changes into? Or possibly the other way around, with master becoming a 1.0.x-release branch and then having a 1.5.x-devel branch as well?

-Neil

PaulStoffregen
06-20-2014, 12:02 AM
I'd go with the 1.0.x format and not use the 1.5.x format at all. My opinion may be biased, since I'm making a product that I only support on 1.0.x.

If you're good an managing multiple branches, then a 1.0.x branch probably makes a lot of sense. Personally, I'm terrible at managing more than 1 master branch, but there are people who are amazing good at it.

As you're seeing, the 1.5.x stuff is still pretty rough around the edges. The simple truth is pretty all 3rd party libraries are using the 1.0.x format today. The 1.5.x format today is at the earliest stages of "early adopter", which is usually a painful path for anything "new".

On the other hand, their latest library spec (https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification) claims no more changes are coming, so perhaps there's nothing to fear?

One thing is pretty certain, nearly all libraries not distributed inside 1.5.6 are using the old 1.0.x format. They're going to have to keep Arduino compatible with the old format for a very, very long time.

mcneight
06-20-2014, 06:36 AM
I forgot to mention my third reason for going with a 1.5.x library was the mistaken belief that 1.5.x couldn't use 1.0.x libraries.

So, I wound up branching the repository so that I could easily find the 1.5.x version of the library if I wanted to switch or add to it for some reason, and now have master laid out as a 1.0.x style library.

PaulStoffregen
06-20-2014, 07:33 AM
Looking at the 5 examples, I'd recommend simplifying the #include stuff. Currently, it's this:



#include <Arduino.h>
#include <CAN.h>

#if defined(ARDUINO_ARCH_AVR) // Arduino with SPI interface to MCP2515 chip
#include <SPI.h>
#include <CAN_MCP2515.h>
#elif defined(ARDUINO_ARCH_SAM) // Arduino Due
#include <CAN_SAM3X.h>
#elif defined(__MK20DX256__) // Teensy 3.1
#include <CAN_K2X.h>
#else
#error "Your CAN controller is currently unsupported."
#endif


I'm hoping you'll simply to something like this:



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


Arduino as a platform is all about simplicity. Details like this are usually handled automatically in library headers, so end users can just use the library. When/if your library is extended to support CAN bus on other boards, like Maple or upcoming Energia boards, you'll only have to update 1 header instead of 5 examples. More importantly, if people using your library publish projects, all that code on other websites won't need to have its #ifdef stuff updated as the library grows.

Unfortunately, you do need to have "#include <SPI.h>", even though it's not necessary on Due & Teensy. Maybe some future version of Arduino will probably detect library dependencies (I tried to contribute this years ago, but David Mellis rejected the idea at the time). For quite a long time, we're all going to be stuck with this requirement. Fortunately, including SPI.h is harmless.

There's no need to include Arduino.h in the .ino file. The system always automatically includes it.

shanevanj
08-02-2014, 01:48 PM
Hi Guys,

What's the final outcome with this library and the PIN assignment Teensy diagram says can is 3 and 4, yet lib says 5/6 are used - does this change the assignment or does it not matter or can I set this somewhere - forgive the newbie questions, but I am trying to build a hardware shield to use the can properly ?

teachop
08-02-2014, 01:58 PM
Hi Guys,

What's the final outcome with this library and the PIN assignment Teensy diagram says can is 3 and 4, yet lib says 5/6 are used - does this change the assignment or does it not matter or can I set this somewhere - forgive the newbie questions, but I am trying to build a hardware shield to use the can properly ?
There is no issue. They are two different ways to talk about the same nets. The Teensy 3.1 module pins 5 and 6 are Arduino I/O 3 and 4 function.

shanevanj
08-02-2014, 02:02 PM
@teachop - Thanks ! I have not yet wired it up yet - any tips and tricks for a newbie CAN user ? My goal is to have a private message system using can to multi drop to a number of teensy's to form a distributed network for redundancy and to share processing load (I suppose not to dissimilar to a car environment)

teachop
08-02-2014, 03:32 PM
@teachop - Thanks ! I have not yet wired it up yet - any tips and tricks for a newbie CAN user ? My goal is to have a private message system using can to multi drop to a number of teensy's to form a distributed network for redundancy and to share processing load (I suppose not to dissimilar to a car environment)
Distributed I/O this way will probably work nicely with a roll-your-own approach. If you are good with the 8 byte limitation, then keep it simple!

For transferring blocks of information, a fragmentation protocol on top of CAN is recommended. You mentioned cars, the diagnostic protocol in cars (often ISO15765) has fragmentation support. I did my own (dead simple) stack, but I bet there are open source diagnostic projects out there to pull from.

slomobile
09-05-2014, 07:06 PM
FRC http://www.usfirst.org/roboticsprograms/frc will be using an all new control system for 2015 competition. http://www.usfirst.org/roboticsprograms/frc/blog-2015-control-system-kop-survey

The new system implements CAN throughout. For example, the power distribution board(PDB) is a CAN node that can report current draw on each circuit. This could be used to detect wheel slippage(abnormally low current draw), or jammed mechanisms(abnormally high current draw).
The new pneumatic control module(PCM) is now solely controlled via CAN. One of the yet to be released motor controllers is CAN only http://www.usfirst.org/roboticsprograms/frc/blog-motor-controller-options-2015

I am a mentor on one of the teams(5002) currently doing the beta testing and have just ordered a few Teensy 3.1 for IO expansion and experimentation. Please contact me if you have questions, ideas, or Teensy code you would like tested with the new control system prior to release.
dmaki@usfirst.org

Delphir
10-02-2014, 06:31 PM
Am I right, that Teensy 3.1 cannot be used for CAN Bus reading itself without using an additional "Can Bus transceivers" attached to it? Or maybe somebody can show a wiring example for this board?

teachop
10-02-2014, 07:08 PM
Am I right, that Teensy 3.1 cannot be used for CAN Bus reading itself without using an additional "Can Bus transceivers" attached to it? Or maybe somebody can show a wiring example for this board?
Please see if this helps:
https://github.com/teachop/FlexCAN_Library/blob/master/README.md

pawelsky
10-02-2014, 07:09 PM
Am I right, that Teensy 3.1 cannot be used for CAN Bus reading itself without using an additional "Can Bus transceivers" attached to it?

Yes you are right.

Delphir
10-02-2014, 07:13 PM
Please see if this helps:
https://github.com/teachop/FlexCAN_Library/blob/master/README.md


I have already saw this, but there is no any schematics available explaining this

Delphir
10-02-2014, 07:14 PM
Yes you are right.

Thanks for the info!

Loto_Bak
10-15-2014, 08:49 PM
Thank you guys! This is great work!

Question,
If the rx buffer is full and another message is received which message is dropped?

Loto_Bak
10-18-2014, 08:33 PM
Anyone getting compilation errors with flexcan?

Fresh 1.0.6 Arduino + Teensyduino 1.20 Install

Example code produces


Arduino: 1.0.6 + Td: 1.20 (Windows 7), Board: "Arduino Uno"
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp: In constructor 'FlexCAN::FlexCAN(uint32_t)':
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:16: error: 'CORE_PIN3_CONFIG' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:16: error: 'PORT_PCR_MUX' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:17: error: 'CORE_PIN4_CONFIG' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:19: error: 'OSC0_CR' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:19: error: 'OSC_ERCLKEN' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:20: error: 'SIM_SCGC6' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:20: error: 'SIM_SCGC6_FLEXCAN0' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp: In member function 'int FlexCAN::read(CAN_message_t&)':
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:133: error: 'yield' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp: In member function 'int FlexCAN::write(const CAN_message_t&)':
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:197: error: 'yield' was not declared in this scope


Any thoughts?

teachop
10-18-2014, 08:35 PM
Anyone getting compilation errors with flexcan?

Fresh 1.0.6 Arduino + Teensyduino 1.20 Install

Example code produces


This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 + Td: 1.20 (Windows 7), Board: "Arduino Uno"
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp: In constructor 'FlexCAN::FlexCAN(uint32_t)':
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:16: error: 'CORE_PIN3_CONFIG' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:16: error: 'PORT_PCR_MUX' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:17: error: 'CORE_PIN4_CONFIG' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:19: error: 'OSC0_CR' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:19: error: 'OSC_ERCLKEN' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:20: error: 'SIM_SCGC6' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:20: error: 'SIM_SCGC6_FLEXCAN0' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp: In member function 'int FlexCAN::read(CAN_message_t&)':
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:133: error: 'yield' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp: In member function 'int FlexCAN::write(const CAN_message_t&)':
C:\Program Files (x86)\Arduino\libraries\FlexCAN\FlexCAN.cpp:197: error: 'yield' was not declared in this scope


Any thoughts?
Change the board to Teensy3.1 and check again please.

Loto_Bak
10-18-2014, 08:36 PM
Duh.... Thankyou teachop

aijii
01-30-2015, 09:55 PM
Hi guys,

I'm wondering if anyone knows if there are any arduino drivers around that support iso-tp ? I've seen some stuff for linux but I don't possess the knowledge or ability to port these across to arduino ?

http://en.wikipedia.org/wiki/ISO_15765-2 is what i'm talking about...

Cheers,

Adrian

Ziam G
03-24-2015, 11:05 PM
Teachop,

Thank you for posting the library. However, Can you provide some more examples please, I am having a hard time understanding how use the Flex_CAN API.

Basically, I am only trying to read CAN messages coming from a PE3 ECU. I was able to read data using mcneight's awesome library with a MCP 2551 on the Teensy 3.1, but now I am unable to. I suspect there is something wrong with my transceiver but I am not sure. I want to double check using your library. I am new to CAN, but I feel like I have a good grasp of it after studying it for my University FSAE project.

instrumentek
05-21-2015, 09:02 PM
Teachop;

Thanks for all the work on this library, Can you tell me would this support the SAE J1939 protocall? From my research it requires using the 29-bit/"extended" identifier.

riodda
05-27-2015, 06:17 PM
Just for the records, i've sucefoully connceted my peak usb to teensy trough canbus at 500k, i've used the waveshare transcriveer module (quite cheap) the IC is a TI VP230 32M A6SG.
i've tryed with flexcan library and with Pedro Cevallos & Neil McNeight unified libray wich i think shares part of the code from flexcan.
For a noob like me i found Neil's library a bit easyer to use but i realle apreciate flexcan library too.
Cheers.

jamajason
10-24-2015, 12:22 PM
maybe this J1939 project files can help you. cool project!
http://tucrrc.utulsa.edu/Publications/Arduino/arduino.html

xboxpro1
01-30-2016, 10:00 AM
Hello, i have add a RTR flag to the library.
https://github.com/xboxpro1/FlexCAN_Library
Now i can see a request. Maybe any one can help me that i can send a frame request?

kvasir
08-15-2017, 03:58 PM
I have set up two Teensy 3.2's with the transceiver, code linked to below.

https://github.com/rummanwaqar/teensy_can_example
(https://github.com/rummanwaqar/teensy_can_example)
http://skpang.co.uk/catalog/images/canbus/can3v3_brk_rev_C.pdf
(http://skpang.co.uk/catalog/images/canbus/can3v3_brk_rev_C.pdf)
I can't seem to receive a Can signal on the receiving teensy even though I can see the signal waveform from transmission on pins 7 and 6 of the transceiver of the transmitting teensy. I have also tried to use the example code with the FlexCan library by pawelsky and have gotten nothing. All of the hardware seems to check out. Any and all help is appreciated.

dpharris
08-15-2017, 05:15 PM
Yes, something was broken. I have had no luck determinig why the newer code doesn't work on Teensies. Any help appreciated.

kvasir
08-15-2017, 05:37 PM
Yes, something was broken. I have had no luck determinig why the newer code doesn't work on Teensies. Any help appreciated.

What library were / are you using? do you happen to have any project files for doing some simple Can receiving that you know worked?

dpharris
08-16-2017, 12:04 PM
What library were / are you using? do you happen to have any project files for doing some simple Can receiving that you know worked?

This is original lib that seems to work, last time I tried it:
https://github.com/teachop/FlexCAN_Library

Newer lib which was written to be more general, does not seem to work:
https://forum.pjrc.com/threads/39867-Another-fork-of-FlexCAN

David

kvasir
08-16-2017, 03:58 PM
Found the problem. I had a non functional Flexcan library already installed at

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries

I think it was imported by some install software for another board.

I have since deleted it and tested teachop/FlexCAN_Library and pawelsky/FlexCAN_Library which both work. Pawelsky's library is stored at
C:\Users\userName\Documents\Arduino\libraries\Flex CAN

There is still a bit of work to do in writing teensy code to send proper byte code to talk to the hardware i'm working with, but I already have a test example working which gets the position value of an electric motor from its PID controller via Canopen

- Joseph