Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BARTH STG-850 Support #61

Closed
ben-mcdonnell-hacksmith opened this issue Sep 19, 2023 · 5 comments
Closed

BARTH STG-850 Support #61

ben-mcdonnell-hacksmith opened this issue Sep 19, 2023 · 5 comments

Comments

@ben-mcdonnell-hacksmith

I am trying to use your library with a BARTH STG-850 using their core. The library does build, but I am having issues sending messages. I have run through the troubleshooting steps in your README. I have termination resistors on both ends of the wire (150 ohm) and the device doesn't have any internal termination.

The PLC is STM32F09x based. I am not sure what the internal CAN transceiver is, but it does use PB8/9 for the pins, and I configured the software as such.

When starting I do get the CAN Initialization OK message.

GPIO_AFR(b)=0x0
GPIO_AFR(a)=0x4
GPIO_MODER(b)=0x0
GPIO_MODER(a)=0x20000
GPIO_OSPEEDR(b)=0x0
GPIO_OSPEEDR(a)=0x30000
GPIO_OTYPER(b)=0x0
GPIO_OTYPER(a)=0x0
GPIO_PUPDR(b)=0x0
GPIO_PUPDR(a)=0x0
GPIO_AFR(b)=0x4
GPIO_AFR(a)=0x44
GPIO_MODER(b)=0x20000
GPIO_MODER(a)=0xA0000
GPIO_OSPEEDR(b)=0x30000
GPIO_OSPEEDR(a)=0xF0000
GPIO_OTYPER(b)=0x0
GPIO_OTYPER(a)=0x0
GPIO_PUPDR(b)=0x0
GPIO_PUPDR(a)=0x0
CAN->BTR=0x1E0003
CAN1 initialize ok
Send Fail
352321621
3080
419430408
Send Fail
1962934357
3080
419430408
Send Fail
788529237
3080
419430408

Any suggestions?

Thanks!

@nopnop2002
Copy link
Owner

I am not sure what the internal CAN transceiver is

You need to clarify the transceiver you are using.

@ben-mcdonnell-hacksmith
Copy link
Author

They aren't super forthcoming with details, but from some Keil example code, it appears to be a sn65hvd234 transceiver.

@nopnop2002
Copy link
Owner

nopnop2002 commented Sep 20, 2023

with a BARTH STG-850

The stm32f072 sample is for STM32F0 running at 48MHz.

This board needs to run at 48MHz.

Transmission failures have been reported many times in the past.

Everything is due to physical causes.

https://github.com/nopnop2002/Arduino-STM32-CAN/issues/

If the transmission fails, these are the possible causes.

  • There is no receiving app on CanBus.
  • The speed does not match the receiver.
  • There is no terminating resistor on the CanBus.
  • There are three terminating resistors on the CanBus.
  • The resistance value of the terminating resistor is incorrect.
  • 3.3V transceiver and 5V transceiver are mixed.
    +1V Ground Shift using Split Termination.
    Check here.
  • Stub length in CAN bus is too long.
    Though the ISO11898 Standard specifies a maximum bus length of 40m and maximum stub length of 0.3m at 1Mbps.
    See here.
  • Noise effects.
    It occurs when the wire cable is thin or wire cable is crossing.
    It is preferable to use wires that are noise-proof.

I changed the single wire to twisted wire. It's fixed.
CAN-SendFail

You will probably need to open the case and check the XTAL used, presence or absence of a terminating resistor, transceiver model number, and internal wiring using a multimeter .

@ben-mcdonnell-hacksmith
Copy link
Author

The board isn't running at 48mhz, according to the datasheet it is running at 16mhz, would I need to adjust the CAN timing to fix that?

@nopnop2002
Copy link
Owner

nopnop2002 commented Sep 29, 2023

would I need to adjust the CAN timing to fix that?

Yes.

You can use this for CAN Bit Time Calculation.

http://www.bittiming.can-wiki.info/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants