diff --git a/.gitignore b/.gitignore index ca9ab00381a966fe90b2c017df6607cc1a488802..0e3c90d27700260d9debbf4ccba3684e44e69cb1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ savestate.* savestatemacro.* *.expanded *.halscope +*.o +mb2halv2/mb2halv2 diff --git a/lcec.hal b/lcec.hal index 5531cf53c4b68dc51965ea0a11538da5d5ce032c..699e73d3f66c164db65b27c4c123e3fe23315b80 100755 --- a/lcec.hal +++ b/lcec.hal @@ -1,6 +1,7 @@ loadrt trivkins loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS +loadusr -W mb2hal config=mb2hal.ini loadusr -W lcec_conf maurice.xml loadrt lcec diff --git a/maurice.clp b/maurice.clp index 82848ab54a32d9398ed517f52d5caaea438d3652..13b62f65ed96b8190a2a956285891679d07c8f97 100644 --- a/maurice.clp +++ b/maurice.clp @@ -1,6 +1,7 @@ _FILES_CLASSICLADDER _FILE-modbusioconf.csv #VER=1.0 +1,5,3240,1,0,0 _/FILE-modbusioconf.csv _FILE-ioconf.csv #VER=1.0 @@ -9,7 +10,7 @@ _FILE-rung_5.csv #VER=2.0 #LABEL= #COMMENT= -#PREVRUNG=2 +#PREVRUNG=6 #NEXTRUNG=3 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 1-0-50/8 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 52-0-0/2 @@ -39,10 +40,10 @@ _FILE-timers_iec.csv 2,1,0 1,1,0 2,1,0 -1,1,1 -1,1,1 -1,0,0 -1,0,0 +1,3,1 +1,3,1 +2,5,2 +2,5,2 1,0,0 1,0,0 _/FILE-timers_iec.csv @@ -239,6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0/0 , 0-0-0/0 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 @@ -274,21 +288,21 @@ _FILE-rung_0.csv 9-0-0/0 , 1-0-0/0 , 9-0-0/0 , 2-0-60/0 , 9-0-0/0 , 9-0-0/0 , 9-1-0/0 , 99-0-0/0 , 13-0-0/4 , 50-0-60/4 0-0-0/0 , 1-1-60/2 , 0-1-0/0 , 0-0-0/0 , 0-0-0/0 , 99-1-0/0 , 13-0-0/0 , 99-0-0/0 , 99-0-0/0 , 51-1-60/5 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 99-0-0/0 , 99-0-0/0 , 9-1-0/0 , 9-0-0/0 , 50-0-60/8 -9-0-0/0 , 1-0-50/0 , 2-0-50/1 , 9-0-0/0 , 1-0-50/2 , 99-0-0/0 , 13-0-0/1 , 9-0-0/0 , 9-0-0/1 , 50-0-60/0 -0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 99-0-0/0 , 99-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 +9-0-0/0 , 1-0-50/0 , 2-0-50/1 , 9-0-0/0 , 1-0-50/2 , 99-0-0/0 , 13-0-0/1 , 99-0-0/0 , 13-0-0/7 , 50-0-60/0 +0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 99-0-0/0 , 99-0-0/0 , 99-0-0/0 , 99-0-0/0 , 0-0-0/0 _/FILE-rung_0.csv _FILE-com_params.txt -MODBUS_MASTER_SERIAL_PORT= +MODBUS_MASTER_SERIAL_PORT=/dev/ttyS0 MODBUS_MASTER_SERIAL_SPEED=9600 MODBUS_MASTER_SERIAL_DATABITS=8 MODBUS_MASTER_SERIAL_STOPBITS=1 MODBUS_MASTER_SERIAL_PARITY=0 MODBUS_ELEMENT_OFFSET=0 MODBUS_MASTER_SERIAL_USE_RTS_TO_SEND=0 -MODBUS_MASTER_TIME_INTER_FRAME=100 +MODBUS_MASTER_TIME_INTER_FRAME=10000 MODBUS_MASTER_TIME_OUT_RECEIPT=500 -MODBUS_MASTER_TIME_AFTER_TRANSMIT=0 -MODBUS_DEBUG_LEVEL=0 +MODBUS_MASTER_TIME_AFTER_TRANSMIT=10 +MODBUS_DEBUG_LEVEL=3 MODBUS_MAP_COIL_READ=0 MODBUS_MAP_COIL_WRITE=0 MODBUS_MAP_INPUT=0 @@ -338,7 +352,7 @@ _FILE-rung_1.csv 9-0-0/0 , 1-0-0/1 , 9-0-0/0 , 2-0-60/1 , 9-0-0/0 , 9-0-0/0 , 9-1-0/0 , 99-0-0/0 , 13-0-0/5 , 50-0-60/6 0-0-0/0 , 1-1-60/3 , 0-1-0/0 , 0-0-0/0 , 0-0-0/0 , 99-1-0/0 , 13-0-50/2 , 99-0-0/0 , 99-0-0/0 , 51-1-60/7 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 99-0-0/0 , 99-0-0/0 , 9-1-0/0 , 9-0-0/0 , 50-0-60/9 -9-0-0/0 , 1-0-50/4 , 2-0-50/5 , 9-0-0/0 , 1-0-50/6 , 99-0-0/0 , 13-0-0/3 , 9-0-0/0 , 9-0-0/0 , 50-0-60/1 -0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 99-0-0/0 , 99-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 +9-0-0/0 , 1-0-50/4 , 2-0-50/5 , 9-0-0/0 , 1-0-50/6 , 99-0-0/0 , 13-0-0/3 , 99-0-0/0 , 13-0-0/6 , 50-0-60/1 +0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 99-0-0/0 , 99-0-0/0 , 99-0-0/0 , 99-0-0/0 , 0-0-0/0 _/FILE-rung_1.csv _/FILES_CLASSICLADDER diff --git a/maurice.ini b/maurice.ini index c8932f27271561bdfc643791c78755898cc73210..c77cb330c739206838f2166f4c269584926bf8af 100644 --- a/maurice.ini +++ b/maurice.ini @@ -4,4 +4,5 @@ HALUI = halui HALFILE = lcec.hal HALFILE = maurice.hal +HALFILE = mb2hal.hal POSTGUI_HALFILE = gmoccapy_postgui.hal diff --git a/mb2hal.hal b/mb2hal.hal new file mode 100644 index 0000000000000000000000000000000000000000..75d6b90f1d5d6d09bcb26ad15ba083b13a1e7aa8 --- /dev/null +++ b/mb2hal.hal @@ -0,0 +1,151 @@ +loadrt bitslice count=6 personality=16,16,6,6,6,2 +loadrt weighted_sum wsum_sizes=16,6,2,2 +loadrt conv_s32_float count=4 +loadrt conv_s32_u32 count=6 + +#loadusr -W mb2hal config=mb2hal.ini + +addf conv-s32-u32.0 servo-thread +addf conv-s32-u32.1 servo-thread +addf conv-s32-u32.2 servo-thread +addf conv-s32-u32.3 servo-thread +addf conv-s32-u32.4 servo-thread +addf conv-s32-u32.5 servo-thread +addf bitslice.0 servo-thread +addf bitslice.1 servo-thread +addf bitslice.2 servo-thread +addf bitslice.3 servo-thread +addf bitslice.4 servo-thread +addf bitslice.5 servo-thread +addf process_wsums servo-thread +addf conv-s32-float.0 servo-thread +addf conv-s32-float.1 servo-thread +addf conv-s32-float.2 servo-thread +addf conv-s32-float.3 servo-thread + + +#================================================== +#Slicing Register Inputs +#================================================== + +# mb2hal.STBin.00.int +net ConvSU0 mb2hal.STBIn.00.int => conv-s32-u32.0.in +net StbDDI3725-1 conv-s32-u32.0.out => bitslice.0.in +net ConvSU1 mb2hal.STBIn.01.int => conv-s32-u32.1.in +net StbDDI3725-2 conv-s32-u32.1.out => bitslice.1.in +net ConvSU2 mb2hal.STBIn.02.int => conv-s32-u32.2.in +net StbDDI3610-1 conv-s32-u32.2.out => bitslice.2.in +net ConvSU3 mb2hal.STBIn.03.int => conv-s32-u32.3.in +net StbDDO3610-2 conv-s32-u32.3.out => bitslice.3.in +net ConvSU4 mb2hal.STBIn.04.int => conv-s32-u32.4.in +net StbDDI3610-3 conv-s32-u32.4.out => bitslice.4.in +net ConvSU5 mb2hal.STBIn.05.int => conv-s32-u32.5.in +net StnDAI7220 conv-s32-u32.5.out => bitslice.5.in + + +net PowerOnSwitch bitslice.0.out-00 +net SpindleNormal bitslice.0.out-01 +net SpindleOff bitslice.0.out-02 +net SpindleReverse bitslice.0.out-03 +net TurretShift bitslice.0.out-04 +net CoolantReqOn bitslice.0.out-05 +net CoolantReqOff bitslice.0.out-06 +net CycleStart bitslice.0.out-07 +net FeedHoldbtn bitslice.0.out-08 +net EStop bitslice.0.out-09 +net XaxisMPG bitslice.0.out-10 +net YaxisMPG bitslice.0.out-11 +net XplusJOG bitslice.0.out-12 +net XminusJog bitslice.0.out-13 +net ZplusJOG bitslice.0.out-14 +net ZminusJOG bitslice.0.out-15 + +net ModeSelect-1 bitslice.1.out-00 +net ModeSelect-2 bitslice.1.out-01 +net ModeSelect-3 bitslice.1.out-02 +net ModeSelect-4 bitslice.1.out-03 +net TurretN-1 bitslice.1.out-04 +net TurretN-2 bitslice.1.out-05 +net TurretN-3 bitslice.1.out-06 +net TurretN-4 bitslice.1.out-07 +net FeedOv-1 bitslice.1.out-08 +net FeedOv-2 bitslice.1.out-09 +net FeedOv-3 bitslice.1.out-10 +net FeedOv-4 bitslice.1.out-11 +net RapidOv-1 bitslice.1.out-12 +net RapidOv-2 bitslice.1.out-13 +net MachineLock bitslice.1.out-14 +net DryRun bitslice.1.out-15 + +net BlockDelete bitslice.2.out-00 +net OptStop bitslice.2.out-01 +net SingleBlock bitslice.2.out-02 +net FootSwitch1 bitslice.2.out-03 +net FootSwitch2 bitslice.2.out-04 +net ChuckInside bitslice.2.out-05 + +net TurretLS9 bitslice.3.out-00 +net TurretLS10 bitslice.3.out-01 +net TurretLS11 bitslice.3.out-02 +net TurretLS12 bitslice.3.out-03 +net TurretLS13 bitslice.3.out-04 +net TurretIndex bitslice.3.out-05 + +net MachineError bitslice.4.out-00 +net MachineReadyFin bitslice.4.out-01 +net ChuckCloseFin bitslice.4.out-02 +net FeedHoldFin bitslice.4.out-03 +net SpindleIlk bitslice.4.out-04 +net StartIlk bitslice.4.out-05 + +net ChuckLm1 bitslice.5.out-00 +net ChuckLm2 bitslice.5.out-01 + +#================================================== +#Summing Register Outputs +#================================================== + +net PgmEnd wsum.0.bit.0.in +net SpindleAlarm wsum.0.bit.1.in +net XZeroReturnLamp wsum.0.bit.2.in +net ZZeroReturnLamp wsum.0.bit.3.in +net MachineReadyLamp wsum.0.bit.4.in +net OptionnalStop wsum.0.bit.5.in +net FeedHoldLamp wsum.0.bit.6.in +net CycleStartLamp wsum.0.bit.7.in +net TurretIndexLamp wsum.0.bit.8.in +net CoolantPumpOnLamp wsum.0.bit.9.in +net CoolantPumpOffLamp wsum.0.bit.10.in +net ChuckClampLamp wsum.0.bit.11.in +net ProgramEndLamp wsum.0.bit.12.in +net ProgramErrorLamp wsum.0.bit.13.in +net MachineErrorLamp wsum.0.bit.14.in +net ResetSignal wsum.0.bit.15.in + +net TurretUnclamp wsum.1.bit.0.in +net TurretClamp wsum.1.bit.1.in +net TurretReverse wsum.1.bit.2.in +net TurretIndex wsum.1.bit.3.in +net ChuckClose wsum.1.bit.4.in +net ChuckOpen wsum.1.bit.5.in + +net MachineReady wsum.2.bit.0.in +net ServoReady wsum.2.bit.1.in + +net CoolantPump wsum.3.bit.0.in + + + +net ConvWsum0 wsum.0.sum => conv-s32-float.0.in +net StbDDO3705 mb2hal.STBOut.00 <= conv-s32-float.0.out + +net ConvWsum1 wsum.1.sum => conv-s32-float.1.in +net StbDDO3600 mb2hal.STBOut.01 <= conv-s32-float.1.out + +net ConvWsum2 wsum.2.sum => conv-s32-float.2.in +net StbDRC3210-1 mb2hal.STBOut.02 <= conv-s32-float.2.out + +net ConvWsum3 wsum.3.sum => conv-s32-float.3.in +net StbDRC3210-2 mb2hal.STBOut.03 <= conv-s32-float.3.out + +#==================================================================== diff --git a/mb2hal.ini b/mb2hal.ini new file mode 100644 index 0000000000000000000000000000000000000000..d098ae0e2808980b076fa5db590694b2dba17e79 --- /dev/null +++ b/mb2hal.ini @@ -0,0 +1,125 @@ +#This .INI file is also the HELP, MANUAL and HOW-TO file for mb2hal. + +#Load the modbus HAL userspace module as the examples below, +#change to match your own HAL_MODULE_NAME and .ini file name +#Using HAL_MODULE_NAME=mb2hal or nothing (default): +#Using HAL_MODULE_NAME=mymodule: loadusr -Wn mymodule mb2hal config=config_file.ini + +#Common section + +[MB2HAL_INIT] + +#OPTIONAL: Debug level of init and INI file parsing. +# 0 = silent. +# 1 = error messages (default). +# 2 = OK confirmation messages. +# 3 = debugging messages. + +INIT_DEBUG=3 + +#OPTIONAL: HAL module (component) name. Defaults to "mb2hal". + +HAL_MODULE_NAME=mb2hal + +#OPTIONAL: Insert a delay of "FLOAT seconds" between transactions in order +#to not to have a lot of logging and facilitate the debugging. +#Useful when using DEBUG=3 (NOT INIT_DEBUG=3) +#It affects ALL transactions. +#Use "0.0" for normal activity. + +SLOWDOWN=0.0 + +#REQUIRED: The number of total Modbus transactions. There is no maximum. + +TOTAL_TRANSACTIONS=2 + +#One transaction section is required per transaction, starting at 00 and counting up sequentially. +#If there is a new link (not transaction), you must provide the REQUIRED parameters 1st time. +#Warning: Any OPTIONAL parameter not specified are copied from the previous transaction. + +[TRANSACTION_00] + +LINK_TYPE=tcp +TCP_IP=192.168.16.55 +TCP_PORT=502 +MB_SLAVE_ID=1 +FIRST_ELEMENT=5391 +NELEMENTS=8 + +#REQUIRED: Modbus transaction function code (see www.modbus.org specifications). +# fnct_02_read_discrete_inputs (02 = 0x02) +# fnct_03_read_holding_registers (03 = 0x03) +# fnct_04_read_input_registers (04 = 0x04) +# fnct_15_write_multiple_coils (15 = 0x0F) +# fnct_16_write_multiple_registers (16 = 0x10) + +#fnct_02_read_discrete_inputs: creates boolean output HAL pins. +#fnct_03_read_holding_registers: creates a floating point output HAL pins. +# also creates a u32 output HAL pins. +#fnct_04_read_input_registers: creates a floating point output HAL pins. +# also creates a u32 output HAL pins. +#fnct_15_write_multiple_coils: creates boolean input HAL pins. +#fnct_16_write_multiple_registers: creates a floating point input HAL pins. + +MB_TX_CODE=fnct_03_read_holding_registers + +#OPTIONAL: Response timeout for this transaction. In INTEGER ms. Defaults to 500 ms. +#This is how much to wait for 1st byte before raise an error. + +MB_RESPONSE_TIMEOUT_MS=500 + +#OPTIONAL: Byte timeout for this transaction. In INTEGER ms. Defaults to 500 ms. +#This is how much to wait from byte to byte before raise an error. + +MB_BYTE_TIMEOUT_MS=500 + +#OPTIONAL: Instead of giving the transaction number, use a name. +#Example: mb2hal.00.01 could become mb2hal.plcin.01 +#The name must not exceed 32 characters. +#NOTE: when using names be careful that you dont end up with two transactions +#usign the same name. + +HAL_TX_NAME=STBIn + +#OPTIONAL: Maximum update rate in HZ. Defaults to 0.0 (0.0 = as soon as available = infinit). +#NOTE: This is a maximum rate and the actual rate may be lower. +#If you want to calculate it in ms use (1000 / required_ms). +#Example: 100 ms = MAX_UPDATE_RATE=10.0, because 1000.0 ms / 100.0 ms = 10.0 Hz + +MAX_UPDATE_RATE=0.0 + +#OPTIONAL: Debug level for this transaction only. +#See INIT_DEBUG parameter above. + +DEBUG=1 + +#While DEBUGGING transactions note the returned "ret[]" value correspond to: +#/* Modbus protocol exceptions */ +#ILLEGAL_FUNCTION -0x01 the FUNCTION code received in the query is not allowed or invalid. +#ILLEGAL_DATA_ADDRESS -0x02 the DATA ADDRESS received in the query is not an allowable address for the slave or is invalid. +#ILLEGAL_DATA_VALUE -0x03 a VALUE contained in the data query field is not an allowable value or is invalid. +#SLAVE_DEVICE_FAILURE -0x04 SLAVE (or MASTER) device unrecoverable FAILUER while attemping to perform the requested action. +#SERVER_FAILURE -0x04 (see above). +#ACKNOWLEDGE -0x05 This response is returned to PREVENT A TIMEOUT in the master. +# A long duration of time is required to process the request in the slave. +#SLAVE_DEVICE_BUSY -0x06 The slave (or server) is BUSY. Retrasmit the request later. +#SERVER_BUSY -0x06 (see above). +#NEGATIVE_ACKNOWLEDGE -0x07 Unsuccessful programming request using function code 13 or 14. +#MEMORY_PARITY_ERROR -0x08 SLAVE parity error in MEMORY. +#GATEWAY_PROBLEM_PATH -0x0A (-10) Gateway path(s) not available. +#GATEWAY_PROBLEM_TARGET -0x0B (-11) The target device failed to repond (generated by master, not slave). +#/* Program or connection */ +#COMM_TIME_OUT -0x0C (-12) +#PORT_SOCKET_FAILURE -0x0D (-13) +#SELECT_FAILURE -0x0E (-14) +#TOO_MANY_DATAS -0x0F (-15) +#INVALID_CRC -0x10 (-16) +#INVALID_EXCEPTION_CODE -0x11 (-17) + +[TRANSACTION_01] +MB_TX_CODE=fnct_16_write_multiple_registers +FIRST_ELEMENT=0 +NELEMENTS=4 +HAL_TX_NAME=STBOut +MAX_UPDATE_RATE=0.0 +DEBUG=1