Arduino + cRIO: Is Arduino the Right Choice?

For a semester project, I've been given a cRIO real-time controller, a CAN module for it, and told to "make it work". The goal is to leave it in a state such that a student in a future class can select it as his own project, and expand it from where I left off.

The cRIO system supports both LABView and VxWorks programming. While I would like to use, and have been encouraged to use VxWorks (if there is time after basically figuring out how to get the thing to turn on), the more pressing requirement is the need to connect the CAN module to another CAN-capable device for remote control and data acquisition.

With all that in mind, I am thinking of getting an Arduino board and one of these: http://www.sparkfun.com/products/10039
I like the idea of getting an Arduino in here because it leaves a lot of choices open for the next person to work on this.

Given that I have no experience with Arduino/embedded systems, and I have two months to complete this, I think making LEDs blink via LABView seems like an appropriate goal. Am I being too ambitious? If anyone has a different suggestion for some way to verify that the CAN module is able to read input, please let me know. I briefly thought of directly applying a voltage to one of the high/low pins of the CAN connector, but I wasn't sure if that might be innappropriate.

If anyone is curious, the cRIO stuff I'm allowed to work with is here:
NI cRIO-9074 Chassis:

NI 9853 2-Port High Speed CAN Module:

to complete this

This? What would "this" be?

If anyone has a different suggestion for some way to verify that the CAN module is able to read input, please let me know.

You want to know if a $1200 module from National Instruments that is designed to interact with CANBUS is capable of reading data from CANBUS? I suspect the answer is "yes". I can't imagine they would stay in business very long if the answer was "no".

I briefly thought of directly applying a voltage to one of the high/low pins of the CAN connector

Why?

This? What would "this" be?

"This" as in "do something with this hardware". I can do pretty much anything I want (and can afford). The problem is that I'm completely new to embedded systems and have no idea what is feasible.

You want to know if a $1200 module from National Instruments that is designed to interact with CANBUS is capable of reading data from CANBUS? I suspect the answer is "yes". I can't imagine they would stay in business very long if the answer was "no".

That's exactly what I've been told to do: "make it turn on, then, if there's still time left in the semester, see what else you can do with it."

Why?

Because there is nothing else in this lab with a DB9 connector. All I would have to do to get a labview program to detect activity on the bus is apply a voltage to one of the high or low pins, right? I have to be able to buy anything I want to use, too, which is why I was thinking an of doing something with an arduino board, since those are cheap.

Unfortunately, it seems that the breakout board I found in my OP doesn't map its CAN_H, CAN_L pins to the "standard" CAN_L on pin 2, CAN_H on pin 7, so I won't be able to use it with this CAN module after all. Would I be a(n even bigger) fool to buy a protoboard, a CAN transceiver, a CAN controller, and a DB9 connector and try to make my own?

asdfGo:
"This" as in "do something with this hardware".

Are you deliberately being evasive or do you really not understand my question?

Because there is nothing else in this lab with a DB9 connector.

In which case you need to obtain a soldering iron, solder, wire, and a few female DB9 connectors. Or, you need to obtain prebuilt CANBUS cables. Or, for a few dollars more, you can get DB9 connectors with screw terminals.

And, you will have to obtain a second CANBUS node. There is nothing useful you can do with one node.

All I would have to do to get a labview program to detect activity on the bus is apply a voltage to one of the high or low pins, right?

In the best case, that will generate a "bus off" condition. In the worst case that will severely damage something. It is not a good idea.

Unfortunately, it seems that the breakout board I found in my OP doesn't map its CAN_H, CAN_L pins to the "standard" CAN_L on pin 2, CAN_H on pin 7, so I won't be able to use it with this CAN module after all. Would I be a(n even bigger) fool to buy a protoboard, a CAN transceiver, a CAN controller, and a DB9 connector and try to make my own?

To get past a simple wiring problem? Yes, you would be a fool. For a few dollars you can get everything you need to make your own cables. As you've discovered, building your own cables is a prerequisite to working with CANBUS so you may as well pursue it. Don't forget the terminating resistors.

I'm sorry, but I guess I don't really understand what you mean. I thought you meant that it seems like I haven't actually set forth any non-trivial plan to complete? I haven't. My assignment is "collect data from this [CAN module] with labview - if you have time left afterward, do something interesting."

After I get a simple LABView program to verify that messages are being sent on the bus, I have free reign to do essentially anything I can learn/afford to do. I realized that I actually need another node with which to communicate, and assumed that Arduino, known for being relatively simple (and low-cost!) to use, would be a good choice - especially since whoever continues this "project" is also going to have absolutely zero knowledge when they come in.

So: The goal I wish to complete is to get a second CAN node and control it via the cRIO module. What it does doesn't really matter to me - I just want to get them to communicate. I would love to try to get them to communicate in a time-triggered manner, but right now, making a node broadcast a message and having it be read by the cRIO controller would be sufficient.

In which case you need to obtain a soldering iron, solder, wire, and a few female DB9 connectors. Or, you need to obtain prebuilt CANBUS cables. Or, for a few dollars more, you can get DB9 connectors with screw terminals.

Got it. Sorry that I was being unclear - I forgot the proper terminology: what I meant is that there are no other CANBUS nodes in this lab, so I have to make/obtain one, which is why I immediately thought of using Arduino.

And, you will have to obtain a second CANBUS node. There is nothing useful you can do with one node.

Right. I was unsure if creating one would a feasible Arduino project.

In the best case, that will generate a "bus off" condition. In the worst case that will severely damage something. It is not a good idea.

Thank you. That is something that I was afraid of happening.

To get past a simple wiring problem? Yes, you would be a fool. For a few dollars you can get everything you need to make your own cables. As you've discovered, building your own cables is a prerequisite to working with CANBUS so you may as well pursue it. Don't forget the terminating resistors.

Sorry, I didn't know that I could make my own cables, and just assumed that it would obvious that I already had some. I actually do have two pairs of female-female connectors from NI, each with a single terminating resistor. They use the wiring standard (pin2 - CAN_L, pin7 - CAN_H, etc.) that I was hoping to find on an existing arduino shield.

asdfGo:
I thought you meant that it seems like I haven't actually set forth any non-trivial plan to complete?

Regardless of the triviality, you have to have some stated goal or no one will be able to help you.

My assignment is "collect data from this [CAN module] with labview - if you have time left afterward, do something interesting."

That is a bit better. Data arrives in LabVIEW through the referenced hardware and the goal has been reached.

Your responsibility is: properly connect and configure the existing hardware; develop a LabVIEW application that interacts with the existing hardware; select more hardware to act as a second test node; develop an application to run on the test node; properly connect the NI 9853 to the test node; ensure data generated by the test node arrives in the LabVIEW application.

Is that a reasonable summary?

I realized that I actually need another node with which to communicate, and assumed that Arduino, known for being relatively simple (and low-cost!) to use, would be a good choice - especially since whoever continues this "project" is also going to have absolutely zero knowledge when they come in.

While an Arduino + CANBUS shield will assuredly work, it's difficult to say if that's a good choice. You have not provided enough information to reach an opinion.

Some example alternatives...

You can purchase ready-to-run diagnostic devices that are capable of emitting CANBUS frames. This may be a better choice.

You can purchase USB-to-CANBUS converters (with accompanying software) that are capable of emitting CANBUS frames. National Instruments sells just such a converter (warning: the kernel driver is a bit buggy). This may be a better choice.

Ultimately, how will the cRIO equipment be used? Prioritized data collection? Engine control?

I would love to try to get them to communicate in a time-triggered manner

Huh?

but right now, making a node broadcast a message and having it be read by the cRIO controller would be sufficient.

This (about $400)...

...and two weeks should get you to that goal.

I've also had good luck with esd converters like this one...
http://www.esd.eu/german/products/CAN/can-usb-mini_e.htm

And, you will have to obtain a second CANBUS node. There is nothing useful you can do with one node. ... Right. I was unsure if creating one would a feasible Arduino project.

Yes. Arduino + CANBUS is feasible.

Sorry, I didn't know that I could make my own cables, and just assumed that it would obvious that I already had some.

Not only can you make your own cables but for short distances or low bit rates, the quality of the cable is almost irrelevant. I've had two nodes communicating reliably with: a single terminating resistor instead of one on each end; no ground (just CAN_H and CAN_L connected); wire I found in a box of scrap; wire wrapped around a 110-to-24 volt transformer.

Basically, you put a 120 ohm resistor across CAN_H and CAN_L at each end, connect CAN_H to CAN_H, connect CAN_L to CAN_L, and connect CAN_GND to CAN_GND.

[quote author=Coding Badly link=topic=75200.msg570430#msg570430 date=1318756134]
Regardless of the triviality, you have to have some stated goal or no one will be able to help you. ...
That is a bit better. Data arrives in LabVIEW through the referenced hardware and the goal has been reached.

Your responsibility is: properly connect and configure the existing hardware; develop a LabVIEW application that interacts with the existing hardware; select more hardware to act as a second test node; develop an application to run on the test node; properly connect the NI 9853 to the test node; ensure data generated by the test node arrives in the LabVIEW application.

Is that a reasonable summary?[/quote]

Okay, now I see what you mean. Only the first two parts are explicit requirements: properly connect and configure the existing hardware; develop a LabVIEW application that interacts with the existing hardware. Doing both of those would be sufficient. The first has partially been done: Identical projects have been done for digital and analog I/O modules by previous students - I just have to repeat it with the NI 9853.

The previous students just wrote a LabVIEW application to read analog input (provided by a 9v battery) and a LabVIEW application to output a voltage via the analog and digital output modules, which they measured with a multimeter.

As for the rest:

select more hardware to act as a second test node; develop an application to run on the test node; properly connect the NI 9853 to the test node; ensure data generated by the test node arrives in the LabVIEW application.

I saw these as necessary steps to satisfy the first two responsibilities.

Another option I have been considering, after you said that I could create my own cables, is to run a loopback test:
http://digital.ni.com/public.nsf/allkb/CC3611C5424B715A862575D700723EB9

I hesitate because the second CAN port on the NI 9853 would have to receive 8-25V from the CAN bus to which it is connected, and I'm not sure how to do that. Other than that, this seems like it would be the best option that doesn't involve buying an expensive CAN-USB or CAN-RS232 adapter.

While an Arduino + CANBUS shield will assuredly work, it's difficult to say if that's a good choice. You have not provided enough information to reach an opinion.
...
Ultimately, how will the cRIO equipment be used? Prioritized data collection? Engine control?

There are currently no plans to use the cRIO equipment for anything. It will likely remain unused until some student gets interested in using it for a class project. The way the lab works is that there is hardware available for use by students, and we take several classes in which we're allowed to pick a piece of hardware and get it into a state such that a student in a later semester may use it to do something. The other option is to pick some equipment that is being used in an existing project, and expand that project.

Since I cannot predict what a future student will want to do with a cRIO system and a second node, I think that the most important considerations are flexibility and ease of use.

That's because the most common complaints I hear from other students are:
-the documentation for their existing project is poorly-written
-the documentation for their equipment is outdated, incomplete, incomprehensible, or impossible to find
-the project they have selected (or been assigned) leaves little room for choice in how to expand it, so they end up working on a project they're not interested in

I see the Arduino + CANBUS shield option as being flexible because a future student can then make this node do pretty much whatever he or she wants. Arduino is well known and widely-used, so that a future student will be less likely to be stuck without documentation to follow or any people to ask for guidance. Whether the next student wants to do data collection, engine control, or add a third node for some reason, adding an Arduino board as a second node won't get in their way, will it?

I would love to try to get them to communicate in a time-triggered manner
...
Huh?

A time-triggered system is a real-time system that sees it nodes communicate according to a fixed schedule so that no two nodes ever attempt to broadcast messages on the bus at the same time, and thus no messages are received "late" due to being preempted by a message of higher priority. Another benefit is that the operation of the system is deterministic, which can make it easier to test. This can be implemented in software for communication over CAN, but it's complicated and would require much more time, effort, and learning on my part. Still, it would make a cool semester project.

In fact, I'll have first dibs on this equipment next semester if I'd like to do something like that. I would also be able to work on it during the entire semester instead of just the last half.

This (about $400)......and two weeks should get you to that goal.

I'm sorry, I really don't want to spend much more than $100-200 on this project. Though I can be reimbursed for anything I get approved by my professor, I doubt he'll approve this since there are cheaper alternatives and it doesn't seem like open the door for expansion by another student.

Not only can you make your own cables but for short distances or low bit rates, the quality of the cable is almost irrelevant. I've had two nodes communicating reliably with: a single terminating resistor instead of one on each end; no ground (just CAN_H and CAN_L connected); wire I found in a box of scrap; wire wrapped around a 110-to-24 volt transformer.

Basically, you put a 120 ohm resistor across CAN_H and CAN_L at each end, connect CAN_H to CAN_H, connect CAN_L to CAN_L, and connect CAN_GND to CAN_GND.

That sounds much more simple than I was hoping.

So, to satisfy my immediate responsibility, I want to run the loopback test. How much more difficult would it be to carry a voltage to the second port of the NI 9853?

As for my personal goal: Do you agree that the Ardunio seems like a good solution in light of vague and unpredictable future requirements?

Never mind the loop back test. I explained the options I see to my professor and he told me to try to find some kind of emulator software for sending messages over the CAN bus by connecting directly to a PC's RS232 port. I asked if those existed and he didn't know of any but thought they probably would.

Would they, though? Some quick Googling doesn't reveal any hits, but I thought that plugging a CAN connector directly into a PC serial port would damage something. Why would there be CAN-RS232 or CAN-USB converters if one could just use a serial port and an emulator?

If I can't find an emulator, then he told me to get a second node (something "automotive related" since CAN is commonly used for automotive applications). If I can find the emulator, then I'm still allowed to get a second node. So it looks like I won't be doing the loopback test, though I may still end up using Arduino if I can't find something "automotive related". Not really sure where to start on that, so I'm going to do some more research. Thank you for being so patient thus far! Sorry for wasting your time, since it seems like whatever I do probably won't be Arduino-related after all. That is, unless I can think of some way that Arduino would be appropriate. I'd really like to use Arduino.

I see the Arduino + CANBUS shield option as being flexible because a future student can then make this node do pretty much whatever he or she wants. Arduino is well known and widely-used, so that a future student will be less likely to be stuck without documentation to follow or any people to ask for guidance. Whether the next student wants to do data collection, engine control, or add a third node for some reason, adding an Arduino board as a second node won't get in their way, will it?

It will not get in their way.

I agree. An Arduino + CANBUS shield is a very good choice for what you are trying to accomplish.

A time-triggered system is a real-time system that sees it nodes communicate according to a fixed schedule so that no two nodes ever attempt to broadcast messages on the bus at the same time, and thus no messages are received "late" due to being preempted by a message of higher priority. Another benefit is that the operation of the system is deterministic, which can make it easier to test. This can be implemented in software for communication over CAN, but it's complicated and would require much more time, effort, and learning on my part. Still, it would make a cool semester project.

That's exactly what CANBUS brings to the table. Prioritized messaging. There's no need to do anything special in software. It's just a matter of properly choosing arbitration values.

So, to satisfy my immediate responsibility, I want to run the loopback test. How much more difficult would it be to carry a voltage to the second port of the NI 9853?

I have no idea. I have never worked with a CANBUS controller that required power to be delivered through the DB9 connector.

As for my personal goal: Do you agree that the Ardunio seems like a good solution in light of vague and unpredictable future requirements?

I do. An Arduino + CANBUS shield seems like a very good choice.

I explained the options I see to my professor and he told me to try to find some kind of emulator software for sending messages over the CAN bus by connecting directly to a PC's RS232 port. I asked if those existed and he didn't know of any but thought they probably would.

It is an impossibility. There is no way to manipulate an RS232 port to create a valid CANBUS frame.

Would they, though? Some quick Googling doesn't reveal any hits, but I thought that plugging a CAN connector directly into a PC serial port would damage something.

I believe that one or both sides would be damaged. But, it makes no difference. It simply will not work.

Why would there be CAN-RS232 or CAN-USB converters if one could just use a serial port and an emulator?

Excellent question. I suspect you already know the answer.

then he told me to get a second node (something "automotive related" since CAN is commonly used for automotive applications)

I can't find a link but I believe someone has developed an engine simulator using an Arduino + CANBUS shield. Have you searched for something like that? When you search try using "ODB" instead of "CANBUS".

This may be helpful...