Feather RP2040 CanBus as PC controller

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
veggie2u_cyberward
 
Posts: 43
Joined: Mon Sep 14, 2015 11:27 am

Feather RP2040 CanBus as PC controller

Post by veggie2u_cyberward »

I was watching the new products video and saw the new Feather RP2040 CanBus and it was mentioned that there is firmware to allow this to act like a USB/CanBus interface. I couldn't catch the letters they mentioned or find it on GitHub. Is this something published?

User avatar
neradoc
 
Posts: 542
Joined: Wed Apr 27, 2016 2:38 pm

Re: Feather RP2040 CanBus as PC controller

Post by neradoc »

Hi, I believe the video mentioned the U2IF firmware.
It's a firmware that can be installed on a RP2040 board, and be used from a PC with blinka to run the Circuitpython driver for the MCP2515 CAN bus chip.

The U2IF guide.
https://learn.adafruit.com/circuitpytho ... ry-pi-pico

The guide to the MCP2515 Circuitpython driver.
This is the featherwing guide but it should work similarly.
https://learn.adafruit.com/adafruit-can ... cuitpython

The problem then is that the pinout is different.
To make it work I believe that you would need to install the Raspberry Pi Pico version of the U2IF firmware (the Feather version won't use the same pins as the CAN feather), and use the correct pins for the SPI connection. Until the learn guide is online, the pinout for the CAN chip is laid out in the Circuitpython definition of the board. Where GPIO14 converts to board.GP14 for example.

If I read it correctly, the guide's code would then convert to this.
This would run on the PC, configured to use U2IF as explained in the U2IF guide.

Code: Select all

from time import sleep
import board
import busio
from digitalio import DigitalInOut
from adafruit_mcp2515.canio import Message, RemoteTransmissionRequest
from adafruit_mcp2515 import MCP2515 as CAN

cs = DigitalInOut(board.GP19)
cs.switch_to_output()
spi = busio.SPI(board.GP14, board.GP15, board.GP8)

can_bus = CAN(
    spi, cs, loopback=True, silent=True
)  # use loopback to test without another device
while True:
    with can_bus.listen(timeout=1.0) as listener:

        message = Message(id=0x1234ABCD, data=b"adafruit", extended=True)
        send_success = can_bus.send(message)
        print("Send success:", send_success)
        message_count = listener.in_waiting()
        print(message_count, "messages available")
        for _i in range(message_count):
            msg = listener.receive()
            print("Message from ", hex(msg.id))
            if isinstance(msg, Message):
                print("message data:", msg.data)
            if isinstance(msg, RemoteTransmissionRequest):
                print("RTR length:", msg.length)
    sleep(1)
I would wait until the Learn Guide is published at least to learn more about the board before deciding if it's a working solution for what you want to do.

User avatar
veggie2u_cyberward
 
Posts: 43
Joined: Mon Sep 14, 2015 11:27 am

Re: Feather RP2040 CanBus as PC controller

Post by veggie2u_cyberward »

Thanks for the reply. I was thinking this might be a way to view and or send the Canbus packets from a laptop or raspi. (my own can bus, not a car's network) I ordered one and will checkout what you posted. If there is a guide coming, that is fantastic.

User avatar
NewUserDave
 
Posts: 8
Joined: Thu May 11, 2023 7:07 pm

Re: Feather RP2040 CanBus as PC controller

Post by NewUserDave »

Hey all I got one of the RMX servo actuator devices and while I'm getting a sense of what it would take to program them in CircuitPy , I don't have any idea where all of this wiring goes. There's a power and ground and then multiple black and white thin wires and one chip that says bluetooth on it.
Never having built a board or soldered a thing , does anyone know where they publish a picture of how all this stuff is supposed to look when it's finished?

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”