Cost reduction on the CAN-GCx boards

RocNet(RaspberryPi), mergCBUS and LocoNet based hardware developed by Peter Giling. (GCA)
Documentation: http://wiki.rocrail.net/doku.php?id=english#hardware
Order information: http://wiki.rocrail.net/doku.php?id=gca:gca-index-en/

Cost reduction on the CAN-GCx boards

Postby RichardPeters » 07.06.2012, 18:06

Hello all,

I am planning to use RocRail in combination with MERG CBUS DCC for my railroad control. The various CAN-GC modules look very interesting, but as I like to fiddle with electronics, I see some opportunities to reduce cost. Of course, the modules are already very cheap to assemble, so first I'd like to thank the various authors for creating these in the first place.

The first thing that I notice is the microcontroller used: This is a PIC18F2580 where CAN is needed. Microchip has a newer controller, the PIC18F25K80, which is about half the price, and probably quite compatible. So my first goal is to port the CAN-GC1e (The ethernet-to-DCC module) to that controller. Now I'm wondering, I do have experience with Microchip controllers, but has anyone already done something similar, or has anyone got some tips to watch out for?

Second thing, I see that all microcontrollers have an external resonator. These are not expensive, but still I'm wondering why the microcontrollers do not use their internal oscillator? An external resonator of 10MHz would enable the PIC18F2580 to run at its maximum speed of 40MHz using the PLL, but since it uses a 8MHz resonator in the schematics, that makes a 32MHz speed, which is also attainable by using the built-in oscillator.
RichardPeters
 

Postby phg » 08.06.2012, 13:38

Hello Richard,

About the different PIC, e will have to check, but these things keep changing, and it is hard to keep up with all the inceasing possibilities.
About the internal oscillator, that is not quite true, because the PLL only work with external resonator or crystal.
And besides.. what are we talking about? (€ 0,20 ?!).
Best regards, herzliche Grüße, chaleureuses salutations, saludo cordial, migliori saluti, hjärtliga hälsningar, hartelijke groet,

Peter Giling (Rocrail - LNet(GCAxxx) - Fiddle Yard control GCA145 - CBUS (CAN-GCx)- RocNet (Raspberry Pi GCA-PIxx)
phg
 

Postby RichardPeters » 08.06.2012, 17:48

You are right that removing the resonator does only yield a saving of about €0.20. So cost-wise this is not the interesting thing. But I'm a bit of a minimalist: One less resonator is one less component that can fail, one less component to route, and 2 pins saved for other functions.
So I was curious if there is a good reason to keep the oscillator. For example, the PIC18F4550 needs an oscillator, or otherwise it cannot generate the correct clock frequency (40MHz) necessary to operate USB (If I remember correctly).
According to the datasheet, 2.6.4 "PLL in INTOSC modes" describes that the PLL can be enabled in software for INTOSC by setting PLLEN in OSCTUNE. When INTOSC is 8MHz, this gives a clock frequency of 32MHz.

About the microcontroller: I saw that at least some flags have moved to other registers, such as ERRIF has moved from PIR3 to PIR5. I will sort out what exactly the changes are.

By the way, how do you build the firmware? I downloaded all source files and created a new project in MPLAB, but before I could compile it correctly for the original microcontroller, I had to change/add a lot of #include <p18f2580.h>. For example, the few #include <p18cxxx.h> seemed to cause compilation errors. I'm using the newest compiler (mcc18 v3.42) and MPLAB.
RichardPeters
 

Postby L.G. » 08.06.2012, 18:20

Based on my experince with AVR`s
I'm note sure removing the resonator is a good idea.

The internal resonator has a much higher toleranz than an external resenator has. I'm not familar with the bus, but in all bus i know, the synchrotime is important.

So in the worts case you have one conrtoller working one highest toleranz, one on lowestr toleranz, so the kommunikations fails.
Last edited by L.G. on 08.06.2012, 21:10, edited 1 time in total.
L.G.
 

Postby RichardPeters » 08.06.2012, 20:39

I initially thought that the DPLL would take care of synchronization, but upon further reading I found that it still needs a reliable clock. Indeed, it appears that the internal oscillator is not accurate enough.

Well, at least it's good to know that there's a good reason for using an external resonator :)
RichardPeters
 

Postby L.G. » 08.06.2012, 21:08

But using PIC18F25K80 is stiil a good idea
L.G.
 

Postby RichardPeters » 09.06.2012, 14:54

I got the GAN-GC1e firmware to compile for the PIC18F25K80. This is what I changed:

First, in utils.c line 24 and project.h line 29 I changed the #include directives to #include <p18cxxx.h>. They pointed to PIC18F2485.

Then, in enc28j60.c I changed these defines:
#define MCP_RESET_TRIS (TRISAbits.TRISA3)
#define MCP_RESET_IO (LATA3)
#define MCP_CS_TRIS (TRISAbits.TRISA5)
#define MCP_CS_IO (LATA5)
so that RA3 is used instead of RA4. RA4 does not exist anymore in PIC18F25K80, and both RA3 and RA4 weren't connected in the CAN-GC1e design anyway.

Some interrupt bits were moved to other registers, so I added these defines in compiler.h and changed the use of those registers accordingly:
#if defined(__18F25K80)
#define TXB1IE PIE5bits.TXB1IE
#define FIFOWMIE PIE5bits.FIFOWMIE
#define ERRIF PIR5bits.ERRIF
#define EEIF PIR4bits.EEIF
#else
#define TXB1IE PIE3bits.TXB1IE
#define FIFOWMIE PIE3bits.FIFOWMIE
#define ERRIF PIR3bits.ERRIF
#define EEIF PIR2bits.EEIF
#endif

Last thing I did was change the config options, but I still got to review them to see if I did them correct before I'll post them here, so that I won't post any rubbish.

By the way, I found that the PICKIT 2 does not support the new PIC18FxxKxx chips... I'm trying to get devicefiles for them anyway, else I have to consider buying a PICKIT 3. Which kind of defeats the cost savings...
RichardPeters
 

Postby Liviu M » 10.06.2012, 07:50

RichardPeters wrote:
By the way, I found that the PICKIT 2 does not support the new PIC18FxxKxx chips... I'm trying to get devicefiles for them anyway, else I have to consider buying a PICKIT 3. Which kind of defeats the cost savings...


Hi,
Have you checked the new device file from the uChip?
It seems to me it has support for the PIC18F26K80, which looks like a PIC18F25K80 with more memory. Maybe you can use it?

LE Sorry, I've just read on uChip forums that it doesn't work.
Liviu M
 

Postby phg » 13.06.2012, 10:22

Hi Richard,

I also got into this replacing proposal to use 25K80 as substitute for 2480.
But since RA4 is not longer there, for units like CAN-GC2 and CAN-GC4 it would be impossible, it should require the board to be reproduced.
I already did stick out my neck to have these board professionally made, and that stock has to go first!

I will keep it in mind for sure, when starting a new batch of pc-boards.
Best regards, herzliche Grüße, chaleureuses salutations, saludo cordial, migliori saluti, hjärtliga hälsningar, hartelijke groet,

Peter Giling (Rocrail - LNet(GCAxxx) - Fiddle Yard control GCA145 - CBUS (CAN-GCx)- RocNet (Raspberry Pi GCA-PIxx)
phg
 

Postby RichardPeters » 14.06.2012, 10:09

OK, I understand that. I'll keep you informed privately when I have succeeded, then you can decide when to use that information.
RichardPeters
 


Return to GCA (Hardware by Peter Giling)