CMRI Setup

This Blog will be going over the initial setup for CMRI using the RS485 connection. This will setup the Arduino with the code to turn on an LED with BIT 0 from JMRI/CMRI and will also show the setup of JMRI connections and wiring between Arduino - RS TTL 485 module and USB to RS485 module.

For the wiring connected everything up as shown below.



Now the Arduino code copy and past this from below and upload this to your Arduino

#include <CMRI.h>
#include <Auto485.h>

#define CMRI_ADDR 1
#define DE_PIN 2

int led = 13;


Auto485 bus(DE_PIN);
CMRI cmri(CMRI_ADDR, 24, 48, bus); 

void setup() {
    pinMode(led, OUTPUT);
    bus.begin(9600);
}

void loop(){
cmri.process();
digitalWrite(led, cmri.get_bit(0));
}
            

You will need to down load the CMRI and RS485 library and place the folders in the Arduino library folder. Links below

CMRI.h RS485.h

Now start up JMRI panelPro and click on Edit > preferences to setup the connection. Set the connections to the same as below except the COM port number for your setup may be different. To find you COM port. with the RS485 to USB connected to your PC. Go to your device manager in control panel and select the Port connections. This should show the COM port number being used.

img

Remember to click on additional connections settings and select 9600 from Baud rate drop down menu

Now click on Configure Nodes so we can add a Node address and ensure the node address is set to 1 as within the Arduino code we set the CMRI_ADDRESS to 1

img

Now save the connection settings, restart PanelPro and you should now have a connection with in the main PanelPro window

img

So, with everything connected up and powered up and n LED in pin 13 of the Arduino we can now create a light table and control the LED

Click on Tools then Tables then Lights table to open the lights table

Then Add new light with address 1001. Save this, now hopefully you can control the Arduino LED with the new JMRI light

img

If this has worked then you now have JMRI to Arduino connected with RS485. The rest of my Blogs should now work ok




Comments



17