Uploaded by Kim Daehee

SimStack Manual

advertisement
SimStack
SYSTEMS MANUAL
Last edited: 24 January 2020
Systems Manual
Table of Contents
Introduction ............................................................................................................................................ 3
Hardware Summary ................................................................................................................................ 3
Software Summary.................................................................................................................................. 4
SimStack Limitations ............................................................................................................................... 6
SimStack Board Version (Revision Numbers).......................................................................................... 8
Foundation Board (top) ........................................................................................................................ 10
Foundation Board (top) - Cont .............................................................................................................. 11
Foundation Board (underside) .............................................................................................................. 12
Foundation Board (dimensions) ........................................................................................................... 13
SimStack Output Board ......................................................................................................................... 14
SimStack Input Board ............................................................................................................................ 16
Hook-up Digital Inputs .......................................................................................................................... 18
Hook-up Lights and LEDs....................................................................................................................... 20
Hook-up Analogue Inputs ..................................................................................................................... 22
Board Demonstration ........................................................................................................................... 26
Custom Code ......................................................................................................................................... 32
© simulator solutions
24 Jan 2020
2
Systems Manual
Introduction
The SimStack Systems Manual is designed to introduce you to SimStack and help you start
connecting hardware to your Simulator software. More in depth information is available on request
from the Simulator Solutions team.
Hardware Summary
The SimStack family of boards is made up of the following standard boards:
•
•
•
Foundation Board
o Contains the microcontroller
o A network interface to connect SimStack to your network
o 16 digital inputs, 8 outputs and 8 analog inputs
o Up to 5 additional advanced inputs and outputs.
Output Board
o Has 16 outputs
o Up to 7 can be stacked onto a foundation board providing 120 outputs per stack.
Input Board
o Has 32 digital inputs
o Up to 4 can be added to a stack for a total of 128 inputs
Note: SimStack is limited to a combined total of 132 inputs and outputs in a single stack. This
number may vary depending on the complexity of the code used.
© simulator solutions
24 Jan 2020
3
Systems Manual
Software Summary
Two software applications are required to use SimStack. The software and associate manuals and
reference material can be downloaded from the Member section of the Simulator Solutions website;
http://www.simulatorsolutions.com.au/members
SimStack Loader
The configuration of each SimStack is set by creating SimStack code using the SimStack Loader
application. SimStack loader will allow you to:
•
•
•
•
Create SimStack Code
Edit SimStack Code
Compile SimStack Code
Upload compiled SimStack Code to a SimStack Foundation Board.
SimStack Switch
SimStack Switch acts as a software switch between SimStack boards and your simulator software.
SimStack Loader also uses SimStack Switch to upload code to your SimStack Foundation board via
the network.
Functional Test Routine (FTR)
The SimStack Functional Test Routine (FTR) a special application that can be installed on a SimStack
Foundation board. The FTR allows you to test SimStack Inputs and Outputs, independently of any
other SimStack code.
The FTR should be used to independently verify that any hardware
connected to a SimStack is working correctly.
Once you have verified that the hardware connected to SimStack is working correctly, you can then
start to write, compile and upload your code.
Please see the SimStack Loader Manual for more information about the SimStack FTR.
© simulator solutions
24 Jan 2020
4
LIMITATIONS
Systems Manual
SimStack Limitations
The Simulator Solutions SimStack range is designed for use in a simulator environment with adequate
ventilation and monitoring.
General Limitations
Ensure All SimStack pins are correctly aligned and not shorting to VCC or GND prior to
applying power.
Ensure SimStack is NOT powered prior to adding or removing boards
Ensure that your SimStack is securely mounted
When stacking boards, take care to ensure that boards are correctly aligned
When stacking boards, always use the 15mm spacer pins supplied
Foundation Board Limitations
Logic power supply must be between 7 & 32 volts DC.
Each Output voltage supply is limited to 32 volts DC
Each Output voltage supply is fused @ 10 Amps
Each output channel is fused @ 3 Amps
Analogue inputs are limited to a maximum of 5 volts.
Should an output fuse fail due to overcurrent, it may be replaced using a 1206 size surface mount
fuse of the same rating. Simulator Solutions can assist with supply and replacement of these fuses.
Input Board Limitations
Do not connected powered devices to the Input channels.
Output Board Limitations
Each Output voltage supply is limited to 32 volts DC
Each Output voltage supply is fused @ 10 Amps
Each output channel is fused @ 3 Amps
Should an output fuse fail due to overcurrent, it may be replaced using a 1206 size surface mount
fuse of the same rating. Simulator Solutions can assist with supply and replacement of these fuses.
Ground Connections
Ensure that ALL SimStack GND connections are connected to a common Ground Bus
Ensure that all wires connected to the Common Ground Bus are suitably rated for load
expected
© simulator solutions
24 Jan 2020
6
Systems Manual
BOARD VERSIONS
© simulator solutions
24 Jan 2020
7
Systems Manual
SimStack Board Version (Revision Numbers)
Over time minor changes have been made to SimStack boards. The majority of these changes are
cosmetic and have only affected the layout.
The details below indicate the board revision numbers and the changes that have been made.
SimStack Foundation Board – Revision 3
•
Output jumpers are incorrectly labelled:
LK 1 – sets HI/LO switching for Output 8
LK 2 – sets HI/LO switching for Output 7

LK 7 – sets HI/LO switching Output 2
LK 8 – sets HI/LO switching Output 1
SimStack Foundation Board – Revision 4
•
•
•
•
Output jumpers labelled correctly – LK1 corresponds HI/LO switching for Output 1
Minor layout changes to jumper position to improve heat dissipation
Addition of jumper LK10 – to enable on board reset feature
Refer to Board Reset Function – LK 10 on page 11
Change diode D9 from through hole to surface mount
SimStack Input Board – Revision 3
•
No reported issues
SimStack Output Board – Revision 3
•
Output jumpers are incorrectly labelled:
LK 1 – sets HI/LO switching Output 16
LK 2 – sets HI/LO switching Output 15

LK 15 – sets HI/LO switching Output 2
LK 16 – sets HI/LO switching Output 1
SimStack Output Board – Revision 4
•
Output jumpers labelled correctly – LK1 corresponds HI/LO switching for Output 1
© simulator solutions
24 Jan 2020
8
Systems Manual
BOARD REFERENCE
© simulator solutions
24 Jan 2020
9
Systems Manual
Foundation Board (top)
© simulator solutions
24 Jan 2020
10
Systems Manual
Foundation Board (top) - Cont
Reset Button
The reset button will reset the SimStack Foundation board. This has the same effect as power
cycling the board.
Power Supply
•
•
•
PWR supplies power to run your SimStack
V1 supplies power for output pins 1-4
V2 supplies power for output pins 5-8
Output Jumpers
Each Output can switch the:
• Supply side of the circuit (+ve or High)
• Ground side of the circuit (-ve or Low)
Output High
Output Low
Set the jumpers (‘LK’ ) for each output
to the required state.
Note: On the Rev 3 version of the Output Board,
the labelling is incorrect and is reversed. This was
corrected on Rev 4 boards.
LK 1 – sets HI/LO switching for Output 1
LK 2 – sets HI/LO switching for Output 2

LK 7 – sets HI/LO switching for Output 7
LK 8 – sets HI/LO switching for Output 8
Board Reset Function – LK 10
LK 10 was added to the Foundation board from Rev 4 onwards.
The purpose of LK10 is to allow the Foundation Board to perform an automatic reset when certain
conditions are met. This is the equivalent of power cycling the board.
When the jumper is installed on LK 10, the Foundation Board is able to perform an automatic
reset. When LK 10 is removed, this function is removed.
© simulator solutions
24 Jan 2020
11
Systems Manual
Foundation Board (underside)
Analogue Connectors
LK9 – These connectors are for future expansion
options and should not normally be connected.
Programming Connector
To connect a 5V FTDI programming adapter.
Check location of GND pins to ensure the FTDI
adaptor is connected with the correct orientation.
Reset Button
The reset button will reset the SimStack Foundation board. This has the same effect as power
cycling the board.
© simulator solutions
24 Jan 2020
12
Systems Manual
Foundation Board (dimensions)
The dimensions of the Foundation board are below as are the location of the mounting holes.
•
•
•
•
•
All Dimensions in millimetres
All holes are 3.5mm diameter
Supplied standoff posts are 15mm
All boards are approximately 15mm in height
Please allow sufficient space around each board for Ethernet and other cables.
14.0
90.0
43.0
22.0
5.0
5.0
80.0
160.0
70.0
© simulator solutions
24 Jan 2020
13
Systems Manual
SimStack Output Board
Output Jumpers
Output High
Output Low
Each Output can switch the supply side of the circuit
(+ve or High side switching) or the ground side of the
circuit (-ve or Low side switching).
Set the jumpers (‘LK’ ) for each output to the required
state.
Note: On the Rev 3 version of the Output Board, the
labelling is incorrect and is reversed. This was
corrected on Rev 4 boards.
LK 1 – sets HI/LO switching for Output 1
LK 2 – sets HI/LO switching for Output 2

LK 15 – sets HI/LO switching for Output 15
LK 16 – sets HI/LO switching for Output 16
© simulator solutions
24 Jan 2020
14
Systems Manual
Power Supply
When using outputs in High Side switching mode, a wire suitable for the load must be soldered
from a Voltage Supply bus to the appropriate ‘OP – PWR’ hole. It is recommended that the wires
are soldered on the top of the Foundation Board.
The High Side switching output supplies are split into four groups of four outputs each;
• OP 1-4 PWR will supply power to Outputs 1-4
• OP 5-8 PWR will supply power to Outputs 5-8
• OP 9-12 PWR will supply power to Outputs 9-12
• OP 13-16 PWR will supply power to Outputs 13-16.
Each Voltage Supply Bus is fed by the corresponding spring-loaded power supply on the top of the
Output Board.
OP – PWR Hole
Voltage Supply Buses
Each Voltage Supply bus is fused @ 10 Amps. DO NOT tamper with, bypass or replace the fuse
with one of a great value.
The example below shows all four power supply groups connected to the V1 Bus.
© simulator solutions
24 Jan 2020
15
Systems Manual
SimStack Input Board
Input Board Jumpers
You can add up to four (4) input boards into any SimStack. When adding input boards to the
stack, you must configure the jumpers on each board.
Use the table below to correctly set the 5 jumpers on each board to set the order of the boards in
the stack.
Note inputs 17 to 32 on the 4th Board are unusable.
LK2
LK3
LK1
LK4
1st Board
Chip 2
Chip 1
2nd Board
Chip 4
Chip 3
3rd Board
Chip 6
Chip 5
4th Board
n/a
Chip 7
LK5
© simulator solutions
24 Jan 2020
16
Systems Manual
HOOKUP REFERENCE
© simulator solutions
24 Jan 2020
17
Systems Manual
Hook-up Digital Inputs
Hook-up Diagram
Simple
Button
Multi Position
Switch
Rotary Encoder
Please Note – The following examples are provided for Aerowinx Precision Simulator X. If you are
using other Simulator Software you will need to change the PSXSwitch variables to suit your
simulator program.
Please see the relevant guide to your Simulator Software in the Member Section of our website:
https://simulatorsolutions.com.au
© simulator solutions
24 Jan 2020
18
Systems Manual
Code Detail
Configure the name and network details of the SimStack
Definitions
Ensure the relevant code is included for digital switches
#include <Arduino.h>
#include <config.h>
//=================================================
// SIMSTACK FUEL PANEL
// (c) John Golin 2014
//=================================================
//=================================================
// DEFINITIONS
//=================================================
// SimStack / Panel Information
// -------------------------SIMSTACK_CODE("FUL");
SIMSTACK_DESCRIPTION("OVHD FUEL");
#define SWITCHES
#define ROTENC
SIMSTACK_IP(192,168,1,240);
SERVER_IP(192,168,1,111);
SERVER_PORT(10747);
SIMSTACK_ADDON_INPUT_BOARDS(1);
SIMSTACK_ADDON_OUTPUT_BOARDS(1);
// System Switches - Comment out to disable (OFF).
// ----------------------------------------------#define DEBUG
#define SHOW_ALL
#define SHOWRAM
#define SWITCHES
#define LIGHTS
#define OUTPUTS
Constructors
Detail the input type etc;
▪
▪
All digital inputs are held in one array called Inputs[]
The position in the array is the pin to which the wire is attached
/************************************************** CORE
SYSTEM INCLUDES - DO NOT EDIT!
***************************************************
*
* This must come AFTER the definitions above as they are
referenced in the below
*
* These are CRITICAL and must be included in all instances
of code.
*
#include <SPI.h>
#include <PSXOutGeneral.h>
.
.
.
// #include <OneWire.h>
*
*
/**************************************************
//=================================================
// CONSTRUCTORS - INPUTS AND OUTPUTS
//=================================================
// INPUTS - Digital - Switches, Encoders etc
// ------------------------------------------------
PSXSwitch Inputs[]={
PSXSwitch(BIG,&HydEng1,BOTH,1,0),
PSXSwitch(ROTENC,&var1),
PSXSwitch(ROTENC,&var1)
}
}
Setup
PSXSwitch Inputs[]= {
.
.
.
};
// OUTPUTS - Lights etc
// -----------------------------------------------INDICATOR_MIN_VALUE(0);
INDICATOR_MAX_VALUE(4095);
LAMP_MIN_VALUE(0);
LAMP_MAX_VALUE(1000);
BACKLIGHT_MIN_VALUE(0);
BACKLIGHT_MAX_VALUE(4095);
COMMONWHITE_MIN_VALUE(0);
COMMONWHITE_MAX_VALUE(4095);
PSXOutput Outputs[] = {
.
.
.
};
//=================================================//
SETUP - Runs once - intialises all items
//=================================================void
setup() {
SETUP_INIT();
.
.
.
SETUP_NETWORKING();
SETUP_WATCHDOG();
}
//=======================================================
// MAIN LOOP - Loops continuously
//=======================================================
void loop(){
if (dataAvailable){
CHECK_SYSTEM_COMMANDS {
UPDATE_SYSTEM();
.
SETUP_SWITCH_INPUTS();
.
.
}
CHECK_QS {
Loop
On situation load, check the switch position
.
.
.
}
CHECK_QI {
.
.
.
}
CHECK_QH {
.
.
.
ONLOAD_SCAN_DIGITAL();
}
CHECK_ADDON_COMMANDS();
CLEANUP_NETWORK_DATA();
}
CHECK_DIGITAL_INPUTS();
UPDATE_DIGITAL_OUTPUTS();
CHECK_FOR_NETWORK_DATA();
Check the hardware for any changes and action
RESET_WATCHDOG();
}
CHECK_DIGITAL_INPUTS();
Check for pending Rotary Encoder changes and send to PSX
CHECK_ROTARY_ENCODER_TIMER {
UPDATE_SINGLE_ROTARIES();
}
© simulator solutions
24 Jan 2020
19
Systems Manual
Hook-up Lights and LEDs
Hook-up Diagram
Jumpers
Output High
Jumpers
Output Low
LED
Output High
LED
Output Low
Incandescent
Output High
Incandescent
Output Low
© simulator solutions
24 Jan 2020
20
Systems Manual
Please Note – The following examples are provided for Aerowinx Precision Simulator X. If you are
using other Simulator Software you will need to change the PSXOutput variables to suit your
simulator program.
Please see the relevant guide to your Simulator Software in the Member Section of our website:
https://simulatorsolutions.com.au
Code Detail
Configure the name and network details of the SimStack
Defines
Ensure the relevant code is included for digital switches, and Rotary Encoders
#define LIGHTS
#define OUTPUTS
Constructors
#include <Arduino.h>
#include <config.h>
//=================================================
// SIMSTACK FUEL PANEL
// (c) John Golin 2014
//=================================================
Detail the input type etc;
▪
▪
//=================================================
// DEFINITIONS
//=================================================
All digital inputs are held in one array called Outputs[]
The position in the array is the pin to which the wire is attached
PSXOutput Outputs[]={
PSXOutput(BMSLOWRIGHT,&HydEng1,dimRelayK2a)
}
Setup
// SimStack / Panel Information
// -------------------------SIMSTACK_CODE("FUL");
SIMSTACK_DESCRIPTION("OVHD FUEL");
SIMSTACK_IP(192,168,1,240);
SERVER_IP(192,168,1,111);
SERVER_PORT(10747);
SIMSTACK_ADDON_INPUT_BOARDS(1);
SIMSTACK_ADDON_OUTPUT_BOARDS(1);
// System Switches - Comment out to disable (OFF).
// ----------------------------------------------#define DEBUG
#define SHOW_ALL
#define SHOWRAM
#define SWITCHES
#define LIGHTS
#define OUTPUTS
/************************************************** CORE
SYSTEM INCLUDES - DO NOT EDIT!
***************************************************
*
* This must come AFTER the definitions above as they are
referenced in the below
*
* These are CRITICAL and must be included in all instances
of code.
*
#include <SPI.h>
#include <PSXOutGeneral.h>
.
.
.
// #include <OneWire.h>
*
*
/**************************************************
//=================================================
// CONSTRUCTORS - INPUTS AND OUTPUTS
//=================================================
// INPUTS - Digital - Switches, Encoders etc
// -----------------------------------------------PSXSwitch Inputs[]= {
.
.
.
};
SETUP_DIGITAL_INPUTS();
// OUTPUTS - Lights etc
// -----------------------------------------------INDICATOR_MIN_VALUE(0);
INDICATOR_MAX_VALUE(4095);
LAMP_MIN_VALUE(0);
LAMP_MAX_VALUE(1000);
BACKLIGHT_MIN_VALUE(0);
BACKLIGHT_MAX_VALUE(4095);
COMMONWHITE_MIN_VALUE(0);
COMMONWHITE_MAX_VALUE(4095);
Loop
Check if the variable was received – if it was, update the relevant
item in the Output array (numbering starts at 0)
PSXOutput Outputs[] = {
.
.
.
};
//=================================================//
SETUP - Runs once - intialises all items
//=================================================void
setup() {
SETUP_INIT();
.
.
.
SETUP_NETWORKING();
SETUP_WATCHDOG();
}
//=======================================================
// MAIN LOOP - Loops continuously
//=======================================================
CHECK_QS{
else if(qIndex==HydEng1) {UPDATE_OUTPUT(0);}
}
void loop(){
if (dataAvailable){
CHECK_SYSTEM_COMMANDS {
UPDATE_SYSTEM();
.
.
.
}
CHECK_QS {
.
.
.
Send any light updates to the hardware
}
CHECK_QI {
.
.
.
}
CHECK_QH {
.
.
.
UPDATE_DIGITAL_OUTPUTS();
}
CHECK_ADDON_COMMANDS();
CLEANUP_NETWORK_DATA();
}
CHECK_DIGITAL_INPUTS();
UPDATE_DIGITAL_OUTPUTS();
CHECK_FOR_NETWORK_DATA();
RESET_WATCHDOG();
}
© simulator solutions
24 Jan 2020
21
Systems Manual
Hook-up Analogue Inputs
Hook-up Diagram
Addon Analogue MUX
Onboard Analogue Input
© simulator solutions
24 Jan 2020
22
Systems Manual
Please Note – The following examples are provided for Aerowinx Precision Simulator X. If you are
using other Simulator Software you will need to change the PSXAnalog variables to suit your
simulator program.
Please see the relevant guide to your Simulator Software in the Member Section of our website:
https://simulatorsolutions.com.au
Code Detail – Analogue MUX
Configure the name and network details of the SimStack
Defines
Ensure the relevant code is included
#define ANALOG
Constructors
Detail all the analogue inputs in PSXAnalog array for the MUX .
#include <Arduino.h>
#include <config.h>
//=================================================
// SIMSTACK FUEL PANEL
// (c) John Golin 2014
//=================================================
//=================================================
// DEFINITIONS
//=================================================
// SimStack / Panel Information
// -------------------------SIMSTACK_CODE("FUL");
SIMSTACK_DESCRIPTION("OVHD FUEL");
SIMSTACK_IP(192,168,1,240);
SERVER_IP(192,168,1,111);
SERVER_PORT(10747);
PSXAnalog AnalogInput[]={
PSXAnalog(LIGHT,&LtOvhd),
PSXAnalog(LIGHT,&LtDome),
PSXAnalog(LIGHT,& LtGlrshPanel)
};
}
SIMSTACK_ADDON_INPUT_BOARDS(1);
SIMSTACK_ADDON_OUTPUT_BOARDS(1);
// System Switches - Comment out to disable (OFF).
// ----------------------------------------------#define DEBUG
#define SHOW_ALL
#define SHOWRAM
#define SWITCHES
#define LIGHTS
#define OUTPUTS
/************************************************** CORE
SYSTEM INCLUDES - DO NOT EDIT!
***************************************************
*
* This must come AFTER the definitions above as they are
referenced in the below
*
* These are CRITICAL and must be included in all instances
of code.
*
#include <SPI.h>
#include <PSXOutGeneral.h>
.
.
.
// #include <OneWire.h>
*
*
/**************************************************
//=================================================
// CONSTRUCTORS - INPUTS AND OUTPUTS
//=================================================
// INPUTS - Digital - Switches, Encoders etc
// -----------------------------------------------PSXSwitch Inputs[]= {
.
.
.
};
// OUTPUTS - Lights etc
// -----------------------------------------------INDICATOR_MIN_VALUE(0);
INDICATOR_MAX_VALUE(4095);
LAMP_MIN_VALUE(0);
LAMP_MAX_VALUE(1000);
BACKLIGHT_MIN_VALUE(0);
BACKLIGHT_MAX_VALUE(4095);
COMMONWHITE_MIN_VALUE(0);
COMMONWHITE_MAX_VALUE(4095);
Setup
PSXOutput Outputs[] = {
.
.
.
};
//=================================================//
SETUP - Runs once - intialises all items
//=================================================void
setup() {
SETUP_INIT();
.
.
.
SETUP_NETWORKING();
SETUP_WATCHDOG();
}
SETUP_ANALOG_MUX();
//=======================================================
// MAIN LOOP - Loops continuously
//=======================================================
Loop
Check the analogue MUX – if changes, send to PSX
void loop(){
if (dataAvailable){
CHECK_SYSTEM_COMMANDS {
UPDATE_SYSTEM();
.
.
.
}
CHECK_QS {
.
.
.
}
CHECK_ANALOG_MUX(AnalogInput);
CHECK_QI {
.
.
.
}
CHECK_QH {
.
.
.
}
CHECK_ADDON_COMMANDS();
CLEANUP_NETWORK_DATA();
}
CHECK_DIGITAL_INPUTS();
UPDATE_DIGITAL_OUTPUTS();
CHECK_FOR_NETWORK_DATA();
RESET_WATCHDOG();
}
© simulator solutions
24 Jan 2020
23
Systems Manual
Code Detail – Onboard Analogue
Configure the name and network details of the SimStack
Defines
Ensure the relevant code is included .
#define ANALOG
Constructors
#include <Arduino.h>
#include <config.h>
//=================================================
// SIMSTACK FUEL PANEL
// (c) John Golin 2014
//=================================================
Detail the analogue input:
▪
//=================================================
// DEFINITIONS
//=================================================
Individually for onboard analogue inputs
// SimStack / Panel Information
// -------------------------SIMSTACK_CODE("FUL");
SIMSTACK_DESCRIPTION("OVHD FUEL");
SIMSTACK_IP(192,168,1,240);
SERVER_IP(192,168,1,111);
SERVER_PORT(10747);
SIMSTACK_ADDON_INPUT_BOARDS(1);
SIMSTACK_ADDON_OUTPUT_BOARDS(1);
// System Switches - Comment out to disable (OFF).
// ----------------------------------------------#define DEBUG
#define SHOW_ALL
#define SHOWRAM
PSXAnalog onboardAnalog(LIGHT,0, &LtOvhd);
#define SWITCHES
#define LIGHTS
#define OUTPUTS
/************************************************** CORE
SYSTEM INCLUDES - DO NOT EDIT!
***************************************************
*
* This must come AFTER the definitions above as they are
referenced in the below
*
* These are CRITICAL and must be included in all instances
of code.
*
#include <SPI.h>
#include <PSXOutGeneral.h>
.
.
.
// #include <OneWire.h>
*
*
/**************************************************
//=================================================
// CONSTRUCTORS - INPUTS AND OUTPUTS
//=================================================
// INPUTS - Digital - Switches, Encoders etc
// -----------------------------------------------PSXSwitch Inputs[]= {
.
.
.
};
Setup
// OUTPUTS - Lights etc
// -----------------------------------------------INDICATOR_MIN_VALUE(0);
INDICATOR_MAX_VALUE(4095);
LAMP_MIN_VALUE(0);
LAMP_MAX_VALUE(1000);
BACKLIGHT_MIN_VALUE(0);
BACKLIGHT_MAX_VALUE(4095);
COMMONWHITE_MIN_VALUE(0);
COMMONWHITE_MAX_VALUE(4095);
SETUP_ANALOG_INPUTS();
Analog_AntiJitter=3;
PSXOutput Outputs[] = {
.
.
.
};
//=================================================//
SETUP - Runs once - intialises all items
//=================================================void
setup() {
SETUP_INIT();
.
.
.
SETUP_NETWORKING();
SETUP_WATCHDOG();
}
//=======================================================
// MAIN LOOP - Loops continuously
//=======================================================
Loop
Check if the analogue input has changed – if so, send to PSX
void loop(){
if (dataAvailable){
CHECK_SYSTEM_COMMANDS {
UPDATE_SYSTEM();
.
.
▪
Individually for onboard analogue inputs
.
}
CHECK_QS {
.
.
.
}
CHECK_QI {
.
.
.
CHECK_ANALOG_INPUT(onboardAnalog);
}
CHECK_QH {
.
.
.
}
CHECK_ADDON_COMMANDS();
CLEANUP_NETWORK_DATA();
}
CHECK_DIGITAL_INPUTS();
UPDATE_DIGITAL_OUTPUTS();
CHECK_FOR_NETWORK_DATA();
RESET_WATCHDOG();
}
© simulator solutions
24 Jan 2020
24
Systems Manual
BOARD DEMONSTRATION
© simulator solutions
24 Jan 2020
25
Systems Manual
Board Demonstration
Hardware
Required
• SimStack Foundation Board
• 12V power supply
• 1 LED and appropriate resistor to go in 12V circuit
• 2 incandescent bulbs (12V) (Can use 2 LEDs with resistors if desired)
• One rotary encoder (preferably with 2 capacitors as a de-bounce circuit)
• One single pole switch
Hook-up – Lights and Switches
Configure the hardware as follows:
•
•
•
•
•
•
•
•
Ensure the Hi/Lo Jumpers are set to ‘OP Hi’ (see to right)
Connect 12V supply to ‘VL In’ and ‘V1 In’
Output High
Connect Ground to ‘GND’
Connect +ve side of Incandescent lights to Outputs O1 and O2
Connect +ve side of LED to output O3
Connect the –ve side of all lights to GND (ensure a resistor is used in-line with LEDs!)
Connect a 2 position (on / off) switch to Input I1 with the other side connected to GND.
Connect a rotary encoder to Inputs I2 and I3, and the centre pole of the encoder to GND.
Hook-up Diagram - Demo1.ino
© simulator solutions
24 Jan 2020
26
Systems Manual
Software
Please Note – The following examples are provided for Aerowinx Precision Simulator X. If you are
using other Simulator Software you will need to change the PSXAnalog variables to suit your
simulator program.
Please see the relevant guide to your Simulator Software in the Member Section of our website:
https://simulatorsolutions.com.au
•
Download SimStack Loader from http://www.simulatorsolutions.com.au/
•
Use the SimStack Loader manual to install and configure SimStack Loader.
•
Obtain the Demo code from the Simulator Solutions forum
https://www.simulatorsolutions.com.au/forum
•
In the editor, change the IP addresses to suit your network;
SIMSTACK_IP(192,168,1,200);
SERVER_IP(192,168,1,149);
SERVER_PORT(10748);
•
•
//this board
//SimStack Switch server
//server port
Save the code (you will need to give it a new name)
Compile your code and upload the it using the Network Upload or an FTDI programmer.
Note: For a detailed guide on how to use SimStack Loader to edit, compile and upload code,
please see the SimStack Loader Manual – available from the Member section of our website.
Testing
•
•
•
•
•
Ensure SimStack Switch and PSX Server are running
Test physical 2 position switch and monitor Hydraulic Dem Pump 1 button in PSX
Turn rotary encoder and monitor MCP altitude knob in PSX
Adjust the Overhead backlighting level in PSX and monitor the incandescent lamps
Watch the LED to check it mimics the PSX HYD DEM 1 PRESS light
Please Note – The following examples are provided for Aerowinx Precision Simulator X. If you are
using other Simulator Software you will need to change the PSX variables to suit your simulator
program.
Please see the relevant guide to your Simulator Software in the Member Section of our website:
https://simulatorsolutions.com.au
© simulator solutions
24 Jan 2020
27
Systems Manual
Demo Code Review
This Demo code has been written for Aerowinx Precision Simulator X. If you are using other
Simulator Software, please see the relevant guide in the Member Section of our website:
https://simulatorsolutions.com.au
#include <Arduino.h>
#include <config.h>
//=================================================
// SIMSTACK DEMO Code
// (c) Simulator Solutions 2019
//=================================================
//=================================================
// DEFINITIONS
//=================================================
// SimStack / Panel Information
// -------------------------SIMSTACK_CODE(DEM);
SIMSTACK_DESCRIPTION(Demo);
Name and address
Enter details of board name, the IP
address of this board and the server
and port it will connect to
SIMSTACK_IP(192,168,1,200);
SERVER_IP(192,168,1,149);
SERVER_PORT(10748);
SIMSTACK_ADDON_INPUT_BOARDS(0);
SIMSTACK_ADDON_OUTPUT_BOARDS(0);
Addon boards
// System Switches - Comment out to disable (OFF).
// ----------------------------------------------#define SWITCHES
#define ROTENC
#define LIGHTS
#define OUTPUTS
Must enter number of addon Input
and output boards
System switches
Enables blocks of code required by
the different types of hardware
/************************************************** CORE
SYSTEM INCLUDES - DO NOT EDIT!
***************************************************
*
* This must come AFTER the definitions above as they are
referenced in the below
*
* These are CRITICAL and must be included in all
instances of code.
*
#include <SPI.h>
#include <PSXOutGeneral.h>
.
.
.
// #include <OneWire.h>
*
*
/**************************************************
© simulator solutions
24 Jan 2020
28
Systems Manual
//=================================================
// CONSTRUCTORS - INPUTS AND OUTPUTS
//=================================================
// INPUTS - Digital - Switches, Encoders etc
// -----------------------------------------------PSXSwitch Inputs[]= {
PSXSwitch(BIG,&HydEng1,BOTH,1,0),
PSXSwitch(ROTENC1,&McpTurnAlt),
PSXSwitch(ROTENC2,&McpTurnAlt)
};
Describe input hardware
Detail the type and connection pins
for digital inputs and / or analogue
inputs.
// OUTPUTS - Lights etc
// -----------------------------------------------INDICATOR_SET_MIN_PWM(0);
INDICATOR_SET_MAX_PWM(4095);
LAMP_SET_MIN_PWM(0);
LAMP_SET_MAX_PWM(1000);
BACKLIGHT_SET_MIN_PWM(0);
BACKLIGHT_SET_MAX_PWM(4095);
COMMONWHITE_SET_MIN_PWM(0);
COMMONWHITE_SET_MAX_PWM(4095);
PSXOutput Outputs[] = {
PSXOutput(BACKLIGHT,dimRelayK2a),
PSXOutput(COMMONWHITE,dimRelayK2a),
PSXOutput(BMSLOWRIGHT,&HydEng1,dimRelayK6b)
};
//=================================================//
SETUP - Runs once - intialises all items
//=================================================
void setup() {
SETUP_INIT();
SETUP_SWITCH_INPUTS();
SETUP_DIGITAL_OUTPUTS();
SETUP_NETWORKING();
SETUP_WATCHDOG();
}
Describe output hardware
Detail the type and connection pins
for digital outputs and / or special
hardware (such as Servos, character
displays etc).
Setup - Initialise!
The Setup routine is the ‘entry’
point when the code runs – it
runs once, and we include any
code that involves a one off
calculation.
© simulator solutions
24 Jan 2020
29
Systems Manual
//=======================================================
// MAIN LOOP - Loops continuously
//=======================================================
void loop(){
if (dataAvailable){
CHECK_SYSTEM_COMMANDS {
UPDATE_SYSTEM();
CHECK_SIT_LOAD_AND_SEND_DIGITAL();
}
CHECK_QS {
CHECK_LIGHT_VOLTAGES {UPDATE_LIGHTS();}
CHECK_DIMTEST_VOLTAGES {UPDATE_DIMTEST();}
}
Loop – ongoing…
The loop does as it says, loops
continuously once Setup has
completed.
Check system commands
Catches anything that is not a
variable – e.g. situation load.
We add any custom actions for
these events here.
CHECK_QI {
}
CHECK_QH {
CHECK_DIMTEST_SWITCH {UPDATE_DIMTEST_SWITCH();}
else if(qIndex==HydEng1)
{UPDATE_OUTPUT(2);}
}
Check Q codes
Examine the incoming variables –
insert our actions here
CHECK_ADDON_COMMANDS();
CLEANUP_NETWORK_DATA();
}
Check / update hardware
CHECK_DIGITAL_INPUTS();
UPDATE_DIGITAL_OUTPUTS();
If any changes have occurred in
hardware, or we need to send a
change to the hardware, action it
here.
CHECK_FOR_NETWORK_DATA();
RESET_WATCHDOG();
}
© simulator solutions
24 Jan 2020
30
Systems Manual
YOUR CUSTOM CODE
© simulator solutions
24 Jan 2020
31
Systems Manual
Custom Code
Overview
SimStack uses an ATMega processor and will processes some basic Arduino functions. As such, you
can add custom variables and functions yourself and, through some library commands, interact with
the SimStack hardware to manually inspect and control the inputs and outputs. An example might be
manipulating data received from a potentiometer to make it fit how your hardware is wired up, such
as using a potentiometer for flap positions.
This document assumes you have knowledge of how to code in C++ and will only outline the special
considerations around adding your code to SimStack.
To help with understanding, an example is included at the end of this section – reviewing the example
while reading the information below will assist greatly with understanding.
Your Own Functions and Libraries
You can write your own functions outside of setup() and loop(), and call them when required. You
can also include your own libraries – be aware however that some libraries may clash with SimStack.
Overloading SimStack
Typically, executing code every time through the loop() may overload SimStack and result in your
code executing more slowly than desired.
You must only perform custom hardware checks, network writes etc when your simulator and
SimStack think it is okay. (note that when checking network data received, SimStack code already take
this into account – see next section).
A flag has been created to indicate when your code should be blocked from executing: blockingFlag.
Only if blockingFlag is false should your code execute - e.g.
if(blockingFlag==false){
By putting your code inside a check
of blockingFlag, it will only execute
when SimStack is not busy.
…do your custom thing…
}
© simulator solutions
24 Jan 2020
32
Systems Manual
Examining Data Received
If valid data is received from your simulator, the flag ‘dataAvailable’ is set. This is automatically
checked at the start of loop() and if true the subsequent section of code examines the received data.
This section only executes when data should be analysed so you do not need to check the
blockingFlag when adding code in this section.
Where to Evaluate Incoming Data
Analysis of received is divided into 4 sections for speed; Insert your check in the relevant section.
CHECK_SYSTEM_COMMANDS {
…do your custom checks…
}
Examine non-Q strings (e.g. load1)
CHECK_QS {
…do your custom checks …
}
Examine Qs Strings
CHECK_QI {
…do your custom checks …
}
Examine Qi Strings
CHECK_QH {
…do your custom checks …
}
Examine Qh Strings
Variables
The data from your simulator is contained in several different SimStack variables. For more
information on specific codes and the protocol please see the relevant documentation for your
simulator software.
Q Data Example
Qi123=1004 (From PSX)
Variable
Example
Type
Description
qType
qIndex
qCode
i
123
Qi123
char
uint16_t
char[]
qChars
1004
char[]
A single letter representing the distinct type of Q code – i, h, s
The numeric index of the particular Q code
The data to the left of the equals sign.
The data to the right of the equals sign. Convert to an integer if
required using atoi() - e.g. int myvar=atoi(qValue)
System Data Example
load1 (From PSX)
Variable
Example
Type
Description
qChars
load1
char[]
The entire received string
© simulator solutions
24 Jan 2020
33
Systems Manual
Checking Hardware Inputs & Other Processing
If you are checking hardware inputs or performing other manipulations that need to occur every time
through the loop(), insert your code outside the if(dataAvailable) network section, ie:
…
void setup(){
…
}
void loop(){
…
CHECK_ADDON_COMMANDS();
CLEANUP_NETWORK_DATA();
}
CHECK_DIGITAL_INPUTS();
Insert code that needs to happen
every cycle of the loop:
after UPDATE DIGITAL INPUTS
and
before UPDATE DIGITAL OUTPUTS
if(blockingFlag==false){
…do your custom thing…
}
UPDATE_DIGITAL_OUTPUTS();
CHECK_FOR_NETWORK_DATA();
RESET_WATCHDOG();
}
REMEMBER You MUST only check inputs when your simulator software and SimStack think it is
okay – stick your code inside a check of the blockingFlag !
© simulator solutions
24 Jan 2020
34
Systems Manual
SimStack Digital Input Pins
To check the state of a SimStack input pin;
•
•
In the Inputs array, define the pin as a Switch of type GENERAL_IN
Insert code to check if a general pin has changed, then get the pin and the state;
o A flag generalInputFlag becomes true when a GENERAL_IN has changed
o Retrieve the value of the pin (1 or 0) using MANUAL_GET_INPUT()
o Determine which GENERAL_IN pin changed by examining INTERRUPT_PIN()
o Reset the generalInputFlag flag when done!
PSXSwitch Inputs[] = {
PSXInput(GENERAL_IN,&HydeDem)
}
…
void setup(){
…
}
void loop(){
Define the input as a GENERAL IN
Check whether a GENERAL_IN input
changed
Get the state (1 or 0) of the input
that just changed.
if(generalInputFlag==true){
int myState=MANUAL_GET_INPUT();
Compare the number of the pin that
just changed with each of your
GENERAL_IN to find a match, then
run your code.
if(INTERRUPT_PIN()==yourpin){
…do your custom thing…
}
generalInputFlag=false;
}
Reset the flag!
NOTE – SimStack does no smart processing on the pin state of GENERAL_IN types and will do
exactly as instructed.
Digital Input Pins
Analogue pins 0 to 5 and Digital pin 6 are available by default and can be used as Digital inputs and
outputs using the standard pin handling functions.
Do NOT include them in the SimStack Input array – keep them entirely standalone.
Analogue Input Pins
You can use the standard analogRead() function to read any of the 8 onboard input pins (pins 0 to 7).
Do NOT include these in the SimStack Analogue array - keep them entirely standalone
© simulator solutions
24 Jan 2020
35
Systems Manual
Sending Data
Syntax
To write data to your simulator, use these standard Ethernet commands:
•
•
client.print();
client.println();
Considerations
Be careful - do not send data to your simulator software unless it is essential or you may cause your
software to lock up. A classic example is a noisy potentiometer that floods the network with spurious
data. The best way to avoid this is to create a timer.
Timers
Depending on what you are processing, it can be good practice to use the internal clock functions
( millis() ) as a timer to limit how often hardware is checked and / or sent e.g.
long mytimer=millis();
…
void setup(){
…
}
void loop(){
…
if(millis()-mytimer>50){
Create a variable to hold the time
In the loop(), check if the required
amount of time has elapsed
Do you custom code
Don’t forget to reset the time in the
variable!
…do your custom thing…
mytimer=millis();
}
}
IMPORTANT NOTE: Do not use delay(). This will delay the other important tasks SimStack needs
to complete while processing the loop…
© simulator solutions
24 Jan 2020
36
Systems Manual
Manually Set an Output
SimStack Digital Output Pins
All SimStack outputs can be set to a PWM value between 0 (full off) and 4095 (full on).
•
•
In the Output array, define the pin as a Light of type GENERAL_OUT (with any power circuit).
In the relevant area of code, use the command MANUAL_SET_OUTPUT(pin,pwm); to set a
specific pin to a specific pwm value.
As with all custom code, this must occur before the SIMSTACK line UPDATE_DIGITAL_OUTPUTS
PSXOutput Outputs[] = {
PSXOutput(GENERAL_OUT,dimRelayK2a)
}
…
void setup(){
…
}
void loop(){
…
MANUAL_SET_OUTPUT(0,2000);
//pin 0
…
Define your pin as a ‘GENERAL_OUT’
Set the PWM value of the pin when
required (0 – 4095).
NOTE – SimStack does no smart processing on the GENERAL_OUT types and will do exactly what is
instructed.
Digital Output Pins
Analog pins 0 to 5 and Digital Pin 6 are available by default and can be used as Digital Outputs using
the standard pin handling functions.
As these are standard pins, you should NOT include them in the Output array.
© simulator solutions
24 Jan 2020
37
Systems Manual
Example Code
#include <Arduino.h>
#include <config.h>
//=================================================
// SIMSTACK DEMO Code
// (c) Simulator Solutions 2019
//=================================================
//=================================================
// DEFINITIONS
//=================================================
// SimStack / Panel Information
// -------------------------SIMSTACK_CODE(CUS);
SIMSTACK_DESCRIPTION(Custom);
SIMSTACK_IP(192,168,1,200);
SERVER_IP(192,168,1,149);
SERVER_PORT(10748);
SIMSTACK_ADDON_INPUT_BOARDS(0);
SIMSTACK_ADDON_OUTPUT_BOARDS(0);
// System Switches - Comment out to disable (OFF).
// ----------------------------------------------#define SWITCHES
#define ROTENC
#define LIGHTS
#define OUTPUTS
#define ANALOG
/*************** CORE SYSTEM INCLUDES - DO NOT EDIT!
*
* This must come AFTER the definitions above as they are referenced in the below
*
* These are CRITICAL and must be included in all instances of code.
*
#include <SPI.h>
#include <PSXOutGeneral.h>
.
.
.
// #include <OneWire.h>
*
*
/**************************************************
© simulator solutions
24 Jan 2020
38
Systems Manual
/========================================================================
// INPUTS AND OUTPUTS
//=======================================================================
// INPUTS - Digital - Switches, Encoders etc
// ----------------------------------------------------------------------
General Input
PSXSwitch Inputs[] = {
PSXSwitch(BIG,&HydeDem1,BOTH,1,0),
PSXSwitch(GENERAL_IN,&HydeDem)
}
Define an input as type GENERAL_IN
// OUTPUTS - Lights etc
// -------------------------------------------------------------------------------------------------------INDICATOR_SET_MIN_PWM(0);
INDICATOR_SET_MAX_PWM(4095);
LAMP_SET_MIN_PWM(0);
LAMP_SET_MAX_PWM(1000);
BACKLIGHT_SET_MIN_PWM(0);
BACKLIGHT_SET_MAX_PWM(4095);
COMMONWHITE_SET_MIN_PWM(0);
COMMONWHITE_SET_MAX_PWM(4095);
// Indicator light min brightness (Ambers, etc)
// Indicator light max brightness ;
// General light min brightness
// General light max brightness
// Backlight min and max: 0 - 4095
// Common Whites
// 0 - 4095
General Output
Define an output of type
GENERAL_OUT
// Lights
PSXOutput Outputs[] = {
PSXOutput(GENERAL_OUT,dimRelayK2a)
};
Timer
long myTimer=millis();
//====================================================
// SETUP - Runs once - intialises all items
//====================================================
Create a variable to hold the time
for my timer and set to current time
void setup() {
SETUP_INIT();
Serial.begin(115200);
SETUP_ANALOG_INPUTS();
analog_AntiJitter=4;
SETUP_NETWORKING();
SETUP_WATCHDOG();
// Essential - stop watchdog, begin SPI
// if debug is enabled, start serial interface
// Start PSX Ethernet client
// Enable watchdog timer to catch 'Hang'
}
© simulator solutions
24 Jan 2020
39
Systems Manual
//====================================================
// MAIN LOOP
//===================================================
// This is the ongoing running area of the program.
// After running through 'setup' once,
// the program loops through loop() infinitely.
void loop(){
if (dataAvailable){
// Flag - We have
CHECK_SYSTEM_COMMANDS {
UPDATE_SYSTEM();
CHECK_SIT_LOAD_BASIC();
}
Ethernet data - lets process!
// Check for system commands
// Action any commands…
// If situation load just completed…
CHECK_QS {
}
// if a Qs received, process
CHECK_QI {
if(qIndex==&example){
MANUAL_SET_OUTPUT(0,atoi(qChars));
}
// if a Qi received, I process
want to trigger my output and send
CHECK_QH {
}
// if a Qh received, process
CHECK_ADDON_COMMANDS();
CLEANUP_NETWORK_DATA();
// Process any "addon=" commands .. speed.
// Resets Ethernet, cleaning …. data
General Output
it the qChars value.
}
}
CHECK_DIGITAL_INPUTS();
// *******
My custom code block
if(!blockingFlag) {
Post Processing
*******
Check if a general input triggered
if(generalInputFlag==true){
int mystate=MANUAL_GET_INPUT();
Get the state of the pin
if(INTERRUPT_PIN()==1){
if(mystate==true){
} else {
}
}
General Input
Check which pin to action
Check the state of the pin and action
accordingly.
}
if(millis()-myTimer>50){
…do update…
myTimer=millis();
}
}
// *******
End custom code block
UPDATE_DIGITAL_OUTPUTS();
CHECK_FOR_NETWORK_DATA();
RESET_WATCHDOG();
Check Blocking flag
// 50ms
Timers
*******
For periodic checks, check if the
timer has elapsed. If so, do your
check or update, and reset timer.
// GET NEXT ETHERNET STREAM
// Pat the Dog
}
© simulator solutions
24 Jan 2020
40
Download