Use SPI or MMC block for CAN buffer?

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
drphil1969
Posts: 10
Joined: Wed Apr 15, 2009 3:50 pm
Contact:

Use SPI or MMC block for CAN buffer?

Post by drphil1969 »

Hello,

I have written a flowcode program to receive CAN messages, convert them and transmit over RS232. The ultimate goal is to transmit over a phone line then convert back into the original CAN messages. The challenge I'm having is the relatively slow baud rate of RS232 (especially over a phone line) compared to CAN (most of the systems I deal with are 250k baud). This is causing me to miss many of the messages as the CAN Tx is effectively sending out "bursts" (probably close to the 250k baud rate) of messages (note: the CAN messages are being generated by a separate system, I am using E-blocks strictly to receive them and Tx over RS232).

I was thinking of using either the SPI or MMC E-Blocks to use as a buffer for the CAN messages prior to sending out over RS232. Would either one of these work? Any recommendations? Using the SPI block with 8k memory would allow over 500 messages to be stored which would be plenty for my purposes.

Thanks for any help!

Best Regards,
Phil

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Use SPI or MMC block for CAN buffer?

Post by Benj »

Hello Phil

You could use a SPI memory device or a SD card but to be honest I dont think these devices will be fast enough to match your 250Kbaud. What you could do is to create an incoming data array on the PICmicro and then use this to send data onto the RS232. What is the maximum RS232 baud rate you have managed to get up and running reliably? Alternativly what device are you using and what clock speed?

drphil1969
Posts: 10
Joined: Wed Apr 15, 2009 3:50 pm
Contact:

Re: Use SPI or MMC block for CAN buffer?

Post by drphil1969 »

Hi Benj,

Thanks for your quick reply. I actually shelved this project a few months ago after I got it working at 38k baud on the RS232. I got sidetracked by a high priority high profit project. :-) I have not tried anything above that baud rate. The messages that were captured worked perfectly (no corrupted data), but I missed at least 80% of the messages. I am using a 16F877A controller with E-Blocks Can bus and RS232 and the clock speed is 19.66 MHz.

After reading your post, it makes sense that I would have to store the incoming messages rather than going through the controller to another device. My current program uses the onboard CAN buffers, but that is not nearly enough capacity. What would be the capacity of the PICmicro device? (i am not tied to the 16F877a).

Thanks for your help!
Phil

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Use SPI or MMC block for CAN buffer?

Post by Benj »

Hello Phil

You could try a custom baud of 115200. This should work as there is only 3% error in the baud calculation at 19.6608MHz. This drops to 1.36% at 20MHz.

The 16F877A should let you create a few fairly large arrays to house the incoming data. this combined with the increased baud may be enough to stay on top of the CAN messages.

If you find that you need more space to store the incoming CAN messages then you can visit this link where you can search for devices by memory size.

http://www.microchip.com/stellent/idcpl ... m=en537796

drphil1969
Posts: 10
Joined: Wed Apr 15, 2009 3:50 pm
Contact:

Re: Use SPI or MMC block for CAN buffer?

Post by drphil1969 »

Thank you so much Benj! I am hoping to get to this within the next couple of weeks.

Best Regards,
Phil

Post Reply