You can define a userpath within matlab, which will be the default folder that matlab starts at when starting. You can read this out with userpath
and set it with userpath(path)
, e.g.
userpath(pwd) % to set to current working directory
Matlab will look for a startup script, named startup.m
here which will be ran upon startup.
For more info, see
Steps:
init.m
scriptxpcexplr
To load a different model
xpcexplr
xpctargetspy
in order to get a live copy of the screen of the xPC on the host PC (so you don’t have to turn around )xpcwwwenable
in the console to enable web connection interface (so you dont have to go back and forth to the host to control the xPC). Then connect to the xPC web interface via any browser navigating to http://192.168.1.10:22222/.getxpcpci('all')
to get all the pci slot and bus numbers.xpclib
shows you all the Simulink blocks related to xPC.There are two common methods that can be used to log data to the host computer.
Please refer to the following guide for further information (link here).
This option should be used for short-time experiments/tests (< few minutes)
To enable this logging option:
Outport
block. If you want, you can add more than one block. The final outputlog will concatenate them accordin to their number.Configuration -> Data Import/Export
and ensure Time
and Output
checkboxes are selected in Save to Workspace
section.getData.m
MATLAB script to import data from xPC target to host computer.This option should be preferred for long experiments (> few minutes)
To enable this logging option:
Working with the models, certain guidlines exist. As the Lokomat models consist of many different files and layers, it is important to keep structured.
Scope
To read data to the included hardware screens, scopes can be used. Scope blocks set to target the xPC will be visible on screen. For validation or other purposes it might be desired to read the values of a variable many layers deep in the code, do not put a scope there! Instead, add a data store element in the top layer and write to that. Then, the data store can be read in the logger, where the scopes are placed. Keeping all the scopes in the same places improves visibility.
1: Place a data store memory block in the top layer, name it clearly (e.g. “Scope_Camera”)
2: Write to this data where needed
3: Read this data in the logger, attach it to a scope
NOTE: The scopes seem to be read/placed in order of the ‘data store read’ numerical values, not per scope index. Change these values as needed to move the scope around and take care to make the naming clear even when mispositioned.
could not set master state to PREOP
Most likely one of the following has gone wrong:
Sometimes fixing this is as simple as pushing in the Ethernet cables a little bit (if the little clips are broken especially, they might come loose a bit when moving the cables around).
Check if any of the red RT Bus Error LEDs are burning on the LinMot drivers. If they do, one of the following might have caused it:
Note that if this crash happens, there is no way to recover, and the xPC should be rebooted…
CPU overload
This happens when you leave the model running for too long (at ~5 min
of runtime).
You’ll need to reboot the xPC to be able to load another model
Prevent this by stopping the model in time.
ERROR: Model reload required
Unfortunately, you need to reload model after every run…
If after starting the model you get the error:
Error in emExecJob
ERROR: invalid parameter
(or some other error or no error at all), and the whole system hangs. The xPC needs to reboot fully to be usable again (you can’t even ping the system).
To prevent this, always just unload the model after stopping it (never try to start it twice). Not sure why this is required.
Character Encoding error: When open the model (in simulink) you get the following error:
To fix: simply run the command slCharacterEncoding(‘windows-1252’) and re-open the model.
using command getxpcpci('all')
:
Unknown Unknown
Bus 0, Slot 0, IRQ 0
Host Bridge
VendorID 0x10de, DeviceID 0x01e0, SubVendorID 0x0000, SubDeviceID 0x0000
Notes: This device is not supported by xPC Target
Unknown Unknown
Bus 0, Slot 1, IRQ 0
ISA Bridge
VendorID 0x10de, DeviceID 0x0080, SubVendorID 0x1695, SubDeviceID 0x100f
Notes: This device is not supported by xPC Target
Unknown Unknown
Bus 0, Slot 2, IRQ 10
Serial Bus Contoller
VendorID 0x10de, DeviceID 0x0087, SubVendorID 0x1695, SubDeviceID 0x100f
Notes: This device is not supported by xPC Target
Unknown Unknown
Bus 0, Slot 4, IRQ 12
PCI Bridge
VendorID 0x10de, DeviceID 0x008c, SubVendorID 0x1695, SubDeviceID 0x100f
Notes: This device is not supported by xPC Target
Unknown Unknown
Bus 0, Slot 8, IRQ 0
PCI-to-PCI Bridge
VendorID 0x10de, DeviceID 0x008b, SubVendorID 0x0000, SubDeviceID 0x0000
Notes: This device is not supported by xPC Target
Unknown Unknown
Bus 0, Slot 9, IRQ 0
IDE Controller
VendorID 0x10de, DeviceID 0x0085, SubVendorID 0x1695, SubDeviceID 0x100f
Notes: This device is not supported by xPC Target
Unknown Unknown
Bus 0, Slot 11, IRQ 11
IDE Controller
VendorID 0x10de, DeviceID 0x008e, SubVendorID 0x1695, SubDeviceID 0x100f
Notes: This device is not supported by xPC Target
Unknown Unknown
Bus 0, Slot 30, IRQ 0
PCI-to-PCI Bridge
VendorID 0x10de, DeviceID 0x01e8, SubVendorID 0x0000, SubDeviceID 0x0000
Notes: This device is not supported by xPC Target
Unknown Unknown
Bus 1, Slot 7, IRQ 0
Unknown Device
VendorID 0x1762, DeviceID 0x1111, SubVendorID 0x1762, SubDeviceID 0x1111
Notes: This device is not supported by xPC Target
Intel Unknown
Bus 1, Slot 8, IRQ 10
Ethernet Controller
VendorID 0x8086, DeviceID 0x1229, SubVendorID 0x8086, SubDeviceID 0x1040
Intel Unknown
Bus 1, Slot 9, IRQ 5
Ethernet Controller
VendorID 0x8086, DeviceID 0x1229, SubVendorID 0x8086, SubDeviceID 0x1040
Quatech QSC-200/300
Bus 1, Slot 10, IRQ 11
Serial Ports
VendorID 0x135c, DeviceID 0x01a0, SubVendorID 0x135c, SubDeviceID 0x01a0
Released in: R14SP2 or Earlier
Humusoft AD622
Bus 1, Slot 11, IRQ 9
AI AO DI DO
VendorID 0x186c, DeviceID 0x0622, SubVendorID 0x186c, SubDeviceID 0x0622
A/D Chan: 8, D/A Chan: 8, DIO Chan: 8
Released in: R2010a
Notes: Eight single-ended 14-bit analog input channels, Eight 14-bit analog output channels and 8 DIO channels
Unknown Unknown
Bus 1, Slot 12, IRQ 10
Raid Controller
VendorID 0x1095, DeviceID 0x3114, SubVendorID 0x1695, SubDeviceID 0x9018
Notes: This device is not supported by xPC Target
Unknown Unknown
Bus 1, Slot 13, IRQ 5
Firewire Controller
VendorID 0x1106, DeviceID 0x3044, SubVendorID 0x1695, SubDeviceID 0x900e
Notes: This device is not supported by xPC Target
Unknown Unknown
Bus 2, Slot 0, IRQ 9
VGA Controller
VendorID 0x10de, DeviceID 0x0185, SubVendorID 0x1462, SubDeviceID 0x9363
Notes: This device is not supported by xPC Target