1746-BAS got some of it to work

controlconcepts

Lifetime Supporting Member
Join Date
Oct 2008
Location
boston
Posts
300
First off I have hesitated to post this question until I got stuck. I have been working on this for 2 days now and finally figured out how to send M0:0 to the port. Also can read ASCII and get it to the M1:0 file. Great!!

I have read every single post on here and other forums as well the manuals (all of them) and cant get the information thati need to proceed.

So what I would like to make this post a BIBLE for the 1746-BAS. as there is great information all over the place that can be put in this post.

I will post my code and all of the future code from the module as well as logic.

Now the question. what I want to do is use a integer to send to the BAS a number 1- 20 1 send XXX-CR and so on.

I cant find out how to get a value from the M file and put it into a pop or a string to then be able to write code to send pre-formatted strings out the serial port. And the reverse for receiving data.

Thanks,
Matt
 
code

WORKING RECEIVE DATA FROM MODULE

165 PUSH 2 : REM PRT2 IS THE SOURCE
170 PUSH 10 : REM RECEIVING 10 BYTES
175 PUSH 13 : REM <CR> IS THE

TERMINATION CHARACTER
180 PUSH 1 : REM select m1 file
185 PUSH 0 : REM offset
190 PUSH 1 : REM STRING NUMBER
195 PUSH 1 : REM BYTE SWAP ENABLED
200 CALL 22 : REM SEND DATA TRANSFER

PARAMETERS
210 POP S : REM STATUS OF CALL SETUP
220 IF (S<>0) PRINT "ERROR IN CALL 22

SETUP"
230 GOTO 230

WORKING M0 TO PORT 2 ******
***** NOTE HAVE M0:0 WORD SET TO 6

1 REM EXAMPLE PROGRAM
10 REM ENABLE CALL 23 INTERRUPTS
20 PUSH 4 : REM SEND DATA TO PRT2
21 REM KKK
30 PUSH 1 : REM GET DATA FROM M0

FILE
40 PUSH 0 : REM WORD OFFSET INTO M0

FILE
50 PUSH 0 : REM STRING NUMBER/NOT

USED
60 PUSH 1 : REM ENABLE BYTE

SWAPPING
70 CALL 23
80 POP S : REM STATUS OF CALL SETUP
90 IF (S<>0) THEN PRINT * LET DATA

UNSUCCESSFUL


NEW TRY TO STRING


1 REM EXAMPLE PROGRAM
10 STRING 106,20
20 PUSH 1 : REM SEND DATA STRING
21 REM KKK
30 PUSH 1 : REM GET DATA FROM M0

FILE
40 PUSH 0 : REM WORD OFFSET INTO M0

FILE
50 PUSH 1 : REM STRING NUMBER/NOT

USED
60 PUSH 1 : REM ENABLE BYTE

SWAPPING
70 CALL 23
80 POP S : REM STATUS OF CALL SETUP
90 IF (S<>0) THEN PRINT * LET DATA

UNSUCCESSFUL
100 PRINT # $(1)
 
This is my next progress. I got a value to trigger a print# out the port.
But It only works if M1 is one any change M1 =4 it still sees the 1 until power cycle or random toggling of the bas output word o but nothing repeatable.

Code

1 REM
2 T=(1+T)
3 IF T>502T=1
4 IF T<500 THEN GOTO 1
80 PUSH 2
90 CALL 56
100 POP S
110 PUSH 100
120 CALL 14
130 POP M1
140 IF M1=1 THEN PRINT #"h6 00 XX",T
150 PRINT M1
160 GOTO 1
 
hello, I'm not sure I understood what you want to do..

This code append the value you wrote in m0 file first word and to a string and send it to PRT2 with <CR> at end:



100 STRING 1200,80

1000 PUSH 10 : CALL 56 : POP X : REM SENDING 10 WORDS FROM M0 FILE TO MODULE INPUT BUFFER WORD 100
1010 PUSH 1 : CALL 37 : REM RESET BUFFER TX/RX PRT2
1020 PUSH 100 : CALL 14 : POP N : REM READ WORD 100 FROM MODULE INPUT BUFFER
1030 PUSH N : REM CALLING NUMBER TO CONVERT IN STRING
1040 PUSH 1 : REM CONVERT NUMBER TO STRING 1
1050 CALL 62 : REM DO THE CONVERSION
1060 $(2)="XXX-"
1070 PUSH 2 : REM STRING NUMBER TO BE APPENDED
1080 PUSH 1 : REM BASE STRING NUMBER
1090 CALL 61 : REM INVOKE STRING APPEND ROUTINE
1100 PRINT #$(1),CHR(13) : REM PRINTING IN PRT2
 
Another possibility is to have an array of ascii values in the M0 file and erad it in the basic. after it's possible to exploit it as string using the ASC function of the basic card like this:

We are using this code to send an 17 characters array using serial port

210 DIM VIN(17)

510 PUSH 45 : CALL 56 : POP X
515 PUSH 1 : CALL 37 : REM RESET BUFFER TX/RX PRT2
520 PUSH 100 : CALL 14 : POP IC1
530 PUSH 101 : CALL 14 : POP PP1
540 PUSH 102 : CALL 14 : POP CMD1
550 PUSH 103 : CALL 14 : POP DEST1
560 FOR N=4 TO 20
570 PUSH N+100 : CALL 14 : POP VIN1(N-3) : NEXT N

2130 ASC($(1),9)=VIN1(1)
2140 ASC($(1),10)=VIN1(2)
2150 ASC($(1),11)=VIN1(3)
2160 ASC($(1),12)=VIN1(4)
2170 ASC($(1),13)=VIN1(5)
2180 ASC($(1),14)=VIN1(6)
2190 ASC($(1),15)=VIN1(7)
2200 ASC($(1),16)=VIN1(8)
2210 ASC($(1),17)=VIN1(9)
2220 ASC($(1),18)=VIN1(10)
2230 ASC($(1),19)=VIN1(11)
2240 ASC($(1),20)=VIN1(12)
2250 ASC($(1),21)=VIN1(13)
2260 ASC($(1),22)=VIN1(14)
2270 ASC($(1),23)=VIN1(15)
2280 ASC($(1),24)=VIN1(16)
2290 ASC($(1),25)=VIN1(17)
 
Yes Jean the second post is what i am trying to do. When I use the call 56 to get the value of M0:0 the data is always the same. Unless I cycle power or re download the basic code and run again. Is there something I am missing in the ladder to reset the buffer out to the bas card? or a way to clear the buffer in the basic code?

And where did you get
515 PUSH 1 : CALL 37 : REM RESET BUFFER TX/RX PRT2
I did not see that in the manual.
Thanks so much for the help,

Matt
 
I'm using a comunication table like this
M0:0 IC
M0:1 TEXT[0]
M0:2 TEXT[1]


M0:63 CIC

in the CLP for each new text to send, I increment IC and CIC

In the basic card i'm testing if IC changed at each loop of my main program
90 REM INIT
100 MODE (PRT2,9600,N,8,1,N,R) : REM SETTINGS PORTA SERIAL 2 (DEPENDING OF YOUR OWN SETTINGS)
110 PUSH 1 : CALL 37 : REM RESET BUFFER TX/RX PRT2
110 STRING 1200,80
120 IC=0 : CIC=0 : LIC=0 : FCYC=1 : REM INDICE COMUNICATION, CONTROL INCICE COMUNICATION, LAST INDICE COMUNICATION, FIRST CYCLE
130 DIM MYTEXT(17)

500 REM MAIN PROGRAM
510 PUSH 64 : CALL 56 : POP X
520 PUSH 1 : CALL 37 : REM RESET BUFFER TX/RX PRT2
530 PUSH 100 : CALL 14 : POP IC
570 FOR N=1 TO 17
580 PUSH N+100 : CALL 14 : POP MYTEXT(N-3) : NEXT N
590 PUSH 163 : CALL 14 : POP CIC
600 IF FCYC=0 THEN GOTO 620 : REM TEST FIRST CYCLE
610 LIC=IC : FCYC=0
620 IF IC=CIC.AND.IC<>LIC THEN GOTO 2000 : REM STRING TREATMENT AND PRINTING
1000 GOTO 500 : REM MAIN PROGRAM LOOP
 
Last edited:
Just s doubt: I'm sorry but I d'ont know what is your kowledge with this module : You know that the basic card loop need to be explicit

INIT PROG (just once)
100
200

500 rem Main prog (loop)
..
600 goto 2000 rem sub routine call
...
1000 goto 500 ( end of main prog - coming back to program beginning)


2000 REM sub routine
..
..
2500 RETURN : REM END OF SUB ROUTINE AND BACK TO MAIN PROGRAM
 
MY GOD AM I RETARDED!! look at rung 20 in the ladder just realized that when I was using the CALL 22 code I forgot to write from my N file to my M file unconditionally. Wow I feel foolish!! Ok got the write part to work now I may need a little help on the read part.

Thanks,
Matt
 
just need to know how to use the CALL 23 and put the data into an internal string. I cant find that in any of the manuls
 
For the read part:

8320 CH=GET# : REM LEITURA PORTA 2
8330 IF CH<>NUL THEN PRINT "CH=",CH


to send to the PLC

5400 PUSH VAL : PUSH 100 : CALL 24 : REM COPYING VAL TO THE OUTPUT BUFFER AT WORD 100
5405 PUSH 64 : CALL 57 : POP X : REM COPYING THE OUTPUT BUFFER WORD 100 TO 163 TO THE M1 FILE
 
IT LOOKS LIKE THE
8320 CH=GET#
only returns hex or decimal values
not the string text I want to use and compare then set a bit high to the M0 file.
 

Similar Topics

Hello, We have an older SLC500 controlled system that is using a BASIC module to communicate to a third party device. Looking into converting the...
Replies
4
Views
1,242
I am trying to program a 1747-M2 EEPROM in a 1746-BAS module. I can download the program and I enter "PROG" and it says successful. I can use the...
Replies
5
Views
1,983
Hi, I am upgrading a AB PLc to Siemens PLC logic and everything is ready for siemens but the problem is the existing PLC is communicating to DCS...
Replies
7
Views
4,693
I'll admit that in all these years I have only encountered M0/M1 files one other time, and it was used to communicate with Eurodrives. In a SLC...
Replies
6
Views
1,687
We are using Sick CLX series bar code reader with AB 1746-BAS module in a outdated system . The processor is SLC 5/04.We want to revamp the system...
Replies
1
Views
1,456
Back
Top Bottom