Wiring Functions |
After any symbols are instantiated in a schematic, you will need to add some wiring to connect the symbols together. For straight (vertical/horizontal) connections there is "Wire". For "Wire" intersections, there is "Dot". And, for more complex wiring operations there is "Route" and "Route_Diag". "Route" allows you to specify wiring that contains multiple turns. "Route_Diag" is use when a multiple turn wiring route requires some of the wires to run diagonally.
The symbol "Jumper" is considered part of wiring that can be used when a user defined break needs to be in a drawing.
Use the buttons that are displayed across each symbol header, to navigate to other symbols. To navigate between other symbol libraries, use the menu on the left.
Wire |
Description: Draws a line, or wire, from
Lib_S_Start_X, Lib_S_Start_Y to
Lib_S_End_X, Lib_S_End_Y. The "wire" is 1 px wide. The function
takes care of converting the start and end valued to "jsDraw2D" references.
Wire( Lib_S_Dwg_Obj, Lib_S_Start_X, Lib_S_Start_Y, Lib_S_End_X, Lib_S_End_Y );.
Wire( Dwg_Obj, Start_X, _Start_Y, Start_X+100, Start_Y+100 ); );
Break Wire |
Description: Draws a line break (X) centered at Start_X, Start_Y. The "Break_Wire" symbol is a 5px by 5px "X". This function allows circuit modification that require a break in a wire, to be shown.
Break_Wire( Dwg_Obj, Start_X, Start_Y ); );
Route |
Description: Internally, Route() keeps track of the drawing position (Current Location). The Current Location is initialized by Lib_S_Start_X, Lib_S_Start_Y and is updated with each wire segment specified. The wire segments are specified in a Route_Array. Wires can be drawn in "X" (Horizontal), "Y" (Vertical), or "XY" (diagonal) using basic commands. Special wire commands exist for branch wires ("XX" and "YY"), and intersection dotting ("XD, "YD", "XXD", "YYD") drawing a wire without updating the Current Location.
Each wire segent requires two or more entries in the array. The first segment is drawn from the start point (Lib_S_Start_X, Lib_S_Start_Y) to the point defined in the first array entry. Each successive segment is them drawn from the end location of the last segment. Segment specifications are defined relative to the end of the previous segment.
There are very subtil differences between the segment specifications listed below. Read the usage carefully.
Parameter | Description | Example | |
---|---|---|---|
Lib_S_Dwg_Obj | jsGraphics Object that points to the drawing. |
R101 100K R102 100K R103 100K R104 100K |
|
Lib_S_Start_X | Route Start X Position |
Show/Hide Grid (10x10), Center Mark (Orange), Pins (purple dot). |
|
Lib_S_Start_Y | Route Start Y Position |
Return: Returns the X and Y valued for the last route end point.
Usage: Just below is a list of Route specifications that can be used in the Route array. Below the list are the code that was used to draw the lines in the example above. The items in Red are the only ones that need to be adjusted to your specific needs. The lines in Green are just comments and can be deleted. Due to space limitations, some of the lines below may be split onto more than one line.
- "X", +/-N ⇒ Draw a wire in the X direction N pixels. N can be Positive or Negative. Update the array pointer by "2".
- "Y", +/-N ⇒ Draw a wire in the Y direction N pixels. N can be Positive or Negative. Update the array pointer by "2"
- "XD", +/-N ⇒ Dot the current location and then draw a wire in the X direction N pixels. Current location is updated to the destination location. N can be Positive or Negative. Update the array pointer by "2".
- "YD", +/-N ⇒ Dot the current location and then draw a wire in the Y direction N pixels. Current location is updated to the destination location. N can be Positive or Negative. Update the array pointer by "2"
- "XY", +/-N, +/-M ⇒ Draw a diagonal line from the current location to a location that is +/-N pixels in X and +/-M pixels in Y from the previous end point. N and M can be Positive or Negative. Update the array pointer by "3".
- "YX", +/-N, +/-M ⇒ Similar to the previous specification except that it draws a diagonal line by moving in Y first, than X. Therefore, draw a diagonal line from the current location to a location that is +/-N pixels in Y and +/-M pixels in X from the previous end point. N and M can be Positive or Negative. Update the array pointer by "3".
- "XX", +/-N ⇒ Draw a wire in the X direction but does not change the current location. Update the array pointer by "2".
- "YY", +/-N ⇒ Draw a wire in the Y direction but does not change the current location. Update the array pointer by "2".
- "XXD", +/-N ⇒ Draw a wire in the X direction but does not change the current location. Then Dot the current location and update the array pointer by "2".
- "YYD", +/-N ⇒ Draw a wire in the Y direction but does not change the current location. Then Dot the current location and update the array pointer by "2".
These two operations allow the user to save a location, draw a branch, and then restore the drawing coordinates back to the saved location, without backtracking on the branch.
- "S" ⇒ Save the Current X/Y coordinates. Update the array pointer by "1".
- "R" ⇒ Restore the Saved X/Y coordinates. Update the array pointer by "1"
Route_Start_X = 70 Route_Start_Y = Height-20;
var Route_End_X, Route_End_Y; var Route_XY_Array = new Array();
Route_XY_Array = [ "Y", -30, "XXD", 35, "Y", -50, "XXD", 35, "Y", -10, "XY", 110, -30, "Y", -10, "XXD", -35, "Y", -50, "XX", -35 ];
Route_XY_Return = Route( Route_Sample, Route_XY_Array, Route_Start_X, Route_Start_Y );
Route_End_X = Route_XY_Array[0]; Route_End_Y = Route_XY_Array[1];
//
// Now draw a route on the right side of the resistors that crosses over to the left.
Route_Start_X = 180; Route_Start_Y = Height-20;
var Route_End_X, Route_End_Y; var Route_XY_Array = new Array();
Route_XY_Array = [ "Y", -30, "XXD", -35, "Y", -50, "XXD", -35, "Y", -10, "XY", -110, -30, "Y", -10, "XXD", +35, "Y", -50, "XX", +35 ];
Route_XY_Return = Route( Route_Sample, Route_XY_Array, Route_Start_X, Route_Start_Y );
Route_End_X = Route_XY_Array[0]; Route_End_Y = Route_XY_Array[1];
Route_Pen |
Description: Special instance of Route(). This instance, Route_Pen() allows for:
- Saving/Restoring a route point - This is useful when you need to branch in multiple directions. The branch point can be saved and then restored later to route in another direction.
- Curved corners - Draws 90 degree curve of a user specified radius.
- Setting the Color of the line - Passed on the command line as a basic color name or HEX number (#XXYYZZ). There are 140 Color Names supported by all browsers.
- Setting the Width of the line - Sets the width of the line being drawn. Note that, the width of a line does not increase symetrically about the line center. Vertical lines will grow to the right and Horizontal lines will grow down.
Start drawing a line at Lib_S_Start_X, Lib_S_Start_Y. End of the drawn line is returned in array Route_XY_Return. The end points of each line segent are defined in the Route_Array array, which is passed to the function. Each line segent requires two or more entries in the array. The first segment is drawn from the start point to the point defined in the first array entry. Each successive segment is them drawn from the location of the last segment. Segment specifications are defined relative to the end of the previous segment.
There are very subtil differences between the segment specifications listed below. Read the usage carefully.
Parameter | Description | Example | |
---|---|---|---|
Lib_S_Dwg_Obj | jsGraphics Object that points to the drawing. |
R101 100K R102 100K R103 100K R104 100K |
|
Lib_S_Color, Lib_S_Width | Pen Color and Width. | ||
Lib_S_Start_X | Route Start X Position |
Show/Hide Grid (10x10), Center Mark (Orange), Pins (purple dot). |
|
Lib_S_Start_Y | Route Start Y Position |
Return: Returns the X and Y valued for the last route end point.
Usage: Just below is a list of Route specifications that can be used in the Route array. Below the list are the code that was used to draw the lines in the example above. The items in Red are the only ones that need to be adjusted to your specific needs. The lines in Green are just comments and can be deleted. Due to space limitations, some of the lines below may be split onto more than one line.
- "X", +/-N ⇒ Draws in the X direction N pixels. N can be Positive or Negative. Update the array pointer by "2".
- "Y", +/-N ⇒ Draws in the Y direction N pixels. N can be Positive or Negative. Update the array pointer by "2".
- "D" ⇒ Dot the current location and update the array pointer by "1".
- "XD", +/-N ⇒ Dot the current location and then draw a wire in the X direction N pixels. Current location is updated to the destination location. N can be Positive or Negative. Update the array pointer by "2".
- "YD", +/-N ⇒ Dot the current location and then draw a wire in the Y direction N pixels. Current location is updated to the destination location. N can be Positive or Negative. Update the array pointer by "2".
- "XY", +/-N, +/-M ⇒ Draws a diagonal line from the current location to a location that is +/-N pixels in X and +/-M pixels in Y from the previous end point. N and M can be Positive or Negative. Update the array pointer by "3".
- "YX", +/-N, +/-M ⇒ Similar to the previous specification except that it draws a diagonal line by moving in Y first, than X. Therefore, draws a diagonal line from the current location to a location that is +/-N pixels in Y and +/-M pixels in X from the previous end point. N and M can be Positive or Negative. Update the array pointer by "3".
- "XX", +/-N ⇒ Draws a line in the X direction but does not change the current location. Update the array pointer by "2".
- "YY", +/-N ⇒ Draws a line in the Y direction but does not change the current location. Update the array pointer by "2".
- "XXD", +/-N ⇒ Draws a line in the X direction but does not change the current location. Then Dot the current location and update the array pointer by "2".
- "YYD", +/-N ⇒ Draws a line in the Y direction but does not change the current location. Then Dot the current location and update the array pointer by "2".
These two operations allow the user to save a location, draw a branch, and then restore the drawing coordinates back to the saved location, without backtracking on the branch.
- "S" ⇒ Save the Current X/Y coordinates. Update the array pointer by "1".
- "R" ⇒ Restore the Saved X/Y coordinates. Update the array pointer by "1"
These two operations allow the user to save a location, draw a branch, and then restore the drawing coordinates back to the saved location, without backtracking on the branch.
- "XYR", "Dir", Rad ⇒ Draw a 90 degree curved line with a specified Radius. The direction of the curve is controlled by the "Dir" specification - "UpLt" - ◝ | "UpRt" - ◜ | "LtUp" - ◟ | "RtUp" - ◞ | "RtDn" - ◝ | "LtDn" - ◜ | "DnRt" - ◟ | "DnLt" - ◞. While some of the curves look to be duplicates, their start point and end point is different. Update the array pointer by "3".
Route_Pen_Start_X = 70 Route_Pen_Start_Y = Height-20;
var Route_Pen_End_X, Route_Pen_End_Y; var Route_Pen_XY_Array = new Array();
var Route_Pen_Color = "red"; Route_Pen_Width = 1;
Route_Pen_XY_Array = [ "Y", -30, "XXD", 35, "Y", -50, "XXD", 35, "Y", -10, "XY", 110, -30, "Y", -10, "XXD", -35, "Y", -50, "XX", -35 ];
Route_Pen_XY_Return = Route_Pen( Route_Pen_Sample, Route_Pen_XY_Array, Route_Pen_Color, Route_Pen_Width, Route_Pen_Start_X, Route_Pen_Start_Y );
Route_Pen_End_X = Route_Pen_XY_Array[0]; Route_Pen_End_Y = Route_Pen_XY_Array[1];
//
// Now draw a route on the right side of the resistors that crosses over to the left.
Route_Pen_Start_X = 180; Route_Pen_Start_Y = Height-20;
var Route_Pen_End_X, Route_Pen_End_Y; var Route_Pen_XY_Array = new Array();
var Route_Pen_Color = "green"; Route_Pen_Width = 1;
Route_Pen_XY_Array = [ "Y", -30, "XXD", -35, "Y", -50, "XXD", -35, "Y", -10, "XY", -110, -30, "Y", -10, "XXD", +35, "Y", -50, "XX", +35 ];
Route_Pen_XY_Return = Route_Pen( Route_Pen_Sample, Route_Pen_XY_Array, Route_Pen_Color, Route_Pen_Width, Route_Pen_Start_X, Route_Pen_Start_Y );
Route_Pen_End_X = Route_Pen_XY_Array[0]; Route_Pen_End_Y = Route_Pen_XY_Array[1];
Dot |
Description: Draw a 3 pixel dot at Start_X, Start_Y.
.
Dot( Dwg_Obj, Start_X, Start_Y+20 );
Jumper |
Description: Draw a jumper from
Start_X, Start_Y and return End_X, End_Y.
Lib_S_Rot = R0 Draws from top to bottom. Lib_S_Rot = R90 draws from left to right.
.
Parameter | Description | Example | |
---|---|---|---|
Lib_S_Dwg_Obj | Graphics Object that points to the drawing. |
1 2 J1 B1 |
|
Lib_S_Label | Label for the Jumper, in quotes. | ||
Lib_S_Value | Value for the Jumper, in quotes. | ||
Lib_S_Pos | Position for the Jumper, in quotes. | ||
Lib_S_Rot | Rotate the Jumper Lib_S_Rot degrees, counter clockwise. Limited to the following rotation angles: "R0" and "R90". |
||
Lib_S_Start_X | Output Symbol Start X Position | Show/Hide Pins Mark the Center with a "X" and I/O pins with a green dot. |
|
Lib_S_Start_Y | Output Symbol Start Y Position |
J1_Ret = Jumper( Dwg_Obj, "J1", "B1", "Norm", "R0", Start_X, Start_Y );
J1_Start_X = J1_Ret[0]; J1_Start_Y = Ret[1]; J1_End_X = J1_Ret[2]; J1_End_Y = J1_Ret[3];
Bus Route & Bus Tap |
Description: Draw a 2 pixel wide data BUS and add one, or more, signal taps (Bus Taps) from the bus.
It's common on drawings to have digital ICs with multiple address and data inputs and outputs. But routing these signals around a drawing can consume a lot of drawing space and cause unnecessary complication to the drawing. To releive this issue, multiple signals can be routed as a single, 2 pixel wide, signal call the BUS. The BUS, drawing wise, is wider (2 Pixels) than a single signal wire, and a different color, in order to destinguish between them. The BUS is labeled as if it were and array of signals. For example: A[15..0] for a 16 bit BUS or D[7..0] for an 8 bit BUS.
To add a signal to the BUS, or extract a signal from the BUS, a BUS Tap is used. The BUS Tap can tap into one, or more, signals in the BUS. For example: A[8] for a single bit tap or A[7:4] for a four bit tap.
Generally, these multi-bit data buses enter and exit a digital IC from the left or right. On some drawing applications, a part can be rotated so that the multi-bit data buses enter from the top or bottom. However, for most of the digital ICs in my library, the symbol can not be rotated. This is because adding that capability addes too much complication.
So, while the BUS can be drawn in multiple directions, a BUS Tap can only access the BUS from the left or right.
The example provides1 Bus_Route and 5 Add_Tap instances. The example, at the bottom, only has 1 Add_Tap.
Parameter | Description | Example | |
---|---|---|---|
Lib_S_Dwg_Obj | Graphics Object that points to the drawing. |
A15 |
|
Lib_S_Wire_Dir | Wire Direction, Right, Left, Up, or Down from Start_X, Start_Y |
|
|
Lib_S_Tap_Dir | Direction that the Tap will bend at the end of Tap Wire. If Wire Direction = Left/Right, Tap Dir = Up/Down only. If Wire Direction = Up/Down, Tap Dir = Left/Right only. |
|
|
Lib_S_Wire_Len | Length, in pixels, of the wire leading into the tap. The minimim tap length, 10, will draw the tap only. |
|
|
Lib_S_Tap_Lab | Tap Label | ||
Lib_S_Start_X, Lib_S_Start_Y |
Route Start X and S_Start_Y Position The Tap starts at Start_X, Start_Y with a Wire that is Wire_Len long, in the direction specified in Wire_Ang. The tap then angles according to Tap_Dir. |
Show/Hide Grid (10x10), Show Center Mark, Show Pins. |
|
Return: Returns X and Y coordinates end of the Tap, in an array.
Usage: Draw a wire that starts at [Tap_Center_X, Tap_Center_Y] in the [Wire_Dir] direction. At 10 pixels before the end of the wire, draw a diagonal wire [Tap_Dir], 10 pixels in X and 10 pixels in Y. At the junction of the wire and the tap, write [Tap_Lab].
Note the double quotes. They are important because some data is passed as a string and others as an integer.
If the return values are not required, the Add_Tap instance can be specified on one line by putting the Wire_Dir, Wire_Len, and Tap_Dir directly into the function call.
// Add_Tap Example
var Tap_Center_X = ???; var Tap_Center_Y = ???;
var Wire_Dir = "Down"; var Wire_Len = 40; var Tap_Dir = "Left"; var Tap_Label = "A15";
Tap_Return_XY = Add_Tap( Dwg_Obj, Wire_Dir, Wire_Len, Tap_Dir, Tap_Label, Tap_Center_X, Tap_Center_Y );
// All-in-one Add_Tap Example with no return values.
Add_Tap( Dwg_Obj, "Down", "40", "Left", "A15", Tap_Center_X, Tap_Center_Y );
Ground |
Description: Special instance of Ground that draw a line with multiple segments/directions. This included angled lines.
Parameter | Description | Example | |
---|---|---|---|
Lib_S_Dwg_Obj | jsGraphics Object that points to the drawing. |
|
|
Lib_S_Type | Text Value ("Common", "Common A-Gnd", "Common D-Gnd", "Earth", "Chassis", "SM_Chassis", etc.). | Select from the dropdown menu ⇒ | |
Lib_S_Start_X | Ground Start X Position |
Show/Hide Grid (10x10), Center Mark (Orange), Pins (purple dot). |
|
Lib_S_Start_Y | Ground Start Y Position |
Gnd_Rtn = Ground( Dwg_Obj, "SM_Earth", Start_X, Start_Y ); Gnd_1_X = Gnd_Rtn[0]; Gnd_1_Y = Gnd_Rtn[1];
Shield Gnd |
Description:
Parameter | Description | Example | |
---|---|---|---|
Lib_S_Dwg_Obj | jsGraphics Object that points to the drawing. |
|
|
Lib_S_Type | Text Value ("Common", "Common A-Gnd", "Common D-Gnd", "Earth", "Chassis", "SM_Chassis", etc.). | Select from the dropdown menu ⇒ | |
Lib_S_Start_X | Ground Start X Position |
Show/Hide Grid (10x10), Center Mark (Orange), Pins (purple dot). |
|
Lib_S_Start_Y | Ground Start Y Position |
Gnd_Rtn = Shield_Gnd( Dwg_Obj, "SM_Chassis", Start_X, Start_Y ); Gnd_1_X = Gnd_Rtn[0]; Gnd_1_Y = Gnd_Rtn[1];
V_Plus |
Description: Special instance of V_Plus that draw a line with multiple segments/directions. This included angled lines.
Parameter | Description | Example | |
---|---|---|---|
Lib_S_Dwg_Obj | jsGraphics Object that points to the drawing. |
+12V |
|
Lib_S_Rot | Text Value ("R0", "R90", "R180", "R270"). | Select from the dropdown menu ⇒ | |
Lib_S_Value | Text Value ("+12V", "-12V", etc.). | Select from the dropdown menu ⇒ | |
Lib_S_Start_X | V_Plus Start X Position |
Show/Hide Grid (10x10), Center Mark (Orange), Pins (purple dot). |
|
Lib_S_Start_Y | V_Plus Start Y Position |
VP_Rtn = V_Plus( Dwg_Obj, "R0", "+12V", Start_X, Start_Y ); VP_X = VP_Rtn[0]; VP_Y = VP_Rtn[1];