|
Post by phillby on Nov 16, 2013 21:24:07 GMT
Hi, I have built the 2 output accessory decoder on a printed circuit- board which I plan to post when I can prove it works. I have no feedback (reading) transistor (my supplier does not stock so am waiting for an OS order to arrive) but I believe it should not prevent operation.
I have an NCE Power Cab. I have DCCConcept Cobalt DCC switch machines and to operate them it is a matter of selecting Accessory the number <enter> and then selecting one or two for operation of normal or reverse.
I tried addresses one two and three selecting both one and two but had no luck.
I guess I am too much of a novice and have to perform other setup routines. Could someone please assist. Hopefully it may be helpful to other novices also.
Cheeers Brian
|
|
|
Post by Paul Harman on Nov 17, 2013 1:27:35 GMT
You are correct that leaving out the feedback transistor will not prevent operation, merely prevent being able to read back CV values.
To operate a Cobalt or similar on the solenoid accessory decoder will require a pair of resistors between the positive supply (common) terminal and the two outputs. The value of resistor will determine the speed the Cobalt operates at and I do not have a Cobalt to see what will be suitable. I would recommend that you try a pair of 220R 1W resistors to start with and see how the Cobalt operates, if it is a bit slow reduce the value and if a bit fast increase it. Reducing the value of the resistors will require that they are rated for higher power. There is a lot of heat generated using this method and a CDU cannot be used.
To operate the decoder with NCE you will need to change the decoder address. Setting CV1=2 should get you up and running on turnout address 1 on the NCE. The default address of the decoder (as mandated by the NMRA when CV1=1) cannot be accessed by the NCE command station.
For operating Cobalts you will be better off with the motor decoder fitted with accessory firmware. There is a slight circuit modification required to the motor decoder - merely connecting pin 5 of the L272 to pin 2 of the PIC instead of pin 5. The cobalt then connects to the decoder's motor terminals.
If using lower power slow motion motors like the Tortoise you can use the low power function decoder with accessory firmware, but unfortunately the Cobalt is a bit of a power hungry beast and requires more current and voltage than this method can provide.
|
|
|
Post by phillby on Nov 17, 2013 3:18:25 GMT
Thanks for your reply. I am not trying to operate the cobalt with the accessory decoder as it is already DCC. I was just using it as an example to show how the NCE Operated a switch motor. At this stage I am just trying to get a reaction out of the decoder checking yoltage as I try it. I will be using them to switch Bachmann points coils built into the points. I will be using the two output accessory decoder as drawn but am still waiting on parts. Just playing in the meantime to prove PCB. I will try changing CV1 when I finish other chores, its the middle of the day here. Once I change CV1 will activating Accessory one and then selecting 1 activate Output A on the Pic and then accessory one and selecting 2 activate B or am I still lost
Thanks again Paul' Brian
Brian
|
|
|
Post by Paul Harman on Nov 17, 2013 9:44:57 GMT
Just change CV1 to 2 (and possibly CV33 to 15) then you should be able to toggle the outputs. For solenoids you will have to change CV3 as well to set a pulse length before you connect the solenoids.
|
|
|
Post by phillby on Nov 17, 2013 10:39:34 GMT
Hi again, I have had another play. No Luck. When trying to program CV1 to 2 the NCE asks for the Accessory No. then the CV No then the Value. Aren't we trying to set the Accessory No. so what do I put in to address the decoder first up. Sorry but (my Dumb).
I Programmed the 12F675 with the new firmware provided after my original posts.
I am using the DIY K150 PICMicro USB programmer and Software. When scrolling through the PIC Hex File within the PIC Programmer while i was originally programming it I saw what was labeled as EEprom Data at that stage I think it looked blank, all FF's.
I have just inspected the Pic in the programmer and now I see.
01 01 FF 00 00 00 00 06 0D 00 FF FF FF FF FF FF
There is more further down but I won't continue. Does this mean that the Micro is working as the data has changed? Have these been changed by the Pic at startup or by the NCE. I ask because until I get a response at the output I have no Idea if I have done something wrong, other than by rechecking the circuit again.
Is this where the CV data is stored and if so can I set it up by editing the PIC data?
Sorry for all the confusion on my part but hopefully I will learn.
Cheers Brian.
|
|
|
Post by Paul Harman on Nov 17, 2013 21:26:30 GMT
Seeing the EEPROM data change does indicate that the PIC has programmed correctly and is running. At first boot it does a factory reset and sets all of the CVs to the manufacturer default.
The EEPROM data maps exactly to the CV numbers. Location 00 is the page register used in paged mode programming, but the rest are all CVs.
EEPROM location 01 contains the contents of CV1, as you can see 01. Just change this to 02 and you will have changed the address to be compatible with the NCE command station as accessory 1, change it to 03 and it will be accessory 5.
|
|
|
Post by phillby on Nov 17, 2013 23:32:31 GMT
Hi, More Snags, While I can read the eeprom data I can't change it, I can change the programm bytes. I thought I may have been able to save the file and change it in an editor but the eeprom data is either not saved or my programmer does not load it. So now I can't change the data directly and an NCE can't change the device until CV1 is set to 2. It appears that the NCE cannot access CV1 because the decoder address is 0 and NCE will not access address zero.
I have since tried on the program track which I just worked out. The NCE does not need the Accessory No in this mode just the CV No and the value but still no luck. It tries to read in this mode first, I don't know if this is causing a problem when it gets no answer. Trying to program CV 2 did not work either.
Could I use a BC547 8 or 9 here instead of the BC182L
I used 1N914's instead of 1N4148's as that was all that was available and was told they were equivalent
Can you think of how I can progress.
Thanks again for all your help. Brian
|
|
|
Post by Paul Harman on Nov 18, 2013 11:54:44 GMT
1N914 is a good replacement for the diodes and BC547/8/9 will be a good replacement for the BC182L (just note that the pinout is different).
I cannot really help with your PIC programmer, but you should be able to read the PIC contents and export to a .HEX file, modify the .HEX file to include the change to CV1=02 (you might have to modify another CV like CV2=FE to save having to recalculate the checksum), then reload.
The DIY decoder does not support operations mode programming (programming on the main) so to make CV changes with the NCE you will have to use the programming track. Without the transistor you will get an error on the NCE, but if you use register or address only mode you should be able to change the address. Direct mode should work as well.
|
|
|
Post by phillby on Nov 18, 2013 22:17:12 GMT
Thanks for the reply. Unfortunately when I read the Pic it shows the EEprom contents but does not write the contents to the file, only the program aera. So changing the value in a file is not available to me. I don't think that it would read it in any way. I haven't had a chance to try anything else but will try to insert a transistor and see if I can read anything. Cheers Brian
|
|
|
Post by phillby on Dec 11, 2013 12:12:55 GMT
Hi again, it's been awhile but I thought that I would wait until my components arrived and try to see if the 12F629 would work, clutching at straws I am. I finally worked out how to modify the Eeprom Data. it turned out you had to erase the value before typing the new value. So I have been able to change address 01 to 02 as required by the NCE. I still am having no luck. Does the Auxilliay decoder operate by entering the Accessory No (say 1 in this case and then entering a one to activate it and then a two to deactivate it. Which pin on the pic is Accessory No1 is it pin 2 or pin 3. I imagine pin 2. If so then what is pin 3. OK I brought out the big guns now (not quite) and put an oscilliscope across pins 6 & 7 on the pic as I think that that is where the data is received. It was set at .5V/DIV and 5ms/DIV. A snap of the screen is attached. I used the resistor dividing network values from the Function Decoder Ver 2.18 i.e. 10K & 1K . I hope we can get to the bottom of this. I don't know what to try next. Thanks Brian the Ozzie Attachments:
|
|
|
Post by Paul Harman on Dec 11, 2013 20:46:50 GMT
Brian
When you activate accessory 1 you should see pin 2 go high and pin 3 go low, deactivating it will see pin 3 go high and pin 2 go low. There are other ways of configuring it but that is what you would normally expect to see.
Looking at your scope trace I am not surprised that things are not working. The signal needs to be a lot cleaner than that. If you have a differential probe or your scope has a differential mode (common on analogue scopes but not so on digital ones) you might see a cleaner signal, and will definitely see what the PIC is seeing.
Not sure why the signal is looking so unclean, but it could possibly be due to problems around D2 and C4. Might also be due to using an earthed scope and having an earthed power supply on the NCE. What does the track signal look like on the red and black wires?
|
|
|
Post by phillby on Dec 12, 2013 12:29:03 GMT
Thanks Paul, My scope is not the greatest and may be part of the problem I am having trouble triggering the signal so it is stable. The NCE is powered by a switchmode plugpak with no ground pin,(it could be earthed via the neutral and the power system. I was unable to trgger the scope on the track signal but it looks OK. I also can't lock to the DCC Signal super imposed on the track power. Scopes fault I believe, It's very basic. However I have taken two shots one of pin 6 to the negative rail (pin 8) and one of pin 7 to the same point. I have croped the snaps to reduce the size of the files and left them as Jpegs. The Scope was set at 0.5 V/Div and 2mV/Div. My concern is that both voltages to "ground" are only 1.3V. Is this enough for the PIC.
|
|
|
Post by phillby on Dec 12, 2013 12:30:51 GMT
Here's Pin 6 to "Ground" Cheers Brian the Ozzie. Attachments:
|
|
|
Post by phillby on Dec 12, 2013 12:33:53 GMT
Here's Pin 7n to "ground" Cheers again Brian the Ozzie Attachments:
|
|
|
Post by Paul Harman on Dec 12, 2013 16:29:18 GMT
The waveforms look good. If you can do it - it is nice to have both pins on the screen at once to verify that one is inverted compared to the other, but 1.3V is more than adequate - it will work with much much lower than that. Triggering is very tricky when there is no clock to lock on to.
If the waveforms turn out to not be inverted with respect to one another temporarily short R3 or R4 to see if that makes a difference and check the connctions at the other end of R1 and R2.
|
|
|
Post by phillby on Dec 13, 2013 11:24:00 GMT
Hi Paul. Once again triggering was a problem but I have managed to capture a shot of the input at both pins. If I expand the timebase I am unable to lock the waveform.The voltage gain was adjusted to get the best picture. It is of channel 1 & 2 it will be chopped so at finite different time. The scope is old and basically analogue TV resolution. I worked in Television. I will include the shot here with the next post showing ADD 1 + 2 with the gains adjusted to show the slight changes. I don't know if it helps but it also seems to show the inversion. Cheers Brian the Ozzie. Attachments:
|
|
|
Post by phillby on Dec 13, 2013 11:37:49 GMT
Hi, On looking further I don't know if the inputs are inverted or just different. The other shot is included here but I don't know if it means anything. Cheers Brian the Ozzie. Attachments:
|
|
|
Post by Paul Harman on Dec 13, 2013 17:06:30 GMT
Brian
Post 16 is showing the type of thing that should be present if you have both channels set to the same gain and one of them inverted.
That trace appears to show a bit of preamble (a series of '1' bits), a start bit (the longer '0' bit) and the start of some data (more '1's).
The trace looks clean enough that it should be decodable.
Just a few quick thoughts:-
1. Is pin 4 linked to pin 5?
2. Does your programmer preserve the oscillator configuration value? Might be worth checking that the oscillator configuration value is OK.
|
|
|
Post by phillby on Dec 14, 2013 4:50:46 GMT
Here we go again. Pins 4 & 5 are linked with the feed resistor to the base of the transistor. I don't think the programmer changes the fuses, but in my still novice state I do not know what is needed. I have included a picture of the screen in the fuses menu. The display is after reading the PIC so I think it has been read from memory. The option "INTOSC IOGP4 IOGP5" is what I think is active. I will also post a snap of the board. It is all a bit out of focus (maybe a lot), the Blackberry is not too good at close up. Cheers, Brian the Ozzie. Attachments:
|
|
|
Post by phillby on Dec 14, 2013 4:57:26 GMT
And Now the Board. I have reduced the size slightly since making this one and will post when we find the problem(s). I think the next step is to post the Board layout with the actual components that I have used to see if you can spot any problem. I will suggest no-one use until the problem is sorted. Attachments:
|
|
|
Post by phillby on Dec 15, 2013 8:43:53 GMT
Paul, I have been busy and produced a layout with the components shown that I have used to build an Accessory Decoder using a 12F629 PIC. Please fellow board members don't use this board until we sort out the problem. I will then post a 1:1 PCB Layout in a couple of versions. Of course if anyone can spot a problem I will be most grateful for the advice. Cheers Brian the Ozzie. Attachments:
|
|
|
Post by Paul Harman on Dec 15, 2013 11:29:46 GMT
Brian
The PCB layout looks fine.
As well as the fuses you have to make sure that the oscillator calibration value in the top memory location which is programmed by Microchip in the factory is retained at the factory value. If you have a programmer that either does not retain this value or allows overwriting you could come unstuck - best to read out this value and put it on a sticker under the PIC to make restoration later easier.
The calibration value will be lost if you erase the PIC, and you will have to restore it. If you are completely stuck you can probably copy the value from another 12F629 from the same batch if you have an unused one lying about and it should be close. PIC programmers that are aware of the internal oscillators on flash devices can usually regenerate the calibration value and will usually retain it and reprogram it when doing an erase but some older programmers don't do this and leave you a bit stuck if you are not aware of the issue. The calibration value is in program location 3FF.
As a test you can change the oscillator fuses to use the next option up in the list and that will output a 1MHz square wave on Pin 3 instead of the usual output which you can measure with your scope or a frequency counter to ensure that it is exactly 1MHz. If it is out you can adjust the value returned by the RETLW instruction at location 3FF. Value at location 3FF will be 4xx where xx is the calibration value between 00 and FF.
|
|
|
Post by phillby on Dec 16, 2013 8:24:37 GMT
EUREKA!!! Paul I am glad you are so conversant with PIC's. It did turn out that the calibration bits had been erased and replaced with 34FF. I had more PIC's for use later. I read the value and promptly erased it until I found the option to write the value from the file. It also worked on the earlier one, so all is good. I put in the transistors and now the LED's light in sequence. I have not had any luck with the 12F675 yet.
I am a bit confused with the addressing in CV 1 I know that a value of 2 is Decoder Address 1 a value of 3 is Decoder Address 5 could I have more guidance please.
I Know that varing CV 3 increases the on time of the output but what about CV 4 5 & 6 are they to increase the time greater than 1.44 secs..
Lots of the other CV Number Values do not make much sense to me but I guess I don't need them at this stage of my DCC journey.
Thanks muchly for your patience I guess the post may help someone else who is as inexperienced as I am so it shoud not be in vain.
When I post the art work can I put more than one attachment per post or do I need to separate them.
Cheers Brian the Ozzie.
|
|
|
Post by Paul Harman on Dec 16, 2013 12:21:00 GMT
Excellent news Brian.
Best practice now would be to read out the calibration values on your new PICs and stick them on the PICs in case you need them again.
I have never had to do more than one attachment so try it and see.
The addressing in CV1 is as per the (slightly woolly) NMRA specification, so 1=first block of four addresses (1-4), 2=second block of four addresses (5-8) 3=third block (9-12) etc. Some (most!) command stations ignore the first block and start with accessory 1 is the first accessory in the second block such that CV1=2 gives accessories 1-4 and CV1=1 is inaccessible.
The original NMRA specification expects all accessory decoders to have four pairs of outputs, which as you know is not always the case (yours only have one pair). There is a revision to the specification called Output Address Mode (as opposed to Decoder Address Mode which is the default) which you can select by setting CV29 to 192.
In output address mode you will find that CV1 will be 1 for accessory 1, 2 for accessory 2 etc. apart from the fact that your command station's numbering is out by four so that CV1=5 will be accessory 1, CV1=6 accessory 2 etc. When you have got more than 250 decoders start looking at adjusting CV9 as well to get the rest of the addresses.
CV3 adjusts the on time of the first pair, CV4 the second pair (not present on your decoder) CV5 the third and so on. You can just ignore CV4-6.
CV33 is the other important one which controls how the outputs respond to the accessory packets. You can configure both outputs to be momentary for as long as you press the button (handy for uncouplers etc. and a rare decoder feature) or you can set them to toggle as a pair, or you can set them to not retrigger. CV33=15 makes the decoder work as most people would expect it to and prevents solenoid burnouts if your Lenz command station crashes (a common problem).
Generally speaking if you don't know what a CV does just leave it at the default until you need to worry about it.
The same code should work in the 12F675. The only difference is the analogue inputs which are enabled by default and have to be disabled to prevent them interfering with the inputs and outputs. The downloadable firmware includes the code to disable the analogue if present.
Take a look at the NMRA specs to understand what most of the CVs do. Probably best to play with the special effect, inversion and brightness CVs to se the effect they have.
It might be worth thinking about laying out your PCBs for 14-pin PICs. You can always just put an 8-pin PIC in the same footprint aligning pin 1 if you do not need the other six outputs.
|
|
|
Post by phillby on Dec 18, 2013 11:03:43 GMT
Hi Paul, I have been busy very busy. Again I implore fellow Forum Members not to use the designs for a while until they have been checked. I hope there are no errors but the components are not the ones specified. the completed ones will refer back to generic numbers like R2 and U3. Could you check the layouts and let me know of any mistakes or suggestions. The boards are a lot larger than their Veroboard equivalents, but for an oldie I think easier to handle. I can progress down the road to the larger PIC with Opto Isolators. The only tricky bit is the wire jumper under the PIC to supply the positive volts. It will be fine if machined pin sockets are used. I hope when I have finished the PCB's they are of use to the community. Just an observation, the internet tells me that TLP621-2's are obsolete and a better replacement are PS2501-2's. Now a couple of questions, with the larger PIC's do they have an Oscillator calibration "word". I am sure that the 12F675 has the wrong Occillator "word" so I will try and figure it out as suggested when I get some time. I notice when I start the Accessory Decoder that issuing the one which would set the Points to Normal has no effect Issuing the 2 does then after that alternate 1's & 2's act as expected. "Why is it So?" We had a Television Phisics Professor "Julius Sumner Miller" who used to utter those words when he posed a question. Thanks & Cheers Brian the Ozzie. Attachments:
|
|
|
Post by Paul Harman on Dec 18, 2013 19:51:08 GMT
Brian
I would have got rid of the links in the power tracks by running the power track under the resistors instead, it will simplify construction and reliability a lot.
I have noticed that the TLP621 appears to be shown as obsolete in places too, but there are still supplies available. I will look at the PS2501 and see.
All PICs with internal oscillators (generally 6-pin, 8-pin, 14-pin and 20pin devices) have a calibration word so need to be treated with the same care.
It is the case that depending on the setting of CV33 the saved state is checked to see what it is before activating the output. At start up the saved state may not match the outputs so the first change of state may be ignored. Use the start up state CV (CV37) to set the desired normal value and all will be well after a decoder reset.
|
|
|
Post by Paul Harman on Dec 19, 2013 0:43:56 GMT
There does not appear to be a sensible replacement for the TLP621-2. It is madness that Toshiba have discontinued the TLP621 family - but looking in my component store it looks like most of what I have are pattern parts from other manufacturers which will probably still be available.
A couple of PS2501-1 or a couple of TLP781 will replace one TLP621-2 in the 2-output accessory decoder.
For the 8-output accessory decoder you can use eight TLP781, eight PS2501-1 or two PS2501-4.
Note that the TLP781F version has wider spaced legs than the TLP781 that will need to be bent in to fit the same PCB layout - but it might be worth the effort since they are available at a quarter of the price!
|
|
|
Post by bblackman on Dec 19, 2013 4:38:54 GMT
Would a ILD615 be a good replacement for the discontinued TLP621-2? I am in the process of making the acessory decoder and have ordered the ILDQ615.
|
|
|
Post by Paul Harman on Dec 19, 2013 11:41:10 GMT
The TLP621 was chosen for its very good current transfer ratio, the ILD615/ILQ615 might not have enough current gain for high outputs and it might be necessary to select a higher gain transistor for the output driver and/or adjust the value of the LED series resistor to compensate if high currents are required to be switched.
Careful selection of the LED series resistor in the 120R-150R region should ensure that the LED is driven at 20-25mA, and the TIP122 with a current gain of around 1000 should provide 8A to drive a pair of Peco solenoids for example.
Insufficient gain in the circuit will result in excessive heating of the output transistors and reduced current available to drive the load.
The total gain of the circuit can be calculated from LED current x opto isolator gain x transistor gain so for example for a typical TLP621 with 220R LED series resistors you would have:-
0.013 x 1 x 1000 = 13A
For a ILD615 with a 150R series resistor you would have:-
0.02 x 0.4 x 1000 = 8A
So as you can see it is cutting things a bit fine in the worse case scenario. You might be lucky and have one of the better grade ILD615 and not have to worry - if you can select the versions with a gain of at least 1 (the ILx615-3 or ILx615-4) there will be no problem and the system will have adequate gain.
|
|
|
Post by phillby on Dec 19, 2013 13:02:40 GMT
Paul The PS2501 comes in a 2 pack version I got some from my OS Supplier. PS2501-2 You will notice that I have used them on my PCB.I have also completed the High current Version of the Accessory Decoder. I used your Suggestion about the power tracks. I was bad because I only have one feed in point for the CDU Supply to save external wiring. However this requires 10 jumpers. I prefer this but could have separate feeds for each. I could extend each track and let the user decide. I think the collector to collector Jumpers will need to remain. If you think that these are satisfactory I will post 1:1 drawings with a "how to" describing how I make a PCB. Please do not use the attached in this post. I have put up a modified circuit correcting mistakes in a new post. Cheers Brian the Ozzie Attachments:
|
|