Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

card reader

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Tue Aug 28, 2018 11:45 am    Post subject: card reader Reply with quote

Hi,

I have the CRT-288D card reader, connected via RS232 to a micro ATMEL1284.

specification of the command structure:

https://drive.google.com/file/d/1ktTtxcWlH32NmUm6QFzDJF_VOMDkblMA/view?usp=sharing

is not clear to me, that is, the command string must be in ASCII?

for example the command to initialize the reader

002 000 002 030 030 003 003

I send it with

print chr (02); chr (00); chr (02); chr (30); chr (30); chr (03); chr (03);

without spaces, CR and LF

quite right?

(BASCOM-AVR version : 2.0.8.1 )
Back to top
View user's profile Visit poster's website
krolikbest

Bascom Member



Joined: 02 Jan 2017
Posts: 69

poland.gif
PostPosted: Tue Aug 28, 2018 1:33 pm    Post subject: Reply with quote

Hello,

I think that you should send an array of bytes, instead of string. Look below:

printbin array_of_bytes(1), N

where you start from 1-st byte and N is cout of bytes. Array might look like:

array_of_bytes(1)=&H02
array_of_bytes(2)=&H00
array_of_bytes(3)=&H00
array_of_bytes(4)=&H30 and so on...
Back to top
View user's profile
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Tue Aug 28, 2018 2:12 pm    Post subject: Reply with quote

two bytes are to be sent in ASCII, The CM, and PM bytes

or am I wrong?
Back to top
View user's profile Visit poster's website
JC

Bascom Member



Joined: 15 Dec 2007
Posts: 489
Location: Cleveland, OH

usa.gif
PostPosted: Tue Aug 28, 2018 4:07 pm    Post subject: Reply with quote

Why not use the Demo Program and either an O'scope or a logic analyzer to actually see what the demo program sends?

JC
Back to top
View user's profile Visit poster's website
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Wed Aug 29, 2018 1:19 pm    Post subject: Reply with quote

then I had the confirmation that the data must be sent in hexadecimal ...

the command is correct, because if I send with REALTERM

0X02 0X00 0X02 0X33 0X30 0X03 0X00

and then

0x05

it works!

I have to do the same thing with BASCOM ...

this is the code I tried but it does not work ...

?

Code:

$regfile = "m1284def.dat"
$crystal = 16000000
$baud = 19200
$hwstack = 40
$swstack = 40
$framesize = 40

Config Com2 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0

Open "COM2:" For Binary As #2                               'open channel

Dim Crtcmd(16) As Byte

enable interrupts

Crtcmd(1) = &H02
Crtcmd(2) = &H00
Crtcmd(3) = &H02
Crtcmd(4) = &H33
Crtcmd(5) = &H30
Crtcmd(6) = &H03
Crtcmd(7) = &H00
Printbin #2 , Crtcmd(1) ; 7

Wait 2

Crtcmd(1) = &H05

Printbin #2 , Crtcmd(1) ; 1

Wait 2

Do
Loop

End
 
Back to top
View user's profile Visit poster's website
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Wed Aug 29, 2018 3:55 pm    Post subject: Reply with quote

I put the driver is not working ...

but maybe I understood what happens:

I tried connecting to the pc ...

send this:

Crtcmd (1) = & H02
Crtcmd (2) = & H00
Crtcmd (3) = & H02
Crtcmd (4) = & H33
Crtcmd (5) = & H30
Crtcmd (6) = & H03
Crtcmd (7) = & H00
Printbin # 2, Crtcmd (1); 7
Wait 2
Crtcmd (1) = & H05
Printbin # 2, Crtcmd (1); 1

and I receive with REALTERM this:

02 00 02 333 030 03 00 05

WHY???
Back to top
View user's profile Visit poster's website
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 113
Location: Graz

austria.gif
PostPosted: Wed Aug 29, 2018 4:16 pm    Post subject: Reply with quote

answered the crosspost here: https://bascomforum.de/index.php?thread/1215-card-reader/&postID=19361#post19361
_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Wed Aug 29, 2018 9:36 pm    Post subject: Reply with quote

not works...
Back to top
View user's profile Visit poster's website
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Wed Aug 29, 2018 9:42 pm    Post subject: Reply with quote

with this code in VB.net and connecting to the PC's RS232 it works!
Back to top
View user's profile Visit poster's website
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Wed Aug 29, 2018 9:45 pm    Post subject: Reply with quote

with this code in VB.net and connecting to the PC's RS232 it works!


I put a rs232 driver in the middle, I checked the rx and tx pins ... nothing works only if I connect it with the PC! the strange thing, and that if I connect the microprocessor to the PC I correctly receive the hexadecimal string with REALTERM!

why???

this is the Bascom code I use:
Back to top
View user's profile Visit poster's website
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Wed Aug 29, 2018 9:46 pm    Post subject: Reply with quote

with code in VB.net and connecting to the PC, it works!

I put a rs232 driver in the middle, I checked the rx and tx pins ... nothing works only if I connect it with the PC! the strange thing, and that if I connect the microprocessor to the PC I correctly receive the hexadecimal string with REALTERM!

why???

this is the Bascom code I use:


Code:
Print #2 , Chr(&H2) ; Chr(&H0) ; Chr(&H2) ; Chr(&H33) ; Chr(&H30) ; Chr(&H3) ; Chr(&H0);
Wait 2
Print #2 , Chr(&H5) ;
Back to top
View user's profile Visit poster's website
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Thu Aug 30, 2018 1:46 pm    Post subject: Reply with quote

then we reset everything.

Point 1.

con questo comando POWERON in vb.net

SerialPort1.Write(Chr(&H2) + Chr(&H0) + Chr(&H2) + Chr(&H33) + Chr(&H30) + Chr(&H3) + Chr(&H0) + Chr(&H5))

and with the card reader, connected directly to the PC via the serial port, it works!

Point 2.

By connecting the reader via an RS232 driver to the ATMEGA1284 and the following code in BASCOM:

Print Chr(&H2) ; Chr(&H0) ; Chr(&H2) ; Chr(&H33) ; Chr(&H30) ; Chr(&H3) ; Chr(&H0); Chr(&H5);

DOES NOT WORK!

Point 3.

By connecting the microprocessor via the RS232 driver to the PC I receive this:
Back to top
View user's profile Visit poster's website
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Fri Aug 31, 2018 9:16 am    Post subject: Reply with quote

it works!
the connector supplied for the rs232 connection had inverted wires !!!
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum