Jump to content
 

Blog- Steam_Julie's Layout Blog - Getting Control


RSS Fetcher

Recommended Posts

Hi

 

This project is intended to enable the control of 2 points using solenoid point motors and another accessory using a standard Hornby 3 function DCC loco decoder.

 

The main layout controller for the layout is a Bachmann Easy Controller.

 

To achieve the above functionality, I have decided to use address 9. A standard loco decoder is programmed to address 9. This has 3 function outputs F0, F1 and F2. These are standard digital 0 – 5v with a driving capacity of 20 mA, either ON or OFF.

 

We require a transition from 0 to 1 to give a short pulse 0 – 12v with about 0.5A output. Simularly a transition from 1 to 0 to give a short pulse 0 -12v with about 0.5A output. See diagram below.

 

My intention is to use a PIC P16C71 microcontroller as the basis of my design. This has 18 pins and

has 2 ports which can be configured as either input or output. The following listing in pseudo code defines the functionality.

 

 

Program Main

 

Lable        Function                Comment

 

Initialise:    .org    00                   ;Set the start address f program    

        Setup input as RA and output as RB    ;Initialse the microcontroller ports

 

Funct_0    RA1               ;DCC decoder function 0

Funct_1    RA2                   ;DCC decoder function 1

Funct_2    RA3                           ;DCC decoder function 2

 

AOut_11    RB1                   ;Acessory 1 Pos 1

AOut_12    RB2                          ;Acessory 1 pos 2

AOut_21    RB3                                  ;Acessory 2 Pos 1

AOut_22    RB4                                 ;Acessory 2 Pos 2

AOut_31    RB5                          ;Acessory 3 Pos 1

AOut_32    RB6                                 ;Acessory 3 Pos 2

 

        AOut_11 = 1; AOut_12 = 0        ;Set Acessory 1 to known state

        Call Subroutine Pulse

        AOut_11 = 0; AOut_12 = 0

 

        AOut_21 = 1; AOut_22 = 0        ;Set Acessory 2 to known state

        Call Subroutine Pulse

        AOut_21 = 0; AOut_22 = 0

 

        AOut_31 = 1; AOut_32 = 0        ;Set Acessory 3 to known state

        Call Subroutine Pulse

        AOut_31 = 0; AOut_32 = 0

        

Start:        if Funct_1 = 1 then Reg_5 = 1

              Call Sub Set

        if Funct_2 = 1 then Reg_5 = 2

              Call Sub Set

        if Funct_3 = 1 then Reg_5 = 3

              Call Sub Set

        if Funct_1 = 0 then Reg_5 = 1

               Call Sub Reset

        if Funct_2 = 0 then Reg_5 = 2

               Call Sub Reset

        if Funct_3 = 0 then Reg_5 = 3

               Call Sub Reset

 

        goto Start

 

Subroutine Set                                      ;Acessory Number in Reg_5

 

Set:  if Reg_5 = 1 then AOut_11 = 1

           AOut_12 = 0

           Call Sub Pulse

           AOut_11 = 0

           AOut_12 = 0

 

        if Reg_5 = 2 then AOut_21 = 1

           AOut_22 = 0

           Call Sub Pulse

           AOut_21 = 0

           AOut_22 = 0

 

        if Reg_5 = 3 then AOut_31 = 1

           AOut_32 = 0

           Call Sub Pulse

           AOut_31 = 0

           AOut_32 = 0

 

        Return

 

Subroutine Reset                                                ;Acessory Number in Reg_5                

 

        if Reg_5 = 1 then AOut_11 = 0

           AOut_12 = 1

           Call Sub Pulse

           AOut_11 = 0

           AOut_12 = 0

 

        if Reg_5 = 2 then AOut_21 = 0

           AOut_22 = 1

           Call Sub Pulse

           AOut_21 = 0

           AOut_22 = 0

 

        if Reg_5 = 3 then AOut_31 = 0

           AOut_32 = 1

           Call Sub Pulse

           AOut_31 = 0

                    AOut_32 = 0

 

        Return

 

Subroutine Pulse                                     ;Define the length of output plulse

 

Lable        Function                Comment

 

Pulse:        Move ff into Reg_3                ;This delay will have to be increased

Loop:        if Reg_3 = 0 then Return        ;Time approx 50 mSec

           else decrement Reg_3

           goto Loop        

 

With Functions 1 and 2 off, both of the points in the goods yard are set to normal, this means that the main line is set to straight, ie straight through. The second point is also set strait too. To select the road into siding no, 1 you are required to select funtion 1 ON and function 2 OFF and for road 2 selection function 1 ON and function 2 ON.

 

To aid the points going over correctly, capacitance discharge circuits are added. The resistor in this circuit is to limit the charging current. The discharge current is only limited by the emitter collector resistance, and since the transistor is switched fully on, this is negligible!

 

I now need to convert the pseudo code, into assembly language, then asemble it and then download it to the PIC P16C71 and then test it. I could have used wire and tube, but where is the FUN in that!

 

Julie

 

View the full article

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...