Page 1 of 1

CAN Adressing

Posted: Mon Apr 06, 2009 2:48 pm
by PINTO
Hi Benj,

How can I adress the nodes on a can bus network via DIP Switches and still be able to use the CAN Component?

When is the Flowcode 4 going to be availabe?

Thanks


Pinto

Re: CAN Adressing

Posted: Mon Apr 06, 2009 3:38 pm
by Dan81
Hello Pinto


CAN adress is 11 or 29 bit long.

You can read some (3 or more) bits of the RA port (for instance or the MCP2515 port) and choose among 8 (or more) fixed adresses.
Or you can create an adress with the upper bits fixed and lower bits according your DIP switches.

Then use the CAN Macro "SetTX..ID"

Daniel

Re: CAN Adressing

Posted: Tue Apr 21, 2009 9:18 pm
by PINTO
Hi Daniel,
Thanks for your input. I havn't had a chance to test it yet because I can't get the Canbus Component to work properly.
If i create a small program switching LED's On & Off on PortA 0,1,2,3 and PortA4,5 I have two inputs connected to a pic16f876 and 20Khz Xtal the program works when dowloaded to the PIC. But as soon I add Can Init. Icon the the PIC stops responding completelly.
I'm a bit stuck because I'm not sure if there's somthing wrong with the Canbus component or ther's something else to be set on the pic registers?
On the attached program the LED flases on Flowcode simulation but as soon is downloaded to the pic nothing works.
Any suggestions


Thanks




Pinto Ramos

Re: CAN Adressing

Posted: Wed Apr 22, 2009 8:46 am
by Benj
Hello

What are your jumper settings on the CAN E-Block. You should have the jumpers in positions A and 1. Also make sure you are wiring 5V power to the E-Block board via the +V screw terminals.

Re: CAN Adressing

Posted: Wed Apr 22, 2009 11:20 am
by PINTO
Hi Benj,
Thanks for the infio.
My connections seem to be ok.
I've connetect CS to RC0 INT to RC1 and changed the configuration bits on the Can module as well.
If you look at the attached program the LED on Port A1 should flash regardless if the Can is comunicating or not but it doesn't, if I remove all the CAN components from the flow chart and reload the code again than the LED Flashes, as soon as I add one of the can components the led's stop working again.
I'm using a pic16f876 with 20Mhz xtal (Not a 19.????) and My IO port is port A.

Regards




Pinto

Re: CAN Adressing

Posted: Wed Apr 22, 2009 1:59 pm
by Benj
Hello Pinto

I cant see a problem with your program except that you are missing the initialise function at the top. Maybe you could add a LED flash after the Init function to make sure that it is completeing correctly before entering your while 1 loop.

Also for your incoming decision instead of using "RetVal <> 0" you can simply use "RetVal" and this will trigger if RetVal is any value other then 0.
I've connetect CS to RC0 INT to RC1 and changed the configuration bits on the Can module as well.
Does this mean you have configured the patch system on the CAN E-Block to jumper setting 2 and wired connections from pin 0 to /CS and pin 1 to /INT?

There shouldn't be a problem with running at 20MHz or with the device you are using.

Let me know how you get on and I will have a dig in if it is still refusing to work correctly.

Re: CAN Adressing

Posted: Thu Apr 23, 2009 6:03 am
by PINTO
Hi Benj,

I've tried what you suggested it didn't fix the problem.
I've placed a LED just after the init. Makro and the pic appear to be stuck on the initialazation makro.
I've re-installed Flowcode with a fresh copy made no difference.
I've simulated the code on Proteus as well and the same thing happen. I've noticed some acticity on the SPI pins and the PIC appears to be in some sort of a loop and not being able to get out of it.

You help is appreciated.

Thanks

Pinto

Re: CAN Adressing

Posted: Thu Apr 23, 2009 11:28 am
by Benj
Hello Pinto

I have had a look into the problem and been able to replicate it here using the 16F876 and the 16F876A. I will see if I can find a way around the problem.

I have tracked the problem down to a single line of code in the initialise function at the moment.

//Put the CAN device into config mode
CAN_Config(REQOP_CONFIG);

Re: CAN Adressing

Posted: Thu Apr 23, 2009 6:05 pm
by PINTO
Hi Benj,

I've tried the same code on the pic16f877 and I got the same problem.
When could we expect the fix for the componet?

Thanks



Pinto

Re: CAN Adressing

Posted: Fri Apr 24, 2009 9:24 am
by Benj
Hello Pinto

Ok I tracked the problem down to a hardware fault. Here is my setup for either a 16F876 or a 16F877.

CAN properties.
INT - 0
CS - 6

CAN E-Block jumper settings
A and 1 connected horizontally.

Multiprogrammer +V wired into +V on the CAN E-Block.

The problem on my test board was related to a faulty crystal. This was because I was using the development version of the board. I replaced my test board with a stock item and the CAN programs are now running correctly. If your board is less then a year old then you can send to me and I will check it and repare or replace if needed. Otherwise you can probably assume that it is the MCP2515 device that has somehow become damaged and simply try replacing this chip.

Re: CAN Adressing

Posted: Fri Apr 24, 2009 11:18 am
by PINTO
Hi Ben,
Ok, now you got me even more confused.
Why is that the PIC gets stuck on the initialization?
Does the pic expect any kind of confirmation from the MCP2551 in order to go to the next step?
If that's the case, it makes sense the program freezes, meaning that the MCP2551 or the SPI section of the PIC are blown.
I'm going out now and buy some MCP2551's and replace them and try again.

Thanks




Pinto

Re: CAN Adressing

Posted: Fri Apr 24, 2009 11:31 am
by PINTO
Hi Ben,

Sorry I mean MCP2515 not MCP2551
Could you tell me as well on the configuration setup for the component the mumber for CS and INT mean connect to Port C0 and C6 on the actual pic and if so how do they change for the 18 pin Pics that this pins are on PortB

If I had to use any other pin on PortC for CS anf INT how would I configure them on flowcode?

Thanks



Pinto

Re: CAN Adressing

Posted: Tue Apr 28, 2009 6:48 pm
by PINTO
Hi Ben,
Ok. The problem was....... I was using a 4Mhz Chip with the 19.660800Mhz :oops: Sorry.
I've now manage to get the PIC to initialize the CAN Bus module.
I wasn't yet able to get any sort of defenitive communications between the modules.
I searched the web and find out that one way of quick testing if the CAN Bus is electically healthy is to measure the voltage between the Hi and LOW lines and should be 2.5Vdc on standby and if the BUS communicates than HI wil go 3.75Vdc and LOW Line wil be 1.25Vdc refered to ground. This is happning but i didn't get any response from any of the nodes yet.

I will post if need any further help

Thaks for your help.

Looking forward for Flowcode4??
Regards


Pinto


Pinto

Re: CAN Component setup

Posted: Wed Apr 29, 2009 12:51 pm
by PINTO
Hi Ben,

How do I edit the values in the CAN component Box.
The component doesn't allow me to erase all the digits.
If I want to change the message ID I can't just erase all the numbers and enter a new one without having to fiddle with the cursor in the box. I'm sure this is not the way of changing the values?
Thanks




Pinto

Re: CAN Adressing

Posted: Wed Apr 29, 2009 4:11 pm
by Benj
Hello Pinto

Thats strange. If you untick the show values as hex tick box then does the same problem happen?

You may want to simply use the setTxID macro to assign the ID to the transmit buffer. This way you do not have to touch the transmit buffer properties.

Re: CAN Adressing

Posted: Sat May 09, 2009 11:50 am
by PINTO
Hi Ben,

I'm not sure what you mean by "If you untick the show values as hex tick box"I don't have this feature in my version of the CAN component?? What I have is "Use Hex Notation box"
and no matter what I do to it as soon as I erase all the digits from any of the boxes to re-type the new value a window pops up (Invalid Value. Please enter a number between 0 and 2047, or between 0x0 and 0xFF if using Hex.)
I've now managed to get my project going. The project was to control 8 sets of traffic lights on a very un-usual roads crossing on a coal mine underground.
Some of the Traffic lights were as far as 300 meters away from the other lights and the very complicated operations logic made the all thing very challenging.
The other feature was because the units were spread to considerable distances the amount of cabling used was reduced to on 4*1.5mm cable (2 cores for 24Vdc and other 2 cores for CAN HI and CAN LO).
I still have a couple issues to resolve but for now the system is working great.

Thanks for your help.

Regards



Pinto