Convert from C (Language) to Basic

a.llex

Member
Join Date
Oct 2004
Posts
6
Im new in PLCS programming and I received from somebody inside my team a challenge of traduce a PLC program from C (language) to Basic.

What is the best way to do that?
In what situations this can be done?

Thanks since now.
 
I'm sure it could be done.

what platform are you targetting?

I don't know of any programs that do this, but with enough time and effort you could write a program that could do that kind of conversion.
 
New asks...

Well, what platform I am targetting? Well, I dont you it yet.

I just has until now received a code, in C, and I have some questions about the conversion...

Do you have programs done in Basic and C? Like a begginer in PLC, but 16 years of Delphi, VB and Eletric Tec. what I am, can you help me to convert with some question what sure I will have?

Do you know some books pdf or tutorial what can help me in this task?

Thank a lot again.

Part of code what I has received...


void ConvertDataMultiLab(void)
{
int itmp;
float ftmp;
char ctmp[10];
int i;

/* Get BCC of message from MultiLab */
ck = 0;
for (i = 1 ; i < 63 ; ++i)
{
carac = BufferInMtl;
ck = ck ^ carac; /* calcula o BCC */
}
carac = BufferInMtl[63];
ck = carac;
if (ck == carac)
{
/* Convert data from Multilab */
/* Place */
ctmp[0] = BufferInMtl[1];
ctmp[1]='\0';
itmp = atoi(ctmp);

DadosBTR[3] = itmp;

/* Get the field HeatNo */
/* 4 MSB */
memcpy(&ctmp[0],&BufferInMtl[49],4);
ctmp[4]=0;
itmp = atoi (ctmp);
DadosBTR[4] = itmp;

/* 4 LSB */
memcpy(&ctmp[0],&BufferInMtl[53],4);
ctmp[4]=0;
itmp = atoi (ctmp);
DadosBTR[5] = itmp;

/* Obtem o campo temperature; */
memcpy(&ctmp[0],&BufferInMtl[18],4);
ctmp[4]=0;
if (ExisteErroMedicaoMultilab(ctmp))
DadosBTR[6] = 0xFFFF;
else
{
itmp = atoi(ctmp);
DadosBTR[6] = itmp;
}

/* get the field Emf */
memcpy(&ctmp[0],&BufferInMtl[23],6);
ctmp[6]=0;
if (thereismedMultilab(ctmp))
DadosBTR[7] = 0xFFFF;
else
{
ftmp = atof(ctmp);
/* Mantissa */
DadosBTR[7] = (int) ftmp;
/* Decimal */
DadosBTR[8] = (ftmp - DadosBTR[7]) * 1000;
}
 
Re: New asks...

a.llex said:
Well, what platform I am targetting? Well, I dont you it yet.


I meant, What hardware will this code be running on. Is it intended to run on a PC or a PLC? What brand? What I/O hardware will be present? What are the model numbers?

All of this determines how the code works and should work to control the hardware's real-world interfaces.
 
Are you trying to convert a Process Program from C to BASIC, or... are you trying to convert a Programming Interface from C to BASIC?

Converting a Process Program from one language to another is nothing more than converting English to Portuguese (or vice versa). All that is necessary is that you really know both languages... including all of the idioms and nuances. (Easier said than done.)

You might have seen how easy this is in our exchanges with dandrade... we haven't been very successful.

Converting a Programming Interface from one language to another is quite different... Ultimately, the determining factor is the particular CPU that is being targeted.

HOWEVER... with respect to PLC's... there might be another issue... that is, just as any PC has a BIOS, I expect that all PLC's have a BIOS.

BIOS's in PC's are sorta-kinda standardized... however, you can not expect to install a COMPAQ BIOS into a DELL or GATEWAY Computer and expect it to work. Among its other basic duties, the BIOS acts kinda like a gate-keeper. If you don't know what the BIOS expects then you will not get through the gate.

I expect that any PLC BIOS would be very proprietary. That is, I doubt very much that a PLC Manufacturer would publish the inner-workings of their particular BIOS. Without an understanding of how the BIOS has setup the environment it is very unlikely that you can simply create a program that will successfully access the CPU.

The C-Language provides some tools and methods that are simply not available in BASIC. To a large extent, many of the effects produced by C can be developed through BASIC... albeit through much extra effort. In some cases, BASIC simply doesn't provide the access to really low-level (native) operations that are available in C.

I should think, without having access to the inner-workings of the BIOS and a firm understanding of how a particular PLC CPU-board is configured, it would be very difficult to simply drop in a home-made Programming Interface program.

But then... what do I know... all I know is that I've never been able to get a copy of the program for the computer in my truck. Boy, would I love to get my hands on that! I KNOW I can do a better job with a PLC!
 
Already starting...

New asks about convert C to Basic ...

Im trying to convert the driver from c to Basic
Inside my comunication driver between schenk balance and multilab eletro nite

(Allen Bradley Basic Module Series B ... Rockwell)

What are the equivalent instruction from C to Basic?

C Basic

#define TIMEOUT_DIS 0x0001 >> Maybe let TIMEOUT_DIS = 1
unsigned char BufferInMtl[12] >> Maybe dim BufferInMtl (12)
float fTare = 9.5877 >> Maybe ket ftare = 9.5877
unsigned char ck >> Maybe ck = ""
int DadosBTR[64] >> Maybe let DadosBTR(64)
#include <include.h> >> ???????????
clr_rcv1() >> call 96
clr_xmt1() >> call 96
clr_rcv2() >> call 36
clr_xmt2() >> call 36


How do I make to have a instruction like this in my basic driver?


Where can I find a Basic compiler to see how is going my convertion?




Thanks since now
 
Well, I've been thinking a lot about your problem, and I think I've come up with the solution.


Phase 1: Learn C
Phase 2: Learn BASIC
Phase 3: ...
Phase 4: Profit!
 
1: Learn C
2: Learn Basic
3: Make translation
4: if it works go to 5: else goto 1:
5: profit!!!

if you want it in assemmbler let me know!!
 

Similar Topics

I have a Fanuc 16M series controller. (Machine is Machining Center) It is in Japanese language now. But operators wants to at English panel. Can...
Replies
0
Views
1,866
Hello all, I'm currently working on a servo motor linear positioning system (ball screw). I'm all set up regarding communication between my HMI...
Replies
1
Views
104
I have an application using an incremental encoder and then I convert it to degree (0-360) using calculation program. For a while, the calculation...
Replies
8
Views
339
Hi all. Me again still learning Rockwell. So I'll be polling an INT data array from a Modbus SE power meter with a L82 (with a Modbus ProSoft in...
Replies
56
Views
1,436
Hello, could someone kindly convert the attached RSP files that are currently used for SLC 5 PLC into PDF please
Replies
6
Views
548
Back
Top Bottom