3. Building Coremini Scripts Using Vehicle Spy
3.1. Basic Vehicle Spy Help
Basic use and knowledge of Vehicle Spy will be required to program this device. It is highly recommended to attend both a Vehicle Spy Basics class and Scripting class, which is complimentary when a Vehicle Spy license is purchased, and if the customer visits our local office. F1 on your keyboard can be pressed for additional help.
The full Vehicle Spy Help Documentation is available here: https://docs.intrepidcs.com/vspy-3-documentation
Once the device is , the next step is to build a script that tells the device what to do. To begin, open Vehicle Spy from the shortcut on the desktop or Start menu. The software will start with a new setup on the logon screen. Using the menu at the top, navigate to Scripting and Automation > Function Blocks. From function blocks, press the + in the upper left-hand corner to add a new Script type block.
A complete list of all Function Block Script commands is available here: https://docs.intrepidcs.com/vspy-3-documentation/vehicle-spy-main-menus/main-menu-scripting-and-automation/function-blocks/function-blocks-types/script-type-function-block-commands
3.2. Basic Commands
For now, the focus is going to be on the more commonly used commands. Additionally, there will be more info regarding options and commands that are unique to the neoOBD2-SIM.
Set Value
Set Value is used to update variables and signals inside of Vehicle Spy. Its use is extremely common. In addition to being able to write values to variables,there are also mathematical functions that can be used.These mathematical functions are simple addition/subtraction, logs, mod, rnd(1), and much more.
Function Block Action
They control other function blocks’ running status. The command can be used to start, stop, or call other function blocks.
Encoders
Encoders work by using what are called ‘ticks’ in each direction to increment or decrement a value.To calculate the current position, add any clockwise ticks and subtract any counterclockwise ticks from a counter holding the total number of ticks. One way to do this would be implementing an equation like this: TotalTicks = TotalTicks + (-1*CCW) + CW. This would be implemented in the software and can be seen in Figure 4.
In this example, the variable ‘Encoder 1 Count’ is set to the old value, then added or subtracted to depending on which way the encoder was turned. Additional steps could be added to force limits to the values. For example, using an If statement: If X > 100, then Set value to 100. This would limit the max value on Encoder 1 to effectively be 100.
Encoders must be added under the Physical IO section of Set Value’s Expression Editor. Please see the figure below:
After double clicking the Value cell next to a Set Value command, this screen shown in Figure 5 should appear. To access the Encoders, simply go to Physical IO, then Encoders. Next, select the direction (CW / CCW), then press Add to Expression. This will add the code to the Expression section. Value To Set will contain the App signal or Tx Message Signal that’s being set
Wait Until
The Wait Until step simply pauses the function until the requested criteria is met. An example is shown in Figure 6.
Buttons
Buttons on the neoOBD2-SIM are used by pressing the Rotary Encoders. The encoders have a noticeable tactile click when the button is pressed.
Switches 1 through 4 will work with the neoOBD2-SIM. The example in Figure 6 below also waits for the value to reset to 0 before restarting (this prevents the script from running more often than intended).
LCD Display
The neoOBD2-SIM also has a LCD display that can also be used to display text. The LCD display consists of four lines with twelve characters each.
When a line is full, but more characters are in the command, the remaining characters will be truncated. When supplying text, make sure to pad out the rest of the characters to twelve with spaces. This is because the LCD will persist characters until they are overwritten by something else.
Log Data
Log Data will be the command used to send the text to the LCD screen.The Log Type must be set to neoECU LCD, and the recommended starting positions (abbreviated as SP) are as follows:
Line 1: Set SP to 0
Line 2: Set SP to 12
Line 3: Set SP to 24
Line 4: Set SP to 36
Pressing the F(x) button opens the Expression Editor. ASCII characters are supported. If the Evaluate as Text box is checked, Message and Application signals can be inserted in-line.
See below:
With the example in Figure 8, the neoOBD2-SIM will show “Param2: 0” on the LCD screen.
Transmit
This is the command used to send a message onto the bus.
The Transmit command is used in conjunction with a Transmit message that is set up using the Messages Editor. Examples of this can be found at the hyperlink listed on page 6. An example of a function block using the Transmit command is shown in Figure 9. Transmit messages can also have signals attached to them. These signals can also be modified using the Set Value command.
3.3. LEDs
The neoOBD2-SIM also has four multicolored LEDs that are programmable using the Set Value command. By default, the LEDs run in an automatic mode that shows different colors under certain circumstances, such as when the device is in bootloader mode while reflashing firmware. To use the LEDs, the first step is to turn the Auto function off. Simply set the Auto property of each LED to 0. LEDs are found under Physical IO, just like Encoders and Buttons.
Below is a snippet from a neoOBD2-SIM Example Function Block that changes LED colors based on the encoder position values (although the values can be fed by any variables, or a static value). The color properties have a range of 0-255, with 0 being off and 255 being maximum.
3.4. Sending the Script for Coremini Mode
Once a script is ready, it’s time to send the script to the device. From Vehicle Spy click on Tools > CoreMini console.The console should look similar to the following figure:
Any errors with the script will be noted in the build tab of the CoreMini console with red LEDs. Yellow LEDs note warnings that may affect functionality. Green LEDs mean all is well. Once ready, press Send to load the script onto the neoOBD2-SIM.