CAN bit timming vs RS232

Started by r_goncalves2000 January 3, 2006
Hello,

This is my first message to this group but I read this group
with atention for some time.

I'm using an Olimex LPC-E2294 board with a cristal of 14.746.000Hz.
This gives perfect baud rate for RS232 but I can find a CAN bit timing
with no error for some usual bit timings like 125K, 250K, etc.
If I go to a 15MHz cristal I have perfect bit timimings in CAN but I
have a RS232 error of about 1.67%.

Is there a way to have no error in both RS232 and CAN baud rates?
If not what's the best choice for the cristal value?
I want to have both RS232 and CAN. Thank you.
Rui



An Engineer's Guide to the LPC2100 Series

Hello Rui,

I 'am using the LPC2129 an there ist the same "problem".

You can fix it with the CAN setup by chosing a time quanta
with a low error in the CANBTR.

For 14,7456 MHz and 125k CAN Buadrate my settings for CANBTR are:

#define CALC_BRP_43 0x0000002A
#define CALC_SJW_1 0x00000000
#define CALC_TSEG1_8 0x00070000
#define CALC_TSEG2_2 0x00100000

#define CANBitrate125k CALC_BRP_43 | CALC_SJW_1 | CALC_TSEG1_8 |
CALC_TSEG2_2

Error: -0,24%

You can find additional infos in:
http://www.hitex.co.uk/arm/lpc2000book/index.html

Best regards,
Martin
> I'm using an Olimex LPC-E2294 board with a cristal of 14.746.000Hz.
> This gives perfect baud rate for RS232 but I can find a CAN bit timing
> with no error for some usual bit timings like 125K, 250K, etc.
> If I go to a 15MHz cristal I have perfect bit timimings in CAN but I
> have a RS232 error of about 1.67%.
>
> Is there a way to have no error in both RS232 and CAN baud rates?
> If not what's the best choice for the cristal value?
> I want to have both RS232 and CAN. > Thank you.
> Rui >
> Yahoo! Groups Links >
>




Martin Steppuhn wrote:

> Hello Rui,
>
> I 'am using the LPC2129 an there ist the same "problem".
>
> You can fix it with the CAN setup by chosing a time quanta
> with a low error in the CANBTR.
>
> For 14,7456 MHz and 125k CAN Buadrate my settings for CANBTR are:
>
> #define CALC_BRP_43 0x0000002A
> #define CALC_SJW_1 0x00000000
> #define CALC_TSEG1_8 0x00070000
> #define CALC_TSEG2_2 0x00100000
>
> #define CANBitrate125k CALC_BRP_43 | CALC_SJW_1 | CALC_TSEG1_8 |
> CALC_TSEG2_2
>
> Error: -0,24%
>
> You can find additional infos in:
> http://www.hitex.co.uk/arm/lpc2000book/index.html
>
> Best regards,
> Martin >

With en error less then 1% there should be no problem for CAN.

Cheers
/Ake

--
---
Ake Hedman (YAP - Yet Another Programmer)
eurosource, Brattbergavagen 17, 820 50 LOS, Sweden
Phone: (46) 657 413430 Cellular: (46) 73 0533 146
Company home: http://www.eurosource.se
Kryddor/Te/Kaffe: http://www.brattberg.com
Personal homepage: http://www.eurosource.se/akhe
Automated home: http://www.vscp.org


Hello guys and thank you very much for your fast answers.

I'm thinking in doing this.
Use a 15MHz cristal.
Use PLL to set cclk to 60MHz.
Set VPDIV to define pclk to 60Mhz.

With this settings I have 0% error in defining the CAN baud rate
and a maximum of 1.72% error in RS-232 baud rate at 115.200.
At 19.200 I get 0.16% error. In this group I found that RS323
error should be less than 3% so I think I'm OK.

I think it's better to have no error in CAN than in RS-232.
In CAN if the cable is to long I get errors due to the baud
rate setting and errors do to the size of the cable.

Am I right? Any comments?

Martin:
Did you test your CAN settings over a large cable (500m)?
Did you test the CAN comunication between your ARM and another
equipment or with 2 ARM with the same settings?

Regards.
Rui
--- In lpc2000@lpc2..., "Ake Hedman, eurosource" <akhe@b...>
wrote:
>
> Martin Steppuhn wrote:
>
> > Hello Rui,
> >
> > I 'am using the LPC2129 an there ist the same "problem".
> >
> > You can fix it with the CAN setup by chosing a time quanta
> > with a low error in the CANBTR.
> >
> > For 14,7456 MHz and 125k CAN Buadrate my settings for CANBTR are:
> >
> > #define CALC_BRP_43 0x0000002A
> > #define CALC_SJW_1 0x00000000
> > #define CALC_TSEG1_8 0x00070000
> > #define CALC_TSEG2_2 0x00100000
> >
> > #define CANBitrate125k CALC_BRP_43 | CALC_SJW_1 |
CALC_TSEG1_8 |
> > CALC_TSEG2_2
> >
> > Error: -0,24%
> >
> > You can find additional infos in:
> > http://www.hitex.co.uk/arm/lpc2000book/index.html
> >
> > Best regards,
> > Martin
> >
> >
> >
>
> With en error less then 1% there should be no problem for CAN.
>
> Cheers
> /Ake
>
> --
> ---
> Ake Hedman (YAP - Yet Another Programmer)
> eurosource, Brattbergavagen 17, 820 50 LOS, Sweden
> Phone: (46) 657 413430 Cellular: (46) 73 0533 146
> Company home: http://www.eurosource.se
> Kryddor/Te/Kaffe: http://www.brattberg.com
> Personal homepage: http://www.eurosource.se/akhe
> Automated home: http://www.vscp.org
>




r_goncalves2000 wrote:

> Hello guys and thank you very much for your fast answers.
>
> I'm thinking in doing this.
> Use a 15MHz cristal.
> Use PLL to set cclk to 60MHz.
> Set VPDIV to define pclk to 60Mhz.
>
> With this settings I have 0% error in defining the CAN baud rate
> and a maximum of 1.72% error in RS-232 baud rate at 115.200.
> At 19.200 I get 0.16% error. In this group I found that RS323
> error should be less than 3% so I think I'm OK.
>
> I think it's better to have no error in CAN than in RS-232.
> In CAN if the cable is to long I get errors due to the baud
> rate setting and errors do to the size of the cable.
>
> Am I right? Any comments?


If you are withing 1% for the CAN bit speed you will be alright. For
cable length adjust the sample point instead. Use 87.5% for instance to
be able to use the length specified for CANOpen

Cheers
/Ake

--
---
Ake Hedman (YAP - Yet Another Programmer)
eurosource, Brattbergavagen 17, 820 50 LOS, Sweden
Phone: (46) 657 413430 Cellular: (46) 73 0533 146
Company home: http://www.eurosource.se
Kryddor/Te/Kaffe: http://www.brattberg.com
Personal homepage: http://www.eurosource.se/akhe
Automated home: http://www.vscp.org


Hello Rui,

the boards TinyArm has a cristal of 12MHz. I think that work fine but
I not still tried the CAN.

Good work

Domingos
Citando r_goncalves2000 <rpsgoncalves@rpsg...>:

> Hello,
>
> This is my first message to this group but I read this group
> with atention for some time.
>
> I'm using an Olimex LPC-E2294 board with a cristal of 14.746.000Hz.
> This gives perfect baud rate for RS232 but I can find a CAN bit timing
> with no error for some usual bit timings like 125K, 250K, etc.
> If I go to a 15MHz cristal I have perfect bit timimings in CAN but I
> have a RS232 error of about 1.67%.
>
> Is there a way to have no error in both RS232 and CAN baud rates?
> If not what's the best choice for the cristal value?
> I want to have both RS232 and CAN. > Thank you.
> Rui >
> Yahoo! Groups Links

_________________________________________________________
CEAC Cursos de formao profissional - pe informaes aqui.:
http://ceac.online.pt/


Hello Rui,

Ake write
>With en error less then 1% there should be no problem for CAN.
I think so too.

> Did you test your CAN settings over a large cable (500m)?
Not yet, only a few meters.

> Did you test the CAN comunication between your ARM and another
> equipment or with 2 ARM with the same settings?
At the moment I communicate with a CAN to USB Dongle and it worked perfect.

http://www.peak-system.com/db/gb/pcanusb_gb.html

Best regards,
Martin

> Hello guys and thank you very much for your fast answers.
>
> I'm thinking in doing this.
> Use a 15MHz cristal.
> Use PLL to set cclk to 60MHz.
> Set VPDIV to define pclk to 60Mhz.
>
> With this settings I have 0% error in defining the CAN baud rate
> and a maximum of 1.72% error in RS-232 baud rate at 115.200.
> At 19.200 I get 0.16% error. In this group I found that RS323
> error should be less than 3% so I think I'm OK.
>
> I think it's better to have no error in CAN than in RS-232.
> In CAN if the cable is to long I get errors due to the baud
> rate setting and errors do to the size of the cable.
>
> Am I right? Any comments?
>
> Martin:
> Did you test your CAN settings over a large cable (500m)?
> Did you test the CAN comunication between your ARM and another
> equipment or with 2 ARM with the same settings?
>
> Regards.
> Rui >
> --- In lpc2000@lpc2..., "Ake Hedman, eurosource" <akhe@b...>
> wrote:
>>
>> Martin Steppuhn wrote:
>>
>> > Hello Rui,
>> >
>> > I 'am using the LPC2129 an there ist the same "problem".
>> >
>> > You can fix it with the CAN setup by chosing a time quanta
>> > with a low error in the CANBTR.
>> >
>> > For 14,7456 MHz and 125k CAN Buadrate my settings for CANBTR are:
>> >
>> > #define CALC_BRP_43 0x0000002A
>> > #define CALC_SJW_1 0x00000000
>> > #define CALC_TSEG1_8 0x00070000
>> > #define CALC_TSEG2_2 0x00100000
>> >
>> > #define CANBitrate125k CALC_BRP_43 | CALC_SJW_1 |
> CALC_TSEG1_8 |
>> > CALC_TSEG2_2
>> >
>> > Error: -0,24%
>> >
>> > You can find additional infos in:
>> > http://www.hitex.co.uk/arm/lpc2000book/index.html
>> >
>> > Best regards,
>> > Martin
>> >
>> >
>> >
>>
>> With en error less then 1% there should be no problem for CAN.
>>
>> Cheers
>> /Ake
>>
>> --
>> ---
>> Ake Hedman (YAP - Yet Another Programmer)
>> eurosource, Brattbergavagen 17, 820 50 LOS, Sweden
>> Phone: (46) 657 413430 Cellular: (46) 73 0533 146
>> Company home: http://www.eurosource.se
>> Kryddor/Te/Kaffe: http://www.brattberg.com
>> Personal homepage: http://www.eurosource.se/akhe
>> Automated home: http://www.vscp.org
> >
>
> Yahoo! Groups Links >