|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
Microcontroller with CAN feature inside VS external controller (MCP2515)Hi,
My name is Igor and it´s the first time I writte in this forum. I don´t know if this question has been answered in the past...sorry! I´ve doubts about CAN Bus devices: Is there any difference between using an 8 bits microcontroller with the CAN feature inside or using an external SPI controller,i.e., MCP2515? I mean if it´s possible to achieve more power or it´s similar. What do you think about the power of an ATMega 8 bits microcontroller processing 15-20 traces with a period of 10-20 ms? (Programming in C) Actually, I´ve an Arduino Diecimila with SPI <-->CAN (http://www.avrcard.com/products/can_adapter.htm) working. But I can´t achieve a big speed of processing and I would like to know if it´s normal or something it´s happenning. I´ve done a program which send again to CAN bus the messanges received with ID+1.With a CAN BUS sniffer, I can follow what it´s hapenning. At 1 Mbit/s of speed, I achieve resend a maximum of 7 mensagges at 20 ms of period which were originally sent. This isn´t too much, but maybe it´s for a 8 bits microcontroller with an external CAN BUS controller...anyone knows it? Maybe changing to a microcontroller with CAN feature inside is a big improvement or maybe it´s a problem of my code... Anyone has done this test? I would like to use it in automotive application (500 Kbit/s and mensagges with periods of 10-20 ms). I would like to know if an 8 bits controller has the enought power to manage 20 mensagges in "real time (20ms)" or if it´s too much. (Receive + look correct ID+ save in a stack + extract individual channels inside mensagge (motorola or intel format)with their linearization). Thank you. Regards, Igor R |
|
|
RE: Microcontroller with CAN feature inside VS external controller (MCP2515)I've used both internal and external (SPI) CAN controllers; externally, you can't tell the difference. External controllers are intrinsically slower to process messages (more overhead) but, with well designed code, 250K and 500K busses should be no problem; I haven't tried 1M but, with the speeds microcontrollers are capable of these days, it should be achievable. My primary concern would be how fast you could crank up the transfer speed between the micro and the CAN controller. I've used the ATMega 8-bit microcontrollers; 15-20 messages in 10-20 ms should not stress it (depending on what else it has to do, of course). One comment I might make is to use the filtering capabilities of the CAN controller (either external or internal) to do as much of the sorting as you can. I've had times when the IDs of the messages were so dispersed that I had to open the filters up, receive every message, and sort it out in the software. If you can cut out half the messages with the filters, that's 50% less incoming message processing you have to do. Regards, Allen Pothoof Date: Sun, 2 Aug 2009 12:28:07 +0200 Subject: [CANLIST] Microcontroller with CAN feature inside VS external controller (MCP2515) From: igorreal@... To: canlist@... Hi, My name is Igor and it´s the first time I writte in this forum. I don´t know if this question has been answered in the past...sorry! I´ve doubts about CAN Bus devices: Is there any difference between using an 8 bits microcontroller with the CAN feature inside or using an external SPI controller,i.e., MCP2515? I mean if it´s possible to achieve more power or it´s similar. What do you think about the power of an ATMega 8 bits microcontroller processing 15-20 traces with a period of 10-20 ms? (Programming in C) Actually, I´ve an Arduino Diecimila with SPI <-->CAN (http://www.avrcard.com/products/can_adapter.htm) working. But I can´t achieve a big speed of processing and I would like to know if it´s normal or something it´s happenning. I´ve done a program which send again to CAN bus the messanges received with ID+1.With a CAN BUS sniffer, I can follow what it´s hapenning. At 1 Mbit/s of speed, I achieve resend a maximum of 7 mensagges at 20 ms of period which were originally sent. This isn´t too much, but maybe it´s for a 8 bits microcontroller with an external CAN BUS controller...anyone knows it? Maybe changing to a microcontroller with CAN feature inside is a big improvement or maybe it´s a problem of my code... Anyone has done this test? I would like to use it in automotive application (500 Kbit/s and mensagges with periods of 10-20 ms). I would like to know if an 8 bits controller has the enought power to manage 20 mensagges in "real time (20ms)" or if it´s too much. (Receive + look correct ID+ save in a stack + extract individual channels inside mensagge (motorola or intel format)with their linearization). Thank you. Regards, Igor R Windows Live™: Keep your life in sync. Check it out. |
|
|
Re: Microcontroller with CAN feature inside VS external controller (MCP2515)Hi Allen,
Thank you very much for your answer. - Did your test done with ATMega programmed in C? If the answer is yes, then something it´s happening to my code... I have ATMega168+MCP2515 both at 16 Mhz and SPI speed at 8 MHz (Fosc/2). To try to evaluate de power of the microcontroller and my software, I´ve connected my electronic to a CAN BUS sniffer (PEAK SYSTEMS USB to CAN http://www.peak-system.com/Product-Details.49+M578cbdb898b.0.html?&L=1&tx_commerce_pi1[catUid]=6&tx_commerce_pi1[showUid]=16). My software resends the incoming menssages to ATMega168+MCP2515 with ID+1 and I can follow with the sniffer in my computer TX and RX menssages counters and periods. Now, the maximum are 7 menssages without modify the original period which they have been transmited (20 ms). When I increase the number of menssages, I see in the sniffer the periods of ID+1 menssages decrease... At this moment, I´m not using filters because I would like to know the power of the system. Regards, Igor 2009/8/2 Allen Pothoof <apothoof@...>
|
|
|
RE: Microcontroller with CAN feature inside VS external controller (MCP2515)This may be opinionated, but I like built-in CAN controllers. If your project is not highly cost-sensitive, do try to find a CPU with enough CAN ports for your application.
I see "ATMega8 not recommended for new designs". Maybe that would encourage you to pick a chip more likely to be available into the future, with CANbus internal. CPUs targeted at the automotive industry tend to have CANbus and tend to promise longevity. I dislike SPI. If you busy-wait inside the CAN-SPI ISR to do all needed SPI sending and receiving, like polling registers to see which buffer to service, you waste a lot of time, limit your throughput and greatly increase your max interrupt latency. (Perhaps it would mitigate the pain if you allowed most other kinds of interrupts to pre-empt or "nest inside" such a long busy-wait SPI-CAN ISR. At least do your busy-wait with interrupts re-enabled.) I saw a 97-microsecond ISR to service an MCP2515 (40 MHz PowerPC, 10 MHz SPIbus). When it looped-back the messages it sent, the ISR took 197 microseconds. 0.2 milliseconds to receive one CAN packet! If instead you start each SPI transfer and then use a "SPI complete" interrupt, code can become complex, especially if your CAN controller makes you query a register before reading or reloading a message buffer. Treat it as a thread or task or state machine. All to read one packet! On the other hand, servicing an _internal_ CAN peripheral can be done in 10-40 microsec, or less if you allow efficiency to trump architectural and reuse purity. Plus, it can take some thought, care and experimentation to get all the SPI parameters to match between your CAN controller and your MCU (my first SPI task was to get a ColdFire QSPI talking to some DSP's SPI, and both were so annoyingly configurable that it took trial and error and much re-reading of both manuals.) Plus, SPI is a 4-wire interface and CANbus is only 2-wire. I would only use an external controller chip again if I absolutely HAD to. Once I used some kind of bus card (PCI mezzanine?) that had a CANbus controller (or two). It had an 8-bit-wide data bus I could access from the main CPU, which would normally be great, but in this case the CPU was a Pentium (2 GHz?). The darn CAN controller card's memory access speed was something pathetic like 2-8 8 MHz (not GHz). The entire Pentium twiddled its fingers for ages while I pushed 14 bytes around at speeds appropriate to a 1980's-era 8086. That Pentium was running some URL-auto-generated code that was big an inefficient, and needed all of the 2 GHz , without periods of running at 2 MHz. On the other hand, that CAN controller was cute, with big buffers and some kind of rollover and very flexible filters ... just slow communicating with it, compared to a Pentium (?? Phillips SJA 1000??). So I have yet to use an external controller and be glad I did. If you need 20 messages / 20 ms now, (10-30% bus loading) five years from now you might need three times as many - plan ahead. One message per ms OUGHT to be easy, that is around 7% bus load at 1 MBPS. However, a busy-wait SPI-based ISR as slow as 100 microseconds would eat 10% of your CPU time at 1 message per msec. No matter how fast your CPU is, it has to wait for SPI to clock all those bits back and forth at 10 MHz or so. Rick Corey | Software Engineer | Crane Aerospace & Electronics | richard.corey@... ________________________________________ From: canlist-owner@... [mailto:canlist-owner@...] On Behalf Of IGOR Sent: Sunday, August 02, 2009 3:28 AM To: canlist@... Subject: [CANLIST] Microcontroller with CAN feature inside VS external controller (MCP2515) Hi, My name is Igor and it´s the first time I writte in this forum. I don´t know if this question has been answered in the past...sorry! I´ve doubts about CAN Bus devices: Is there any difference between using an 8 bits microcontroller with the CAN feature inside or using an external SPI controller,i.e., MCP2515? I mean if it´s possible to achieve more power or it´s similar. What do you think about the power of an ATMega 8 bits microcontroller processing 15-20 traces with a period of 10-20 ms? (Programming in C) Actually, I´ve an Arduino Diecimila with SPI <-->CAN (http://www.avrcard.com/products/can_adapter.htm) working. But I can´t achieve a big speed of processing and I would like to know if it´s normal or something it´s happenning. I´ve done a program which send again to CAN bus the messanges received with ID+1.With a CAN BUS sniffer, I can follow what it´s hapenning. At 1 Mbit/s of speed, I achieve resend a maximum of 7 mensagges at 20 ms of period which were originally sent. This isn´t too much, but maybe it´s for a 8 bits microcontroller with an external CAN BUS controller...anyone knows it? Maybe changing to a microcontroller with CAN feature inside is a big improvement or maybe it´s a problem of my code... Anyone has done this test? I would like to use it in automotive application (500 Kbit/s and mensagges with periods of 10-20 ms). I would like to know if an 8 bits controller has the enought power to manage 20 mensagges in "real time (20ms)" or if it´s too much. (Receive + look correct ID+ save in a stack + extract individual channels inside mensagge (motorola or intel format)with their linearization). Thank you. Regards, Igor R -------------------------------------------------------------------------------- We value your opinion! How may we serve you better? Please click the survey link to tell us how we are doing: http://www.craneae.com/ContactUs/VoiceofCustomer.aspx Your feedback is of the utmost importance to us. Thank you for your time. -------------------------------------------------------------------------------- Crane Aerospace & Electronics Confidentiality Statement: The information contained in this email message may be privileged and is confidential information intended only for the use of the recipient, or any employee or agent responsible to deliver it to the intended recipient. Any unauthorized use, distribution or copying of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify the sender immediately and destroy the original message and all attachments from your electronic files. -------------------------------------------------------------------------------- -- Archives and useful links: http://groups.yahoo.com/group/CANbus Subscribe and unsubscribe at www.vector-informatik.com/canlist/ Report any problems to <canlist-owner@...> |
|
|
Re: Microcontroller with CAN feature inside VS external controller (MCP2515)Hi Rick,
Thank you for your answer. It makes sense...Maybe I have to think about changing to AT90CAN128 controller. Olimex has a good solution with this chip to rapid prototyping and I could test the differences.... Best Regards, Igor 2009/8/2 Corey, Richard <Richard.Corey@...> This may be opinionated, but I like built-in CAN controllers. If your project is not highly cost-sensitive, do try to find a CPU with enough CAN ports for your application. |
|
|
RE: Microcontroller with CAN feature inside VS external controller (MCP2515)Hi,
I've
had a bit of experience with trying to send messages quickly on the CAN
bus. I would take a different approach from yours.
First
I'd determine what the average message size was and how long it should take to
transmit. What I've worked out in the past is that a message with a
29 bit ID and 8 data bytes is about 135 total bits in length. At 1Mbps
that's 135uS.
Next, I'd look into the published literature on
CAN hardware and I'd discover that pretty well all CAN devices have at least 3
transmit objects. I believe it was Ken Tindell back in the early 90's that
published a paper on what was required in a system in order to maintain a bus at
100% utilization.
So why
3 transmit objects? The first one is in use transmitting a message.
The second one has a message ready to transmit and the third is being filled
with a message to transmit. Once it's full there are really two messages
ready to transmit. You may have to watch message object priority to keep
sequences correct in this case.
Once
the first message object has been transmitted the second immediately follows the
interframe space so the bus remains utilized. There's now a free message
object and still one waiting to be transmitted. So the buffer empty
interrupt can be used to trigger the code to fill another message
object.
Now
how to fill it? Well, If you are trying to maintain 100% bus activity then
your code must already have another message ready to be put into a message
object. Otherwise, eventually the message objects will empty and you
won't be transmitting back to back. You also know you have only 135uS to
fill the next object. That's probably around 13 to 15 bytes of data.
Let's
say it's 15 bytes for a total of 120 bits. If you are using SPI it means
you need a minimum of 2Mbps SPI clock so that 60 uSec are spent transferring the
data and 75uS for processor overhead. Using processor test code and
an output bit connected to a scope I'd write a transfer routine that sets the
bit, transfers via SPI my structure of 120 bits and then clear the output
bit. The scope will tell me how long it took with my C code. If it
takes too long maybe I have to do this with a 5Mbps SPI clock or re-evaluate the
hardware.
Alternatively, pick the right processor for the project
rather than trying to make the wrong processor do the job. In my
application I chose a processor with 5 CAN modules and I used all 5. I
also send out 375 11 bit ID with 8 byte messages every 40mS and total time
taken is about 11mS.
In my
project I would fill CAN0 with a message and tell it to transmit. I'd then
fill CAN1 and do the same. All the way to CAN4. Then I'd start over
again on CAN0 filling the alternate message buffer. (I used only two in this
example). Then on to CAN1, CAN2 etc.
By the
time I got back to CAN0 I'd now be waiting for the message to be finished or it
would be just finished and the second one was on the way out. And so
on. A scope photo showed each of the 5 CAN bus channels was running a
burst of 75 message at 100% utilization for about 11 mS. Then the bus was
quiet till the next 40mS time tick that started everything all over
again. I had about 29mS to prepare for the next burst.
BTW,
just to show what is possible when you choose the correct tool for the job, my 5
channel 9S12 really only talked with one node on each CAN bus. That was a
Bridge from TKE. The bridge took the incoming messages and sent them out 3
CAN ports all still at 1MBps.
Later,
when we found we had some bus length issues I changed the main 9S12 board to
send out the data at 500kbps. Now it took 21mS to send everything and
I still had 19mS time to process and prepare. The Bridges take the
messages at 500kbps and route them out the other three channels at either
500kbps or 1Mbps depending on what hardware is on what net. The end result
is 742 nodes are updated with 375 messages every 40mS with plenty of processing
time to spare.
With
some careful programming I could probably work it so again I spent only 11mS
filling up buffers and the rest of the time doing other stuff but I didn't need
to for this project.
So
pick your CAN bit rate.
Determine how long a message will
take.
Determine how many messages you need to send back to
back.
Evaluate whether your hardware can support the CAN
engine with enough data.
Write
your code so it takes advantage of the weak and strong
points.
John
Dammeyer
Automation Artisans Inc.
|
|
|
Re: Microcontroller with CAN feature inside VS external controller (MCP2515)The MCU with CAN module is absolutely recommended. The standalone CAN module with SPI bus, the device itself is not an issue, the chanllenge is how you get those received package into the MCU. So far, I have run MCU SPI bus at 5MHz without too much issue, but higher SPI speed would be a challenge to some low end MCUs. If your application it timing critical, I would recommend take a MCU with embedded CAN module(s). There are plenty of choice these days, ST ARM family, NXP ARM chips, Microchip PIC18F4580, dsPIC30F6012A, etc. They are all nice chip. We have been using some Microchip CAN chips in our design, they seems working fine for most auto and truck application. A few example are listed here: 1. "Au J1939 simulators": standalone device generating most frequently used J1939 CAN signals. http://www.auelectronics.com/System-J1939Simulator.htm http://www.auelectronics.com/products/system/simj1939.html 2. "Au Truck / Bus Fleet Management System (FMS) Simulators": standalone device generating all CAN signals per FMS standard (01.00) and BUS-FMS standard (00.02). http://www.auelectronics.com/System-FleetManagementSystemSimulator.htm http://www.auelectronics.com/products/system/sim-fms.html?limit=all 3. "Au J1939 Message Center": A toolkit displays received J1939 message on computer screen (actual physical values in Graphic User Interface (GUI) format). http://www.auelectronics.com/products/system/mcs.html http://www.auelectronics.com/System-MCSJ1939-001.htm 4. "Au J1939 Data Center": A toolkit displays received J1939/CAN data package on computer screen ('1(s)' and '0(s)', in raw data format). http://www.auelectronics.com/System-DCSJ1939-001.htm http://www.auelectronics.com/products/system/dcs.html 5. "Au Automotive ABS ECU CAN simulator with Speed Inputs": A set of toolkit capable of measuring wheel speed and feed into the newest CAN-Bus automotive Engine ECU(s). http://augroups.blogspot.com/2009/05/user-manual-of-automotive-abs-ecu-can.html Au Group Electronics, http://www.AuElectronics.com http://www.AuElectronics.com/products http://augroups.blogspot.com/ From: "Corey, Richard" <Richard.Corey@...> To: canlist@... Sent: Sunday, August 2, 2009 3:37:55 PM Subject: RE: [CANLIST] Microcontroller with CAN feature inside VS external controller (MCP2515) This may be opinionated, but I like built-in CAN controllers. If your project is not highly cost-sensitive, do try to find a CPU with enough CAN ports for your application. I see "ATMega8 not recommended for new designs". Maybe that would encourage you to pick a chip more likely to be available into the future, with CANbus internal. CPUs targeted at the automotive industry tend to have CANbus and tend to promise longevity. I dislike SPI. If you busy-wait inside the CAN-SPI ISR to do all needed SPI sending and receiving, like polling registers to see which buffer to service, you waste a lot of time, limit your throughput and greatly increase your max interrupt latency. (Perhaps it would mitigate the pain if you allowed most other kinds of interrupts to pre-empt or "nest inside" such a long busy-wait SPI-CAN ISR. At least do your busy-wait with interrupts re-enabled.) I saw a 97-microsecond ISR to service an MCP2515 (40 MHz PowerPC, 10 MHz SPIbus). When it looped-back the messages it sent, the ISR took 197 microseconds. 0.2 milliseconds to receive one CAN packet! If instead you start each SPI transfer and then use a "SPI complete" interrupt, code can become complex, especially if your CAN controller makes you query a register before reading or reloading a message buffer. Treat it as a thread or task or state machine. All to read one packet! On the other hand, servicing an _internal_ CAN peripheral can be done in 10-40 microsec, or less if you allow efficiency to trump architectural and reuse purity. Plus, it can take some thought, care and experimentation to get all the SPI parameters to match between your CAN controller and your MCU (my first SPI task was to get a ColdFire QSPI talking to some DSP's SPI, and both were so annoyingly configurable that it took trial and error and much re-reading of both manuals.) Plus, SPI is a 4-wire interface and CANbus is only 2-wire. I would only use an external controller chip again if I absolutely HAD to. Once I used some kind of bus card (PCI mezzanine?) that had a CANbus controller (or two). It had an 8-bit-wide data bus I could access from the main CPU, which would normally be great, but in this case the CPU was a Pentium (2 GHz?). The darn CAN controller card's memory access speed was something pathetic like 2-8 8 MHz (not GHz). The entire Pentium twiddled its fingers for ages while I pushed 14 bytes around at speeds appropriate to a 1980's-era 8086. That Pentium was running some URL-auto-generated code that was big an inefficient, and needed all of the 2 GHz , without periods of running at 2 MHz. On the other hand, that CAN controller was cute, with big buffers and some kind of rollover and very flexible filters ... just slow communicating with it, compared to a Pentium (?? Phillips SJA 1000??). So I have yet to use an external controller and be glad I did. If you need 20 messages / 20 ms now, (10-30% bus loading) five years from now you might need three times as many - plan ahead. One message per ms OUGHT to be easy, that is around 7% bus load at 1 MBPS. However, a busy-wait SPI-based ISR as slow as 100 microseconds would eat 10% of your CPU time at 1 message per msec. No matter how fast your CPU is, it has to wait for SPI to clock all those bits back and forth at 10 MHz or so. Rick Corey | Software Engineer | Crane Aerospace & Electronics | richard.corey@... ________________________________________ From: canlist-owner@... [mailto:canlist-owner@...] On Behalf Of IGOR Sent: Sunday, August 02, 2009 3:28 AM To: canlist@... Subject: [CANLIST] Microcontroller with CAN feature inside VS external controller (MCP2515) Hi, My name is Igor and it´s the first time I writte in this forum. I don´t know if this question has been answered in the past...sorry! I´ve doubts about CAN Bus devices: Is there any difference between using an 8 bits microcontroller with the CAN feature inside or using an external SPI controller,i.e., MCP2515? I mean if it´s possible to achieve more power or it´s similar. What do you think about the power of an ATMega 8 bits microcontroller processing 15-20 traces with a period of 10-20 ms? (Programming in C) Actually, I´ve an Arduino Diecimila with SPI <-->CAN (http://www.avrcard.com/products/can_adapter.htm) working. But I can´t achieve a big speed of processing and I would like to know if it´s normal or something it´s happenning. I´ve done a program which send again to CAN bus the messanges received with ID+1.With a CAN BUS sniffer, I can follow what it´s hapenning. At 1 Mbit/s of speed, I achieve resend a maximum of 7 mensagges at 20 ms of period which were originally sent. This isn´t too much, but maybe it´s for a 8 bits microcontroller with an external CAN BUS controller...anyone knows it? Maybe changing to a microcontroller with CAN feature inside is a big improvement or maybe it´s a problem of my code... Anyone has done this test? I would like to use it in automotive application (500 Kbit/s and mensagges with periods of 10-20 ms). I would like to know if an 8 bits controller has the enought power to manage 20 mensagges in "real time (20ms)" or if it´s too much. (Receive + look correct ID+ save in a stack + extract individual channels inside mensagge (motorola or intel format)with their linearization). Thank you. Regards, Igor R -------------------------------------------------------------------------------- We value your opinion! How may we serve you better? Please click the survey link to tell us how we are doing: http://www.craneae.com/ContactUs/VoiceofCustomer.aspx Your feedback is of the utmost importance to us. Thank you for your time. -------------------------------------------------------------------------------- Crane Aerospace & Electronics Confidentiality Statement: The information contained in this email message may be privileged and is confidential information intended only for the use of the recipient, or any employee or agent responsible to deliver it to the intended recipient. Any unauthorized use, distribution or copying of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify the sender immediately and destroy the original message and all attachments from your electronic files. -------------------------------------------------------------------------------- -- Archives and useful links: http://groups.yahoo.com/group/CANbus Subscribe and unsubscribe at www.vector-informatik.com/canlist/ Report any problems to <canlist-owner@...> |
|
|
RE: Microcontroller with CAN feature inside VS external controller (MCP2515)I agree with you, I prefer internal CAN controllers. It is typically a quicker set-up and has less overhead (sometimes much less, as you pointed out). But I don't always have a choice and it didn't sound like Igor did, either (although later messages indicate maybe he does). And, while I don't dislike SPI, SPI/CAN has been problematic. I haven't used the MCP2515 but have used the older 2510; using am interrupt-driven SPI transfer, I never lost a message (SAE J1939 bus, which is 250K) but until I got the timing perfect, I would get corrupted messages quite often. I've never had a similar situation with internal controllers (probably because the chip isn't trying to do 2 things with 1 message buffer). As an aside, I would never "busy-wait" anything; that's what interrupts and state machines are for. And, while I know some people don't like interrupts because they aren't deterministic enough to suit them, they're what I cut my teeth on and I'll use them if they are available. Regards Allen Pothoof > Subject: RE: [CANLIST] Microcontroller with CAN feature inside VS external controller (MCP2515) > Date: Sun, 2 Aug 2009 12:37:55 -0700 > From: Richard.Corey@... > To: canlist@... > > This may be opinionated, but I like built-in CAN controllers. If your project is not highly cost-sensitive, do try to find a CPU with enough CAN ports for your application. > > I see "ATMega8 not recommended for new designs". Maybe that would encourage you to pick a chip more likely to be available into the future, with CANbus internal. CPUs targeted at the automotive industry tend to have CANbus and tend to promise longevity. > > I dislike SPI. > > If you busy-wait inside the CAN-SPI ISR to do all needed SPI sending and receiving, like polling registers to see which buffer to service, you waste a lot of time, limit your throughput and greatly increase your max interrupt latency. (Perhaps it would mitigate the pain if you allowed most other kinds of interrupts to pre-empt or "nest inside" such a long busy-wait SPI-CAN ISR. At least do your busy-wait with interrupts re-enabled.) > > I saw a 97-microsecond ISR to service an MCP2515 (40 MHz PowerPC, 10 MHz SPIbus). > When it looped-back the messages it sent, the ISR took 197 microseconds. > 0.2 milliseconds to receive one CAN packet! > > If instead you start each SPI transfer and then use a "SPI complete" interrupt, code can become complex, especially if your CAN controller makes you query a register before reading or reloading a message buffer. Treat it as a thread or task or state machine. All to read one packet! > > > On the other hand, servicing an _internal_ CAN peripheral can be done in 10-40 microsec, or less if you allow efficiency to trump architectural and reuse purity. > > > Plus, it can take some thought, care and experimentation to get all the SPI parameters to match between your CAN controller and your MCU (my first SPI task was to get a ColdFire QSPI talking to some DSP's SPI, and both were so annoyingly configurable that it took trial and error and much re-reading of both manuals.) > > Plus, SPI is a 4-wire interface and CANbus is only 2-wire. > > I would only use an external controller chip again if I absolutely HAD to. > > > Once I used some kind of bus card (PCI mezzanine?) that had a CANbus controller (or two). It had an 8-bit-wide data bus I could access from the main CPU, which would normally be great, but in this case the CPU was a Pentium (2 GHz?). The darn CAN controller card's memory access speed was something pathetic like 2-8 8 MHz (not GHz). The entire Pentium twiddled its fingers for ages while I pushed 14 bytes around at speeds appropriate to a 1980's-era 8086. That Pentium was running some URL-auto-generated code that was big an inefficient, and needed all of the 2 GHz , without periods of running at 2 MHz. > > On the other hand, that CAN controller was cute, with big buffers and some kind of rollover and very flexible filters ... just slow communicating with it, compared to a Pentium (?? Phillips SJA 1000??). > > So I have yet to use an external controller and be glad I did. > > > If you need 20 messages / 20 ms now, (10-30% bus loading) five years from now you might need three times as many - plan ahead. > > One message per ms OUGHT to be easy, that is around 7% bus load at 1 MBPS. > > However, a busy-wait SPI-based ISR as slow as 100 microseconds would eat 10% of your CPU time at 1 message per msec. No matter how fast your CPU is, it has to wait for SPI to clock all those bits back and forth at 10 MHz or so. > > Rick Corey | Software Engineer | Crane Aerospace & Electronics | > richard.corey@... > > ________________________________________ > From: canlist-owner@... [mailto:canlist-owner@...] On Behalf Of IGOR > Sent: Sunday, August 02, 2009 3:28 AM > To: canlist@... > Subject: [CANLIST] Microcontroller with CAN feature inside VS external controller (MCP2515) > > Hi, > > My name is Igor and it´s the first time I writte in this forum. I don´t know if this question has been answered in the past...sorry! > > I´ve doubts about CAN Bus devices: > > Is there any difference between using an 8 bits microcontroller with the CAN feature inside or using an external SPI controller,i.e., MCP2515? I mean if it´s possible to achieve more power or it´s similar. > > What do you think about the power of an ATMega 8 bits microcontroller processing 15-20 traces with a period of 10-20 ms? (Programming in C) > > Actually, I´ve an Arduino Diecimila with SPI <-->CAN (http://www.avrcard.com/products/can_adapter.htm) working. But I can´t achieve a big speed of processing and I would like to know if it´s normal or something it´s happenning. > I´ve done a program which send again to CAN bus the messanges received with ID+1.With a CAN BUS sniffer, I can follow what it´s hapenning. > At 1 Mbit/s of speed, I achieve resend a maximum of 7 mensagges at 20 ms of period which were originally sent. This isn´t too much, but maybe it´s for a 8 bits microcontroller with an external CAN BUS controller...anyone knows it? > Maybe changing to a microcontroller with CAN feature inside is a big improvement or maybe it´s a problem of my code... > > Anyone has done this test? I would like to use it in automotive application (500 Kbit/s and mensagges with periods of 10-20 ms). I would like to know if an 8 bits controller has the enought power to manage 20 mensagges in "real time (20ms)" or if it´s too much. (Receive + look correct ID+ save in a stack + extract individual channels inside mensagge (motorola or intel format)with their linearization). > > > > Thank you. > > > > Regards, > > > > Igor R > -------------------------------------------------------------------------------- > We value your opinion! How may we serve you better? > Please click the survey link to tell us how we are doing: > http://www.craneae.com/ContactUs/VoiceofCustomer.aspx > Your feedback is of the utmost importance to us. Thank you for your time. > -------------------------------------------------------------------------------- > Crane Aerospace & Electronics Confidentiality Statement: > The information contained in this email message may be privileged and is > confidential information intended only for the use of the recipient, or any > employee or agent responsible to deliver it to the intended recipient. Any > unauthorized use, distribution or copying of this information is strictly prohibited > and may be unlawful. If you have received this communication in error, please notify > the sender immediately and destroy the original message and all attachments from > your electronic files. > -------------------------------------------------------------------------------- > -- > Archives and useful links: http://groups.yahoo.com/group/CANbus > Subscribe and unsubscribe at www.vector-informatik.com/canlist/ > Report any problems to <canlist-owner@...> Get free photo software from Windows Live Click here. |
|
|
RE: Microcontroller with CAN feature inside VS external controller (MCP2515)I did a system with the ATMega128 (programmed in C) and the MCP2510; this was a production system, not a test or prototype. I was given the hardware and told to make it work, which I did, but we didn't run any tests to see what happened if we cranked up the bus speed or started loading it to 80% or 90% bus capacity. Regards, Allen Pothoof Date: Sun, 2 Aug 2009 18:36:05 +0200 Subject: Re: [CANLIST] Microcontroller with CAN feature inside VS external controller (MCP2515) From: igorreal@... To: canlist@... Hi Allen, Thank you very much for your answer. - Did your test done with ATMega programmed in C? If the answer is yes, then something it´s happening to my code... I have ATMega168+MCP2515 both at 16 Mhz and SPI speed at 8 MHz (Fosc/2). To try to evaluate de power of the microcontroller and my software, I´ve connected my electronic to a CAN BUS sniffer (PEAK SYSTEMS USB to CAN http://www.peak-system.com/Product-Details.49+M578cbdb898b.0.html?&L=1&tx_commerce_pi1[catUid]=6&tx_commerce_pi1[showUid]=16). My software resends the incoming menssages to ATMega168+MCP2515 with ID+1 and I can follow with the sniffer in my computer TX and RX menssages counters and periods. Now, the maximum are 7 menssages without modify the original period which they have been transmited (20 ms). When I increase the number of menssages, I see in the sniffer the periods of ID+1 menssages decrease... At this moment, I´m not using filters because I would like to know the power of the system. Regards, Igor 2009/8/2 Allen Pothoof <apothoof@...>
Express your personality in color! Preview and select themes for Hotmail®. Try it now. |
|
|
Re: Microcontroller with CAN feature inside VS external controller (MCP2515)Hi,
Thank you very much for your support. There are too many good answers, and with a lot of experience behind them. I´m able to choose the micro which I want, there isn´t a problem (within reasonable). I would like to do the project with an Atmel micro, because the C compiler and tools are free... In the begining,the idea of external CAN controller liked me because I could choose different micros without problems of CAN feature. I´ve continued this days doing small test with ATMega168 and MCP2515 and I can´t improve more than 7-8 mensajes (all with 20 ms of period). What I do is check with an USB to CAN device (Peak Systems) which has a small tool. I send with it these messanges. The ATMega160, received them and resend with ID+1. I can follow the TX counter and the RX counter. Seven is the maximum without no difference between TX and RX counters of each ID menssage. I don´t know if this test is too stressing, because I can´t control when this menssages start (thinking in absolute time). Because you can have this period but with enough time between menssages to be saved.... Am I right? For example, if I start sending messages as: ABSOLUTE TIME t=0 ms, ID=100, next message at 20 ms, 40ms,... t=3 ms, ID=102, next message at 22 ms, 42ms,.. t=6 ms, ID=104, next message at 24 ms, 44 ms,.. .. It not the same if I have: t=0 ms, ID=100, next message at 20 ms, 40ms,... t=0,5 ms, ID=102, next message at 20.5 ms, 41ms,.. t=1 ms, ID=104, next message at 21 ms, 41.5 ms,.. .. I mean, could be happening that the phase(time between messages) is being too sort, and in addition my software is not debugged enough......What do you think? I´ve always used CAN bus as user (automotive data acquisition), but never as designer-programmer. Althought I´m going to choose a microcontroller with can inside, I would like to know the power of mcp2515...ha,ha,ha Regards, Igor 2009/8/3 Allen Pothoof <apothoof@...>
|
|
|
RE: Microcontroller with CAN feature inside VS external controller (MCP2515)Hi,
So how
fast are you running your SPI?
What
bit rate are you using?
How
many Tx Objects are you using?
When
you send a message to the MCP2515 how many bytes do you
transfer.
How do
you signal that a message should be sent?
You
have so many variables here and no reports of controlling any of those.
Pretty hard to help you debug.
John
Dammeyer
Automation Artisans Inc.
|
|
|
Re: Microcontroller with CAN feature inside VS external controller (MCP2515)Hi John,
A small briefing: - SPI Speed = 8 Mhz - Bit rate = 1Mbit/s - Tx Objects of MCP2515 = 3 - Data bytes of all messages = 8 Electronic: PC with PEAK USB-CAN <====can bus ====> ATMega168+ SPI-CAN from www.avrcards.com Hardware Links: - http://www.peak-system.com/Product-Details.49+M578cbdb898b.0.html?&L=1&tx_commerce_pi1[catUid]=6&tx_commerce_pi1[showUid]=16# - http://www.avrcard.com/products/can_adapter.htm Today I´m going to do a test controlling the time between messages, because I think that I´m not doing good my test to know the maximum bus load capacity of the system. I´ll keep you updated... Regards, Igor 2009/8/4 John Dammeyer <johnd@...>
|
|
|
Fwd: Microcontroller with CAN feature inside VS external controller (MCP2515)Hi guys!!
Now, I´ve done a better test....
Two ATMega168+MCP2515 and PEAK SYSTEM USB<=>CAN
- Clock Speed ATMega and MCP2515 => 16 Mhz
- Bus Speed => 1Mbit/s
- SPI => 8 Mhz (Fosc/2)
+ Boards => Arduino Diecimila
+ SPI <-->CAN => http://www.avrcard.com/products/can_adapter.htm
+ "Sniffer" => http://www.peak-system.com/Product-Details.49+M578cbdb898b.0.html?&L=1&tx_commerce_pi1[catUid]=6&tx_commerce_pi1[showUid]=16
Software method to get the Incomming msgs=> Polling (Timer 2 event every 1 ms).
At the moment,I´m not implement RX interrupt to get it.
* One of ATMega => Sends 16 periodic messages (20 ms).
* Second ATMega => Receive can messages and send again with ID+1 and multiply per two data bytes. (To add a little math operation to check what happens).
With sniffer I can check can bus activity. The ID messages and ID+1 have the same counters in my sniffer tool => OK!!
I think the problems in my last tests was try to send many messages with short time between them (I can´t control this with the USB <-->CAN device), which it´s equivalent to a huge load can bus activity. Althought the periods were of 20 ms, the device try to send all the mesagges at the same time.
I think, this is enought power for my application.... But just in case, I´ve ordered an AT90CAN128 (Olimex prototype board) to Sparkfun. I´m going to add more messages and less period to find the limits....
What is your opinion?
Regards,
Igor
---------- Forwarded message ---------- From: IGOR <igorreal@...> Date: 2009/8/4 Subject: Re: [CANLIST] Microcontroller with CAN feature inside VS external controller (MCP2515) To: canlist@... Hi John, A small briefing: - SPI Speed = 8 Mhz - Bit rate = 1Mbit/s - Tx Objects of MCP2515 = 3 - Data bytes of all messages = 8 Electronic: PC with PEAK USB-CAN <====can bus ====> ATMega168+ SPI-CAN from www.avrcards.com Hardware Links: - http://www.peak-system.com/Product-Details.49+M578cbdb898b.0.html?&L=1&tx_commerce_pi1[catUid]=6&tx_commerce_pi1[showUid]=16# - http://www.avrcard.com/products/can_adapter.htm Today I´m going to do a test controlling the time between messages, because I think that I´m not doing good my test to know the maximum bus load capacity of the system. I´ll keep you updated... Regards, Igor 2009/8/4 John Dammeyer <johnd@...>
|
|
|
Re: Microcontroller with CAN feature inside VS external controller (MCP2515)All the messages with 8 bytes of data!!!
2009/8/4 IGOR <igorreal@...>
|
|
|
CAN advantageshi sir |
|
|
RE: CAN advantageserror detection and correction (CRC
protection in hardware. hardware-driven retries) bus arbitration assures nodes do not ‘step
on each other’ if two try to transmit at once one node will shut down (go bus-off) if
it starts to disrupt the whole bus pre-implemented message IDs with
filtering & masking so that a node only needs to receive messages it needs one interrupt provides an entire 8-byte
payload plus MsgID (not one interrupt per byte) CAN controllers typically have many
message buffers (mailboxes) so you might not even need to respond to every
interrupt promptly. assured simultaneous delivery to all
nodes (or none) try Wikipedia and Googling ‘CANbus’ Rick Corey | Software Engineer | Crane Aerospace & Electronics | From:
canlist-owner@...
[mailto:canlist-owner@...] On Behalf Of Joy.George@... hi sir
Your feedback is of the utmost importance to us. Thank you for your time. Crane Aerospace & Electronics
Confidentiality Statement: |
|
|
RE: CAN advantagesIs
this a question for a school assignment or an exam that you are asking
here?
John
Dammeyer
Subject: [CANLIST] CAN
advantages
|
|
|
CAN hardware designHi,
I have to convert a Valve or IO board(that
controls the pneumatics), which currently exists with no intelligence into a CAN
based device. Our team has decided to use AT90CAN128 for the
product and I have to redesign the board. Currently the IO board talks to
the mother board through digital address lines and some SPI lines
which definitely might carry some noise(hard for EMI). I
need inputs from the CAN experts to make some
decisions.
1) Is there a guideline to choose a Bus transceiver.
The max speed speed could be 1Mbps.
2) Do I need a choke and should I use internal
termination resistor.
3) Is there any pointer to design hardware using CAN or
application note.
Thanks in advance.
|
|
|
RE: CAN hardware designHello, One of the features of CAN is its inherent immunity to EMI –
as long as it’s not a really bad case. Vendors like NXP or TI make
good transceivers for this environment, all with a 1 Mbps top signaling rate.
I wouldn’t use a choke unless you absolutely have to since they can add worse
problems. You may want to try “split termination.” That
is, terminate each end of the bus with two 60 ohm resistors. Then place a
47 nF (or so) cap to ground to act as a noise filter. Be sure to google “Controller Area Network” –
in quotes as shown. There are many papers on many topics online. Cheers, Steve C. From:
canlist-owner@...
[mailto:canlist-owner@...] On Behalf Of Subramanian,
Ramkumar Hi, I have to convert a Valve or IO board(that controls the
pneumatics), which currently exists with no intelligence into a CAN based
device. Our team has decided to use AT90CAN128 for the product and I
have to redesign the board. Currently the IO board talks to the mother board
through digital address lines and some SPI lines
which definitely might carry some noise(hard for EMI). I
need inputs from the CAN experts to make some decisions. 1) Is there a guideline to choose a Bus transceiver. The max speed speed could
be 1Mbps. 2) Do I need a choke and should I use internal termination
resistor. 3) Is there any pointer to design hardware using CAN or application
note. Thanks in advance. Ram Life Technologies Corporation 5781 Van Allen Way, Carlsbad, CA 92008 Phone: (760) 918-3859 Email: ramkumar.subramanian@... Internal: x63859 |
|
|
RE: CAN hardware designHello again, I was not clear about where to place the cap on the split termination
– in between the two 60 ohm resistors to ground. It acts as a good
filter. Sorry about that, Steve C. From: canlist-owner@...
[mailto:canlist-owner@...] On Behalf Of Steve
Corrigan Hello, One of the features of CAN is its inherent immunity to EMI
– as long as it’s not a really bad case. Vendors like NXP or
TI make good transceivers for this environment, all with a 1 Mbps top signaling
rate. I wouldn’t use a choke unless you absolutely have to since
they can add worse problems. You may want to try “split termination.” That
is, terminate each end of the bus with two 60 ohm resistors. Then place a
47 nF (or so) cap to ground to act as a noise filter. Be sure to google “Controller Area Network” –
in quotes as shown. There are many papers on many topics online. Cheers, Steve C. From:
canlist-owner@...
[mailto:canlist-owner@...] On Behalf Of Subramanian,
Ramkumar Hi, I have to convert a Valve or IO board(that controls the
pneumatics), which currently exists with no intelligence into a CAN based
device. Our team has decided to use AT90CAN128 for the product and I
have to redesign the board. Currently the IO board talks to the mother board
through digital address lines and some SPI lines
which definitely might carry some noise(hard for EMI). I
need inputs from the CAN experts to make some decisions. 1) Is there a guideline to choose a Bus transceiver. The max
speed speed could be 1Mbps. 2) Do I need a choke and should I use internal termination
resistor. 3) Is there any pointer to design hardware using CAN or application
note. Thanks in advance. Ram Life Technologies Corporation 5781 Van Allen Way, Carlsbad, CA 92008 Phone: (760) 918-3859 Email: ramkumar.subramanian@... Internal: x63859 |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |