Not much has happened since March. I have acquired a USB-to-RS232 adapter which I will use in the RS232 Interface project.
I have decided to modularise as much as possible. The PIC µcontroller will have its own board with a clock, ICSP header and headers for the other pins.
I have also decided to split the DCC Signal Generator and take the Track Power out of the immediate picture. This should be done by a booster.
I contacted www.electronickits.com and was redirected to Quasar Electronics. So I reckon I will source the parts from them, that is PSU (£20) and Programmer (£60).
A third PIC Programmer has entered the arena and it is a USB PIC Programmer available from www.electronickits.com. Is is only $60 including a ZIF socket. It is probably going to be my choice.
The DCC Signal will probably remain a TTL signal at +5V/0V.
I have had a rethink about how the system will work, and revised the block diagram. An RS485 relay interface does not need to been implemented as part of the system. An RS485 interface may be needed, but that is a future consideration. A suitable power supply can be sourced off-the-shelf.
I have still to decide on whether the Signal output is +5V/0V or whether it should be differential.
I have been thinking, the RS485 interface isn't really needed, as this could be added to the PC using its USB interfaces. So a redesign of the block diagram is needed. The RS232 interface can use the UART and an external clock is still needed for the Track Signal.
1MHz crystals are not really available. I will use a 4MHz crystal and prescalar it to /4.
I think a simpler and cheaper 16F627A will also provide all the functionality I need. It also comes operating at 20MHz.
So I got my 'milli' and 'micro' a bit confused!
I have been trying to find answers on the web, but each question spawns more questions. To summarise I need to resolve the following questions:
I have also been looking at how RS232 actually works and I was horrified to learn that serial support for .NET is only really available out-of-the-box with .NET 2.0.
The answer to the first question is 'yes', but I need to investigate using the UART for the Track Signal instead of for the RS485 interface. Hmmm, this is going to need some thought. I have thought about it and I am sticking with my original decisiion of using the internal timer on Tmr0. But, perhaps a 1MHz clock on T0CKI would work, and the PIC can still run at 20MHz.
The answer to the third question is 'yes'. I fired up the C# Express Edition and a dummy program compiled using the SerialPort class. That doesn't mean it works, but the signs are promising.
I have been searching the web for a suitable PIC Programmer and I have narrowed my choices down to 2 (at the moment). Both are externally powered. One is the Microchip PICSTART Plus which has a serial interface. The other is the USB/Serial Port PIC Programm kit (CPS149) from Electronics123.com.
The PICSTART Plus comes ready assembled, good to go and is available from Rapid Electronics for about £140 not including shipping. It needs a USB to RS232 converter which Rapid also supply for about £10.
The CPS149 kit is available for $54 and comes without a ZIF socket. The optional socket adds $19. Then there is tax and shipping from the USA, making an estimated cost of $120, or roughly £80. A suitable power supply is needed for it, probably a laptop aupply for £12 available from Rapid. This is also a kit and requires some assembly. But it comes with a USB port.
It becomes a choice of hassle versus cost. I have decided on the Microchip option.
I have taken delivery of PIC Microcontrollers by Martin Bates. I reckon this is going to be some essential reading, although at first glance it focuses on the 16F84, which I understand is considered 'old' technology now.
The MERG website has also planted the seed of another idea. That is using RC servos to actuate semaphore signals. That is another PIC project to add to the list.
Although I have to admit, setting up this website is taking up most of my time.
My interest in computers started back in 1981 with the Acorn Atom. It wasn't really a games machine and I had many enjoyable years of programming it with the in-built BASIC interpreter and Assembler. I now have a PC running Windows XP and the magic of the heady days with the Atom seems lost.
I have additional interests in digital electronics and in model railways. I rekindled my interest in model railways in 2005 and I am currently building a small N gauge layout. Exciting things are happening in the world of model railways with Digital Command and Control (DCC), and associated computer interfacing.
There are many ways of using a computer to control a model railway. The method adopted by the NMRA is now considered the standard way. This defines how locomotives are powered and controlled but not how the 'other bits' interface. There seem to be three rival methods, LocoNet by DigiTrax, XpressNet by Lenz, and a CAN bus method of which I know nothing. I don't know much about the other methods, but XpressNet is in the 'public domain'.
In general browsing I stumbled accross the BASIC Stamp and PIC µControllers, and dismissed them as a novelty interest. I also investigated the ARM processor because of its link with Acorn.
I was investigating Capacitor Discharge Units for my Model Railway layout and I plan to switch to DCC after 2010. DCC control of my points will cost over £500 and that is money I would rather spend on other things. So I looked into what I think I might need to do to 'homebrew' such a point control system and how best to incorporate the CDU. I concluded that I need to interface to the DCC bus. Up until now I had been favouring DigiTrax system, but its protocol and bus is guarded, so XpressNet now seems much more appealing.
The XpressNet hardware layer uses RS485 and to use this I revisited the PIC using appropriate line drivers. The plan I came up with is that the PIC would listen on the RS485 network an? follow instructions. The PIC would also allow the CDU, or multiple CDUs used in a round-robin fashion, to charge before firing them.
So I started to investigate how to do this. I looked at the MERG group to see if anything like this has been done before (no sense in re-inventing the wheel) and looked at the diy-DCC system. It all seemed a bit disappointing there, but that was probably due to my unrealistic expectations. I will join MERG at some point I am sure.
And I also asked myself 'How do I use a PIC anyway?' I figured I would need a 'burner' or programmer to get the code in. That on top of the electronic circuitry. The challenge was making itself known to me.
I investigated PIC programmers. Most cheap'n'cheerful types seemed to use the PC Parallel port or the RS232 serial port. With tricks to utilise the power supplied by these ports. But my PC only has USB 2.0 ports. What I really want is a PIC programmer that uses USB and is powered seperately, i.e. doesn't use the USB power (I don't want to fry my PC - it has to last another five years!)
The idea of using a PC as a DCC command station seems appealing. Investigation only uncovered a DOS based system that utilised the parallel port. Now I am not going to need a big DCC setup, and from looking at the MERG site, the idea of building my own command station might work. It would use the PC for the main work, and interface with a DCC Signal Generator. This would also act as the RS485 relay so that the PC can communicate with control the accessory devices using XpressNet.
That gives me 3 projects:
In summary, using a PIC may restore the early heady days.