Model Railway DCC Arduino Wireless Commands On A Dead Rail ...
Maybe your like
Components:Arduino Mini Pro
nRF24L01 wireless transceiver SN754410 H-bridge DC regulator 5v outputDC regulator 3v3 outputRectifier diodes 1N4001 (2off)Resistors 10K and 4K7 Capacitors 22uf, 3.3uf, 3.3uf
The circuit above, is the transmitter. A pair of resistors reduces the input voltage to acceptable levels for the Mini Pro. I used the 5volt version of the Mini Pro. The 3.3v version may be used which would eliminate the need for a 5 volt regulator. The Arduino code is based on great work done by Geoff Bunza in the Model Railroad Hobbyist Magazine forum.
The loco commands are extracted from the DCC signal. The packet data is therefore isolated from the signal and transmitted as digital instructions to the receiver via the nRF24.
Transmit sketch updated 4 April 2018: To send data in one array instead of a byte at a time.
<p>// nrf24 - transmit DCC data 1 April 2018</p><p>#include #include #include #include "SPI.h" #include "NmraDcc.h"</p><p>//Settings RF24 radio(9,10); NmraDcc Dcc ; DCC_MSG Packet ; struct CVPair{ uint16_t CV; uint8_t Value; };</p><p>const byte slaveAddress[5] = {'R','x','A','A','A'}; char dataToSend[20] = "DD,9,63,0,54,";</p><p>void setup() { Serial.begin(115200); radio.begin(); radio.setDataRate( RF24_250KBPS ); radio.setChannel(108); radio.setRetries(0,0); // delay, count radio.openWritingPipe(slaveAddress); Serial.println("Ready");</p><p> Dcc.pin(0, 2, 0); // Call the main DCC Init function to enable the DCC Receiver Dcc.init( MAN_ID_DIY, 100, FLAGS_DCC_ACCESSORY_DECODER , 0 ); Serial.println("Ready"); }</p><p>void loop(){ Dcc.process(); }</p><p>extern void notifyDccMsg( DCC_MSG * Msg ) { if( ( Msg->Data[0] == 0 ) && ( Msg->Data[1] == 0 ) ) return; //reset packlet if( ( Msg->Data[0] == 0b11111111 ) && ( Msg->Data[1] == 0 ) ) return; //idle packet String s1 = String(Msg->Data[0], DEC) + ","; String s2 = String(Msg->Data[1], DEC) + ","; String s3 = String(Msg->Data[2], DEC) + ","; String s4 = String(Msg->Data[3], DEC) + ","; String Message = "DD," + s1 + s2 + s3 + s4 + '\0';</p><p> int Msg_size = Message.length(); for (int i = 0; i <= Msg_size; i++) { dataToSend[i] = Message.charAt(i); } Serial.println(dataToSend); radio.write( &dataToSend, sizeof(dataToSend) ); }</p>Tag » Arduino Model Train Dcc Decoder
-
DCC Decoder! (DCC Model Railway With Arduino 3) - YouTube
-
DCC Model Railway With Arduino –
-
Arduino DCC Decoder - Electronics DIY
-
Made An Arduino Based Simple Dcc Decoder -- And It Seems To Work
-
Using Arduino Nano As Basic DCC Decoder
-
Model Rail Digital DCC Command Station Arduino And Free App
-
SMA20 Low Cost 17 Channel DCC Decoders Ver 6.0 With Sound ...
-
Fun With Arduino 29 DCC Accessory Decoder - Pinterest
-
Do-It-Yourself DCC Projects
-
Dcc · GitHub Topics
-
Arduino Model Railway DCC Interface
-
DCC Interface - Model Railroading With Arduino
-
Simple Arduino Dcc Decoder - Search - EasyEDA