Saturday, 31 December 2016

Networking XLogic PLCs

My house is run with XLogic PLC controllers.  The manuals are thorough, but are written in terrible Chinglish.  Which is unfortunate, because the UIs are almost completely incomprehensible.

All "manual" references in these notes are to the X-Messenger manual and xLogic's "eSms Config" software unless indicated otherwise.

WIFI PLC - Network Module

My network includes one EXM-12 series module with ethernet and wifi.  It was a real bear to understand the unintuitive setup process.  It'll go better for you if you think of all the TCP networking as being located in a stand-alone external module with its own CPU, which talks to the PLC over a 9600 baud serial interface.

Web Interface

 The device has a mostly useless web interface.  You can use it for two things:
  • change WIFI between AP (Serve as a wifi access point) and STA (Connect to your existing AP).  You should use a serial cable instead.
  • You can also use it to screw up some other settings:
    • the serial connection to the PLC.  Must remain at 9600 N 8 1.
    • the ethernet port
  • If you reset the device from the panel->set->network menu, it sets the network module's serial speed to 57600, which is incompatible with the PLC.  You *must* connect by wifi and change it back to 9600 before you can make any serial changes to the network module.

Ethernet  

  • I couldn't make it work at all, not even respond to ping.
  • The LEDs on the ethernet are hijacked to indicate WIFI status.  Nothing to do with ethernet.  (pg 356)
  • Open/Closed in this context means the ethernet port is active or disabled.
  • Possibly the ethernet port is only useful for Modbus TCP -- I didn't test this.

WIFI Modbus/TCP

  • Initial configuration is AP mode.  Connect to it at http://10.10.100.256, credentials admin / admin.
  • You should probably change wifi settings with eSMS config and a serial cable
  • If you're feeling lucky, you can use the web interface to change it to STA mode and have it connect to your AP.  If you screw up the cryptic settings for security, you won't be able to access the unit over WIFI anymore, and you'll need to fail over to changing settings with the config software
  • MAC field is optional.

eSms Config

Use an onboard RS232 port if you're using the serial cable.  I had very little luck with USB-RS232 converters [update 2019: I found a genuine PL2303 device that worked, albeit not very well].  If you own the xLogic USB cable you'll probably be in better shape than me, but I couldn't bring myself to pay US$25 shipping on such a simple part.  Anyhow, once you have a physical serial connection, the process looks like this:
  1. Tools->Configuration
  2. Select RS232 port and EXM address
  3. Click "connect to EXM"
  4. Check that you have a valid connection 
    • Use "get time from PLC" (toolbar L-circle-up-arrow)
  5. Tools->Wifi Param
  6. On every screen in Wifi Param,  click "READ" to see current state.
  7. If you make changes, also click "WRITE".
  8. I have no idea what the apply button does.
The left (Program) port is Com0.  The right (Extend) port is Com1.

HMI / SCADA development

See my later blog entry.

Friday, 30 December 2016

ICBC - Cost of short-term Autoplan policy

ICBC doesn't seem to publish anything about the cost of a short-term auto insurance policy.  I couldn't get a straight answer out of the Autoplan agent about the total amount of fees that are non-refundable.

TLDR: Up to about 5 days, buy a trip permit.  Above that, buy a year and cancel.



Early Cancellation

  • refund is pro-rated by day, except for nonrefundable:
    • $30 early cancellation fee
    • $18 plate is forfeited
    • Some other costs.
  • EG: Imagine your total yearly charge is $1000 
    • That includes $48 in non-refundable charges
    • refundable premiums will be $952.
    • Final cost will be $48 + $2.61 / day.

Short-Term policy

  • Is not cheaper than cancelling a full-year policy
  • premiums are pro-rated to the day
  • some of the fees are not pro-rated (?)
  • there is an additional $30 or $40 short-term fee 

Trip Permit

Length of Period
$1 million Liability only
$5 million Liability only
$5MM, Collision & Comprehensive
one day
$31
$36
$43
(most common permit)
2 days
$48
$55
$70
3 days
$64
$71
$92
one week
$138
$150
$189
15 days
$238
$254
$310

Tuesday, 8 November 2016

Basil experiment: 440nm blue LED grow light

Growing Basil under 450nm LED

Summary:

Grew basil under a 50W LED at 450nm, at a distance of about 15 cm.  Growth was markedly inferior to plants grown on a window ledge in the September BC sun.

Problem:

Apparently blue wavelengths are optimal for promoting leafy growth, centered at around 430 nm.

Apparatus:

A bit of searching on Aliexpress turned up this 50W LED and matching driver at 450nm.
It came without instructions, but it wasn't hard to figure out the polarity of the terminals.

The driver is rated for 30-34V, but only made about 28V.  It was still insanely bright, but got hot enough to melt the solder off after about 2 minutes.  Obviously it needed a heat sink.  That got me thinking about how to safely assemble the whole thing.


A 4.5" device box is just the thing to contain the driver.  It's fireproof, and it's already got 1/2" knockouts.

The driver didn't have mounting holes for standoffs, and this was a quick-and-dirty experiment, so I just made some clips out of strapping and screwed it onto a scrap of plywood.    I needed a buck power supply to generate 12V for the heat sink fan, but fortunately there was still enough room on the plywood.

Light intensity wasn't very high relative to sunlight, so I put the LED about 10cm above the basil.  The basil seemed to be browning a little after a week, possibly from excess IR, so I raised it 5cm.

Experiment:

I ran the LED on a lamp timer for 14 hours per day, for two weeks, on a tray of four recently propagated basil plants, watered with capillary ceramic watering spikes.

My control was two more cuttings from the same batch, placed on a south-facing kitchen window ledge, getting most of the day's late-september sun.

Results:

I didn't do any rigorous measurement, and one of the LED plants died.

The control basil had almost twice as much growth as the LED basil.

Conclusion:


The basil mostly didn't die, but wasn't very happy under the monochromatic light.

I should try another experiment in deep winter, doing actual growth measurements, and comparing against both the (very poor) BC winter sunlight, and a full-spectrum T5 grow light.

Tuesday, 8 March 2016

KOdi keymap for USB remote "X10 lola"

Had remarkably a lot of trouble getting my old X10 RF  remote set up to work with Kodi.  Linux keymapping isn't quite as trivial as it once was.  Here are the steps I followed:
 
1. find the device vendor with lsusb.    Mine was 0BC7.

2. Find all the device's modalias files with
    find /sys -name *modalias | xargs grep -i 0BC7

3. Use the one that is a single string.  Mine was the file at
    /sys/devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1:1.0/modalias

My modalias string looks like this.  We want everything before the 'e', because we want it to apply to all versions.
    input:b0003v0BC7p0002e0100-e0,1,2,k110,111,113,114,r0,1,amlsfw

4. Using heavy reference to this Arch wiki page,
    https://wiki.archlinux.org/index.php/Map_scancodes_to_keycodes
    /usr/include/linux/input.h

I create a hwdb file in /etc/udev/hwdb.d/10-x10.hwdb.  It contains:

Here's the HWDB file

evdev:input:b0003v0BC7p0002*
 KEYBOARD_KEY_00=esc    #    setup
 KEYBOARD_KEY_2c=favorites    #    learn
 KEYBOARD_KEY_02=power    #    power
 KEYBOARD_KEY_03=tv    #    tv
 KEYBOARD_KEY_04=audio    #    audio
 KEYBOARD_KEY_31=tv2    #    cable
 KEYBOARD_KEY_05=pc    #    pc
 KEYBOARD_KEY_06=vcr    #    x10
 KEYBOARD_KEY_0b=up    #    ch+
 KEYBOARD_KEY_08=volumedown    #    vol-
 KEYBOARD_KEY_0a=mute    #    m
 KEYBOARD_KEY_09=volumeup    #    vol+
 KEYBOARD_KEY_0c=down    #    ch-
 KEYBOARD_KEY_0d=1    #    1
 KEYBOARD_KEY_0e=2    #    2
 KEYBOARD_KEY_0f=3    #    3
 KEYBOARD_KEY_10=4    #    4
 KEYBOARD_KEY_11=5    #    5
 KEYBOARD_KEY_12=6    #    6
 KEYBOARD_KEY_13=7    #    7
 KEYBOARD_KEY_14=8    #    8
 KEYBOARD_KEY_15=9    #    9
 KEYBOARD_KEY_17=0    #    0
 KEYBOARD_KEY_16=numeric_star    #    add/del
 KEYBOARD_KEY_18=numeric_pound    #    a/b
 KEYBOARD_KEY_19=fn_f1    #    red – album
 KEYBOARD_KEY_1b=fn_f2    #    yellow – artist
 KEYBOARD_KEY_21=fn_f3    #    green – genre
 KEYBOARD_KEY_23=fn_f4    #    blue – track
 KEYBOARD_KEY_1c=pageup    #    pg up
 KEYBOARD_KEY_20=pagedown    #    pgdown
 KEYBOARD_KEY_1a=up    #    thumb up
 KEYBOARD_KEY_1d=left    #    thumb left
 KEYBOARD_KEY_1f=right    #    thumb right
 KEYBOARD_KEY_22=down    #    thumb down
 KEYBOARD_KEY_1e=enter    #    thumb press
 KEYBOARD_KEY_01=fn_f5    #    purple – playlist
 KEYBOARD_KEY_2d=fn_f6    #    orange – playing
 KEYBOARD_KEY_2e=home    #    t top
 KEYBOARD_KEY_2f=end    #    e end
 KEYBOARD_KEY_07=find    #    find
 KEYBOARD_KEY_30=select    #    select
 KEYBOARD_KEY_2b=previoussong    #    scan -
 KEYBOARD_KEY_24=rewind    #    rewind
 KEYBOARD_KEY_25=playpause    #    play
 KEYBOARD_KEY_26=fastforward    #    fast fwd
 KEYBOARD_KEY_2a=nextsong    #    scan +
 KEYBOARD_KEY_27=record    #    rec
 KEYBOARD_KEY_28=stop    #    stop
 KEYBOARD_KEY_29=pause    #    pause