Can bus between two pyboards



  • Hi dear friends , I try to communicate two pyboards with CAN bus protocol with micropython but I don`t know where is my problem .
    This is the code to send

    import pyb
    import time
    from pyb import CAN,LED
    from pyb import Pin
    
    #inicializaciones
    led=LED(1)
    control=pyb.Pin(pyb.Pin.cpu.B9,pyb.Pin.OUT_PP)
    control.off()#habilita el pin del trans
    
    can1=CAN(1,CAN.NORMAL,extframe=False,prescaler=18,sjw=1,bs1=8,bs2=3)
    
    can1.setfilter(1,CAN.LIST16,0,[0x700,0x701,0x702,0x703],rtr=[0,1,0,0])
    
    data=b'\x01\x50'
    
    
    while True:
       print('enviando...')
       can1.send(data,id=0x702,timeout=0,rtr=False) 
       time.sleep(2)
       print('enviado')
       time.sleep(2)
       control.on()
    

    and this is the code to receive

    #inicializaciones
    led=LED(1)
    control=pyb.Pin(pyb.Pin.cpu.B9,pyb.Pin.OUT_PP)
    control.off()#habilita el pin del trans
    
    can1=CAN(1,CAN.NORMAL,extframe=False,prescaler=18,sjw=1,bs1=8,bs2=3)
    
    
    can1.setfilter(1,CAN.LIST16,0,[0x700,0x701,0x702,0x703],rtr=[0,1,0,0])
    
    while True:
       print('Entrando al ciclo')
        if can.any(0):
           a=can1.recv(0)
           print(a)
           
    
    

    The problem is that the second pyboard never receive nothing , I use a transiver MCP2562 . any suggestion?


  • administrators

    I suggest you check out https://forum.micropython.org for support regarding the Pyboard hardware.



  • @erick said in Can bus between two pyboards:

    The problem is that the second pyboard

    You are on the wrong forum
    this is forum for pycom boards like wipy, lopy, gypy, fipy


Log in to reply
 

Pycom on Twitter

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.