News:

Let's find out together what makes a PIC Tick!

Main Menu

CANbus assistance?

Started by chris_cb_uk, Apr 06, 2022, 09:38 AM

Previous topic - Next topic

chris_cb_uk

Hi all, I have a customer who wants me to create an interface with a propeller speed controller to be used with their existing proportional control system. Processing pulse width for the time being is fine, its the CANbus connection I am having a brain fog with.

I've never used CANbus protocol, have read the few posts on this forum and others.  I've looked at both the MCP2551 and mcp2515 and see they're a dumb / clever controller but not sure the best way to go, and how to send commands in basic from the PIC and receive them in.  I notice that there are PICs with CANbus controllers built in, how does this work with this compiler for commands etc?

I have a PDF list of messages from manufacturer to read and write but I have a block in my mind as it's a new protocol to me the bit in between and how I send commands out of pic to talk to the controller, requirements etc and it's all a little bit of a mystery.

Calling on the forum pool for experience and views


Many thanks
Chris

 

RGV250

Hi,
It depends on which device you want to use. If you use a device with CAN built in then you would use a MCP2551 or equivalent as the transceiver. If you use a device without you would use SPI to communicate and then the MCP2551 transceiver.
I do have a library (re written for procedures) for devices with CAN built in but it has not been tested yet due to the lack of time. You can also do it just by register manipulation. There is also some info on here for SPI but very simple messages.

The other very important thing is do you know the information such as BAUD rate and the messages from the device you want to communicate with.

Regards,
Bob

chris_cb_uk

Thanks Bob, yes I have the datasheet of the controller which has the command addresses with variable types and min max figures for each command data size etc, this includes BAUD rate options 100,125,250kbps Node Number commands etc
Pardon such a seemingly obvious question but what commands do I use in basic when addressing a PIC with inbuilt CAN?  I've had a look at the 18Fxx8 datasheet and see you use registers to set the functions, but how does this translate into data? I just cant get my head around the "bit in between"

RGV250

Hi,
It took me ages to figure it all out so it will be a bit of a long answer that I do not have time for now.
Can you send me the datasheet you have, I am not sure if I am set up for emails but if not PM me with your address.
The other question is, do you know what device you are planning to use or is it a blank canvas. The other thing that throws a spanner in the works is the I/O voltage, I would suggest 5v as 3.3v seems to be an issue with some transceivers.

Bob

RGV250

I have just had a look, RS seem to be all on back order, Farnell do not have many either, it might pay to just grab one or two of these while you can.
https://uk.farnell.com/microchip/pic18f258-i-sp/mcu-8bit-pic18-40mhz-ndip-28/dp/9762132?ICID=I-RP-STM7REC-0
You will also need the MCP2551 or equivalent but they seem to have loads of those.

Bob