View previous topic :: View next topic |
Author |
Message |
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Tue Aug 28, 2018 11:45 am Post subject: card reader |
|
|
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
0×02 0×00 0×02 0×30 0×30 0×03 0×03
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 |
|
|
krolikbest
Joined: 02 Jan 2017 Posts: 112
|
Posted: Tue Aug 28, 2018 1:33 pm Post subject: |
|
|
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 |
|
|
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Tue Aug 28, 2018 2:12 pm Post subject: |
|
|
two bytes are to be sent in ASCII, The CM, and PM bytes
or am I wrong? |
|
Back to top |
|
|
JC
Joined: 15 Dec 2007 Posts: 584 Location: Cleveland, OH
|
Posted: Tue Aug 28, 2018 4:07 pm Post subject: |
|
|
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 |
|
|
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Wed Aug 29, 2018 1:19 pm Post subject: |
|
|
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 |
|
|
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Wed Aug 29, 2018 3:55 pm Post subject: |
|
|
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 |
|
|
Netzman
Joined: 25 Nov 2005 Posts: 127 Location: Graz
|
|
Back to top |
|
|
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Wed Aug 29, 2018 9:36 pm Post subject: |
|
|
not works... |
|
Back to top |
|
|
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Wed Aug 29, 2018 9:42 pm Post subject: |
|
|
with this code in VB.net and connecting to the PC's RS232 it works! |
|
Back to top |
|
|
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Wed Aug 29, 2018 9:45 pm Post subject: |
|
|
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 |
|
|
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Wed Aug 29, 2018 9:46 pm Post subject: |
|
|
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 |
|
|
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Thu Aug 30, 2018 1:46 pm Post subject: |
|
|
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 |
|
|
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Fri Aug 31, 2018 9:16 am Post subject: |
|
|
it works!
the connector supplied for the rs232 connection had inverted wires !!! |
|
Back to top |
|
|
|