The Simulator
There are several 'files' in the PLC that are dedicated to the simulator as well as some variables like a counter, a timer, etc
The first file, N50, is a number. I call this the 'command'.
Command values:
1 - 9. Move the number in N51 to the input card or output card. 1 - 5 are input cards, 6 - 9 are output cards.
10 - 29. These are analog inputs 0, 1, ... 19. Again, move the value in N51 to the proper input. There are no decimals. N51 is a signed integer, so values are - 32768 to 32767
30. Set distance trigger. This loads the value in N51 into a counter that 'waits' in this step and counts down until it reaches 0. It then steps to the next simulator step. This command has a maximum timeout, measured in hundredths of a second, stored in N52. That gives me a range of 10 ms to 655.35 seconds. The distance is in meters.
31. Set speed trigger. This loads the value in N51 to a compare and 'waits' until the speed has reached this value (or higher) then steps to the next simulator step. This command has a maximum timeout, in hundredths of a second, stored in N52. Scale is 1000 for 10 kph or 10.00 kph with an implied decimal.
32. Copy accelerator to present speed setpoint. This allows for speeds that are not coded into the simulator program. There is no timeout. It is executed, then the next simulator step is activated. This is approximately 'maintain speed' when the speed setpoint has been reached. Since there is a 'greater than' involved, it introduces some variability into the speeds and distances in the simulation.
33. Copy the present brake setting to the brake setpoint. That allows for brake settings that are not coded into the simualator. There is not timeout. It is executed, then the next simulator step is activated. As you cross the speed setpoint, you take the brake setpoint and hold it there.
So far, that's all I have for a simulator. I list below what I have for starting the truck and backing out of the driveway. That will (hopefully) give you an idea of what the simulator can and cannot do for testing.
The spreadsheet shows the columns Step, Command (N50), Value (N51) and Timeout (N52) along with a description of what the step is doing
I attached the spreadsheet - the info below is a bit hard to read. In the spreadsheet, the second tab - Binary - shows which bit is turned on for which input. That is the user hostile part.
Step Command Value Timer Description
1 1 30 1 Initial conditions Park, Estop OK, Ebrake set
2 2 30 1 Initial conditions, redundant inputs Park, Estop OK, Ebrake set
3 10 3FF 1 Accelerator 0% Acc pedal is not active
4 11 7FF 1 Brake pedal 0% Brake pedal is not active
5 1 38 100 Start Start truck
6 1 34 500 Run, delay for POST
7 1 36 1 Press Brake Seq to reverse out of garage. NOT to be used as a template for moving from stopped to stopped
8 11 07ff 100 Brake > 50% Push the brake to the floor
9 1 37 100 remove ebrake
10 2 37 100 and from redundant input
11 1 57 100 Park to Reverse
12 11 03FF 1 Brake to 0% Begin reverse of 30 m
13 1 55 100 Brake pedal released
14 1 155 1 Accel pedal pressed
15 10 6FF 100 accel to 25%
16 30 25 1 set distance to travel 25 m
17 31 1000 1000 set max speed 10 kph in 10 s
18 32 0 2000 set speed sp to present when speed is reached from last step transition Stay in this step until distance done triggers next step
19 30 5 1 set distance to brake
20 31 03FF 1 accel to 0%
21 1 57 1 remove acc, press brake
22 11 07FF 500 brake 50% Stay in this step until distance done triggers next step
At this point, you would press the brake further and switch from Reverse to Drive
|