<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../XSLT/decoder.xsl"?>

<!-- Copyright (C) JMRI 2006 All rights reserved -->
<!--                                                                        -->
<!-- JMRI is free software; you can redistribute it an<B></B>d/or modify it under  -->
<!-- the terms of version 2 of the GNU General Public License as published  -->
<!-- by the Free Software Foundation. See the "COPYING" file for a copy     -->
<!-- of this license.                                                       -->
<!--                                                                        -->
<!-- JMRI is distributed in the hope that it will be useful, but WITHOUT    -->
<!-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or  -->
<!-- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License  -->
<!-- for more details.                                                      -->

<decoder-config xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://jmri.org/xml/schema/decoder-4-15-2.xsd">
  <version author="Egbert Broerse" version="3" lastUpdated="20210306"/> <!-- xinclude for CV34-38 -->
  <version author="Bob Jacobsen" version="2" lastUpdated="20190727"/> <!-- xinclude for CV19 -->
	<version author="LDH" version="1" lastUpdated="20170213" />

<decoder>
	<family name="LDH decoders" mfg="LDH" lowVersionID="27">
		<model model="LDH 4F1.5 v27" numOuts="6" numFns="6">
				<output name="1" label="A - Blanco" />
				<output name="2" label="B - Amarillo" />
				<output name="3" label="C - Verde" />
				<output name="4" label="D - Marron" />
				<output name="5" label="E - Blanco" />
				<output name="6" label="F - Amarillo" />
		</model>
	</family>

	<programming direct="yes" paged="yes" register="yes" ops="yes"/>

	<variables>

		<variable label="Direccion principal de la locomotora (1-127)" CV="1"
			item="Short Address" default="3"
			comment="Rango 1-127">
			<shortAddressVal/>
		</variable>

		<variable label="Velocidad minima(1-128)" CV="2" item="Vstart"
			comment="Rango 1-128" default="2">
			<decVal min="1" max="128"/>
			</variable>
		<variable label="Velocidad minima(1-128)" CV="2" item="EMF Droop Config"
			comment="Rango 1-128" default="2" tooltip="CV2">
			<decVal min="1" max="128"/>
			</variable>
		<variable label="Aceleracion (0-50)" CV="3"
			comment="Rango 0-50" default="5" item="Accel">
			<decVal min="0" max="50"/>
			</variable>

		<variable label="Desaceleracion (0-50)" CV="4"
			comment="Rango 0-50" default="5" item="Decel">
			<decVal min="0" max="50"/>
			</variable>
		
		<variable label="Velocidad maxima (0-255)" CV="5"
			item="Vhigh" default="220"
			comment="Rango 0-255">
			<decVal min="0" max="255"/>
		</variable>

		<variable label="Velocidad media (50-120)" CV="6"
			item="Vmid" default="70"
			comment ="Rango 50-120">
			<decVal min="50" max="120"/>
		</variable>

		<variable CV="7" item="Decoder Version" label="Version del programa " readOnly="yes"
			default="27">
			<decVal/>
		</variable>

		<variable CV="8" item="Manufacturer" label="Numero de Fabricante asignado por NMRA" readOnly="yes"
			default="56">
			<decVal/>
		</variable>

	  <variable label="Velocidad por encima de la cual BEMF baja hasta el valor del CV49 (64-255)" CV="10"
			item="Load Control" default="160" comment="Rango 64-255" tooltip="CV10">
			<decVal min="64" max="255"/>
		</variable>
    		
	  <variable label="Limite de tiempo (seg.) sin se~al DCC para este decoder 0= sin limite" CV="11"
			item="Motor Option 2" default="2" comment ="Rango 0-255"
			tooltip="Si pierde el control de la central el deco se detiene">
			<decVal/>
		</variable>

		<variable item="Analog Mode Function Status - F1" label="Analog Mode Function Status - F1" CV="13" mask="XXXXXXXV" tooltip="CV 13 bit 0">
			<enumVal>
				<enumChoice choice="off"/>
				<enumChoice choice="on"/>
      </enumVal>
    </variable>
		<variable item="Analog Mode Function Status - F2" label="Analog Mode Function Status - F2" CV="13" mask="XXXXXXVX" tooltip="CV 13 bit 1">
			<enumVal>
				<enumChoice choice="off"/>
				<enumChoice choice="on"/>
      </enumVal>
    </variable>
		<variable item="Analog Mode Function Status - F3" CV="13" mask="XXXXXVXX" tooltip="CV 13 bit 2">
			<enumVal>
				<enumChoice choice="off"/>
				<enumChoice choice="on"/>
      </enumVal>
    </variable>
		<variable item="Analog Mode Function Status - F4" label="Analog Mode Function Status - F4" CV="13" mask="XXXXVXXX" tooltip="CV 13 bit 3">
			<enumVal>
				<enumChoice choice="off"/>
				<enumChoice choice="on"/>
      </enumVal>
    </variable>
		
		<variable item="Analog Mode Function Status - FL(f)" label="Analog Mode Function Status - FL(f)" CV="14" mask="XXXXXXXV" tooltip="CV 14 bit 0" default="1">
			<enumVal>
				<enumChoice choice="off"/>
				<enumChoice choice="on"/>
      </enumVal>
    </variable>
		<variable item="Analog Mode Function Status - FL(r)" label="Analog Mode Function Status - FL(r)" CV="14" mask="XXXXXXVX" tooltip="CV 14 bit 1" default="1">
			<enumVal>
				<enumChoice choice="off"/>
				<enumChoice choice="on"/>
      </enumVal>
    </variable>
       
    <variable item="Codigo de Bloqueo de CVs" label="Codigo de Bloqueo de CVs" CV="15" default="4" comment="Cuando el CV15 coincide con el CV16 desbloquea CVS">
			<decVal min="0" max="255"/>
		</variable>

	 <variable item="Codigo de Bloqueo" label="Codigo de Bloqueo" CV="16" default="4" comment="Un valor distinto a 4 bloquea cambios">
			<decVal min="0" max="255"/>
		</variable>
    
		<variable label="Direccion extendida (0-9999)" CV="17"
			item="Long Address" default="0"
			comment="Direccion de 4 digitos (Rango 0-9999)">
			<longAddressVal/>
		</variable>
<!-- lo copie de lo que dice en decoders\NMRA\short and long address - lo mismo en V26 -->
<!-- si pongo ango para CV18 anda mal; le quiere sumar 192, etc   -->

    <xi:include href="http://jmri.org/xml/decoders/nmra/consistAddrDirection.xml"/>

		<variable label="F1 Activa en Consist" CV="21" mask="XXXXXXXV" minFn="1" item="Consist Address Active For F1">
			<enumVal>
				<enumChoice choice="Responde a la direccion Principal"/>
				<enumChoice choice="Responde a la direccion de Consist"/>
      </enumVal>
    </variable>
		<variable label="F2 Activa en Consist" CV="21" mask="XXXXXXVX" minFn="2" item="Consist Address Active For F2">
			<enumVal>
				<enumChoice choice="Responde a la direccion Principal"/>
				<enumChoice choice="Responde a la direccion de Consist"/>
      </enumVal>
    </variable>
		<variable label="F3 Activa en Consist" CV="21" mask="XXXXXVXX" minFn="3" item="Consist Address Active For F3">
			<enumVal>
				<enumChoice choice="Responde a la direccion Principal"/>
				<enumChoice choice="Responde a la direccion de Consist"/>
      </enumVal>
    </variable>
		<variable label="F4 Activa en Consist" CV="21" mask="XXXXVXXX" minFn="4" item="Consist Address Active For F4">
			<enumVal>
				<enumChoice choice="Responde a la direccion Principal"/>
				<enumChoice choice="Responde a la direccion de Consist"/>
      </enumVal>
    </variable>

				<variable label="FL Activa en Consist" CV="22" mask="XXXXXXXV" item="Consist Address Active For FL in Forward">
			<enumVal>
				<enumChoice choice="Responde a la direccion Principal"/>
				<enumChoice choice="Responde a la direccion de Consist"/>
      </enumVal>
    </variable>
		<variable label="FR Activa en Consist" CV="22" mask="XXXXXXVX" item="Consist Address Active For FL in Reverse">
			<enumVal>
				<enumChoice choice="Responde a la direccion Principal"/>
				<enumChoice choice="Responde a la direccion de Consist"/>
			</enumVal>
    </variable>

    <variable label="Ajuste de aceleracion (CV23)" CV="23" mask="XVVVVVVV"
              tooltip="CV23" item="Consist Acceleration Adjustment" >
        <decVal max="127"/>
    </variable>
    <variable label="Operacion" CV="23" mask="VXXXXXXX"
              item="Consist Acceleration Adjustment Sign" >
      <enumVal>
        <enumChoice choice="Suma"/>
        <enumChoice choice="Resta"/>
      </enumVal>
    </variable>
      
    <variable label="Ajuste de desaceleracion (CV24)" CV="24" mask="XVVVVVVV"
              tooltip="CV24" item="Consist Deceleration Adjustment" >
        <decVal max="127"/>
      </variable>
    <variable label="Operacion" CV="24" mask="VXXXXXXX"
              item="Consist Deceleration Adjustment Sign">
      <enumVal>
        <enumChoice choice="Suma"/>
        <enumChoice choice="Resta"/>
      </enumVal></variable>

    
		<variable label="Sentido de marcha" CV="29" mask="XXXXXXXV"
			item="Locomotive Direction" default="0">
			<enumVal>
				<enumChoice choice="Normal"/>
				<enumChoice choice="Inverso"/>
			</enumVal>
		</variable>

		<variable label="Pasos de velocidad" CV="29" mask="XXXXXXVX"
			item="Speed Step Mode" default="1" comment="Configura la opcion de pasos de velocidad">
			<enumVal>
				<enumChoice choice="14"/>
				<enumChoice choice="28/128"/>
			</enumVal>
		</variable>

		<variable label="Modo Analogico" CV="29" mask="XXXXXVXX" 
			item="Analog (DC) Operation" default="1">
			<enumVal>
				<enumChoice choice="Deshabilitado"/>
				<enumChoice choice="Habilitado"/>
			</enumVal>
		</variable>
	
		<variable label="Tabla de velocidades" CV="29" mask="XXXVXXXX"
			item="Speed Table Definition" default="1">
			<enumVal>
				<enumChoice choice="Tabla de velocidades desactivada"/>
				<enumChoice choice="Tabla de velocidades activada"/>
			</enumVal>
		</variable>

		<variable label="Tipo de direccion" CV="29" mask="XXVXXXXX"
			item="Address Format">
			<enumVal>
				<enumChoice choice="Direccion Corta (CV1)"/>
				<enumChoice choice="Direccion Extendida"/>
			</enumVal>
		</variable>

    <xi:include href="http://jmri.org/xml/decoders/ldh/cv33-39mapping.xml"/>

	  <variable label="Compensacion de velocidad minima. Sin BEMF se suma a CV2 (1-100)" CV="48"
			default="5" comment ="Rango 1-100" item="EMF Option 1" tooltip="CV48">
			<decVal min="1" max="100"/>
		</variable>

		<variable label="Valor remanente del BEMF, en % del correspondiente a velocidad baja (0-100)" CV="49"
			default="50" comment ="Rango 0-100" item="EMF Static Config" tooltip="CV49">
			<decVal min="0" max="100"/>
		</variable>

		<variable label="BEMF" mask="XXXXXXXV" CV="50" default="1" item="Motor PWM Frequency" tooltip="CV50">
        <enumVal>
				  <enumChoice choice="Desactivado"/>
				  <enumChoice choice="Activado"/>
				</enumVal>
		</variable>

		<variable label="Alimentacion del motor (PWM)" mask="XXXXXXVX" CV="50" default="1" item="EMF Dynamic Config" tooltip="CV50">
        <enumVal>
				  <enumChoice choice="Baja frecuencia"/>
				  <enumChoice choice="Alta frecuencia"/>
				</enumVal>
		</variable>

		<variable label="Suma CV2 a los primeros valores de la tabla" mask="XXXXXVXX" CV="50" default="1" tooltip="CV50" item="EMF Feedback Cutout">
        <enumVal>
				  <enumChoice choice="Desactivado"/>
				  <enumChoice choice="Activado"/>
				</enumVal>
		</variable>

		<variable label="Para Decoder provisto con Banco de Energia" mask="XXXXVXXX" CV="50" default="0" tooltip="Mantiene vel. y funciones cuando se alimenta del Banco de Energia (no pasa a DC)" item="EMF Option 4">
        <enumVal>
				  <enumChoice choice="Desactivado"/>
				  <enumChoice choice="Activado"/>
				</enumVal>
		</variable>		

		<variable label="Ki - Ajuste de BEMF integral (CV51)" CV="51"
			default="60" comment="Rango 0-255" item="Dither frequency" tooltip="CV51">
			<decVal min="0" max="255"/>
		</variable>

		<variable label="Kp - Ajuste de BEMF proporcional (CV52). No poner ambos CV51 y CV52 en 0" CV="52"
			default="120" tooltip="CV52" comment="Rango 0-255" 	item="Dither option">
			<decVal min="0" max="255"/>
		</variable>
			
    <variable label="Efecto de FL:" CV="53" mask="XVVXXVVV" tooltip="CV 53"
				item="Output 1 effect generated">
			  <enumVal>
				  <enumChoice choice="Desactivado"/>
				  <enumChoice choice="Intermitente" value="32" />
        	<enumChoice choice="En contrafase" value="64" />
        	<enumChoice choice="Destellos" value="2" />
				  <enumChoice choice="Intensidad modulada (Mars)" value="4" />
				  <enumChoice choice="Luz atenuada" value="1" />
				</enumVal>
			</variable>
		<variable label="Modo:" CV="53" mask="XXXVVXXX" tooltip="CV 53"
				item="Output 1 behavior" default="2">
			<enumVal>
				<enumChoice choice="Siempre activado"/>
			  <enumChoice choice="Solo en reversa"/>
			  <enumChoice choice="Solo en directa"/>
      </enumVal>
		</variable>
			
    <variable label="Efecto de RL:" CV="54" mask="XVVXXVVV" tooltip="CV 54"
				item="Output 2 effect generated">
			  <enumVal>
				  <enumChoice choice="Desactivado"/>
				  <enumChoice choice="Intermitente" value="32" />
      		<enumChoice choice="Intermitente (contrafase)" value="64" />
        	<enumChoice choice="Destellos" value="2" />
				  <enumChoice choice="Intensidad modulada (Mars)" value="4" />
				  <enumChoice choice="Luz atenuada" value="1" />
				</enumVal>
    </variable>
		<variable label="Modo:" CV="54" mask="XXXVVXXX" tooltip="CV 54"
				item="Output 2 behavior" default="1">
			  <enumVal>
				  <enumChoice choice="Siempre activado"/>
			  	<enumChoice choice="Solo en reversa"/>
			  	<enumChoice choice="Solo en directa"/>
				</enumVal>
    </variable>
			
    <variable label="Efecto de F1:" CV="55" mask="XVVXXVVV" tooltip="CV 55"
				item="Output 3 effect generated">
			  <enumVal>
				  <enumChoice choice="Desactivado"/>
				  <enumChoice choice="Intermitente" value="32" />
        	<enumChoice choice="Intermitente (contrafase)" value="64" />
        	<enumChoice choice="Destellos" value="2" />
				  <enumChoice choice="Intensidad modulada (Mars)" value="4" />
				  <enumChoice choice="Luz atenuada" value="1" />
				</enumVal>
			</variable>
		<variable label="Modo:" CV="55" mask="XXXVVXXX" tooltip="CV 55"
				item="Output 3 behavior">
			<enumVal>
				<enumChoice choice="Siempre activado"/>
			  	<enumChoice choice="Solo en reversa"/>
			  	<enumChoice choice="Solo en directa"/>
				</enumVal>
    </variable>
			
		<variable label="Efecto de F2:" CV="56" mask="XVVXXVVV" tooltip="CV 56"
				item="Output 4 effect generated">
			<enumVal>
				  <enumChoice choice="Desactivado"/>
				  <enumChoice choice="Intermitente" value="32" />
          <enumChoice choice="Intermitente (contrafase)" value="64" />
          <enumChoice choice="Destellos" value="2" />
				  <enumChoice choice="Intensidad modulada (Mars)" value="4" />
				  <enumChoice choice="Luz atenuada" value="1" />
				</enumVal>
    </variable>
		<variable label="Modo:" CV="56" mask="XXXVVXXX" tooltip="CV 56"
				item="Output 4 behavior">
			<enumVal>
			  <enumChoice choice="Siempre activado"/>
			  <enumChoice choice="Solo en reversa"/>
			  <enumChoice choice="Solo en directa"/>
      </enumVal>
    </variable>

		<variable label="Efecto de F3:" CV="57" mask="XVVXXVVV" tooltip="CV 57"
				item="Output 5 effect generated">
			<enumVal>
				<enumChoice choice="Desactivado"/>
				<enumChoice choice="Intermitente" value="32" />
        <enumChoice choice="Intermitente (contrafase)" value="64" />
        <enumChoice choice="Destellos" value="2" />
				<enumChoice choice="Intensidad modulada (Mars)" value="4" />
				<enumChoice choice="Luz atenuada" value="1" />
			</enumVal>
		</variable>
		<variable label="Modo:" CV="57" mask="XXXVVXXX" tooltip="CV 57"
				item="Output 5 behavior">
			<enumVal>
				<enumChoice choice="Siempre activado"/>
			  <enumChoice choice="Solo en reversa"/>
			  <enumChoice choice="Solo en directa"/>
			</enumVal>
		</variable>
		<variable label="Efecto de F4:" CV="58" mask="XVVXXVVV" tooltip="CV 58"
				item="Output 6 effect generated">
			<enumVal>
				<enumChoice choice="Desactivado"/>
				<enumChoice choice="Intermitente" value="32" />
        <enumChoice choice="Intermitente (contrafase)" value="64" />
        <enumChoice choice="Destellos" value="2" />
				<enumChoice choice="Intensidad modulada (Mars)" value="4" />
				<enumChoice choice="Luz atenuada" value="1" />
			</enumVal>
		</variable>
		<variable label="Modo:" CV="58" mask="XXXVVXXX" tooltip="CV 58"
				item="Output 6 behavior">
			<enumVal>
				<enumChoice choice="Siempre activado"/>
			  <enumChoice choice="Solo en reversa"/>
			  <enumChoice choice="Solo en directa"/>
			</enumVal>
		</variable>

		<variable label="Control frecuencia de efectos (255-50)" CV="61" default="120"
					item="Global lighting option 1" tooltip="Valor 100 = 1Hz ; Valor 200 = 0,5Hz" >
	          	<decVal min="50" max="255"/>
		</variable>

		<variable label="Intensidad con efecto luz atenuada (1-3)" CV="62" default="2" 
					item="Global lighting option 2" tooltip="Valor 1 = 25% ; Valor 2 = 50% ; Valor 3 = 75%" >
	          	<decVal min="1" max="3"/>
		</variable>

	  <variable label="Tiempo de cada pausa en inversion de marcha:" CV="63"
			default="100" item="EMF Option 2" comment="Rango 0-255" tooltip="Valor 100 = 2 segundos en total">
			<decVal min="0" max="255"/>
		</variable>			
                        
    <variable label="Tiempo para compensacion de juego mecanico en la inversion de marcha" CV="64"
			default="120" item="EMF Option 3" comment="Rango 1-255" tooltip="CV 64">
			<decVal min="1" max="255"/>
		</variable>		
		<variable item="Speed Table" label="Speed Table" CV="67" default="1">
			<speedTableVal/>
		</variable>

    <xi:include href="http://jmri.org/xml/decoders/ldh/cv67-94speed.xml"/>

	<variable label="Libre para usuario 1" CV="105"
		item="User Id #1" default="0"
		comment="Rango 0-255">
		<decVal min="0" max="255"/>
	</variable>

	<variable label="Libre para usuario 2" CV="106"
		item="User Id #2" default="0"
		comment="Rango 0-255">
		<decVal min="0" max="255"/>
	</variable>
	
	<variable label="Potencia del motor en lectura de CVs" item="Motor Option 3" 
	          tooltip="aumentar valor si el consumo del motor es muy bajo"
	         CV="128"  default="160">	<decVal min="0" max="255" />
	</variable>

</variables>

</decoder>

</decoder-config>
