fulda
New Member
Posts: 1
|
Post by fulda on Nov 28, 2010 14:28:35 GMT
Hi Paul, your decoder look like good. I see, you are inspirated Dean Probst decoder. Have you chance to see other decoders? Here is useful schematics (inspirated by MERG and Georg Ziegler). Benefit of these decoders is, that they are using resistors for DC drive (R4/R5). If train running on DC track, the PIC is disconnected and H-bridge feeding track. Also only one input is used (GP3 --> Input only). It mean, there are 3 free outputs - 2 for FR/FL lights (with ampfiler) and one for additional light (one LED only) Here is schematics of "usual" decoder: ... and here is schematics of my version - I'm using small motor from mobile phone vibra-ring in small model = I have motor voltage 3V Here is source code - problem is, that PIC12CE519 is old fashion controller (as you know). I will try to recode it for PIC12F519 - this one have different type of eeprom. OR if you will have a time, it will be great if you can retype old one to PIC12F629. here is zip file with eagle schematics and PDF files Jindra
|
|
|
Post by Paul Harman on Nov 29, 2010 13:14:33 GMT
Jindra
You need to bear in mind all the design criteria that I have used when creating my decoder. I have seen all the other designs and taken some aspects from them, and added quite a lot of new features that are not available on most decoders (DIY or otherwise).
1. The 12F519 is a seriously legacy processor which should not be used on new designs. The 12F629 was brand new when I started and the best 8-pin processor available so I used that. If you are starting out now you should think about using the 12F683 (it has built in PWM hardware) as a minimum, and look towards using the 12F1840 which should be available soon. The limited code space, EEPROM and processing power make it impossible to create an adequate decoder in a 12F519.
2. The comparator input rather than pin 4 is a key design feature enabling the decoder to decode data in the most difficult conditions so that it should work with out of spec controllers like the Hornby Select and in difficult conditions like on dirty track or in locos with poor pickups.
3. DC running is best handled in software. The comparator can accurately measure the track polarity to allow the H-bridge to be switched on for DC operation. There is no need for the resistors - DC running can start as soon as there is enough voltage to bring the PIC out of brown-out-reset.
4. The key design criteria was to be able to use standard components on stripboard with no custom PCB - hence the need to use an 8-pin PIC to keep things small. At the same time the cost has been minimised without reducing performance.
5. I have included over voltage protection to try and prevent high voltages building up on the reservoir capacitor when the decoder is idle - hence the use of a series pass regulator (LDO 78L05) and a zener shunt regulator. I have seen commercial decoders without properly implementing this dual protection fail from over voltage, it is a real problem.
6. The limited processing capability makes it quite hard to add function output support on the single GPIO port in the 12F629. It would be a lot easier to do in a faster processor (12F683) or one of the 14-pin variants which include Port C (16F630 and 16F676). If you need function outputs in a DIY decoder you will need to look at Heiko Schroeter's original design and extend that a bit.
7. The DIY motor decoder has only been made available due to popular demand, and it is quite popular. It is quite basic but still better than most £10 decoders available in the shops if you have room for it. If you want a really good decoder you will need to buy a Zimo or make a MERG DIY one. I do not have the resources to develop motor drive as good as a Zimo!
Most of the DIY decoders available have specific advantages. Mine is cheap and easy to build, Heiko Schroeter's is small enough for Z gauge, MERG has high motor performance, and most of the others are just simple and basic. You need to know what you want from a decoder in order to choose which of the available designs is best for you, and you need to look at what you are trying to achieve before you start out on a new design.
Have fun.
|
|
|
Post by Jon Benn on Feb 18, 2013 9:54:32 GMT
I've made a good old number of Paul's excellent decoders (thanks Paul!) and am now toying with the idea of adding load compensation using back EMF sensing.
I know I could use the MERG circuits but I've grown attached to Paul's circuits and have a ready supply of 629 & 675 PICS.
My thought is to add a secondary PIC12F675 between the decoder and the motor driver. This will take as inputs the FORWARD & REVERSE signals from the decoder and stretch/reduce appropriately as a result of comparing the back EMF and the input pulse length. The two outputs will form the input to the L272.
My gut feeling is it should work and I'll knock up the PIC code this week but wondering if anyone else has tried this approach and curious how they got on?
|
|
|
Post by Paul Harman on Feb 18, 2013 11:57:05 GMT
The 12F675 has analogue input so could do it, but I think if I was looking to add BEMF I would look at porting the motor decoder code to a 12F683 (quite easy and twice as fast) or 12F1840 (more tricky but eight times as fast) and using the 'spare' pins (1 and 4) as analogue inputs to sense the back EMF and control the motor feedback loop using the extra processing power (one 12F683 is equivelent to two 12F675).
The 12F683 is as fast as the MERG decoder so similar motor performance should be possible in a chip less than half the size (MERG use an 18-pin chip with external resonator), the 12F1840 should be an interesting solution though, it is awsome!
|
|
|
Post by Jon Benn on Feb 18, 2013 12:41:43 GMT
Hello Paul Yes good points - I was always eager to avoid the 18pin + xtal MERG chip. Looking through the code to port to 12F683 my only concern is retaining the timing.
Are all the timing critical elements marked as such with eg ";20,21"? If so I reckon I'll have a bash. Thanks again
|
|
|
Post by Paul Harman on Feb 18, 2013 14:44:02 GMT
Yes, all the timing critical bits are counted in instruction cycles. The 12F683 can be configured for 4MHz clock so you can check the porting before changing the timing part.
When you increase the clock speed up to 8MHz, just add 22 NOPs in to each leg of the loop (value subroutine and speed macro), and use the NOPs in the speed macro for the space for your BEMF code. Each loop will then count to 44.
If at the same time you want to use the internal PWM generator to drive the motor and save code, you can because it outputs on pin 5.
|
|
|
Post by Jon Benn on Feb 26, 2013 10:06:54 GMT
Have got some pic12f1840 on order, but in the meantime I knocked up a 675 as the 'Bemf sensor / pulse adjuster' and seems to work nicely (.asm attached in case of use to anyone). Haven't realised the 1840 existed before but got me thinking/distracted about making a diy sound decoder - I see people have connected it up to an SD card to play WAV files, latest thought is one of your 14 pin decoders tweaked to output the 'speed' on PORTC and using a 14 pin 1840 equivalent (pic16f1824 ?) to react to 5 digital I/O lines and play the relevant 'chuff'. I think it'll work and be cheap. A tangent from the motor decoders but worth a thought I think. Attachments:
|
|
|
Post by Paul Harman on Feb 26, 2013 12:26:22 GMT
Excellent that you have the BEMF working.
It is probably easiest to use PORTC for the inputs/SD interface/sound out and keep the motor outputs where they are. There should be a nice lot of processing power in the 12F1840 to do sound. 16F1824 and 16F1828 are respectively the 14-pin and 20-pin equivelents and should be broadly compatible with the same code.
|
|