| Author |
Message |
victorf
Joined: 01 Jan 2006
Location: Schenectady, New York
|
|
Posted: 29 April 2006, 19:02 PM Post subject: Signal Inverter revisited |
|
|
Last month I posted a request for help here:
[url]
http://www.zbasic.net/forum/viewtopic.php?t=252
[/url]
The problem was this. I am interfacing to a LCD display and send stuff to it using non-inverted serial. To me this means that data pulses are positive going, rising from 0V to 5V. This works well as I can send strings to be displayed on the screen and they do. This particular display has a keypad interface and I have attached a Grayhill 4 X 4 pad to it. The weird thing is that the key data (pressing 1 should return 49/&H30) is returned as inverted serial. To me this means that data pulses are negative going, dropping from 5V to 0V. Now it is not possible for the ZX-24 to handle this over the com link that is expecting non-inverted serial. I am using com3 to transmit and receive.
After discussing this on the above mentioned thread, I implemented the invert2 solution. I am using the ZX-24 as a signal generator to send a continuous stream of data (non-inverted serial) to the IN terminal of one of the XOR gates. If I don't place a jumper on this gate's input (see diagram), the OUT terminal is inverted and mimics the keypress signal. I then turn this OUT signal around and apply it to another gate's IN terminal hence mimicing a inverted serial signal and DO NOT jumper this gate's input, it's OUT shows an non-inverted signal of about 2V. This explains why the ZX-24 never detects the mock (or real) keypress. Why is this happening? What can I do to get this puppy working?
The truth table for the 74LS86 Quad XOR is:
A B Z
L L L
L H H
H L H
H H L
Jumper ON - NO inversion
Jumper OFF - inversion
Any enlightenment will be appreciated.
Vic
|
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Location: Portland, OR
|
|
Posted: 29 April 2006, 23:34 PM Post subject: |
|
|
| Quote: | | [I'm] using non-inverted serial. To me this means that data pulses are positive going, rising from 0V to 5V. |
The asynchronous serial protocol doesn't really have "data pulses", per se. Rather, there is an "idle" state, and an "active" state. When no data is being transmitted, the line is said to be idle.
When using non-inverted mode, the idle state is a high level, near 5 volts. Data transmission always begins with a "start bit" that is the opposite level of the idle state. The receiver periodically samples the receive line and when it detects a start bit it arranges to sample the receive line again at precise intervals to read each of the data bits, high or low as they may be. The transmission terminates with at least one "stop bit" that is the same level as the idle state.
Inverted mode simply inverts all of the logic levels previously described. The idle state is low level, a start bit is a high level, the data bits are all inverted and the stop bit is low level again.
Which LCD/Keypad interface are you using?
Last edited by dkinzer on 30 April 2006, 0:39 AM; edited 1 time in total |
|
| Back to top |
|
 |
zbasicandy
Joined: 26 Jan 2006
|
|
Posted: 30 April 2006, 0:15 AM Post subject: Seetron 425 |
|
|
| Quote: | | The weird thing is that the key data (pressing 1 should return 49/&H30) is returned as inverted serial | <------ wrong.
If the interface has a non-inverted serial going to the LCD display then the output of the keypad is also the same e.g. non-inverted!
There is no way that a manufacturer would reverse or not keep them the same!
From the manual ... and the demo code for the Basic Stamp they are using special handshaking and timing to get the keypress to read. It will be tricky for you. Good Luck!
|
|
| Back to top |
|
 |
zbasicandy
Joined: 26 Jan 2006
|
|
Posted: 30 April 2006, 2:27 AM Post subject: further thoughts |
|
|
Further thoughts:
Not having a schematic is very hard but ... the section where they have the
RS232 connector J3 they had to invert the serial non inverted TTL using a RS232 converter IC or just an inverter TTL gate for 5 VDC RS232.
The "connector section" where you hooked up for the keypad keystrobe I/O is non-inverted per manual.
To convert this non-inverted keystrobe I/O pin J1 Pin 6 to RS232 you need a RS232 converter IC Note: You need on the other end also RS232.
OR
You could just "leave it alone" and just talk non inverted TTL.
My advice is to convert the keystrobe I/O to RS232 and use the PC terminal program to troubleshoot it first before using a microcontroller.
|
|
| Back to top |
|
 |
zbasicandy
Joined: 26 Jan 2006
|
|
Posted: 30 April 2006, 3:06 AM Post subject: |
|
|
Please dis-reguard!
| Quote: | To convert this non-inverted keystrobe I/O pin J1 Pin 6 to RS232 you need a RS232 converter IC Note: You need on the other end also RS232.
OR
You could just "leave it alone" and just talk non inverted TTL.
My advice is to convert the keystrobe I/O to RS232 and use the PC terminal program to troubleshoot it first before using a microcontroller. |
My neighbor has one of these puppies and he said "to disconnect J1
pins 4 and 5 but keep the power on. Then tie both of them together to do
a loop back test. Hit a key on the keypad and it should show up on the display. Then use the RS232 cable from the display to a PC terminal program to check the operation. Then, here's the tricky part, you have to read the keypad strobe and also the serial data stream to decode the key press. Inspect the Basic Stamp program for further guidance"
|
|
| Back to top |
|
 |
victorf
Joined: 01 Jan 2006
Location: Schenectady, New York
|
|
Posted: 30 April 2006, 13:28 PM Post subject: |
|
|
First, let me say that I am no electronics person, having made my living doing
software for many years. I am sure that I do not speak the electronics language
the way I should as I do not know much. I defer to the members if this forum for
the expertize in electronics.
I want to thank all who have taken the time to respond to my queries. It is much
appreciated that you take the time to help!
Keep in mind that I have only a modest set of test equipment, a logic probe, an
old TEK analog 453 o'scope and a WAVETek multimeter. Thats it!
I am working on a project that is very important to me. I have been stalled for
the better part of a month because of a problem that I cannot solve. I need
help!
I have placed a ZIP file in the Files section that contains the following:
An expressPCB schemetic ZX24.sch, the schematic MUX.sch, the files MAIN.BAS,
COM.BAS and KBD.bas.
This project requires the ZX-24 to talk to one of 3 components via a serial
connection. To that end, I developed the board shown in MUX.sch. The purpose of
this board it to connect the com3 port from the ZX-24 to an attached component.
This is done under software control. Any one of the MUX ports can be connected
to the ZX-24 by passing to the routine SelectMuxPort() in MAIN.BAS the port
number. In the case of my problem this is port LCD (MUX J1) to which is attached
a TRM-425.
The Seetron TRM-425 is a 4 line by 20 character LCD display that has the
capability to store up to 95 full screens of data for display. You can call up
any one to the screens by sending a screen number to the TRM. The TRM has a non-
inverted serial interface on it's J1 port. It also has a RS232 compliant port on
J3. The TRM also supports an interface for a matrix keypad. I have a Grayhill 4
X 4 keypad attached to the J2 port.
Please note that in my OpenCom routine I have defined the COM3 port using the
flag &H08 in accordance with the DefineCom routine discussion in the SysLib
docs. I believe that this sets the Com3 port to non-inverting and 8 data bits.
I can reliably send a screen number to the TRM and display the screen on the
LCD. However, I cannot receive any keypresses from the TRM. I refer you to the
module KBD.BAS to see my code for doing this. The pertinent routine is
GetKeyInput(). I believe that I have implemented the keystobe handling properly
as I get the message "Got data ready strobe". Zero is always returned from the
routine Com3GetByte(data). I have tried adding a little delay in the routine
just in case them TRM is slow to send, but that didn't help. I have done the
experiment of attaching the TRM's RS232 port to a computer running a terminal
program and using the ZX-24 to manipulate the strobe line, I can see the
keppresses appear on the terminal screen. Press 1, see 1, press 2, see 2 etc. so
I know that the strobe handling works and the TRM is responding. However, when I
attempt to do this using the TRM's TTL serial port on J1.5, I get nothing. Since
only one byte is sent for each keypress, I am not able to see the results on my
o'scope. If I set the KeyStrobeTime value to zero and press a key as fast as I
can I can fleetingly see something. The TRM will return 49 ("1") if the 1 key is
pressed. In the call to Com3GetByte, value should be set to 49. NOT! Value is
always 0. Nothing seems to get to the recieve buffer rxq3.
This, then is the crux of my problem. What am I doing wrong? The TRM appears to
work properly but nothing seems to get to rxq3.
As I always say when asking for help:
Any enlightenment will be appreciated.
Vic
| Description: |
| ZX24.sch, MUX.sch, MAIN.BAS, COM.BAS, KBD.BAS |
|
 Download |
| Filename: |
Help.zip |
| Filesize: |
53.26 KB |
| Downloaded: |
712 Time(s) |
|
|
| Back to top |
|
 |
DH* Guest
|
|
Posted: 30 April 2006, 14:26 PM Post subject: |
|
|
| victorf wrote: | | However, I cannot receive any keypresses from the TRM. I refer you to the module KBD.BAS to see my code for doing this. The pertinent routine is GetKeyInput(). I believe that I have implemented the keystobe handling properly as I get the message "Got data ready strobe". Zero is always returned from the routine Com3GetByte(data). I have tried adding a little delay in the routine just in case them TRM is slow to send, but that didn't help. |
Try replacing the Do:Call Com3GetByte:Loop routine with a direct call to GetQueue using the optional timeout version.GetQueue(queue, var, count, timeLimit, timeoutFlag) | victorf wrote: | | I have done the experiment of attaching the TRM's RS232 port to a computer running a terminal program and using the ZX-24 to manipulate the strobe line, I can see the keppresses appear on the terminal screen. Press 1, see 1, press 2, see 2 etc. so I know that the strobe handling works and the TRM is responding. |
I don't think this tests what you assume it tests. As I interpret the TRM manual, the RS232 connection is a 3-wire connection. It assumes it's talking to a buffered RS232 port and sends keypresses automatically. There is no need nor is there any way to send/receive a strobe since there are no handshaking lines.
EDIT:
I guess you can configure it to only send to the PC when you send the strobe. However, the difference is still that the PC serial port has a buffer that will capture the input and signal the PC when there is a byte available.
I do not understand why you chose to multiplex the serial devices. You use 4 pins for that. You have 3 pins free. If you were to use one of the existing LEDs or even the OutPutCapture pin to signal a low battery, you would have enough pins to maintain 4 full-time 9600 bps RS232 connections on channels 3, 4, 5 & 6, eliminating the MUX board.
|
|
| Back to top |
|
 |
victorf
Joined: 01 Jan 2006
Location: Schenectady, New York
|
|
Posted: 30 April 2006, 17:26 PM Post subject: |
|
|
| Quote: |
I don't think this tests what you assume it tests. As I interpret the TRM manual, the RS232 connection is a 3-wire connection. It assumes it's talking to a buffered RS232 port and sends keypresses automatically. There is no need nor is there any way to send/receive a strobe since there are no handshaking lines.
|
I'm not sure I agree with this. I had the system wired like this. Keyboard strobe to the ZX-24 board and the TRM connected to the J3 serial line. Then the software calls GetKeyInput() in order to handle the keystrobe. When the routine drops the strobe line and I press a key on the pad, that key's character appears on the terminal screen on the PC. BTW: the keystrobe time is set to 100 on the TRM so it does NOT send any keypress until it sees the strobe line go low.
| Quote: |
I do not understand why you chose to multiplex the serial devices. You use 4 pins for that. You have 3 pins free. If you were to use one of the existing LEDs or even the OutPutCapture pin to signal a low battery, you would have enough pins to maintain 4 full-time 9600 bps RS232 connections on channels 3, 4, 5 & 6, eliminating the MUX board.
|
Actually, I would have 5 pins free as I would regain the two lines used to address the MUX. I have 3 spares now. pins 13-15 in the current configuration.
I am seriously considering this and I guess the only thing holding me back is the use of memory for the queues. My app only requires a two way comm path for an attached sensor board, a one way transmit only path for the display(not the TRM), a one way receive path for a serially connected PC type keyboard and a one way transmit path for a serial printer for a total 5 pins = 3 additional pins. My only concern is program memory.The app will be quite big and I have a fear of running out of it. The idea was that the TRM helps because I could store the screens in it thus saving 4*95*20 bytes = 7600 bytes. I just may go to a cheaper display and scrap the TRM. I could allocate some memory in the FRAM to hold the screen strings. I am using it to store some system info and will use it for a storage buffer to hold output data in case the user wishes to reprint it.
I am getting the idea that my MUX is never going to do the job I intended it to do. I am going into redesign mode NOW.
To all that took time to respond, THANKS!
Vic
|
|
| Back to top |
|
 |
DH* Guest
|
|
Posted: 30 April 2006, 17:42 PM Post subject: |
|
|
You don't necessarily have to have separate queues. I had 4 secondary serial ports using the BX-24. I just redefined Com3 as needed to assign it to each pair of pins. I could only send/receive with one device at a time but the only device that needed a near full-time connection would poll once per second if it had data so that was not a problem.
While I think having 4 full-time ports operating in the background is one of the biggest advantages of the ZX, it's not always needed.
The change I suggested (calling GetQueue with a timeout) should solve your current problem. Start with a long timeout, reduce it until you start missing keys and then increase it until you can reliably capture each keypress.
|
|
| Back to top |
|
 |
DH* Guest
|
|
Posted: 30 April 2006, 19:30 PM Post subject: |
|
|
I spent a bit more time reading the manual for the TRM-425. The RS232 connection uses ±10V levels so, if you connect it to the ZX you'll need some current limiting resistors in the TX & RX lines.
Given this, I'm again of the opinion that your test with a PC and HyperTerminal proves nothing since it is testing different circuitry on the TRM. It's not testing the TTL level serial output.
It could be that the TRM is not outputting the TTL level serial signal or is outputting at a level below the threshold of the ZX pins.
Also, I wasn't reading your code as carefully as I should. Your routine should get the keypress if the signal is arriving.
|
|
| Back to top |
|
 |
zbasicandy
Joined: 26 Jan 2006
|
|
Posted: 01 May 2006, 0:31 AM Post subject: seetron 425 |
|
|
Victorf
Have you tally up the number of hours you have worked on this module?
From the looks of all the links on this forum it must be a lot!
You have to say to yourself, at some time, what other alternative solution do I have?
Goto www.elabinc.com and buy their keypad serial encoder chip for the outrageous price of $7.00. Part#EDE1144. Then bypass the Seetron- 425 "quality piece of equipment" and get on with your life. If you still can't make it work, I will personally buy the chip and a keypad and will produce the code for you FREE of charge.
I don't do this often, but on quality pieces of equipment I use a sledge hammer
|
|
| Back to top |
|
 |
victorf
Joined: 01 Jan 2006
Location: Schenectady, New York
|
|
Posted: 01 May 2006, 10:35 AM Post subject: |
|
|
| Quote: |
Have you tally up the number of hours you have worked on this module?
From the looks of all the links on this forum it must be a lot!
You have to say to yourself, at some time, what other alternative solution do I have?
|
I have asked this question and because of the responses received from this forum, I am moving on. I have alternate ideas, mostly inspired by all of the responses to my plea.
I don't think I'll take the sledge hammer to the TRM just yet though.
Thanks for the link to EDE.
Again I thank all of you for your advice and help.
Vic
|
|
| Back to top |
|
 |
victorf
Joined: 01 Jan 2006
Location: Schenectady, New York
|
|
Posted: 01 May 2006, 10:39 AM Post subject: |
|
|
dhouston wrote:
| Quote: |
You don't necessarily have to have separate queues. I had 4 secondary serial ports using the BX-24. I just redefined Com3 as needed to assign it to each pair of pins. I could only send/receive with one device at a time but the only device that needed a near full-time connection would poll once per second if it had data so that was not a problem.
|
Since I am only sending/receiving from one device at a time, this works for me. Thanks for sharing I would never have thought of it.
Vic
|
|
| Back to top |
|
 |
DH* Guest
|
|
Posted: 01 May 2006, 14:08 PM Post subject: |
|
|
| victorf wrote: | dhouston wrote: | Quote: | | You don't necessarily have to have separate queues. I had 4 secondary serial ports using the BX-24. I just redefined Com3 as needed to assign it to each pair of pins. I could only send/receive with one device at a time but the only device that needed a near full-time connection would poll once per second if it had data so that was not a problem. |
Since I am only sending/receiving from one device at a time, this works for me. |
Here are two BX-24 procedures that I used. You can modify them as needed. | Code: | '-------------------------------------------------------------------------------
Sub SetCom3(ByVal rxPin As Byte)
Dim bps As Long
Dim dummy As Byte
bps = 9600
Do While StatusQueue(iq3)
Call GetQueue(iq3, dummy, 1) 'flush input queue
Loop
Call CloseCom3
Call DefineCom3(rxPin, rxPin + 1, bx0000_1000)
Call OpenCom(3, bps, iq3, oq3)
Call Delay(0.025)
End Sub
'-------------------------------------------------------------------------------
Public Sub CloseCom3() 'Closes Com3 after the output buffer is flushed.
Const TOIE2 As Byte = bx0100_0000
Const NotTOIE2 As Byte = bx1011_1111
Const Com3Status As Integer = 21
Const TXC3 As Byte = bx0100_0000
' Wait until output queue is empty.
Do While StatusQueue(oq3)
' Null
Loop
' Wait for transmission to complete.
Do While ( (RAMpeek(CuInt(Com3Status)) And TXC3) = TXC3 )
' Null
Loop
' Close port.
Register.TIMSK = Register.TIMSK And NotTOIE2
End Sub
'------------------------------------------------------------------------------- |
I noticed that your schematic indicates use of either the ZX-24 or BX-24. I think both the ZX-24 and BX-24P have clamping diodes on the pins so you can use RS232 voltages as long as you limit the current. I do this frequently with PICs, using 22K in the RX line and 1K in the TX line.
The BX-24 does not have clamping diodes so you need level converters or need to add clamping diodes on the RX line for RS232 voltages.
Also, given the cost of the TRM, you might consider using the ezLCD color touchscreen.
|
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Location: Portland, OR
|
|
Posted: 01 May 2006, 15:22 PM Post subject: |
|
|
I believe that the (untested) code below is the ZX equivalent of the BX-24 code that Dave posted. The BX code exploits an implementation detail (the value at address 21) because there is no other way to achieve the desired effect. However, since the ZX implementation is different, that particular technique won't work. Fortunately, there is a System Library function that provides the necessary functionality.
| Code: | Sub SetCom3(ByVal rxPin As Byte)
Const bps as Long = 9600
Call CloseCom3()
Call DefineCom3(rxPin, rxPin + 1, bx0000_1000)
Call OpenCom(3, bps, iq3, oq3)
End Sub
'-------------------------------------------------------------------------------
Public Sub CloseCom3() 'Closes Com3 after the output buffer is flushed.
' Wait until transmission is complete.
Do While CBool(StatusCom(3) And &H04)
Loop
' Discard all received data.
Call ClearQueue(iq3)
' Close port.
Call CloseCom(3, iq3, oq3)
End Sub |
|
|
| Back to top |
|
 |
|