diff --git a/examples/SMA/AccDec_10Servos_7LED_6Ftn/AccDec_10Servos_7LED_6Ftn.ino b/examples/SMA/AccDec_10Servos_7LED_6Ftn/AccDec_10Servos_7LED_6Ftn.ino old mode 100755 new mode 100644 index 68798d4..cb34d32 --- a/examples/SMA/AccDec_10Servos_7LED_6Ftn/AccDec_10Servos_7LED_6Ftn.ino +++ b/examples/SMA/AccDec_10Servos_7LED_6Ftn/AccDec_10Servos_7LED_6Ftn.ino @@ -1,5 +1,5 @@ // Production 17 Switch Acessory DCC Decoder AccDec_10Servos_7LED_6Ftn.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses for CV Control Default 24 (LSB CV 121 ; MSB CV 122) // ACCESSORY DECODER DEFAULT ADDRESS IS 40 (MAX 40-56 SWITCHES) // ACCESSRY DECODER ADDRESS CAN NOW BE SET ABOVE 255 @@ -82,12 +82,15 @@ CVPair FactoryDefaultCVs [] = {CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0}, {CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, 0}, + // Speed Steps don't matter for this decoder // ONLY uncomment 1 CV_29_CONFIG line below as approprate DEFAULT IS SHORT ADDRESS -// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps - {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps -// {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps - + // {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps + // {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps + // {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps + {CV_29_CONFIG,CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_F0_LOCATION}, // Accesory Decoder Short Address + // {CV_29_CONFIG, CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Accesory Decoder Long Address + {CV_DECODER_MASTER_RESET, 0}, {CV_To_Store_SET_CV_Address, SET_CV_Address&0xFF }, // LSB Set CV Address {CV_To_Store_SET_CV_Address+1,(SET_CV_Address>>8)&0x3F }, //MSB Set CV Address @@ -216,7 +219,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 100, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); + Dcc.init( MAN_ID_DIY, 601, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); delay(800); #if defined(DECODER_LOADED) diff --git a/examples/SMA/AccDec_13Servos_4LED_6Ftn/AccDec_13Servos_4LED_6Ftn.ino b/examples/SMA/AccDec_13Servos_4LED_6Ftn/AccDec_13Servos_4LED_6Ftn.ino old mode 100755 new mode 100644 index a6cf15b..e84a12e --- a/examples/SMA/AccDec_13Servos_4LED_6Ftn/AccDec_13Servos_4LED_6Ftn.ino +++ b/examples/SMA/AccDec_13Servos_4LED_6Ftn/AccDec_13Servos_4LED_6Ftn.ino @@ -1,6 +1,6 @@ // Production 17 Function DCC Decoder // Production 17 Switch Acessory DCC Decoder AccDec_13Servos_4LED_6Ftn.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses for CV Control Default 24 (LSB CV 121 ; MSB CV 122) // ACCESSORY DECODER DEFAULT ADDRESS IS 40 (MAX 40-56 SWITCHES) // ACCESSRY DECODER ADDRESS CAN NOW BE SET ABOVE 255 @@ -82,12 +82,15 @@ CVPair FactoryDefaultCVs [] = {CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0}, {CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, 0}, + // Speed Steps don't matter for this decoder // ONLY uncomment 1 CV_29_CONFIG line below as approprate DEFAULT IS SHORT ADDRESS -// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps - {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps -// {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps - + // {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps + // {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps + // {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps + {CV_29_CONFIG,CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_F0_LOCATION}, // Accesory Decoder Short Address + // {CV_29_CONFIG, CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Accesory Decoder Long Address + {CV_DECODER_MASTER_RESET, 0}, {CV_To_Store_SET_CV_Address, SET_CV_Address&0xFF }, // LSB Set CV Address {CV_To_Store_SET_CV_Address+1,(SET_CV_Address>>8)&0x3F }, //MSB Set CV Address @@ -217,7 +220,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); + Dcc.init( MAN_ID_DIY, 601, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); delay(800); #if defined(DECODER_LOADED) diff --git a/examples/SMA/AccDec_15Servos_2LED_6Ftn/AccDec_15Servos_2LED_6Ftn.ino b/examples/SMA/AccDec_15Servos_2LED_6Ftn/AccDec_15Servos_2LED_6Ftn.ino old mode 100755 new mode 100644 index f6e407b..109e843 --- a/examples/SMA/AccDec_15Servos_2LED_6Ftn/AccDec_15Servos_2LED_6Ftn.ino +++ b/examples/SMA/AccDec_15Servos_2LED_6Ftn/AccDec_15Servos_2LED_6Ftn.ino @@ -1,5 +1,5 @@ // Production 17 Switch Acessory DCC Decoder AccDec_15Servos_2LED_6Ftn.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses for CV Control Default 24 (LSB CV 121 ; MSB CV 122) // ACCESSORY DECODER DEFAULT ADDRESS IS 40 (MAX 40-56 SWITCHES) // ACCESSRY DECODER ADDRESS CAN NOW BE SET ABOVE 255 @@ -81,12 +81,15 @@ CVPair FactoryDefaultCVs [] = {CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0}, {CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, 0}, + // Speed Steps don't matter for this decoder // ONLY uncomment 1 CV_29_CONFIG line below as approprate DEFAULT IS SHORT ADDRESS -// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps - {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps -// {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps - + // {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps + // {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps + // {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps + {CV_29_CONFIG,CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_F0_LOCATION}, // Accesory Decoder Short Address + // {CV_29_CONFIG, CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Accesory Decoder Long Address + {CV_DECODER_MASTER_RESET, 0}, {CV_To_Store_SET_CV_Address, SET_CV_Address&0xFF }, // LSB Set CV Address {CV_To_Store_SET_CV_Address+1,(SET_CV_Address>>8)&0x3F }, //MSB Set CV Address @@ -216,7 +219,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); + Dcc.init( MAN_ID_DIY, 601, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); delay(800); #if defined(DECODER_LOADED) diff --git a/examples/SMA/AccDec_17LED_1Ftn/AccDec_17LED_1Ftn.ino b/examples/SMA/AccDec_17LED_1Ftn/AccDec_17LED_1Ftn.ino old mode 100755 new mode 100644 index a8c8fbf..b10cf7f --- a/examples/SMA/AccDec_17LED_1Ftn/AccDec_17LED_1Ftn.ino +++ b/examples/SMA/AccDec_17LED_1Ftn/AccDec_17LED_1Ftn.ino @@ -1,5 +1,5 @@ // Production 17 Switch Acessory DCC Decoder AccDec_17LED_1Ftn.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses for CV Control Default 24 (LSB CV 121 ; MSB CV 122) // ACCESSORY DECODER DEFAULT ADDRESS IS 40 (MAX 40-56 SWITCHES) // ACCESSRY DECODER ADDRESS CAN NOW BE SET ABOVE 255 @@ -56,12 +56,15 @@ CVPair FactoryDefaultCVs [] = {CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0}, {CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, 0}, + // Speed Steps don't matter for this decoder // ONLY uncomment 1 CV_29_CONFIG line below as approprate DEFAULT IS SHORT ADDRESS -// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps - {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps -// {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps - + // {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps + // {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps + // {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps + {CV_29_CONFIG,CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_F0_LOCATION}, // Accesory Decoder Short Address + // {CV_29_CONFIG, CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Accesory Decoder Long Address + {CV_DECODER_MASTER_RESET, 0}, {CV_To_Store_SET_CV_Address, SET_CV_Address&0xFF }, // LSB Set CV Address {CV_To_Store_SET_CV_Address+1,(SET_CV_Address>>8)&0x3F }, //MSB Set CV Address @@ -105,7 +108,7 @@ void setup() // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); + Dcc.init( MAN_ID_DIY, 601, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); } void loop() { @@ -116,4 +119,4 @@ extern void notifyDccAccTurnoutOutput( uint16_t Addr, uint8_t Direction, uint8_t if ( Addr >= Accessory_Address && Addr < Accessory_Address+17) //Controls This_Decoder_Address+16 digitalWrite( ledpins[Addr-Accessory_Address], Direction ); } - + diff --git a/examples/SMA/AccDec_17LED_6Ftn/AccDec_17LED_6Ftn.ino b/examples/SMA/AccDec_17LED_6Ftn/AccDec_17LED_6Ftn.ino old mode 100755 new mode 100644 index 99b6c28..ff2b934 --- a/examples/SMA/AccDec_17LED_6Ftn/AccDec_17LED_6Ftn.ino +++ b/examples/SMA/AccDec_17LED_6Ftn/AccDec_17LED_6Ftn.ino @@ -1,5 +1,5 @@ // Production 17 Switch Acessory DCC Decoder AccDec_17LED_6Ftn.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses for CV Control Default 24 (LSB CV 121 ; MSB CV 122) // ACCESSORY DECODER DEFAULT ADDRESS IS 40 (MAX 40-56 SWITCHES) // ACCESSRY DECODER ADDRESS CAN NOW BE SET ABOVE 255 @@ -81,12 +81,15 @@ CVPair FactoryDefaultCVs [] = {CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0}, {CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, 0}, + // Speed Steps don't matter for this decoder // ONLY uncomment 1 CV_29_CONFIG line below as approprate DEFAULT IS SHORT ADDRESS -// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps - {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps -// {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps - + // {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps + // {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps + // {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps + {CV_29_CONFIG,CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_F0_LOCATION}, // Accesory Decoder Short Address + // {CV_29_CONFIG, CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Accesory Decoder Long Address + {CV_DECODER_MASTER_RESET, 0}, {CV_To_Store_SET_CV_Address, SET_CV_Address&0xFF }, // LSB Set CV Address {CV_To_Store_SET_CV_Address+1,(SET_CV_Address>>8)&0x3F }, //MSB Set CV Address @@ -219,7 +222,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); + Dcc.init( MAN_ID_DIY, 601, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); delay(800); #if defined(DECODER_LOADED) diff --git a/examples/SMA/AccDec_7ServoBackandForth6Ftn/AccDec_7ServoBackandForth6Ftn.ino b/examples/SMA/AccDec_7ServoBackandForth6Ftn/AccDec_7ServoBackandForth6Ftn.ino old mode 100755 new mode 100644 index 3923248..131bab7 --- a/examples/SMA/AccDec_7ServoBackandForth6Ftn/AccDec_7ServoBackandForth6Ftn.ino +++ b/examples/SMA/AccDec_7ServoBackandForth6Ftn/AccDec_7ServoBackandForth6Ftn.ino @@ -1,5 +1,5 @@ // Production 17 Switch Acessory DCC Decoder AccDec_7ServoBackandForth6Ftn.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses for CV Control Default 24 (LSB CV 121 ; MSB CV 122) // ACCESSORY DECODER DEFAULT ADDRESS IS 40 (MAX 40-56 SWITCHES) // ACCESSRY DECODER ADDRESS CAN NOW BE SET ABOVE 255 @@ -85,12 +85,15 @@ CVPair FactoryDefaultCVs [] = {CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0}, {CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, 0}, + // Speed Steps don't matter for this decoder // ONLY uncomment 1 CV_29_CONFIG line below as approprate DEFAULT IS SHORT ADDRESS -// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps - {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps -// {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps - + // {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps + // {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps + // {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps + {CV_29_CONFIG,CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_F0_LOCATION}, // Accesory Decoder Short Address + // {CV_29_CONFIG, CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Accesory Decoder Long Address + {CV_DECODER_MASTER_RESET, 0}, {CV_To_Store_SET_CV_Address, SET_CV_Address&0xFF }, // LSB Set CV Address {CV_To_Store_SET_CV_Address+1,(SET_CV_Address>>8)&0x3F }, //MSB Set CV Address @@ -223,7 +226,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); + Dcc.init( MAN_ID_DIY, 601, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); delay(800); #if defined(DECODER_LOADED) diff --git a/examples/SMA/AccDec_7Servos_10LED_6Ftn/AccDec_7Servos_10LED_6Ftn.ino b/examples/SMA/AccDec_7Servos_10LED_6Ftn/AccDec_7Servos_10LED_6Ftn.ino old mode 100755 new mode 100644 index c888b63..859dbd5 --- a/examples/SMA/AccDec_7Servos_10LED_6Ftn/AccDec_7Servos_10LED_6Ftn.ino +++ b/examples/SMA/AccDec_7Servos_10LED_6Ftn/AccDec_7Servos_10LED_6Ftn.ino @@ -1,5 +1,5 @@ // Production 17 Switch Acessory DCC Decoder AccDec_7Servos_10LED_6Ftn.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses for CV Control Default 24 (LSB CV 121 ; MSB CV 122) // ACCESSORY DECODER DEFAULT ADDRESS IS 40 (MAX 40-56 SWITCHES) // ACCESSRY DECODER ADDRESS CAN NOW BE SET ABOVE 255 @@ -81,12 +81,15 @@ CVPair FactoryDefaultCVs [] = {CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0}, {CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, 0}, + // Speed Steps don't matter for this decoder // ONLY uncomment 1 CV_29_CONFIG line below as approprate DEFAULT IS SHORT ADDRESS -// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps - {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps -// {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps - + // {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps + // {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps + // {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps + {CV_29_CONFIG,CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_F0_LOCATION}, // Accesory Decoder Short Address + // {CV_29_CONFIG, CV29_ACCESSORY_DECODER|CV29_OUTPUT_ADDRESS_MODE|CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Accesory Decoder Long Address + {CV_DECODER_MASTER_RESET, 0}, {CV_To_Store_SET_CV_Address, SET_CV_Address&0xFF }, // LSB Set CV Address {CV_To_Store_SET_CV_Address+1,(SET_CV_Address>>8)&0x3F }, //MSB Set CV Address @@ -219,7 +222,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); + Dcc.init( MAN_ID_DIY, 601, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, CV_To_Store_SET_CV_Address); delay(800); #if defined(DECODER_LOADED) diff --git a/examples/SMA/Dec_10Serv_7LED_6Ftn/Dec_10Serv_7LED_6Ftn.ino b/examples/SMA/Dec_10Serv_7LED_6Ftn/Dec_10Serv_7LED_6Ftn.ino old mode 100755 new mode 100644 index cc97362..6c0ce05 --- a/examples/SMA/Dec_10Serv_7LED_6Ftn/Dec_10Serv_7LED_6Ftn.ino +++ b/examples/SMA/Dec_10Serv_7LED_6Ftn/Dec_10Serv_7LED_6Ftn.ino @@ -1,5 +1,5 @@ // Production 17 Function DCC Decoder -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses // NO LONGER REQUIRES modified software servo Lib // Software restructuring mods added from Alex Shepherd and Franz-Peter @@ -211,7 +211,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_MY_ADDRESS_ONLY, 0 ); + Dcc.init( MAN_ID_DIY, 601, FLAGS_MY_ADDRESS_ONLY, 0 ); delay(800); #if defined(DECODER_LOADED) diff --git a/examples/SMA/Dec_13Serv_4LED_6Ftn/Dec_13Serv_4LED_6Ftn.ino b/examples/SMA/Dec_13Serv_4LED_6Ftn/Dec_13Serv_4LED_6Ftn.ino old mode 100755 new mode 100644 index b463aa4..9d6e6f7 --- a/examples/SMA/Dec_13Serv_4LED_6Ftn/Dec_13Serv_4LED_6Ftn.ino +++ b/examples/SMA/Dec_13Serv_4LED_6Ftn/Dec_13Serv_4LED_6Ftn.ino @@ -1,5 +1,5 @@ // Production 17 Function DCC Decoder Dec_13Serv_4LED_6Ftn.ino -// Version 5.4 Geoff Bunza 2014,2015,2016 +// Version 6.01 Geoff Bunza 2014,2015,2016 // NO LONGER REQUIRES modified software servo Lib // Software restructuring mods added from Alex Shepherd and Franz-Peter // With sincere thanks @@ -12,7 +12,6 @@ // ******** INFO TO THE SERIAL MONITOR //#define DEBUG - #include #include @@ -208,7 +207,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 100, FLAGS_MY_ADDRESS_ONLY, 0 ); + Dcc.init( MAN_ID_DIY, 601, FLAGS_MY_ADDRESS_ONLY, 0 ); delay(800); #if defined(DECODER_LOADED) diff --git a/examples/SMA/Dec_15Serv_2LED_6Ftn/Dec_15Serv_2LED_6Ftn.ino b/examples/SMA/Dec_15Serv_2LED_6Ftn/Dec_15Serv_2LED_6Ftn.ino old mode 100755 new mode 100644 index 2cfbfdb..fc2440f --- a/examples/SMA/Dec_15Serv_2LED_6Ftn/Dec_15Serv_2LED_6Ftn.ino +++ b/examples/SMA/Dec_15Serv_2LED_6Ftn/Dec_15Serv_2LED_6Ftn.ino @@ -1,5 +1,5 @@ // Production 17 Function DCC Decoder Dec_15Serv_2LED_6Ftn.ino -// Version 5.4 Geoff Bunza 2014,2015,2016 +// Version 6.01 Geoff Bunza 2014,2015,2016 // NO LONGER REQUIRES modified software servo Lib // Software restructuring mods added from Alex Shepherd and Franz-Peter // With sincere thanks @@ -68,10 +68,17 @@ struct CVPair CVPair FactoryDefaultCVs [] = { - {CV_MULTIFUNCTION_PRIMARY_ADDRESS, This_Decoder_Address}, - {CV_ACCESSORY_DECODER_ADDRESS_MSB, 0}, - {CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0}, - {CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, 0}, + {CV_MULTIFUNCTION_PRIMARY_ADDRESS, This_Decoder_Address&0x7F }, + + // These two CVs define the Long DCC Address + {CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, ((This_Decoder_Address>>8)&0x7F)+192 }, + {CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, This_Decoder_Address&0xFF }, + + // ONLY uncomment 1 CV_29_CONFIG line below as approprate DEFAULT IS SHORT ADDRESS +// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps + {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps +// {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps + {CV_DECODER_MASTER_RESET, 0}, {30, 2}, //F0 Config 0=On/Off,1=Blink,2=Servo,3=DBL LED Blink,4=Pulsed,5=fade {31, 1}, //F0 Rate Blink=Eate,PWM=Rate,Servo=Rate @@ -200,7 +207,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 100, FLAGS_MY_ADDRESS_ONLY, 0 ); + Dcc.init( MAN_ID_DIY, 601, FLAGS_MY_ADDRESS_ONLY, 0 ); delay(800); #if defined(DECODER_LOADED) diff --git a/examples/SMA/Dec_17LED_1Ftn/Dec_17LED_1Ftn.ino b/examples/SMA/Dec_17LED_1Ftn/Dec_17LED_1Ftn.ino old mode 100755 new mode 100644 index 81a57f3..f07204f --- a/examples/SMA/Dec_17LED_1Ftn/Dec_17LED_1Ftn.ino +++ b/examples/SMA/Dec_17LED_1Ftn/Dec_17LED_1Ftn.ino @@ -1,5 +1,5 @@ // Production 17 Function DCC Decoder Dec_17LED_1Ftn.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses // ******** UNLESS YOU WANT ALL CV'S RESET UPON EVERY POWER UP @@ -87,7 +87,7 @@ void setup() // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_MY_ADDRESS_ONLY, 0 ); + Dcc.init( MAN_ID_DIY, 601, FLAGS_MY_ADDRESS_ONLY, 0 ); delay(800); #if defined(DECODER_LOADED) if ( Dcc.getCV(CV_DECODER_MASTER_RESET)== CV_DECODER_MASTER_RESET ) diff --git a/examples/SMA/Dec_17LED_6Ftn/Dec_17LED_6Ftn.ino b/examples/SMA/Dec_17LED_6Ftn/Dec_17LED_6Ftn.ino old mode 100755 new mode 100644 index e022030..2f989b6 --- a/examples/SMA/Dec_17LED_6Ftn/Dec_17LED_6Ftn.ino +++ b/examples/SMA/Dec_17LED_6Ftn/Dec_17LED_6Ftn.ino @@ -1,5 +1,5 @@ // Production 17 Function DCC Decoder Dec_17LED_6Ftn.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses // NO LONGER REQUIRES modified software servo Lib // Software restructuring mods added from Alex Shepherd and Franz-Peter @@ -211,7 +211,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_MY_ADDRESS_ONLY, 0 ); + Dcc.init( MAN_ID_DIY, 601, FLAGS_MY_ADDRESS_ONLY, 0 ); delay(800); #if defined(DECODER_LOADED) diff --git a/examples/SMA/Dec_2Mot_12LED_1Srv_6Ftn/Dec_2Mot_12LED_1Srv_6Ftn.ino b/examples/SMA/Dec_2Mot_12LED_1Srv_6Ftn/Dec_2Mot_12LED_1Srv_6Ftn.ino index 2f5658f..94c16c4 100644 --- a/examples/SMA/Dec_2Mot_12LED_1Srv_6Ftn/Dec_2Mot_12LED_1Srv_6Ftn.ino +++ b/examples/SMA/Dec_2Mot_12LED_1Srv_6Ftn/Dec_2Mot_12LED_1Srv_6Ftn.ino @@ -1,7 +1,7 @@ // Production 2 Motor 13 Function DCC Decoder Dec_2MotDrive_12LED_1Srv_6Ftn.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01a Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses - +// Better motor control added // NO LONGER REQUIRES modified software servo Lib // Software restructuring mods added from Alex Shepherd and Franz-Peter // With sincere thanks @@ -35,12 +35,10 @@ SoftwareServo servo[13]; #define servo_slowdown 12 //servo loop counter limit int servo_slow_counter = 0; //servo loop counter to slowdown servo transit -uint8_t Motor1Speed = 0; +int Motor1Speed = 0; uint8_t Motor1ForwardDir = 1; -uint8_t Motor1MaxSpeed = 127; -uint8_t Motor2Speed = 0; +int Motor2Speed = 0; uint8_t Motor2ForwardDir = 1; -uint8_t Motor2MaxSpeed = 127; int kickstarton = 1400; //kick start cycle on time int kickstarttime = 5; //kick start duration on time int fwdon = 0; @@ -49,6 +47,7 @@ int bwdon = 0; int bwdtime = 1; int bwdshift = 0; int cyclewidth = 2047; +int loopdelay =14; int m2h = 3; //R H Bridge //Motor1 int m2l = 4; //B H Bridge //Motor1 int m0h = 9; //R H Bridge //Motor2 @@ -56,7 +55,7 @@ int m0l = 10; //B H Bridge //Motor2 int speedup = 112; //Right track time differntial int deltime = 1500; -int tim_delay = 80; +int tim_delay = 30; int numfpins = 17; int num_active_fpins = 13; byte fpins [] = {3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; @@ -71,7 +70,6 @@ const int FunctionPin6 = 13; const int FunctionPin7 = 14; //A0 const int FunctionPin8 = 15; //A1 - const int FunctionPin9 = 16; //A2 const int FunctionPin10 = 17; //A3 const int FunctionPin11 = 18; //A4 @@ -111,9 +109,9 @@ CVPair FactoryDefaultCVs [] = {CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, This_Decoder_Address&0xFF }, // ONLY uncomment 1 CV_29_CONFIG line below as approprate DEFAULT IS SHORT ADDRESS -// {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps + // {CV_29_CONFIG, 0}, // Short Address 14 Speed Steps {CV_29_CONFIG, CV29_F0_LOCATION}, // Short Address 28/128 Speed Steps -// {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps + // {CV_29_CONFIG, CV29_EXT_ADDRESSING | CV29_F0_LOCATION}, // Long Address 28/128 Speed Steps {CV_DECODER_MASTER_RESET, 0}, {30, 0}, //F0 Config 0=On/Off,1=Blink,2=Servo,3=DBL LED Blink,4=Pulsed,5=fade @@ -244,7 +242,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_MY_ADDRESS_ONLY, 0 ); + Dcc.init( MAN_ID_DIY, 601, FLAGS_MY_ADDRESS_ONLY, 0 ); delay(800); #if defined(DECODER_LOADED) @@ -340,14 +338,28 @@ void loop() //**************************************************************** Dcc.process(); SoftwareServo::refresh(); delay(2); +#ifdef DEBUG + Serial.print("Motor1Speed= "); + Serial.println(Motor1Speed, DEC) ; + Serial.print("Motor2Speed= "); + Serial.println(Motor2Speed, DEC) ; +#endif if (Motor1Speed != 0) { - if (Motor1ForwardDir == 0) gofwd1 (fwdtime, int((Motor1Speed&0x7f)*21)); - else gobwd1 (bwdtime, int((Motor1Speed&0x7f)*21)); + if (Motor1ForwardDir == 0) gofwd1 (fwdtime, Motor1Speed<<4); + else gobwd1 (bwdtime, Motor1Speed<<4); } + else { + digitalWrite(m2h, LOW); //Motor1 OFF + digitalWrite(m2l, LOW); //Motor1 OFF + } if (Motor2Speed != 0) { - if (Motor2ForwardDir == 0) gofwd2 (fwdtime, int((Motor2Speed&0x7f)*21)); - else gobwd2 (bwdtime, int((Motor2Speed&0x7f)*21)); - } + if (Motor2ForwardDir == 0) gofwd2 (fwdtime, Motor2Speed<<4); + else gobwd2 (bwdtime, Motor2Speed<<4); + } + else { + digitalWrite(m0h, LOW); //Motor1 OFF + digitalWrite(m0l, LOW); //Motor1 OFF + } // for (int i=0; i < num_active_fpins; i++) { if (ftn_queue[i].inuse==1) { @@ -420,61 +432,73 @@ void loop() //**************************************************************** } void gofwd1(int fcnt,int fcycle) { int icnt; - int totcycle; + int delta_tp,delta_tm; + delta_tp = fcycle+loopdelay<<2; + delta_tm = cyclewidth-fcycle-loopdelay; icnt = 0; while (icnt < fcnt) { digitalWrite(m2h, HIGH); //Motor1 - delayMicroseconds(fcycle); + delayMicroseconds(delta_tp); digitalWrite(m2h, LOW); //Motor1 - delayMicroseconds(cyclewidth - fcycle); + delayMicroseconds(delta_tm); icnt++; } } void gobwd1(int bcnt,int bcycle) { int icnt; + int delta_tp,delta_tm; + delta_tp = bcycle+loopdelay<<2; + delta_tm = cyclewidth-bcycle-loopdelay; icnt=0; while (icnt < bcnt) { digitalWrite(m2l, HIGH); //Motor1 - delayMicroseconds(bcycle); + delayMicroseconds(delta_tp); digitalWrite(m2l, LOW); //Motor1 - delayMicroseconds(cyclewidth - bcycle); + delayMicroseconds(delta_tm); icnt++; } } void gofwd2(int fcnt,int fcycle) { int icnt; - int totcycle; + int delta_tp,delta_tm; + delta_tp = fcycle+loopdelay<<2; + delta_tm = cyclewidth-fcycle-loopdelay; icnt = 0; while (icnt < fcnt) { digitalWrite(m0h, HIGH); //Motor2 - delayMicroseconds(fcycle); + delayMicroseconds(delta_tp); digitalWrite(m0h, LOW); //Motor2 - delayMicroseconds(cyclewidth - fcycle); + delayMicroseconds(delta_tm); icnt++; } } void gobwd2(int bcnt,int bcycle) { int icnt; + int delta_tp,delta_tm; + delta_tp = bcycle+loopdelay<<2; + delta_tm = cyclewidth-bcycle-loopdelay; icnt=0; while (icnt < bcnt) { digitalWrite(m0l, HIGH); //Motor2 - delayMicroseconds(bcycle); + delayMicroseconds(delta_tp); digitalWrite(m0l, LOW); //Motor2 - delayMicroseconds(cyclewidth - bcycle); + delayMicroseconds(delta_tm); icnt++; } } void notifyDccSpeed( uint16_t Addr, DCC_ADDR_TYPE AddrType, uint8_t Speed, DCC_DIRECTION ForwardDir, DCC_SPEED_STEPS SpeedSteps ) { if (Function13_value==1) { - Motor1Speed = Speed; + Motor1Speed = (Speed & 0x7f ); + if (Motor1Speed == 1) Motor1Speed=0; Motor1ForwardDir = ForwardDir; } if (Function14_value==1) { - Motor2Speed = Speed; + Motor2Speed = (Speed & 0x7f ); + if (Motor2Speed == 1) Motor2Speed=0; Motor2ForwardDir = ForwardDir; } } @@ -592,4 +616,4 @@ void exec_function (int function, int pin, int FuncState) { ftn_queue[function].inuse = 0; break; } -} +} \ No newline at end of file diff --git a/examples/SMA/Dec_2Mot_3LED_TrigAud/Dec_2Mot_3LED_TrigAud.ino b/examples/SMA/Dec_2Mot_3LED_TrigAud/Dec_2Mot_3LED_TrigAud.ino index 4b4b5f9..977eed1 100644 --- a/examples/SMA/Dec_2Mot_3LED_TrigAud/Dec_2Mot_3LED_TrigAud.ino +++ b/examples/SMA/Dec_2Mot_3LED_TrigAud/Dec_2Mot_3LED_TrigAud.ino @@ -1,7 +1,7 @@ // Production 2 Motor w/Triggered Audio Multi Function DCC Decoder Dec_2Mot_3LED_TrigAudio.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01a Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses - +// Improved motor control added // This decoder will control 2 motors and play audio clips by function: // F0=LED on pin 8, F1-F4 Controls playing specific audio tracks in the 3rd CV (start) at the volume in the 2nd CV (rate) // F5 Controls playing audio track in CV57 at the volume in CV56 ONLY when F5 is ON and Pin17/A3 is held low, @@ -21,7 +21,7 @@ * Motor speed for each can only be changed if the corresponding Function is on * (F13 and/or F14). Motor speed is maintained if the corresponding Motor select function * is off. Thus, each motor can be controlled independently and run at different speeds. - * F0 LED Pin 8 + * F0 LED Pin 13 * F1-F6 6 Functions Configures As Audio Play * F7-F8 2 Functions Configures As LEDs by default PINS 18 and 19 * F13 Motor1 Control Enable @@ -68,12 +68,10 @@ SoftwareServo servo[10]; #define servo_slowdown 4 //servo loop counter limit int servo_slow_counter = 0; //servo loop counter to slowdown servo transit -uint8_t Motor1Speed = 0; +int Motor1Speed = 0; uint8_t Motor1ForwardDir = 1; -uint8_t Motor1MaxSpeed = 127; -uint8_t Motor2Speed = 0; +int Motor2Speed = 0; uint8_t Motor2ForwardDir = 1; -uint8_t Motor2MaxSpeed = 127; int kickstarton = 1400; //kick start cycle on time int kickstarttime = 5; //kick start duration on time int fwdon = 0; @@ -82,6 +80,7 @@ int bwdon = 0; int bwdtime = 1; int bwdshift = 0; int cyclewidth = 2047; +int loopdelay =14; int m2h = 3; //R H Bridge //Motor1 int m2l = 4; //B H Bridge //Motor1 int m0h = 9; //R H Bridge //Motor2 @@ -89,31 +88,31 @@ int m0l = 10; //B H Bridge //Motor2 int speedup = 112; //Right track time differntial int deltime = 1500; -int tim_delay = 100; +int tim_delay = 30; int numfpins = 13; int num_active_fpins = 9; byte fpins [] = {3,4,8,9,10,11,12,13,14,15,16,18}; -const int FunctionPin0 = 8; -const int FunctionPin1 = 11; -const int FunctionPin2 = 12; -const int FunctionPin3 = 13; -const int FunctionPin4 = 14; //A0 +const int FunctionPin0 = 13; +const int FunctionPin1 = 20; // Place holders ONLY +const int FunctionPin2 = 20; // Place holders ONLY +const int FunctionPin3 = 20; // Place holders ONLY +const int FunctionPin4 = 20; //A0 Place holders ONLY -const int FunctionPin5 = 15; //A1 -const int FunctionPin6 = 16; //A2 -const int FunctionPin7 = 18; //A5 -const int FunctionPin8 = 19; //A4 +const int FunctionPin5 = 20; //A1 Place holders ONLY +const int FunctionPin6 = 20; //A2 Place holders ONLY +const int FunctionPin7 = 18; //A5 Place holders ONLY +const int FunctionPin8 = 19; //A4 Place holders ONLY const int AudioTriggerPin = 17; //A3 NOW USED AS Audio Trigger Pin INPUT_PULLUP -const int FunctionPin9 = 20; // Place holders ONLY +const int FunctionPin9 = 20; // Place holders ONLY const int FunctionPin10 = 20; // Place holders ONLY -const int FunctionPin11 = 20; -const int FunctionPin12 = 20; -const int FunctionPin13 = 20; -const int FunctionPin14 = 20; -const int FunctionPin15 = 20; -const int FunctionPin16 = 20; +const int FunctionPin11 = 20; // Place holders ONLY +const int FunctionPin12 = 20; // Place holders ONLY +const int FunctionPin13 = 20; // Place holders ONLY +const int FunctionPin14 = 20; // Place holders ONLY +const int FunctionPin15 = 20; // Place holders ONLY +const int FunctionPin16 = 20; // Place holders ONLY int Function13_value = 0; int Function14_value = 0; @@ -122,7 +121,6 @@ NmraDcc Dcc ; DCC_MSG Packet ; uint8_t CV_DECODER_MASTER_RESET = 120; int t; // temp - struct QUEUE { int inuse; @@ -242,7 +240,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_MY_ADDRESS_ONLY, 0 ); + Dcc.init( MAN_ID_DIY, 601, FLAGS_MY_ADDRESS_ONLY, 0 ); delay(800); #if defined(DECODER_LOADED) @@ -354,14 +352,28 @@ void loop() //**************************************************************** Dcc.process(); SoftwareServo::refresh(); delay(2); +#ifdef DEBUG + Serial.print("Motor1Speed= "); + Serial.println(Motor1Speed, DEC) ; + Serial.print("Motor2Speed= "); + Serial.println(Motor2Speed, DEC) ; +#endif if (Motor1Speed != 0) { - if (Motor1ForwardDir == 0) gofwd1 (fwdtime, int((Motor1Speed&0x7f)*21)); - else gobwd1 (bwdtime, int((Motor1Speed&0x7f)*21)); + if (Motor1ForwardDir == 0) gofwd1 (fwdtime, Motor1Speed<<4); + else gobwd1 (bwdtime, Motor1Speed<<4); } + else { + digitalWrite(m2h, LOW); //Motor1 OFF + digitalWrite(m2l, LOW); //Motor1 OFF + } if (Motor2Speed != 0) { - if (Motor2ForwardDir == 0) gofwd2 (fwdtime, int((Motor2Speed&0x7f)*21)); - else gobwd2 (bwdtime, int((Motor2Speed&0x7f)*21)); - } + if (Motor2ForwardDir == 0) gofwd2 (fwdtime, Motor2Speed<<4); + else gobwd2 (bwdtime, Motor2Speed<<4); + } + else { + digitalWrite(m0h, LOW); //Motor1 OFF + digitalWrite(m0l, LOW); //Motor1 OFF + } // for (int i=0; i < num_active_fpins; i++) { if (ftn_queue[i].inuse==1) { @@ -460,61 +472,73 @@ void loop() //**************************************************************** } void gofwd1(int fcnt,int fcycle) { int icnt; - int totcycle; + int delta_tp,delta_tm; + delta_tp = fcycle+loopdelay<<2; + delta_tm = cyclewidth-fcycle-loopdelay; icnt = 0; while (icnt < fcnt) { digitalWrite(m2h, HIGH); //Motor1 - delayMicroseconds(fcycle); + delayMicroseconds(delta_tp); digitalWrite(m2h, LOW); //Motor1 - delayMicroseconds(cyclewidth - fcycle); + delayMicroseconds(delta_tm); icnt++; } } void gobwd1(int bcnt,int bcycle) { int icnt; + int delta_tp,delta_tm; + delta_tp = bcycle+loopdelay<<2; + delta_tm = cyclewidth-bcycle-loopdelay; icnt=0; while (icnt < bcnt) { digitalWrite(m2l, HIGH); //Motor1 - delayMicroseconds(bcycle); + delayMicroseconds(delta_tp); digitalWrite(m2l, LOW); //Motor1 - delayMicroseconds(cyclewidth - bcycle); + delayMicroseconds(delta_tm); icnt++; } } void gofwd2(int fcnt,int fcycle) { int icnt; - int totcycle; + int delta_tp,delta_tm; + delta_tp = fcycle+loopdelay<<2; + delta_tm = cyclewidth-fcycle-loopdelay; icnt = 0; while (icnt < fcnt) { digitalWrite(m0h, HIGH); //Motor2 - delayMicroseconds(fcycle); + delayMicroseconds(delta_tp); digitalWrite(m0h, LOW); //Motor2 - delayMicroseconds(cyclewidth - fcycle); + delayMicroseconds(delta_tm); icnt++; } } void gobwd2(int bcnt,int bcycle) { int icnt; + int delta_tp,delta_tm; + delta_tp = bcycle+loopdelay<<2; + delta_tm = cyclewidth-bcycle-loopdelay; icnt=0; while (icnt < bcnt) { digitalWrite(m0l, HIGH); //Motor2 - delayMicroseconds(bcycle); + delayMicroseconds(delta_tp); digitalWrite(m0l, LOW); //Motor2 - delayMicroseconds(cyclewidth - bcycle); + delayMicroseconds(delta_tm); icnt++; } } void notifyDccSpeed( uint16_t Addr, DCC_ADDR_TYPE AddrType, uint8_t Speed, DCC_DIRECTION ForwardDir, DCC_SPEED_STEPS SpeedSteps ) { if (Function13_value==1) { - Motor1Speed = Speed; + Motor1Speed = (Speed & 0x7f ); + if (Motor1Speed == 1) Motor1Speed=0; Motor1ForwardDir = ForwardDir; } if (Function14_value==1) { - Motor2Speed = Speed; + Motor2Speed = (Speed & 0x7f ); + if (Motor2Speed == 1) Motor2Speed=0; Motor2ForwardDir = ForwardDir; } } @@ -699,4 +723,4 @@ void exec_function (int function, int pin, int FuncState) { void mp3_single_loop (boolean state); //set single loop void mp3_DAC (boolean state); void mp3_random_play (); - */ + */ \ No newline at end of file diff --git a/examples/SMA/Dec_2Mot_4LED_Aud_8Ftn/Dec_2Mot_4LED_Aud_8Ftn.ino b/examples/SMA/Dec_2Mot_4LED_Aud_8Ftn/Dec_2Mot_4LED_Aud_8Ftn.ino index 853d844..a33aa05 100644 --- a/examples/SMA/Dec_2Mot_4LED_Aud_8Ftn/Dec_2Mot_4LED_Aud_8Ftn.ino +++ b/examples/SMA/Dec_2Mot_4LED_Aud_8Ftn/Dec_2Mot_4LED_Aud_8Ftn.ino @@ -1,6 +1,14 @@ // Production 2 Motor w/Audio 13 Function DCC Decoder Dec_2Mot_10LED_Audio_8Ftn.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01a Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses +// Improved motor control added +// This decoder will control 2 motors and play audio clips by function: +// F0=LED on pin 13, F1-F4 Controls playing specific audio tracks in the 3rd CV (start) at the volume in the 2nd CV (rate) +// F5 Controls playing audio track in CV57 at the volume in CV56 ONLY when F5 is ON and Pin17/A3 is held low, +// and plays continuously until F5 turns off or Pin17 trigger goes HIGH or open +// F6 plays one track selected randomly off the memory card +// F13 and F14 select each separate motor which will respond to speed and direction controls +// F7-F8 control LEDs by default PINS 18 and 19 // NO LONGER REQUIRES modified software servo Lib // Software restructuring mods added from Alex Shepherd and Franz-Peter @@ -10,7 +18,7 @@ * Motor speed for each can only be changed if the corresponding Function is on * (F13 and/or F14). Motor speed is maintained if the corresponding Motor select function * is off. Thus, each motor can be controlled independently and run at different speeds. - * F0 LED Pin 8 + * F0 LED Pin 13 * F1-F6 6 Functions Configures As Audio Play * F7-F9 3 Functions Configures As LEDs * F13 Motor1 Control Enable @@ -57,12 +65,10 @@ SoftwareServo servo[10]; #define servo_slowdown 4 //servo loop counter limit int servo_slow_counter = 0; //servo loop counter to slowdown servo transit -uint8_t Motor1Speed = 0; +int Motor1Speed = 0; uint8_t Motor1ForwardDir = 1; -uint8_t Motor1MaxSpeed = 127; -uint8_t Motor2Speed = 0; +int Motor2Speed = 0; uint8_t Motor2ForwardDir = 1; -uint8_t Motor2MaxSpeed = 127; int kickstarton = 1400; //kick start cycle on time int kickstarttime = 5; //kick start duration on time int fwdon = 0; @@ -71,6 +77,7 @@ int bwdon = 0; int bwdtime = 1; int bwdshift = 0; int cyclewidth = 2047; +int loopdelay =14; int m2h = 3; //R H Bridge //Motor1 int m2l = 4; //B H Bridge //Motor1 int m0h = 9; //R H Bridge //Motor2 @@ -78,29 +85,31 @@ int m0l = 10; //B H Bridge //Motor2 int speedup = 112; //Right track time differntial int deltime = 1500; -int tim_delay = 100; +int tim_delay = 30; int numfpins = 14; int num_active_fpins = 10; byte fpins [] = {3,4,8,9,10,11,12,13,14,15,16,17,18,19}; -const int FunctionPin0 = 8; -const int FunctionPin1 = 11; -const int FunctionPin2 = 12; -const int FunctionPin3 = 13; -const int FunctionPin4 = 14; //A0 +const int FunctionPin0 = 13; +const int FunctionPin1 = 20; // Place holders ONLY +const int FunctionPin2 = 20; // Place holders ONLY +const int FunctionPin3 = 20; // Place holders ONLY +const int FunctionPin4 = 20; //A0 Place holders ONLY -const int FunctionPin5 = 15; //A1 -const int FunctionPin6 = 16; //A2 -const int FunctionPin7 = 17; //A3 -const int FunctionPin8 = 18; //A4 -const int FunctionPin9 = 19; //A5 +const int FunctionPin5 = 20; //A1 Place holders ONLY +const int FunctionPin6 = 20; //A2 Place holders ONLY +const int FunctionPin7 = 18; //A5 Place holders ONLY +const int FunctionPin8 = 19; //A4 Place holders ONLY +const int AudioTriggerPin = 17; //A3 NOW USED AS Audio Trigger Pin INPUT_PULLUP + +const int FunctionPin9 = 20; // Place holders ONLY const int FunctionPin10 = 20; // Place holders ONLY -const int FunctionPin11 = 20; -const int FunctionPin12 = 20; -const int FunctionPin13 = 20; -const int FunctionPin14 = 20; -const int FunctionPin15 = 20; -const int FunctionPin16 = 20; +const int FunctionPin11 = 20; // Place holders ONLY +const int FunctionPin12 = 20; // Place holders ONLY +const int FunctionPin13 = 20; // Place holders ONLY +const int FunctionPin14 = 20; // Place holders ONLY +const int FunctionPin15 = 20; // Place holders ONLY +const int FunctionPin16 = 20; // Place holders ONLY int Function13_value = 0; int Function14_value = 0; @@ -227,7 +236,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_MY_ADDRESS_ONLY, 0 ); + Dcc.init( MAN_ID_DIY, 601, FLAGS_MY_ADDRESS_ONLY, 0 ); delay(800); #if defined(DECODER_LOADED) @@ -336,14 +345,28 @@ void loop() //**************************************************************** Dcc.process(); SoftwareServo::refresh(); delay(2); + #ifdef DEBUG + Serial.print("Motor1Speed= "); + Serial.println(Motor1Speed, DEC) ; + Serial.print("Motor2Speed= "); + Serial.println(Motor2Speed, DEC) ; +#endif if (Motor1Speed != 0) { - if (Motor1ForwardDir == 0) gofwd1 (fwdtime, int((Motor1Speed&0x7f)*21)); - else gobwd1 (bwdtime, int((Motor1Speed&0x7f)*21)); + if (Motor1ForwardDir == 0) gofwd1 (fwdtime, Motor1Speed<<4); + else gobwd1 (bwdtime, Motor1Speed<<4); } + else { + digitalWrite(m2h, LOW); //Motor1 OFF + digitalWrite(m2l, LOW); //Motor1 OFF + } if (Motor2Speed != 0) { - if (Motor2ForwardDir == 0) gofwd2 (fwdtime, int((Motor2Speed&0x7f)*21)); - else gobwd2 (bwdtime, int((Motor2Speed&0x7f)*21)); - } + if (Motor2ForwardDir == 0) gofwd2 (fwdtime, Motor2Speed<<4); + else gobwd2 (bwdtime, Motor2Speed<<4); + } + else { + digitalWrite(m0h, LOW); //Motor1 OFF + digitalWrite(m0l, LOW); //Motor1 OFF + } // for (int i=0; i < num_active_fpins; i++) { if (ftn_queue[i].inuse==1) { @@ -432,65 +455,78 @@ void loop() //**************************************************************** } void gofwd1(int fcnt,int fcycle) { int icnt; - int totcycle; + int delta_tp,delta_tm; + delta_tp = fcycle+loopdelay<<2; + delta_tm = cyclewidth-fcycle-loopdelay; icnt = 0; while (icnt < fcnt) { digitalWrite(m2h, HIGH); //Motor1 - delayMicroseconds(fcycle); + delayMicroseconds(delta_tp); digitalWrite(m2h, LOW); //Motor1 - delayMicroseconds(cyclewidth - fcycle); + delayMicroseconds(delta_tm); icnt++; } } void gobwd1(int bcnt,int bcycle) { int icnt; + int delta_tp,delta_tm; + delta_tp = bcycle+loopdelay<<2; + delta_tm = cyclewidth-bcycle-loopdelay; icnt=0; while (icnt < bcnt) { digitalWrite(m2l, HIGH); //Motor1 - delayMicroseconds(bcycle); + delayMicroseconds(delta_tp); digitalWrite(m2l, LOW); //Motor1 - delayMicroseconds(cyclewidth - bcycle); + delayMicroseconds(delta_tm); icnt++; } } void gofwd2(int fcnt,int fcycle) { int icnt; - int totcycle; + int delta_tp,delta_tm; + delta_tp = fcycle+loopdelay<<2; + delta_tm = cyclewidth-fcycle-loopdelay; icnt = 0; while (icnt < fcnt) { digitalWrite(m0h, HIGH); //Motor2 - delayMicroseconds(fcycle); + delayMicroseconds(delta_tp); digitalWrite(m0h, LOW); //Motor2 - delayMicroseconds(cyclewidth - fcycle); + delayMicroseconds(delta_tm); icnt++; } } void gobwd2(int bcnt,int bcycle) { int icnt; + int delta_tp,delta_tm; + delta_tp = bcycle+loopdelay<<2; + delta_tm = cyclewidth-bcycle-loopdelay; icnt=0; while (icnt < bcnt) { digitalWrite(m0l, HIGH); //Motor2 - delayMicroseconds(bcycle); + delayMicroseconds(delta_tp); digitalWrite(m0l, LOW); //Motor2 - delayMicroseconds(cyclewidth - bcycle); + delayMicroseconds(delta_tm); icnt++; } } void notifyDccSpeed( uint16_t Addr, DCC_ADDR_TYPE AddrType, uint8_t Speed, DCC_DIRECTION ForwardDir, DCC_SPEED_STEPS SpeedSteps ) { if (Function13_value==1) { - Motor1Speed = Speed; + Motor1Speed = (Speed & 0x7f ); + if (Motor1Speed == 1) Motor1Speed=0; Motor1ForwardDir = ForwardDir; } if (Function14_value==1) { - Motor2Speed = Speed; + Motor2Speed = (Speed & 0x7f ); + if (Motor2Speed == 1) Motor2Speed=0; Motor2ForwardDir = ForwardDir; } } + void notifyDccFunc( uint16_t Addr, DCC_ADDR_TYPE AddrType, FN_GROUP FuncGrp, uint8_t FuncState) { #ifdef DEBUG Serial.print("Addr= "); @@ -666,4 +702,4 @@ void exec_function (int function, int pin, int FuncState) { void mp3_single_loop (boolean state); //set single loop void mp3_DAC (boolean state); void mp3_random_play (); - */ + */ \ No newline at end of file diff --git a/examples/SMA/Dec_7Serv_10LED_6Ftn/Dec_7Serv_10LED_6Ftn.ino b/examples/SMA/Dec_7Serv_10LED_6Ftn/Dec_7Serv_10LED_6Ftn.ino old mode 100755 new mode 100644 index c6738ae..6b0f3bc --- a/examples/SMA/Dec_7Serv_10LED_6Ftn/Dec_7Serv_10LED_6Ftn.ino +++ b/examples/SMA/Dec_7Serv_10LED_6Ftn/Dec_7Serv_10LED_6Ftn.ino @@ -1,5 +1,5 @@ // Production 17 Function DCC Decoder Dec_7Serv_10LED_6Ftn.ino -// Version 5.4 Geoff Bunza 2014,2015,2016 +// Version 6.01 Geoff Bunza 2014,2015,2016 // NO LONGER REQUIRES modified software servo Lib // Software restructuring mods added from Alex Shepherd and Franz-Peter // With sincere thanks @@ -207,7 +207,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 100, FLAGS_MY_ADDRESS_ONLY, 0 ); + Dcc.init( MAN_ID_DIY, 601, FLAGS_MY_ADDRESS_ONLY, 0 ); delay(800); #if defined(DECODER_LOADED) diff --git a/examples/SMA/Dec_Dir_and_Fade/Dec_Dir_and_Fade.ino b/examples/SMA/Dec_Dir_and_Fade/Dec_Dir_and_Fade.ino old mode 100755 new mode 100644 index 2df4109..059b308 --- a/examples/SMA/Dec_Dir_and_Fade/Dec_Dir_and_Fade.ino +++ b/examples/SMA/Dec_Dir_and_Fade/Dec_Dir_and_Fade.ino @@ -1,5 +1,5 @@ // Production 17 Function DCC Decoder Dec_Dir_and_Fade.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses // LED control is dependent on direction of travel and Fade can be added @@ -110,7 +110,7 @@ void setup() // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_MY_ADDRESS_ONLY, 0 ); + Dcc.init( MAN_ID_DIY, 601, FLAGS_MY_ADDRESS_ONLY, 0 ); } void loop() { diff --git a/examples/SMA/Dec_SMA12_LED_Groups/Dec_SMA12_LED_Groups.ino b/examples/SMA/Dec_SMA12_LED_Groups/Dec_SMA12_LED_Groups.ino old mode 100755 new mode 100644 index 413678a..8eb441c --- a/examples/SMA/Dec_SMA12_LED_Groups/Dec_SMA12_LED_Groups.ino +++ b/examples/SMA/Dec_SMA12_LED_Groups/Dec_SMA12_LED_Groups.ino @@ -1,5 +1,5 @@ // Production 17 Function DCC Decoder Dec_SMA12_LED_Groups.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses // NO LONGER REQUIRES modified software servo Lib @@ -127,7 +127,7 @@ void setup() // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_MY_ADDRESS_ONLY, 0 ); + Dcc.init( MAN_ID_DIY, 601, FLAGS_MY_ADDRESS_ONLY, 0 ); delay(800); #if defined(DECODER_LOADED) if ( Dcc.getCV(CV_DECODER_MASTER_RESET)== CV_DECODER_MASTER_RESET ) diff --git a/examples/SMA/Dec_Stepper_6Ftn/Dec_Stepper_6Ftn.ino b/examples/SMA/Dec_Stepper_6Ftn/Dec_Stepper_6Ftn.ino index 9bde9b7..b237e09 100644 --- a/examples/SMA/Dec_Stepper_6Ftn/Dec_Stepper_6Ftn.ino +++ b/examples/SMA/Dec_Stepper_6Ftn/Dec_Stepper_6Ftn.ino @@ -1,5 +1,5 @@ // Production Stepper Drive DCC Decoder Dec_Stepper_6Ftn.ino -// Version 6.0 Geoff Bunza 2014,2015,2016,2017,2018 +// Version 6.01 Geoff Bunza 2014,2015,2016,2017,2018 // Now works with both short and long DCC Addesses // NO LONGER REQUIRES modified software servo Lib @@ -236,7 +236,7 @@ void setup() //****************************************************** // Setup which External Interrupt, the Pin it's associated with that we're using Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver - Dcc.init( MAN_ID_DIY, 600, FLAGS_MY_ADDRESS_ONLY, 0 ); + Dcc.init( MAN_ID_DIY, 601, FLAGS_MY_ADDRESS_ONLY, 0 ); delay(800); #if defined(DECODER_LOADED) diff --git a/examples/SMA/SMA 6.0 Release Notes.rtf b/examples/SMA/SMA 6.01 Release Notes.rtf similarity index 94% rename from examples/SMA/SMA 6.0 Release Notes.rtf rename to examples/SMA/SMA 6.01 Release Notes.rtf index df5387a..19ba09a 100644 Binary files a/examples/SMA/SMA 6.0 Release Notes.rtf and b/examples/SMA/SMA 6.01 Release Notes.rtf differ