How to add xS40 to Neuron L203 using custom software



  • How do I connect an xS40 to my Neuron L203? I see no documentation how to do this.

    I connected the RS485-A and -B to the Neuron, but when I go to the IP address in my browser, I do not see the extra in/outputs. Do I have to configure something in the system?

    I am using the websockets API in my custom software to manage in and outputs. What should I do to make this work?


  • administrators

    @Boy-Lenssen Ok, so I guess you are using Evok, right? So moving this to Evok section.

    You have to 'tell' evok that you connected the extension - this is done in the /etc/evok.conf. See this the example starting on line 27: https://github.com/UniPiTechnology/evok/blob/master/etc/evok-neuron.conf#L27



  • I have no idea yet how to handle this. Can I also just set the hardware DIP switches to something and have it working without any software adjustments? I read this in the manual, but don't understand how it works

    Ok, I've added it to /etc/evok.conf

    #!! don't use # for inline comments
    
    [MAIN]
    log_level = ERROR   ; one of INFO, DEBUG, WARNING, ERROR, CRITICAL
    log_file = /var/log/evok.log
    webname = unipi-neuron
    staticfiles = /var/www/evok
    ;password = test
    ;rpcpassword = test
    secret = ut5kB3hhf6VmZCujXGQ5ZHb1EAfiXHcy
    port = 80
    enable_cors = False
    cors_domains = *
    modbus_port = 0
    #modbus_address = 127.0.0.1
    modbus_address = *
    
    [NEURON_1]
    scan_frequency = 50
    scan_enabled = True
    
    [OWBUS_1]
    owbus = --i2c=/dev/i2c-1:ALL     ; scanned bus (--i2c=/dev/i2c-1:ALL or localhost:2122 or 'u' for USB dongle)
    interval = 3          ; [s] default sensor reading
    scan_interval = 300    ; [s] how often is made searching
    
    [EXTENSION_1]
    global_id = 5                                                   ; Mandatory, REQUIRED TO BE UNIQUE
    device_name = xS40                                              ; Mandatory
    modbus_uart_port = /dev/extcomm/0/0     ; Mandatory
    ;neuron_uart_circuit = 1_01                             ; Optional, allows associating extensions with specific Neuron UART-over-Modbus ports (not possible for non-Modbus UART ports, e.g. /dev/ttyUSB0 or /dev/ttyS0)
    ;allow_register_access = True                   ; Optional, False default, is mandatory with third-party devices
    ;address = 15                                                   ; Optional, 15 default
    ;scan_frequency = 2                                     ; Optional, 1 default
    ;scan_enabled = True                                    ; Optional, True default
    ; Note that the following settings will be inherited by other devices sharing the same port, i.e. /dev/extcomm/0/0
    ;baud_rate = 19200                                              ; Optional, NEEDS UNIPI IMAGE TO WORK! USE API TO CONFIGURE UART MANUALLY IF USING STANDARD RASPBIAN
    ;parity = N                                                             ; Optional, NEEDS UNIPI IMAGE TO WORK! USE API TO CONFIGURE UART MANUALLY IF USING STANDARD RASPBIAN
    ;stop_bits = 1                                                  ; Optional, NEEDS UNIPI IMAGE TO WORK! USE API TO CONFIGURE UART MANUALLY IF USING STANDARD RASPBIAN
    

    But still the led on the xS40 keeps blinking slowly (every 2 seconds), so not up-and-running apparently.

    I'm using the evok software from may 2017 btw.


  • administrators

    It should be running now, the slow blinking is only for on-board modules.

    You can increase the reading speed by altering the scan_frequency setting.



  • Are you sure? The slow blinking usually shows me the boards are not communicating with evok. I Had this issue before, restarting evok fixed that.

    If they are blinking slowly, they do not show up in the web interface.

    I updated the system to the newest EVOK version (2.0.5b), but no input/outputs are showing up in the webinterface, so I broke my setup. Already in contact with support in this issue. Hope we will be able to fix it.

    I'm now actually seeing this issue: https://forum.unipi.technology/topic/557/evok-stopped-working/3


  • administrators

    The flashing TX/RX leds signal UART communication, specifically a reply from the device. If you uncomment and increase the scan_frequency setting you should see the blinking frequency increase.

    Try to play with the address/parity options instead, since it looks like the device replies but with invalid data. If you don't see the TX/RX leds lighting up at all, then it is likely a cabling issue.

    The RUN LED works in a different manner, and it does work in the way you describe.



  • the run led is blinking slowly, so there is no communication.

    Can you tell me or point me to somewhere where it describes step-by-step what to do to connect the extension module? I have no idea what to do with the dip switches and if I set them, what do I need to do to configure them? I'm quite novice on this. I see 8 DIP switches and have them set to 0 atm.

    I also se an 'on/off' dipswitch next to the rs485 connection on the Neuron. That needs to be put to 'on'?


  • administrators

    @Boy-Lenssen

    Do you see the TX and RX leds blinking? That's the most part important. Ideally if you could mention the status of all four of them.

    The dip switches are used to set speed, parity and address, as per the descriptions on top. They need to be set to 19200, N, and e.g. 1 (you will need to set the address to 1 in the configuration file as well).

    The switch on the Neuron (there is another equivalent switch on the extension marked END) is used to turn on termination resistors. These are used to make the line more resistant to noise, and you can ignore it for now.



  • I have no idea how to set the dipswitches to 19200 N and 1. They are just 8 "toggles".

    The TX / RX on both xS40 and Neuron don't do anything. I have all dipswitches to 'off'.
    The run led is blinking every 2 seconds. Power led is on ofcourse :)

    Do I need a minimum version of the EVOK service installed on the system?


  • administrators

    Does the file /dev/extcomm/0/0 exist? Try changing it to /dev/ttyNS0 if it does not.

    If the TX light on the Neuron doesn't turn on it means there is no communication at all.

    I'm not quite clear on what you by having an EVOK service installed.



  • root@raspberrypi:/home/pi# ls /dev/extcomm/
    0 1
    root@raspberrypi:/home/pi# ls /dev/extcomm/0/0
    /dev/extcomm/0/0
    root@raspberrypi:/home/pi#

    seems to exists.

    With evok service, I mean the latest EVOK software from Github.

    Is it correct to have the RS-485-A connected to the RS-485-A of the xS40 and the B's too?

    Can you point me to the page in the documentation someone should follow when adding an Extension unit?


  • administrators

    @Boy-Lenssen
    It should be connected A-A, B-B, yes, the other way around will not work. The documentation, such as it is, is available from https://evok-6.api-docs.io/1.05/cgct7pncnqf9fper7/introduction, but it's targeted at users with prior experience with serial lines.

    I would use the following settings myself:

    [EXTENSION_1]
    global_id = 2                                                   ; Mandatory, REQUIRED TO BE UNIQUE
    device_name = xS40                                              ; Mandatory
    modbus_uart_port = /dev/extcomm/0/0     ; Mandatory
    neuron_uart_circuit = 1_01                             ; Optional, allows associating extensions with specific Neuron UART-over-Modbus ports (not possible for non-Modbus UART ports, e.g. /dev/ttyUSB0 or /dev/ttyS0)
    ;allow_register_access = True                   ; Optional, False default, is mandatory with third-party devices
    address = 1                                                   ; Optional, 15 default
    scan_frequency = 10                                     ; Optional, 1 default
    ;scan_enabled = True                                    ; Optional, True default
    ; Note that the following settings will be inherited by other devices sharing the same port, i.e. /dev/extcomm/0/0
    baud_rate = 19200                                              ; Optional, NEEDS UNIPI IMAGE TO WORK! USE API TO CONFIGURE UART MANUALLY IF USING STANDARD RASPBIAN
    parity = N                                                             ; Optional, NEEDS UNIPI IMAGE TO WORK! USE API TO CONFIGURE UART MANUALLY IF USING STANDARD RASPBIAN
    stop_bits = 1  
    

    Then connect the line and set the dip switches to the following positions:
    0_1526637503219_20180518_115609.jpg

    (apologies for the rotation)
    I have verified that these settings work with a fresh EVOK install, with the device in the photo.



  • @TomasKnot Hey, thanks a lot! I got it working now. I think I might have forgotten to remove the semi-colon before [EXTENSION 1] :face_palm:

    Now the Rx light on the xS40 is now constant on, the run light is still going on / off every 2 seconds. On the neuron, the TX flashes on very swiftly.

    I don't see the extra in/outputs when I go to my ip address. How can I read / write the ports now? I thought I would get some ports like 4_05 or so...

    I tried something like this: http://192.168.1.16/rest/relay/UART_1_2 but gives a 500 error


  • administrators

    @Boy-Lenssen
    This looks like an address problem perhaps, or possibly some other communication setting issue. Did you try to set it up as I have above? At least for testing purposes.

    If you did do so then it may be another issue, possibly with a hardware definition; if you can run the following commands while connected to the Neuron and paste the output here we may find the problem.

    sudo su
    systemctl stop evok
    python /opt/evok.py
    


  • @TomasKnot
    Hi! As far as I can see, I set it up exactly the way you said above...
    This is the output:

    The /get/all call is my software requesting the status of all in and outputs, you can ignore that.

    root@raspberrypi:/home/pi# python /opt/evok/evok.py 
    [I 180522 06:56:19 config:63] eprom: UniPi Neuron L203 version: 1.0 serial: 0x51
    [I 180522 06:56:19 evok:1634] Starting using config file /etc/evok.conf
    [I 180522 06:56:20 config:75] YAML Definition loaded: L30x.yaml, type: 3, definition count 0
    [I 180522 06:56:20 config:75] YAML Definition loaded: M20x.yaml, type: 3, definition count 1
    [I 180522 06:56:20 config:75] YAML Definition loaded: M50x.yaml, type: 3, definition count 2
    [I 180522 06:56:20 config:75] YAML Definition loaded: xS40.yaml, type: 3, definition count 3
    [I 180522 06:56:20 config:75] YAML Definition loaded: M30x.yaml, type: 3, definition count 4
    [I 180522 06:56:20 config:75] YAML Definition loaded: L40x.yaml, type: 3, definition count 5
    [I 180522 06:56:20 config:75] YAML Definition loaded: S10x.yaml, type: 3, definition count 6
    [I 180522 06:56:21 config:75] YAML Definition loaded: L51x.yaml, type: 3, definition count 7
    [I 180522 06:56:21 config:75] YAML Definition loaded: CUSTOM MODBUS DEVICE.yaml, type: 3, definition count 8
    [I 180522 06:56:21 config:75] YAML Definition loaded: L50x.yaml, type: 3, definition count 9
    [I 180522 06:56:21 config:75] YAML Definition loaded: xS30.yaml, type: 3, definition count 10
    [I 180522 06:56:21 config:75] YAML Definition loaded: xS10.yaml, type: 3, definition count 11
    [I 180522 06:56:21 config:75] YAML Definition loaded: M40x.yaml, type: 3, definition count 12
    [I 180522 06:56:21 config:75] YAML Definition loaded: M10x.yaml, type: 3, definition count 13
    [I 180522 06:56:21 config:75] YAML Definition loaded: M60x.yaml, type: 3, definition count 14
    [I 180522 06:56:22 config:75] YAML Definition loaded: L20x.yaml, type: 3, definition count 15
    [I 180522 06:56:22 config:75] YAML Definition loaded: xS50.yaml, type: 3, definition count 16
    [I 180522 06:56:22 config:75] YAML Definition loaded: evok-alias.yaml, type: 2, definition count 0
    [I 180522 06:56:22 evok:1698] HTTP server listening on port: 8080
    [I 180522 06:56:22 modbusclient_tornado:122] SPI client started
    [I 180522 06:56:22 modbusclient_rs485:333] UART client started
    [I 180522 06:56:22 neuron:268] Reading the UART board on Modbus address 1
    [D 180522 06:56:22 owclient:377] Entering 1wire loop
    [I 180522 06:56:22 web:2064] 101 GET /ws (::1) 3.76ms
    [D 180522 06:56:22 evok:158] New WebSocket client connected
    [I 180522 06:56:22 neuron:157] Reading SPI boards
    [I 180522 06:56:22 web:2064] 200 GET /rest/all (::1) 3.10ms
    [I 180522 06:56:22 config:351] Alias loaded: <neuron.Relay object at 0x75f42690> al_lights_kitchen
    [I 180522 06:56:22 config:351] Alias loaded: <neuron.Relay object at 0x75f42650> al_lights_bedroom
    [I 180522 06:56:24 web:2064] 101 GET /ws (::1) 1.79ms
    [D 180522 06:56:24 evok:158] New WebSocket client connected
    [I 180522 06:56:24 web:2064] 200 GET /rest/all (::1) 7.07ms
    [E 180522 06:56:28 neuron:290] No cached value of register 1018 on unit 1 - read error
        Traceback (most recent call last):
          File "/opt/evok/neuron.py", line 283, in readboards
            yield board.parse_definition(self.hw_dict, 1)
          File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1055, in run
            value = future.result()
          File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 238, in result
            raise_exc_info(self._exc_info)
          File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1069, in run
            yielded = self.gen.send(value)
          File "/opt/evok/neuron.py", line 409, in parse_definition
            regpolarity=m_feature['polar_reg'], legacy_mode=self.legacy_mode)
          File "/opt/evok/neuron.py", line 1309, in __init__
            curr_ds = self.arm.neuron.modbus_cache_map.get_register(1, self.regmode, unit=self.arm.modbus_address)[0]
          File "/opt/evok/neuron.py", line 48, in get_register
            raise Exception('No cached value of register %d on unit %d - read error' % (counter, unit))
        Exception: No cached value of register 1018 on unit 1 - read error
    ^C[I 180522 06:56:39 evok:1773] Shutting down
    

  • administrators

    It looks like the system can't connect to the device - does the RX light on the Neuron (not the extension) flash at all? It should be roughly simultaneous with the TX light.

    From the log it looks like there's no valid communication with the extension unfortunately, so something must be wrong with the connection.



  • Hi
    this day after a reboot i have the same error message and the link from S103G to xs50 not working only one short blink from the modbus rx/tx

    reinstall evok and fresh image not working.

    root@pimatic:~# /usr/bin/python /opt/evok/evok.py
    [I 180524 19:27:48 config:63] eprom: UniPi Neuron S103 version: 1.0 serial: 0xd
    [I 180524 19:27:48 evok:1634] Starting using config file /etc/evok.conf
    [I 180524 19:27:48 config:75] YAML Definition loaded: M20x.yaml, type: 3, definition count 0
    [I 180524 19:27:48 config:75] YAML Definition loaded: xS40.yaml, type: 3, definition count 1
    [I 180524 19:27:48 config:75] YAML Definition loaded: M30x.yaml, type: 3, definition count 2
    [I 180524 19:27:48 config:75] YAML Definition loaded: L40x.yaml, type: 3, definition count 3
    [I 180524 19:27:49 config:75] YAML Definition loaded: L50x.yaml, type: 3, definition count 4
    [I 180524 19:27:49 config:75] YAML Definition loaded: M50x.yaml, type: 3, definition count 5
    [I 180524 19:27:49 config:75] YAML Definition loaded: M40x.yaml, type: 3, definition count 6
    [I 180524 19:27:49 config:75] YAML Definition loaded: L30x.yaml, type: 3, definition count 7
    [I 180524 19:27:49 config:75] YAML Definition loaded: xS50.yaml, type: 3, definition count 8
    [I 180524 19:27:49 config:75] YAML Definition loaded: CUSTOM MODBUS DEVICE.yaml, type: 3, definition count 9
    [I 180524 19:27:50 config:75] YAML Definition loaded: M60x.yaml, type: 3, definition count 10
    [I 180524 19:27:50 config:75] YAML Definition loaded: L20x.yaml, type: 3, definition count 11
    [I 180524 19:27:50 config:75] YAML Definition loaded: S10x.yaml, type: 3, definition count 12
    [I 180524 19:27:50 config:75] YAML Definition loaded: xS30.yaml, type: 3, definition count 13
    [I 180524 19:27:50 config:75] YAML Definition loaded: M10x.yaml, type: 3, definition count 14
    [I 180524 19:27:51 config:75] YAML Definition loaded: L51x.yaml, type: 3, definition count 15
    [I 180524 19:27:51 config:75] YAML Definition loaded: xS10.yaml, type: 3, definition count 16
    [I 180524 19:27:51 config:75] YAML Definition loaded: DALI.yaml, type: 3, definition count 17
    [I 180524 19:27:51 config:75] YAML Definition loaded: evok-alias.yaml, type: 2, definition count 0
    [I 180524 19:27:51 evok:1698] HTTP server listening on port: 8080
    [I 180524 19:27:51 modbusclient_tornado:122] SPI client started
    [I 180524 19:27:51 modbusclient_rs485:333] UART client started
    [I 180524 19:27:51 neuron:268] Reading the UART board on Modbus address 15
    [I 180524 19:27:51 neuron:157] Reading SPI boards
    [D 180524 19:27:51 owclient:377] Entering 1wire loop
    [I 180524 19:27:51 neuron:172] No board on SPI 2
    [E 180524 19:27:51 neuron:290] 'NoneType' object has no attribute 'get_register'
        Traceback (most recent call last):
          File "/opt/evok/neuron.py", line 283, in readboards
            yield board.parse_definition(self.hw_dict, 1)
          File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1055, in run
            value = future.result()
          File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 238, in result
            raise_exc_info(self._exc_info)
          File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1069, in run
            yielded = self.gen.send(value)
          File "/opt/evok/neuron.py", line 561, in parse_definition
            self.parse_feature(m_feature, board_id)
          File "/opt/evok/neuron.py", line 546, in parse_feature
            self.parse_feature_ao(max_count, m_feature, board_id)
          File "/opt/evok/neuron.py", line 478, in parse_feature_ao
            dev_id=self.dev_id, major_group=m_feature['major_group'], legacy_mode=self.legacy_mode)
          File "/opt/evok/neuron.py", line 1777, in __init__
            self.offset = (uint16_to_int(self.arm.neuron.modbus_cache_map.get_register(1, self.regcal + 1, unit=self.arm.modbus_address)[0]) / 10000.0)
        AttributeError: 'NoneType' object has no attribute 'get_register'
    [I 180524 19:27:51 neuron:172] No board on SPI 3
    [I 180524 19:27:51 config:351] Alias loaded: <neuron.Relay object at 0x7600dc70> al_lights_kitchen
    [I 180524 19:27:51 config:351] Alias loaded: <neuron.Relay object at 0x7600df50> al_lights_bedroom
    

    Regards



  • I have this exact same issue as "unix", both with the master branch and 2.0.6. Anyone that came up with a solution?


  • administrators

    Hi @alydersen!

    Do you also have the xS50 and S103G models? The error is simply a generic error indicating that no data from the device is available to EVOK in its cache.

    It can be caused by wrong parity, bitcount or address settings, as well as potentially any other issues which break the communication.

    By far the most crucial LED indicator is the RX LED light on the master Neuron unit - does it light at all? If not it means that no response has been sent on the bus, which means that there is no data received on the underlying hardware - much less EVOK itself.

    Please see below, apologies


  • administrators

    @alydersen

    It looks like there has been a recent bug in EVOK which caused the hardware definitions to be parsed incorrectly. What I said above does stand, but the error is a software bug on our part.

    You will need to download the release 2.0.7 in order to fix the problems you are seeing. The source of the error is a missing condition which causes UART hw_definitions to break, though only some of the time.