Examples | Shop
 
OOPicII+™ and SCP


 
This example application demonstrates use of the Serial Control Protocol (SCP) in firmware version 5.0.1 on an OOPicII+™ controller. It becomes accessible by using the DS-IM RS232 Interface Module. The module allows commands to be sent from an RS232 device (in this application a desktop PC), which can then control the program flow of the connected OOPicII+ using SCP.

Connections
Using a 40 pin-40 pin IDC ribbon cable (part of the 2 module fixing kit), connect the OOPicII+ 40 pin header to the outer most 40 pin header on the DS-IM. The inner 40-pin header is used for IO connections and is connected to the other 40-pin header.

The LED’s will be connected to the inner 40-pin header on the DS-IM as follows:

The leg that is closest to the flat edge of the LED is connected to Gnd.

The positive leg is connected to the designated pin on DS-IM via a 1K resistor. This resistor is needed other wise the LED will blow.

Red LED - Flat Edge Leg to Gnd - Positive Leg to 1K resistor to Pin 20

Yellow LED - Flat Edge Leg to Gnd - Positive Leg to 1K resistor to Pin 17

Green LED - Flat Edge Leg to Gnd - Positive Leg to 1K resistor to Pin 19

The DS-IM can be mounted above the OOPicII+ using the spacers in the 2 module fixing kit.

The serial cable is connected to the DS-IM board via a female to male gender changer (the DS-IM has a DB9F connector). The other end is connected to a spare serial comm. port.


Download the Program
Download the program as normal from the OOPic compiler (Version 5.0.1). Ensure the target device is set to OOPic Firmware Version B.2.x+.

Tools >Target Device > OOPic Firmware Version B.2.x+

Check that the programming cable is configured correctly.

Tools >Cable Configuration

The OOPicII+ can be programmed via the DS-IM using the serial comm. port. In the Cable configuration window, select the comm. port you are connected to and press Find Serial Cable. When found, press ok. If no serial cable is found, make sure the DS-IM and OOPicII+ are powered up and try again. If it still cannot find it, double-check what comm. port you are connected to.

When all the above is set, press F5 (compile and download). You will be prompted to save the program if not already saved.

The three LED’s will be lit, but will be dimmer than usual. This is because the LED’s are turning on and off very fast, so it seems that they are on, even though this is not the case. We will see the true pattern of LED lighting when we invoke the single step command.

Serial Control Protocol (SCP)
The full set of SCP commands can be viewed at www.oopic.com. In this application, we are demonstrating the use of Single Stepping.

*The Single Step command puts the OOPic's application program into single-step mode. In firmware version B.2.0, the Step property was added to the OOPic object.

*When the Step property is set to 1, the OOPic's Paused property will be set to 1 after each OOPic instruction executes, thereby giving the user the ability to single step through the program. The Start Single Step command "P" set the Step property to 1 and also clears the Paused property to 0 so that a single instruction gets executed. Issuing the Start Single Step command "P" repeatedly, will execute one instruction per issue. The Stop Single Step command "O" exits the single step mode by clearing both the Step and the Paused property which results in the program resuming.

Example: To single step through the program,
Send "\0V", Receive "v"
Send "0J", Receive "j"
Send "P" Receive "p"

(Turn on single step and execute one instruction)
Send "P", Receive "P" (execute one instruction)
Send "P", Receive "P" (execute one instruction)
Send "P", Receive "P" (execute one instruction)
Send "P", Receive "P" (execute one instruction)
Send "0", Receive "o" (Turn off single step and resume program)

Note that the Step and Paused properties are also available to the OOPic's application program. This gives the program the ability to stop at a pre-programmed place and then wait for SCP to instruct it to resume.

The above serial instructions can be sent using a hyper terminal (download com 1 hyper terminal here). Type the characters above (no need to press enter after each character) into the terminals window. Responses will be displayed straight after a command has been sent.

When you send “P”, the OOPic will step through its program. By doing this, the three LED’s will step through a traffic light sequence. This demonstrates that the OOPic is being walked through each line and command.

To return back to autonomous mode, the command “O” is sent. The LED’s will all come on again.

*Taken from the OOPic Programmers Guide, Chapter 16, Serial Control Protocol (SCP).


 

'***************************************************************************
'***************************************************************************
'
'This example program is used to demonstrate the Serial Control Protocol (SCP) Single Step command ‘with the OOPicII+ and the DS-IM Serial Interface Module.
'
'Compiler Version : 5.0.1 OOPicII+
'Written By: Total Robots (Jamie Finnan)
'TR-020
'***************************************************************************
'***************************************************************************
Dim Red_Led As New oDio1
Dim Yellow_Led As New oDio1
Dim Green_Led As New oDio1
'***************************************************************************
Sub Main()
Red_Led.IOLine = 8
Yellow_Led.IOLine = 6
Green_Led.IOLine = 7
Red_Led.Direction = cvOutput
Yellow_Led.Direction = cvOutput
Green_Led.Direction = cvOutput
Do
Red_Led.Value = 1
Yellow_Led.Value = 1
Red_Led.Value = 0
Yellow_Led.Value = 0
Green_Led.Value = 1
Green_Led.Value = 0
Yellow_Led.Value = 1
Yellow_Led.Value = 0
Red_Led.Value = 1
Loop
End Sub
'***************************************************************************
'***************************************************************************
download the oopic code SCP Single Step.osc

Examples | Shop