RS232和CSpinEdit要如何連接 |
答題得分者是:dotdot
|
kimi
一般會員 發表:37 回覆:76 積分:22 註冊:2003-07-17 發送簡訊給我 |
|
dllee
站務副站長 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
基本上,您的問題 CSpinEdit 的數字 與 RS232 是兩件不相干的事,只是您使用 CSpinEdit 來顯示或輸入資料,而資料透過 RS232 與外部的裝置互傳。
不知道您的電路板上有什麼控制元件?
8051? Z80? PIC?
在您的電路板上要寫對應的 RS232 傳輸程式,與 PC 端的 RS232 傳輸程式互傳資料,而通訊協定您必需先定出來,這樣,兩個程式才能解讀互傳的資料,例如是以文字 ASCII CODE '1' = 0x31 來傳 1 或是以 BINARY CODE 0x01 來傳 1 或是以其他的方式。如此,只要兩個程式可以互傳資料,再來,
對於 PC 端的程式,就是將收到的資料以 CSpinEdit 來顯示,或是 CSpinEdit 有改變時,把它的資料由 RS232 送出;
對於電路板的程式,將 RS232 收到的資料,轉成七段顯示器要顯示的資料送給七段顯示器(此部分大多使用查表法)。 沒空更新的網頁...
http://dllee.ktop.com.tw C及指標教學,計算機概論,資訊管理導論... http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
------
http://www.ViewMove.com |
kimi
一般會員 發表:37 回覆:76 積分:22 註冊:2003-07-17 發送簡訊給我 |
|
dllee
站務副站長 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
引言: 請問大大如果用8051的話,那我的8051和bcb的程式要如何寫,rs232才能傳輸。再來你說的查表法是查ASCII碼嗎?是不是每個數字都要寫入對應的值呢???建議您去看 8051 實作的書,直接翻翻有 8051 接七段顯示器的(附電路圖),看一下它的程式,就會知道我所說的查表是查什麼表(因為這個表與電路圖有關),再來就是再翻翻要有 8051 經 MAX232 或類似的 RS232 介面 IC,與 PC 的連線(附電路圖),看一下它的程式,就可以知道,如何與 PC 端通訊。 您要作的題目,基本上 8051 實作的書應該都有,沒有的只是 PC 端 BCB 的部分,因為它們可能使用 VB 或 VC,但應該都沒差,8051 端先解決了,BCB 端再使用一些現成的 RS232 元件就可以了。在本站就可以找到許多資料。 沒空更新的網頁... http://dllee.ktop.com.tw C及指標教學,計算機概論,資訊管理導論... http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
------
http://www.ViewMove.com |
kimi
一般會員 發表:37 回覆:76 積分:22 註冊:2003-07-17 發送簡訊給我 |
|
dllee
站務副站長 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
|
kimi
一般會員 發表:37 回覆:76 積分:22 註冊:2003-07-17 發送簡訊給我 |
|
dllee
站務副站長 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
CSpinEdit 的數字 與 RS232 是兩件不相干的事,由 ■【BCB】【問題】"CSpinEdit"如何在超過一定範圍,還是顯示原來的數字
http://delphi.ktop.com.tw/topic.php?TOPIC_ID=35181 這篇,討論中,說真的我並不清楚為什麼您有這樣的需求,是有什麼特別的原因嗎?簡單的方法是最好的方法,這是我寫程式的原則之一。除非客戶要特別要求,否則,我一定只用簡單的方法,只要程式不出錯即可。 CSpinEdit 本身在設好最大最小值後,由其上/下按鈕一定可以在輸入範圍內,如果是直接輸入數值,則在輸入完成,游標離開 CSpinEdit 後,它就會自動幫您判斷,如果超過範圍會自動變成最大或最小值。這樣的設計己經很 Smart 很夠用了,誰叫操作者自己要亂輸入數值 <>沒空更新的網頁...
href="http://dllee.adsldns.org">http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
------
http://www.ViewMove.com |
kimi
一般會員 發表:37 回覆:76 積分:22 註冊:2003-07-17 發送簡訊給我 |
|
daniel__lee
高階會員 發表:18 回覆:124 積分:113 註冊:2002-11-10 發送簡訊給我 |
//8051-----------------------------------------------------
//當然在使用前你必須先設定好 8051 的暫存器 書局8051的書一堆 一定找的到
static void com_isr (void) interrupt 4
{
/*------------------------------------------------
Received data interrupt.
------------------------------------------------*/
if (RI != 0)
{
RI = 0; if (((r_in - r_out) & ~(RBUF_SIZE-1)) == 0)
{
rbuf [r_in & (RBUF_SIZE-1)] = SBUF;
r_in ;
}
} /*------------------------------------------------
Transmitted data interrupt.
------------------------------------------------*/
if (TI != 0)
{
TI = 0; if (t_in != t_out)
{
SBUF = tbuf [t_out & (TBUF_SIZE-1)];
t_out ;
ti_restart = 0;
}
else
{
ti_restart = 1;
}
} }
//-------------------------------------------------------------
//BCB RS232 try if [DCB] 參考看看或收尋其他文章有很多人PO過
The DCB structure defines the control setting for a serial communications device. typedef struct _DCB {
DWORD DCBlength;
DWORD BaudRate;
DWORD fBinary: 1;
DWORD fParity: 1;
DWORD fOutxCtsFlow:1;
DWORD fOutxDsrFlow:1;
DWORD fDtrControl:2;
DWORD fDsrSensitivity:1;
DWORD fTXContinueOnXoff:1;
DWORD fOutX: 1;
DWORD fInX: 1;
DWORD fErrorChar: 1;
DWORD fNull: 1;
DWORD fRtsControl:2;
DWORD fAbortOnError:1;
DWORD fDummy2:17;
WORD wReserved;
WORD XonLim;
WORD XoffLim;
BYTE ByteSize;
BYTE Parity;
BYTE StopBits;
char XonChar;
char XoffChar;
char ErrorChar;
char EofChar;
char EvtChar;
WORD wReserved1;
} DCB;
Members
DCBlength
Length, in bytes, of the DCB structure.
BaudRate
Baud rate at which the communications device operates. This member can be an actual baud rate value, or one of the following indexes:
CBR_110
CBR_19200
CBR_300
CBR_38400
CBR_600
CBR_56000
CBR_1200
CBR_57600
CBR_2400
CBR_115200
CBR_4800
CBR_128000
CBR_9600
CBR_256000
CBR_14400 fBinary
Indicates whether binary mode is enabled. Windows does not support nonbinary mode transfers, so this member must be TRUE.
fParity
Indicates whether parity checking is enabled. If this member is TRUE, parity checking is performed and errors are reported.
fOutxCtsFlow
Indicates whether the CTS (clear-to-send) signal is monitored for output flow control. If this member is TRUE and CTS is turned off, output is suspended until CTS is sent again.
fOutxDsrFlow
Indicates whether the DSR (data-set-ready) signal is monitored for output flow control. If this member is TRUE and DSR is turned off, output is suspended until DSR is sent again.
fDtrControl
DTR (data-terminal-ready) flow control. This member can be one of the following values. Value Meaning
DTR_CONTROL_DISABLE Disables the DTR line when the device is opened and leaves it disabled.
DTR_CONTROL_ENABLE Enables the DTR line when the device is opened and leaves it on.
DTR_CONTROL_HANDSHAKE Enables DTR handshaking. If handshaking is enabled, it is an error for the application to adjust the line by using the EscapeCommFunction function. fDsrSensitivity
Indicates whether the communications driver is sensitive to the state of the DSR signal. If this member is TRUE, the driver ignores any bytes received, unless the DSR modem input line is high.
fTXContinueOnXoff
Indicates whether transmission stops when the input buffer is full and the driver has transmitted the XoffChar character. If this member is TRUE, transmission continues after the input buffer has come within XoffLim bytes of being full and the driver has transmitted the XoffChar character to stop receiving bytes. If this member is FALSE, transmission does not continue until the input buffer is within XonLim bytes of being empty and the driver has transmitted the XonChar character to resume reception.
fOutX
Indicates whether XON/XOFF flow control is used during transmission. If this member is TRUE, transmission stops when the XoffChar character is received and starts again when the XonChar character is received.
fInX
Indicates whether XON/XOFF flow control is used during reception. If this member is TRUE, the XoffChar character is sent when the input buffer comes within XoffLim bytes of being full, and the XonChar character is sent when the input buffer comes within XonLim bytes of being empty.
fErrorChar
Indicates whether bytes received with parity errors are replaced with the character specified by the ErrorChar member. If this member is TRUE and the fParity member is TRUE, replacement occurs.
fNull
Indicates whether null bytes are discarded. If this member is TRUE, null bytes are discarded when received.
fRtsControl
RTS (request-to-send) flow control. This member can be one of the following values. Value Meaning
RTS_CONTROL_DISABLE Disables the RTS line when the device is opened and leaves it disabled.
RTS_CONTROL_ENABLE Enables the RTS line when the device is opened and leaves it on.
RTS_CONTROL_HANDSHAKE Enables RTS handshaking. The driver raises the RTS line when the "type-ahead" (input) buffer is less than one-half full and lowers the RTS line when the buffer is more than three-quarters full. If handshaking is enabled, it is an error for the application to adjust the line by using the EscapeCommFunction function.
RTS_CONTROL_TOGGLE Windows NT/2000/XP: Specifies that the RTS line will be high if bytes are available for transmission. After all buffered bytes have been sent, the RTS line will be low. fAbortOnError
Indicates whether read and write operations are terminated if an error occurs. If this member is TRUE, the driver terminates all read and write operations with an error status if an error occurs. The driver will not accept any further communications operations until the application has acknowledged the error by calling the ClearCommError function.
fDummy2
Reserved; do not use.
wReserved
Reserved; must be zero.
XonLim
Minimum number of bytes allowed in the input buffer before flow control is activated to inhibit the sender. Note that the sender may transmit characters after the flow control signal has been activated, so this value should never be zero. This assumes that either XON/XOFF, RTS, or DTR input flow control is specified in fInX, fRtsControl, or fDtrControl.
XoffLim
Maximum number of bytes allowed in the input buffer before flow control is activated to allow transmission by the sender. This assumes that either XON/XOFF, RTS, or DTR input flow control is specified in fInX, fRtsControl, or fDtrControl. The maximum number of bytes allowed is calculated by subtracting this value from the size, in bytes, of the input buffer.
ByteSize
Number of bits in the bytes transmitted and received.
Parity
Parity scheme to be used. This member can be one of the following values. Value Meaning
EVENPARITY Even
MARKPARITY Mark
NOPARITY No parity
ODDPARITY Odd
SPACEPARITY Space StopBits
Number of stop bits to be used. This member can be one of the following values. Value Meaning
ONESTOPBIT 1 stop bit
ONE5STOPBITS 1.5 stop bits
TWOSTOPBITS 2 stop bits XonChar
Value of the XON character for both transmission and reception.
XoffChar
Value of the XOFF character for both transmission and reception.
ErrorChar
Value of the character used to replace bytes received with a parity error.
EofChar
Value of the character used to signal the end of data.
EvtChar
Value of the character used to signal an event.
wReserved1
Reserved; do not use. ~ 勿在浮沙上面築高塔 ~
------
~ 勿在浮沙上面築高塔 ~ |
kimi
一般會員 發表:37 回覆:76 積分:22 註冊:2003-07-17 發送簡訊給我 |
|
dotdot
版主 發表:29 回覆:142 積分:64 註冊:2002-08-09 發送簡訊給我 |
kimi 我想你現在最大的問題要一樣一樣來~
你所要求的已經是從PC上到實驗板透過232的一個完整的收送 以我的做法流程會大概如下提供您參考:
1.我先寫PC的程式透過可自收自送 先簡單送字串驗證PC端的程式收送沒問題
2.開始做實驗板硬體 假使硬體覺得沒問題了
3.開始寫8051的程式 此時先前寫的PC端的程式就成了可以幫助你DEBUG的工具了 至於:第2,3項可以找8051關於RS232實作書上的一個認為完整的範例仔細的先照做(一般都會順便有電路圖)
而第1項在我之前提到有一本書 C Builder與RS-232內有很完整的範例可以用 232的PORT第2,3腳回接的自迴範例~
所以當以上所提的這三個步驟確定都OK了~相信就絕對沒問題了~而不是S/W H/W F/W通通一起來 請問 誰要DEBUG誰?對嗎?提供參考~你可以看看你已經做到哪個步驟了~~讓其他大大才有辦法幫您分析~~
|
daniel__lee
高階會員 發表:18 回覆:124 積分:113 註冊:2002-11-10 發送簡訊給我 |
|
kimi
一般會員 發表:37 回覆:76 積分:22 註冊:2003-07-17 發送簡訊給我 |
|
dotdot
版主 發表:29 回覆:142 積分:64 註冊:2002-08-09 發送簡訊給我 |
|
kimi
一般會員 發表:37 回覆:76 積分:22 註冊:2003-07-17 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |