CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

CCS CAN Dev Board
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

CCS CAN Dev Board
PostPosted: Sun Dec 17, 2006 11:24 am     Reply with quote

It was all going well, I had Node A listening and monitoring all and the other nodes transmitting.

I then decided to put a RX and TX LED on Node A so I could do some initial prototyping before having a board built. I inserted a 390 ohm resistor and LED between 5 volts and B3 and had a very fast, dim blinking RX indicator. This was on B3 between the 18F4580 and the 82C251.

I wanted to make the LED a little brighter so I grabbed a 220 ohm and used it instead. All my CAN traffic came to a halt.

Well, upon checking, I grabbed a 150 ohm resistor by mistake instead of the 220 which I guess in turn loaded B3 to hard and must have taken it out. Can High and Low were both right at 5 volts.

So in a deperate move to continue testing for the weekend, I wanted to remove Node A from the bus to allow the other nodes to continue talking.
I took my exacto and cut the traces from node A's 82C251 CAN HI/LO lines to the bus.

I still have absolutely no data on the bus from the other nodes. I know I could have damaged Node A, but surely what I did should not have affected other nodes.

Anyone here technical enough to tell me what I could have done to mess up the other nodes? I really have to try and finish some testing this weekend.

Embarassed
jma_1



Joined: 08 Feb 2005
Posts: 147
Location: Wisconsin

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 1:15 pm     Reply with quote

Greetings,

How many nodes do you have? What are you monitoring them with? If you have only 1 node, there will not be any acknowledgment and most likely your single node setup will continually send the signal (viewed w/' oscilloscope). What initiates the transmission of messages from the node? (is the software supposed to be sending, or is it only in response to another message)

I do not have the CCS CAN development board and I have not looked at the schematics for the board. Did you cut the traces separating the pull-ups from the transceiver or the transceiver from the bus? If the transceiver on node A has been seriously damaged, your bus levels might affect the other nodes ability to function correctly (all sorts of error frames, etc). Do you have still have the correct termination resistors in your modified bus?

Have you tried debugging the other nodes? Try sending a single message. If you monitor the lines with an o-scope, what do you see? I've seen the can_inti() function continually block if it cannot setup the hardware correctly. Double check your software completes this step.

Hopefully this puts you in the right direction.

Cheers,
JMA
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 2:50 pm     Reply with quote

Quote:

I then decided to put a RX and TX LED on Node A so I could do some
initial prototyping before having a board built. I inserted a 390 ohm
resistor and LED between 5 volts and B3 and had a very fast, dim
blinking RX indicator. This was on B3 between the 18F4580 and the
82C251.
Well, upon checking, I grabbed a 150 ohm resistor by mistake instead of
the 220 which I guess in turn loaded B3 to hard and must have taken it out.

This is unlikely, because Pin B3 is the CANRX pin. It's an input. You
can't "load it too hard". (At least, as long as it's configured as an input).
If anything was taken out, it would be the output pin on the PCA82C251
CAN bus tranceiver (This is the RXD pin, on pin 4).

What would the load be on this pin ? According to the PCA82C251
data sheet, on page 7, the Voh voltage on the RXD will be 4 volts.
http://www.semiconductors.philips.com/acrobat/datasheets/PCA82C251_3.pdf
But the condition is listed as only 100 ua load. That doesn't mean it's
limited to that current level. It just means they did their testing with
that amount of load. Unfortunately, the data sheet doesn't give the
short circuit output current for the RXD pin. A competing product,
the MCP2551 CAN bus transceiver, lists their test condition for RXD
as 8 ma. Another product the T.I. snN65hvd251 uses 4 ma for
the RXD Voh test condition. It's tough for me to know what the real
maximum (or even nominal) Ioh value is for the Philips chip.

But anyway, let's calculate the load placed on the RXD pin by your LED
circuit. A typical LED, at least of the Panasonic type shown on the back
page of the Digikey catalog, has a Vf voltage drop of about 2.2 volts.
So if Voh is 4 volts (maybe) then, the drop across your series resistor
is 4v - 2.2v = 1.8v. Then 1.8v/150 ohms = 12 ma. For an ordinary
CMOS chip, it's unlikely that a 12 ma load is going to burn out the Voh
driver. But given that the Philips chip lists their test condition for the
Voh output driver as 100 ua, I suppose it's possible.

My guess is that in soldering the LED circuit onto your board, you
shorted something out ( maybe with a solder bridge) or damaged it
in some other way. My advice is to physically inspect the connections
under a magnifier, or use an ohmeter to see if your RXD (and TXD)
pins are shorted to any other pins on the Philips chips.
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 6:20 pm     Reply with quote

In your datasheet directory, there is a schematic of the CAN Development board there.

PCM Programmer. I hooked the LED + to 5volts on the header. The LED went to a resistor, then inserted into the B3 hole.

This board has 4 individual nodes on a single board, plus allows the CAN BUS to be used externally.

In my setup, I have Node B programmed to send out data every 100ms. I then have Node reading in the data, and posting it to modbus registers. I also have an external USB to CAN adapter hooked to the External CAN BUS pins.

Before I messed with the LED, Node B was clicking along sending out messages while Node A was storing them in registers view able via a modbus master, and also the external node was logging data so it has been working great.

The LED I never soldered, the board has a small header on node a for accessing the IO. I simply connected a resistor to a LED, and inserted into the holes.

Thi pics are alive and well, flashing LEDs and doing everything they had before, there is just no can msgs on the bus at all.

When I severed the traces from Node A's 82C251 from the bus that should have freed up all the nodes to continue doing there thing, but they dont.

I do not see how I possily could have affected any other node on the bus even if I did fry that one transceiver.
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 6:25 pm     Reply with quote

A total of 5 nodes. 4 are on the same board, then 1 external node.

It was all previously working for several days before I did my LED deal.

I cut the traces removing Node A's transiever from the bus all together.

CanInit is not blocking or shouldn't be because I have activity LED's on 2 of the nodes which are blinking fine as part of the main loop.

I have a scope and will check for life on the bus.

jma_1 wrote:
Greetings,

How many nodes do you have? What are you monitoring them with?
I do not have the CCS CAN development board and I have not looked at the schematics for the board.
Did you cut the traces separating the pull-ups from the transceiver or the transceiver from the bus?
Have you tried debugging the other nodes?
Can Init
Hopefully this puts you in the right direction.

Cheers,
JMA
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 6:37 pm     Reply with quote

I don't have the kit so I don't have the data sheet directory for it,
and thus I don't have the schematic.

The only thing I can think of is that when you cut the traces, you may
have removed a 120 ohm terminator resistor from the CAN bus.

Or, the traces may go somewhere else on the board, to some circuit
that's necessary for the operation of the board.

I can't really help much more. All I have to work with is the photo
of the board from the CCS webpage:
http://www.ccsinfo.com/product_info.php?products_id=CANbuspb
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 7:39 pm     Reply with quote

PCM programmer wrote:
I don't have the kit so I don't have the data sheet directory for it,
and thus I don't have the schematic.


The board has SMD components on top, the CAN Bus is on bottom. two vias for each transceiver is how they connect to the lower bus. It's very easy to drill the vias in order to isolate each chip. It makes it's pretty easy to hook them back up if need be.


Well, It appears I did not fry Node A as you previously stated. I hooked my external can device to node A and it works perfectly fine.

The problem is however, Node B which I have not touched, is the one causing the CAN Bus to freeze. When I cut the traces to node B everything took off working.

For grins, I loaded a simply LED Blinky program into Node B and although it took the program, and said it should be running, there is absolutely no life coming from it.

At I have it narrowed down.
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 8:02 pm     Reply with quote

Reprogrammed it with the CAN TX program, hooked the bus back up, and she is working fine now.

Next time I powered down and powered up she is locked up again. On node B, I put a small loop that blinks an LED 10 times before I do CAN_Init, then after CAN_Init I blink the LED.

After a power down, the LED always blinks 10 times then stops. Occasionally it makes it past CAN_Init and continues.

You all were right, something in CAN_Init causes it to hang up sometimes.

Where do I go now? The book doesn't say much about CAN_Init at all.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 9:04 pm     Reply with quote

Quote:

On node B, I put a small loop that blinks an LED 10 times before I do
CAN_Init, then after CAN_Init I blink the LED.
After a power down, the LED always blinks 10 times then stops.
Occasionally it makes it past CAN_Init and continues.

Node B has a MCP2515 chip on it, according to the CCS web page.
The driver for this chip is called can-mcp2510.c. (The new chip is
supposed to be upward compatible with the old one).
The example file that calls this driver is ex_can_ccs_b.c.
The driver file (can-mcp2510.c) has a list of PIC pins that it uses.
Make sure that the pins are correct for your board. They probably
are, but verify it.

The board has RS-232 serial port connectors for both Node A and Node B.
These are 3.5mm stereo jacks. My advice is to connect the RS-232
to your PC with the provided cable, and then put in some printf()
statements inside the can_init() function in can-mcp2510.c, and track
down exactly which line of code in that routine is causing the problem.
Put a printf() or a putc() statement after each line. Use a terminal
progra to view the output. (For example, HyperTerminal). Then just
run the PIC program and you'll find out very quickly how far it
progresses before it locks up. Example:
Quote:
void can_init(void) {
struct struct_RXB0CTRL b_rxb0ctrl;
printf("start of can_init()\n\r");
mcp2510_init();
putc('A');
can_set_mode(CAN_OP_CONFIG);
putc('B');
can_set_baud();
putc('C');

b_rxb0ctrl=0;
b_rxb0ctrl.rxm=CAN_RX_VALID;
b_rxb0ctrl.bukt=CAN_USE_RX_DOUBLE_BUFFER;
mcp2510_write(RXB0CTRL, (int)b_rxb0ctrl);
putc('D');
mcp2510_write(RXB1CTRL, (int)b_rxb0ctrl);
putc('E');
etc.
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 9:44 pm     Reply with quote

Good Idea, I will give it a shot tomorrow. Thanks again.
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 10:10 pm     Reply with quote

First, After programming the 876A with the ICD_U it doesn't always restart the chip and I have to remove power to get it to start.

Next;

Here is where it's getting me, in Can_Set_Baud

Putc('3');
mcp2510_write(CNF3, (int)new_CNF3);
Putc('4');

I get a 3 on the screen but I never make it to 4.

CNF3 is this:

new_CNF3.phseg2=CAN_BRG_PHASE_SEGMENT_2;
new_CNF3.wakfil=CAN_BRG_WAKE_FILTER;

In the 2510.h file its defined like this....

Code:

#IFNDEF CAN_BRG_SYNCH_JUMP_WIDTH
  #define CAN_BRG_SYNCH_JUMP_WIDTH  0  //synchronized jump width (def: 1 x Tq)
#ENDIF

#IFNDEF CAN_BRG_PRESCALAR
  #define CAN_BRG_PRESCALAR  3 //250=3 //125=4  //baud rate generator prescalar (def: 4) ( Tq = (2 x (PRE + 1))/Fosc )
#ENDIF

#ifndef CAN_BRG_SEG_2_PHASE_TS
 #define CAN_BRG_SEG_2_PHASE_TS   TRUE //phase segment 2 time select bit (def: freely programmable)
#endif

#ifndef CAN_BRG_SAM
 #define CAN_BRG_SAM 0 //sample of the can bus line (def: bus line is sampled 1 times prior to sample point)
#endif

#ifndef CAN_BRG_PHASE_SEGMENT_1
 #define CAN_BRG_PHASE_SEGMENT_1  4 //250=4 //125=5 //phase segment 1 (def: 6 x Tq)
#endif

#ifndef CAN_BRG_PROPAGATION_TIME
 #define CAN_BRG_PROPAGATION_TIME 0   //250= 0 //125= 2 //propagation time select (def: 3 x Tq)
#endif

#ifndef CAN_BRG_WAKE_FILTER
 #define CAN_BRG_WAKE_FILTER FALSE   //selects can bus line filter for wake up bit
#endif

#ifndef CAN_BRG_PHASE_SEGMENT_2
 #define CAN_BRG_PHASE_SEGMENT_2  2   //250=2 //125=5 //phase segment 2 time select (def: 6 x Tq)
#endif



Now, Last week, I did change it from 125K to 250K and you will see those lines commented. But it's been running that way all week with absolutely no problems until Friday night.
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 11:00 pm     Reply with quote

I set everything back to the factory defaults and I have the same issues.
I even moved over the original 2510.c and h files to make sure there were no typos. Same results.
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 11:27 pm     Reply with quote

Okay, is there anything wrong with this code, besides that I have a lot of hard coded stuff here for testing?

Code:

#Include <16F876A.h>
#fuses HS,NOPROTECT,NOLVP,NOWDT,NOPUT
#use delay(clock=2500000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#include <can-mcp2510.c>


int16 DLY = 100;
#define WRITE_REGISTER_A_ID  0x1CFEA3F1    //82 75 d8 75 1b 76 6b 75
#define WRITE_REGISTER_B_ID  0x1CFEA2F1    //78 75 18 75 72 76 ef 75
#define WRITE_REGISTER_C_ID  0x1CFEA1F1    //b8 73 52 75 0b 76 25 75
#define WRITE_REGISTER_D_ID  0x1CFEA0F1    //c1 25 be 25 bb 25 be 25

#define WRITE_REGISTER_E_ID  0x18FE97F1    //0f 5e d5 5e ff ff ff ff
#define WRITE_REGISTER_F_ID  0x1CFEEE00    //80 28 c0 2c ff ff ff ff
#define WRITE_REGISTER_G_ID  0x18FEF5F1    //ff ff ff 1e 25 ff ff ff
#define WRITE_REGISTER_H_ID  0x1CFEF700    //ff ff ff ff 20 02 ff ff 

#define WRITE_REGISTER_I_ID  0x0CF00400    //ff ff ff 57 21 ff ff ff
#define WRITE_REGISTER_J_ID  0x1CFEA900    //cc 07 ff ff c6 07 ff ff
#define WRITE_REGISTER_K_ID  0x1CFEEF00    //ff ff ff 7b ff ff 63 ff
#define WRITE_REGISTER_L_ID  0x1CFEF600    //ff ff ff 50 ff ff ff ff

#define Button
int buffer[8];

// Loads values into buffer
void LoadBuf (int p0,p1,p2,p3,p4,p5,p6,p7)
{
   buffer[0] = p0;
   buffer[1] = p1;
   buffer[2] = p2;
   buffer[3] = p3;
   buffer[4] = p4;
   buffer[5] = p5;
   buffer[6] = p6;
   buffer[7] = p7;
 }



void WriteCan ()
{
LoadBuf(0x82,0x75,0xd8,0x75,0x1b,0x76,0x6b,0x75);
can_putd(WRITE_REGISTER_A_ID,buffer,8,7,True,False);
delay_ms(Dly);

LoadBuf(0x78,0x75,0x18,0x75,0x72,0x76,0xef,0x75);
can_putd(WRITE_REGISTER_B_ID,buffer,8,7,True,False);
delay_ms(Dly);

LoadBuf(0xb8,0x73,0x52,0x75,0x0b,0x76,0x25,0x75);
can_putd(WRITE_REGISTER_C_ID,buffer,8,7,True,False);
delay_ms(Dly);

LoadBuf(0xc1,0x25,0xbe,0x25,0xbb,0x25,0xbe,0x25);
can_putd(WRITE_REGISTER_D_ID,buffer,8,7,True,False);
delay_ms(Dly);

LoadBuf(0x0f,0x5e,0xd8,0x5e,0xff,0xff,0xff,0xff);   
can_putd(WRITE_REGISTER_E_ID,buffer,8,7,True,False);
delay_ms(Dly);

LoadBuf(0x80,0x28,0xc0,0x2c,0xff,0xff,0xff,0xff); 
can_putd(WRITE_REGISTER_F_ID,buffer,8,7,True,False);
delay_ms(Dly);

if( input(PIN_A4) )  //Lets me push a button and turn off other channels
   {
   Output_High(Pin_A3);
   LoadBuf(0xff,0xff,0xff,0x1e,0x25,0xff,0xff,0xff);
   can_putd(WRITE_REGISTER_G_ID,buffer,8,7,True,False);
   delay_ms(Dly);

   LoadBuf(0xff,0xff,0xff,0xff,0x20,0x02,0xff,0xff);
   can_putd(WRITE_REGISTER_H_ID,buffer,8,7,True,False);
   delay_ms(Dly);
   
   LoadBuf(0xff,0xff,0xff,0x57,0x21,0xff,0xff,0xff);
   can_putd(WRITE_REGISTER_I_ID,buffer,8,7,True,False);
   delay_ms(Dly);

   LoadBuf(0xcc,0x07,0xff,0xff,0xc6,0x07,0xff,0xff);
   can_putd(WRITE_REGISTER_J_ID,buffer,8,7,True,False);
   delay_ms(Dly);

   LoadBuf(0xff,0xff,0xff,0x7b,0xff,0xff,0x63,0xff);
   can_putd(WRITE_REGISTER_K_ID,buffer,8,7,True,False);
   delay_ms(Dly);

   LoadBuf(0xff,0xff,0xff,0x50,0xff,0xff,0xff,0xff);
   can_putd(WRITE_REGISTER_L_ID,buffer,8,7,True,False);
   }
}



void main()
{
   //for debugging
   Printf("Before Init...");   
   delay_ms(1000);
   can_init();

   Printf("After Init...");

   can_putd(0x100,0,0,1,True,False);
   delay_ms(1000);

   Printf("After Wakeup 2510...");
   while(TRUE)
   {
     writecan();
     Printf("In Main Loop.");
     delay_ms(500);
   
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 11:32 pm     Reply with quote

Quote:

Here is where it's getting me, in Can_Set_Baud
Putc('3');
mcp2510_write(CNF3, (int)new_CNF3);
Putc('4');
I get a 3 on the screen but I never make it to 4.

There is nothing special about the mcp2510_write() function that
would cause it to lock up. It just bit-bangs 24 bits out to the CAN
controller. Also, that's not the first time that mcp2510_write() is
called.

If it locks up on that line, it means there's something flaky about the
operation of the PIC. The problem could be could be hardware or
software.

I think you're using version 4 of the compiler. The first thing you
should do is download vs. 3.249 and try it.
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Sun Dec 17, 2006 11:47 pm     Reply with quote

This loads and runs fine everytime!

Code:

#Include <16F876A.h>
#fuses HS,NOPROTECT,NOLVP,NOWDT,NOPUT
#use delay(clock=2500000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#include <can-mcp2510.c>

#define WRITE_REGISTER_A_ID  0x1CFEA3F1    //82 75 d8 75 1b 76 6b 75
int buffer[8];



void WriteCan ()
{
   Buffer[0] = 0x82;
   Buffer[1] = 0x75;
   Buffer[2] = 0xD8;
   Buffer[3] = 0x75;
   Buffer[4] = 0x1B;
   Buffer[5] = 0x76;
   Buffer[6] = 0x6B;
   Buffer[7] = 0x75;
   
   can_putd(WRITE_REGISTER_A_ID,buffer,8,7,True,False);
}



void main()
{
   //for debugging
   Printf("Before Init...");   

   can_init();

   Printf("After Init...");

   can_putd(0x100,0,0,1,True,False);
   delay_ms(100);

   Printf("After Wakeup 2510...");
   while(TRUE)
   {
     writecan();
     Printf("In Main Loop.");
     delay_ms(100);
   
   }
}


What? all I did was shorten it some. I'll try the other compiler.


Last edited by rwskinner on Mon Dec 18, 2006 6:03 am; edited 1 time in total
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group