GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 20-Feb-2008, 16:01
boschow boschow is offline
Junior Member
 
Join Date: Feb 2007
Location: Slovenia
Posts: 47
boschow can only hope to improve

Making communication table


I am trying to make some sort of communication between two home made PLC's "micro controllers". Since my communication protocol will send the bits first and only then the registers I need two tables one for bits and the other for registers. In my code there is a single structure called TNNvvar. This structure can access to other structures like inputs, outputs, pid ... See example below:

CPP / C++ / C Code:
typedef struct
{
   TNSA_DigitalInputs    DigitalInputs;
   TNSA_DigitalOutputs  DigitalOutputs;
   TNSA_AnalogInputs    AnalogInputs;
   TNSA_AnalogOutputs  AnalogOutputs;
}TNSA_MainModule;

typedef struct
{
   TNSA_MainModule    MainModule;        
   TNSA_Module01       Module01;
   TNSA_Module02       Module02;
   TNSA_Module03       Module03;
}TNNvar;

Each of this "sub" structures has registers and bits as show in the example for digital inputs:
CPP / C++ / C Code:
typedef union
{
   struct
  {
    unsigned a_bs:1;   //digital input status
    unsigned s_ac:1;   // digital input active simulation
    unsigned s_enb:1; // digital input simulation enable
    unsigned alm_enb:1; // digital input alarm enable
    unsigned t_od_enb:1; // digital input enable timer on delay
  }bit;
  unsigned int all; // i put here 16 bits because maybe i will need to add additional bits ... 
}TNSA_DigitalInputs_BBN;
typedef struct
{
TNSA_DigitalInputs_BBN bb_var;
unsigned int t_od; //timer on delay
unsigned long t_al;  //alarm timer
}TNSA_DigitalInputs;

My idea of communication table for bits is :

CPP / C++ / C Code:
#define NUMBER_OF_COILS 1600

typedef struct _PDU_COIL_MAP
{
    unsigned char *base_addr;
    unsigned char byte_index;
    unsigned char bit_index;
}PDU_COIL_MAP;

TNNvar coils;
PDU_COIL_MAP server_coil_map[NUMBER_OF_COILS]={
{&coils.MainModule.DigitalInput.bb_var.bit, 0, 0},
{&coils.MainModule.DigitalInput.bb_var.bit, 0, 1},
{&coils.MainModule.DigitalInput.bb_var.bit, 0, 2},
{&coils.MainModule.DigitalInput.bb_var.bit, 0, 3},
{&coils.MainModule.DigitalInput.bb_var.bit, 0, 4},
{&coils.MainModule.DigitalInput.bb_var.bit, 0, 5}
};

My idea of communication table for registers is :

CPP / C++ / C Code:
#define NUMBER_OF_REG 2000

typedef struct _PDU_REG_MAP
{
    unsigned int *reg;
}PDU_REG_MAP;

TNNvar registers;

PDU_REG_MAP server_reg_map[NUMBER_OF_REG]={
{&registers.MainModule.DigitalInput.t_od},
{&registers.MainModule.DigitalInput.t_al}
};

The function for data transfer has a prototype like this:

CPP / C++ / C Code:
signed int CSS_SocketSent(int socket, const unsigned char  *data, unsigned int length);

My problem is that I don't know how to make the pointer for data transferring, and if my idea of communication tables is the correct one. Can somebody help me with this.

Best regards,
BoSCHoW.
Last edited by admin : 20-Feb-2008 at 16:27. Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
 
 

Recent GIDBlogInstall Adobe Flash - Without Administrator Rights by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2D arrays:dynamic allocation and freeing bravetanveer C Programming Language 48 27-Nov-2007 15:55
Verify if a specific data exists in a table Richardknox MySQL / PHP Forum 3 01-Jun-2007 11:16
Transfer longblob from one table to another table Richardknox MySQL / PHP Forum 6 13-Dec-2006 04:26
Cannot create a table in DB WaltP MySQL / PHP Forum 3 26-Apr-2006 16:09
[Tutorial] MySQL Basics nniehoff MySQL / PHP Forum 15 23-Mar-2003 19:42

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 08:50.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.