Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
Signal Inverter revisited
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Forum Index -> Files
Author Message
victorf



Joined: 01 Jan 2006
Posts: 342
Location: Schenectady, New York

Posted: 01 May 2006, 17:55 PM    Post subject: Reply with quote

zbasicandy,

Do you have any experience with the EDE1144 that you would care to share with us Question

Vic
Back to top
zbasicandy



Joined: 26 Jan 2006
Posts: 193

Posted: 01 May 2006, 18:59 PM    Post subject: Keyboard encoder Reply with quote

EDE1144 Looks like a pre-programmed micochip with a sticker on it.
My neighbor uses it in his ham/repeater/junk equipment.
If you look at the specs they are very simple...
All the overhead is taken care by the PIC.

From the manual
SERIAL DATA CONNECTION
To receive keypress data serially from the EDE1144, two options exist. The first (typically used with a host microcontroller having an onboard hardware UART) is to simply connect the XMIT (Pin 1) line to the host microcontroller's serial data input. Each time a key is pressed (or the
autorepeat loop cycles) one byte will be transmitted, corresponding to the values shown in Table One. The host microcontroller's hardware UART's 'Receive Buffer Full' flag can be polled to monitor for newly received serial data; alternately the host microcontroller can be configured to generate an interrupt when a new byte is received by the UART.

RS-232 OUTPUT
The RS-232 Output (Pin 1) transmits serial data to the host microcontroller. This data is sent at either 2400 or 9600 Baud, as selected by Pin 2. Data is send in traditional N-8-1 (no parity, 8data bits, one stop bit) format at TTL/CMOS voltage levels; i.e. 0V to 5V. This serial output
signal can be connected directly to the host microcontroller's serial input pin without any type of voltage level conversion. However, if data is to be sent to a device expecting RS-232 voltage levels of -12V to +12V (such as a PC), a voltage level conversion IC such as the MAX232 will be needed between the EDE1144's serial output pin and the PC's serial input pin.

Hint:
Do not read the data from your queue into a string!

Like I said, "if you can't make this simple serial keypad encoder work then
I will produce the code for you - for FREE"


What is your specific question?
Back to top
victorf



Joined: 01 Jan 2006
Posts: 342
Location: Schenectady, New York

Posted: 02 May 2006, 10:05 AM    Post subject: Reply with quote

zbasicandy wrote:
Quote:

Hint:
Do not read the data from your queue into a string!


Why Question

Vic
Back to top
zbasicandy



Joined: 26 Jan 2006
Posts: 193

Posted: 02 May 2006, 11:27 AM    Post subject: Reply with quote

I was referring to the he link "ZBasic's software UART insight"
Don's
Quote:
I suspected that you might be doing that. You can't pass a reference to a string to the queue retrieval functions. The retrieval functions simply begin writing the retrieved data beginning at the first byte of the address that they receive. They don't know (can't know) that the first two bytes should be skipped because they contain control information for the string. Moreover, they don't know that the length control byte might need to be updated.
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR

Posted: 02 May 2006, 15:35 PM    Post subject: Reply with quote

Quote:
Do not read the data from your queue into a string!

More precisely, do not pass a string variable to the GetQueue() routine. This caveat is explicitly noted in the documentation for GetQueue along with an explanation of how to get characters from a queue into a string.

The next release of the compiler and VM will support a new System Library routine GetQueueStr() that returns a string containing characters extracted from a queue. The new versions are in final test now.
Back to top
zbasicandy



Joined: 26 Jan 2006
Posts: 193

Posted: 02 May 2006, 16:20 PM    Post subject: new string function Reply with quote

Quote:
The next release of the compiler and VM will support a new System Library routine GetQueueStr() that returns a string containing characters extracted from a queue. The new versions are in final test now.


Below is my "workhorse" of all my serial "input" communication routines.
Will your new string function reduce this code?

Code:
'===============================================
public Sub Get_String_40(Byval port as byte, Byref Rx_str as string, Byref Num_char as integer, _
ByRef TimeOuts as single, Byref Success as boolean)
'
'This routine will retreive up to 40 chars from the input buffer.
'(Note in/out buffers are set at 41) (50 - 9 = 41)
'It has an adjustable timeout parameter (TimeOutS in (single) seconds)
' and a Timeout "flag" -> (True = Timeout) and (False is no Timeout)
' Return Success = no timeout!
'====================================
' Revision 1.0b 4/5/06 by Don Kinzer
'====================================

'Number of chars (Num_Char) has to be < = 40 chars!
Dim RxBuf(1 to 40) as Byte
Dim Timeout as boolean

Timeout = Not Success ' make (default) timeout true for sub GetQueue

CALL GetQueue(CByteArray(Inbuf(1, port ).DataAddress), RxBuf,Num_Char,TimeOutS,Timeout)
Rx_str = MakeString(RxBuf.DataAddress, Num_Char)

If (Timeout) then 'GetQueue char "timeout" due to not enough time e.g. TimeOutS
Success = False
Else
Success = True
End if

End Sub
'===============================================
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR

Posted: 02 May 2006, 18:47 PM    Post subject: Reply with quote

Quote:
Will your new string function reduce this code?

In this case, no. The GetQueueStr() function doesn't have the timeout feature that the more general GetQueue() has. It is intended to be used where either you know that the desired number of characters exists in the queue or you just want to retrieve whatever characters happen to be in the queue. For those use cases, you can avoid having to fetch characters into the temporary buffer and then construct a string with them.

The code below is a modified version of your code (untested) that includes protection against overflowing the temporary buffer. It also returns an empty string when a timeout occurs. This may allow you to eliminate the 'Success' parameter since the string length will indicate success/failure.

Code:
Public Sub Get_String_40(ByVal port as byte, ByRef Rx_str as String, Byref Num_char as Integer, _
    ByRef TimeOuts as Single, ByRef Success as Boolean)
  Dim RxBuf(1 to 40) as Byte
  Dim Timeout as Boolean

  ' limit the number of characters to be retrieved
  Num_char = Min(Num_char, SizeOf(RxBuf))

  ' retrieve the requested number of characters, subject to timeout
  CALL GetQueue(CByteArray(Inbuf(1, port).DataAddress), RxBuf, Num_char, TimeOutS, Timeout)

  ' create a string containing the retrieved characters, if any
  If TimeOut Then
    Num_char = 0
  End If
  Rx_str = MakeString(RxBuf.DataAddress, Num_char)

  ' indicate success/failure
  Success = Not TimeOut
End Sub


Last edited by dkinzer on 02 May 2006, 22:30 PM; edited 2 times in total
Back to top
zbasicandy



Joined: 26 Jan 2006
Posts: 193

Posted: 02 May 2006, 19:41 PM    Post subject: Reply with quote

Quote:
The code below is a modified version of your code (untested) that includes protection against overflowing the temporary buffer. It also returns an empty string when a timeout occurs. This may allow you to eliminate the 'Success' parameter since the string length will indicate success/failure.


Point taken on this "patch" for my string return subroutine. Cool

Having both the success and empty string will allow greater flexibility in my comm/response routines.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> Files Time synchro. with the server - Timezone/DST with your computer
Goto page Previous  1, 2
Page 2 of 2

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group