Structure of code for Moscad M

Hello,
I need a code example for Moscad M, it is not the same that program just C code because with Moscad M we don't have *main* , insted of it has user tasks that we have to call but I don't know how. It will be very useful for me to have a C code for Moscad M, and know about the inicialization of the Moscad and the structure of the code for Moscad M.

Thanks a lot
 
Hi,
I assume you have the C ToolKit manual. In the C toolkit there are 2 aids to help a MOSCAD C programmer to migrate to MOSCAD-M

1. In the ctoolkit.pdf (C Toolkit manual) there is a chapter named Tutorial (MOSCAD-M) - p. 256 that demonstrates how to convert the first example in the C toolkit's examples set, so it will run in MOSCAD-M

2. Examples 41-45 (i.e. EXA041-EXA045) in the C toolkit's examples set also demonstrate how to operetta some C Toolkit API's on MOSCAD-M on account of C tasks (in the absence of ladder)

Hope this helps.
Kobi
 
K

Karina Duran

Hi Kobi,

Thanks a lot for your answer, I appreciate it. I would like to ask you how can I make a transmission for exception and a transmission for polling.

Thanks.
 
Hi Karine,
There is no need for C code to poll the MOSCAD-M. The front end (FIU, IP Gateway or M-OPC)polls the MOSCAD-M tables (data base) using the MDLC protocol.

Below see example for MOSCAD C code you can easily convert to MOSCAD-M as explained in the tutorial.

Regards,
Kobi

Example 25 - demonstrates sends a burst to the central using MOSCAD_tx_burst


/**+**************************************************************************
* NAME : exa025.c *
* EXAMPLE FOR : MOSCAD_tx_std_burst, MOSCAD_tx_burst, MOSCAD_end_burst *
* USING : CB_COPY_WORD *
* DESCRIPTION : The example sends a burst to the central in two ways:- *
* *
* 1) using MOSCAD_tx_std_burst: By pushing PB1, the Ladder *
* application calls "PB1_burst" function. This function *
* sends the first 2 rows in the "Burst table" to the *
* central. The burst message is built by the function, *
* where the input is the table number, the column number *
* and the central site ID. *
* MOSCAD_end_burst should be called at the end of the *
* the task if the caller task is not the Main Process. *
* In case of the Main Process this function is called *
* automatically by the system. *
* *
* 2) using MOSCAD_tx_burst: By pushing PB2, the Ladder *
* application calls "PB2_burst" function. This function *
* sends the last 2 rows in the "Burst table" to the *
* central. The burst message should be built by the user.*
* Refer to the scheme below to see how to build the *
* message for single or multiple bursts. *
* *
* The message format: *
* -------------------- *
* The first byte has to be 0xFF (burst code) followed by *
* blocks of bursts. In each block, the first byte is the *
* table number, the second byte is the row number, the *
* following bytes are the values of the columns. (1 byte *
* per bit, 2 bytes per integer and 4 bytes per real). The *
* total buffer size should not exceed 160 bytes. *
* *
* LADDER EXAMPLE : By pushing PB1 or PB2, the main process calls the *
* function pb2_burst. *
* The ladder also contains the burst table with *
* 4 rows and two columns -int type (2 bytes). *
* *
* NOTES : This example includes a special folder which contains *
* the MCP-T configuration, site table, TCP/IP conf. *
* *
* THE BUFFER STUCTURE DIAGRAM FOR MOSCAD_tx_burst. *
* *
* +---+---+---+---+---+ +---+---+---+---+---+ +---+---+ +---+---+ +---+ *
* | | | | | | | | | | | | | | | | | | | | *
* | | | | | | | | | | | | | | | | | | | | *
* | FF|Z1 |Y1 |X1 |X2 |..|Xi |Z2 |Y2 |X1 |X2 |..|Xj |Z3 |..|Xk | |.| | *
* | | | | | | | | | | | | | | | | | | | | *
* | | | | | | | | | | | | | | | | | | | | *
* +---+---+---+---+---+ +---+---+---+---+---+ +---+---+ +---+---+ +---+ *
* ^ ^ ^ ^ ^ ^ *
* | | first burst | new burst |last burst| bytes | *
* | +----------------------+----------------------+----------+ left | *
* | | *
* | | *
* | Multiple Burst buffer - 160 bytes. | *
* +----------------------------------------------------------------------+ *
* *
* *
* FF -The first byte must be 0xff (burst code). *
* Z -Table number. *
* Y -Line number in Z table. *
* X -Element in line y in Z table. *
* The parameter X contains a value. *
* The value type can be one of these types: *
* *
* 1 byte - Discrete in ladder. *
* 2 bytes - Int in ladder. *
* 4 bytes - Real in ladder. *
* *
* [C] Copyright Motorola Inc, 1995-99. All Rights Reserved *
* *
* REV DATE PROGRAMMER REVISION HISTORY *
* 1.0 17/01/99 Original *
* 1.1 29/08/99 Edit comments *
**-**************************************************************************/

#include "CAPPLIC.H"
#include <stdio.h>

/*-----------------------------------*/
/* The central index in site table. */
/*-----------------------------------*/
# define CENTER_SITE 1

/*--------------------------------------------------------------------------*/
/* Prototypes and defines */
/*--------------------------------------------------------------------------*/
extern void PB1_burst(unsigned short brst_tbl_num);
extern void PB2_burst(unsigned short brst_tbl_num);

/*--------------------------------------------------------------------------*/
/* The list of the function included in this block */
/*--------------------------------------------------------------------------*/
const CB_JUMPTBL user_jumptable[]=
{
{"Burst1", PB1_burst},
{"Burst2", PB2_burst},
{0 , 0 }
};


CB_TABLE_INFO burst_info;

/*--------------------------------------------------------------------------*/
/* 'C' Block Initialization and Completion */
/*--------------------------------------------------------------------------*/
void user_control_function(int control)
{

switch(control)

{
case CB_INIT :
break;

case CB_EXIT :
break;
}
}



/*--------------------------------------------------------------------------*/
/* functions. */
/*--------------------------------------------------------------------------*/
void PB1_burst(unsigned short brst_tbl_num)
{
unsigned char row_number ;
char message[80];

/*--------------------------------------------*/
/* Get the burst table into burst_info struct.*/
/*--------------------------------------------*/
if (MOSCAD_get_table_info ((unsigned char)brst_tbl_num, &burst_info) != 0 )
{
MOSCAD_sprintf(message,"No valid information in table no: %id",brst_tbl_num);
MOSCAD_error(message );
return;
}

/*----------------------------------------------------------------*/
/* Send the first two rows in burst table (ladder) to the central.*/
/*----------------------------------------------------------------*/
for (row_number = 0; row_number < 2; row_number++)
{
if (MOSCAD_tx_std_burst(CENTER_SITE, (unsigned char)brst_tbl_num, row_number) != 0)
{
MOSCAD_error("Failed to send the burst (PB1_burst)");
}
}
}


void PB2_burst(unsigned short brst_tbl_num)
{
unsigned char buf[CB_MAX_MDLC_BUF_SIZE];
unsigned short len;
char message[80];

short *p_col_0; /* pointer to column 0 in burst table */
short *p_col_1; /* pointer to column 1 in burst table */
short val0; /* The value of row in index 0 (column 0) */
short val1; /* The value of row in index 0 (column 1) */

/*--------------------------------------------*/
/* Get the burst table into burst_info struct.*/
/*--------------------------------------------*/
if (MOSCAD_get_table_info ((unsigned char)brst_tbl_num, &burst_info) != 0 )
{
MOSCAD_sprintf(message,"No valid information in table no: %id",brst_tbl_num);
MOSCAD_error(message );
return;
}

/*------------------------------------------------------*/
/* Set the value of val0 to burst table row 2 column 1. */
/* Set the value of val1 to burst table row 2 column 2. */
/*------------------------------------------------------*/
p_col_0 = (short *)(burst_info.ColDataPtr[0]);
p_col_1 = (short *)(burst_info.ColDataPtr[1]);
val0 = p_col_0[2];
val1 = p_col_1[2];

/*------------------------------------------------*/
/* First byte ff- burst code */
/* Start Multiple Burst buffer-maximum 160 bytes. */
/*------------------------------------------------*/
buf[0] = 0xff;

/*------------------------------------------------*/
/* Second byte z1- first burst table number */
/* Third byte y1- row number in table z1 */
/*------------------------------------------------*/
buf[1] = brst_tbl_num;
buf[2] = 2;

/*---------------------------------------------------------*/
/* Next two bytes x1-the first value from table z1 row y1. */
/* Use CB_COPY_WORD to copy the value to the buffer. */
/*---------------------------------------------------------*/
CB_COPY_WORD(&buf[3],&val0);
CB_COPY_WORD(&buf[5],&val1);


/*-----------------------*/
/* Move to next row. */
/*-----------------------*/

/*------------------------------------------------------*/
/* Set the value of val0 to burst table row 3 column 1. */
/* Set the value of val1 to burst table row 3 column 2. */
/*------------------------------------------------------*/
val0 =p_col_0[3];
val1 =p_col_1[3];


/*----------------------------------------------------------------*/
/* Second byte z1- second burst table number (the same table). */
/* Third byte y2- second row_number in table z1. */
/*----------------------------------------------------------------*/
buf[7] = brst_tbl_num;
buf[8] = 3;

/*---------------------------------------------------------*/
/* Next two bytes x1-the first value from table z1 row y2. */
/* Use CB_COPY_WORD to copy the value to the buffer. */
/*---------------------------------------------------------*/
CB_COPY_WORD(&buf[9],&val0);
CB_COPY_WORD(&buf[11],&val1);

/*---------------------------------------------------------*/
/* The number of bytes in the buffer that we build. */
/* The buffer must contain no more than 160 bytes. */
/*---------------------------------------------------------*/

len = 13;

/*--------------------------------------------------------------*/
/* Send the last two rows in burst table(ladder) to the central.*/
/*--------------------------------------------------------------*/
if (MOSCAD_tx_burst(CENTER_SITE, buf, len) != 0)
{
MOSCAD_error("Failed to send the burst (PB2_burst)");
}
}
 
Do you guys know where I can find the ctoolkit.pdf (C Toolkit manual)?

I need to write 'C' for a MOSCAD CPU 420.

Thank you,
Diego
 
Diego,

I don't think Kobi frequents control.com any more.

> Do you guys know where I can find the ctoolkit.pdf (C Toolkit manual)?

> I need to write 'C' for a MOSCAD CPU 420.

To create/compile/use C Toolkit applications for Moscad, you need:

The Motorola Moscad C Toolkit
The Microtek C compiler
A copy of Motorola Moscad Toolbox (to use for download.)

As far as I know, none of these are available any more.

Here is a OneDrive link to the C Toolkit Manual:

http://1drv.ms/1GLmHdU

All Moscad products are discontinued. This includes:

Moscad
Moscad-L
Moscad-M
Moscad Toolbox
Moscad C Toolkit.


The C compiler for Moscad was created by Microtek (very pricey). Microtek was acquired years ago by Mentor Graphics and I have not seen them list the Motorola Moscad C Toolkit since the acquisition.

The current Motorola Fixed Data product line is centered on the ACE3600 RTU. Most Moscad ladder applications can be converted to ACE3600 with minimal work. However, this excludes any Moscad applications that emulated the Motorola Intrac protocol.

ACE3600 is not hardware compatible with Moscad hardware, but ACE3600 and Moscad can exist in the same system and communicate with each other.

ACE3600 uses System Tools Suite for what was formerly handled by Moscad Toolbox.

ACE3600 also has its own C Toolkit and many, but not all, Moscad C-calls are available, either identically, or with some changes, in ACE3600. ACE3600 C Toolkit also adds other system calls.

The ACE3600 C Toolkit is economically priced from Motorola and features a version of the free GCC compiler.

Motorola recently announced the ACE1000 RTU, but I do not think North American pricing has been finalized. This product line is probably widely available outside NA. ACE1000 uses an entirely different software support system and is not hardware compatible with ACE3600. However, ACE1000 adds numerous new features and is compatible with most ACE3600 communications.

NOTE: Motorola Marketing still sometimes refers to the ACE3600 as being part of the overall Moscad line. I don't know anyone on the technical side who considers ACE part of the Moscad line.

jack
 
Top