線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2909
推到 Plurk!
推到 Facebook!

RS232和CSpinEdit要如何連接

答題得分者是:dotdot
kimi
一般會員


發表:37
回覆:76
積分:22
註冊:2003-07-17

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-08-03 13:28:12 IP:61.227.xxx.xxx 未訂閱
如何將CSpinEdit的數字透過RS232傳到電路板上的七段顯示器上,而七段顯示器上的數字也能回傳給CSpinEdit,作為雙向的傳輸方式。 拜託大大教教我
dllee
站務副站長


發表:321
回覆:2519
積分:1711
註冊:2002-04-15

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-08-03 19:30:57 IP:61.224.xxx.xxx 未訂閱
基本上,您的問題 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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-08-03 20:00:45 IP:61.227.xxx.xxx 未訂閱
請問大大如果用8051的話,那我的8051和bcb的程式要如何寫,rs232才能傳輸。再來你說的查表法是查ASCII碼嗎?是不是每個數字都要寫入對應的值呢???
dllee
站務副站長


發表:321
回覆:2519
積分:1711
註冊:2002-04-15

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-08-03 21:24:13 IP:61.224.xxx.xxx 未訂閱
引言: 請問大大如果用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

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-08-04 00:17:08 IP:61.13.xxx.xxx 未訂閱
請dllee大大,幫我推薦相關的書,和一些資料,拜託大大的幫忙
dllee
站務副站長


發表:321
回覆:2519
積分:1711
註冊:2002-04-15

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-08-04 18:24:38 IP:61.224.xxx.xxx 未訂閱
我說過,我書讀得少  還是請您到大書局去找,您要的基本上在您找到的書中都會有附上電路圖的那本就是您所需要的了。 >沒空更新的網頁... href="http://dllee.adsldns.org">http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell.... 發表人 - dllee 於 2003/08/04 18:36:58
------
http://www.ViewMove.com
kimi
一般會員


發表:37
回覆:76
積分:22
註冊:2003-07-17

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-08-04 21:00:39 IP:61.227.xxx.xxx 未訂閱
8051 接七段顯示器,8051 接 MAX232 或類似的 IC 再接到 RS232 的接頭 這些我都有資料可以看了,但是CSpinEdit 的數字問題,是我現在所遇到最大的困難所在 因為CSpinEdit 的程式設定,我一直想不出要如何寫,請大大幫幫我吧!!
dllee
站務副站長


發表:321
回覆:2519
積分:1711
註冊:2002-04-15

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-08-05 22:04:28 IP:61.224.xxx.xxx 未訂閱
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

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-08-05 23:34:47 IP:61.227.xxx.xxx 未訂閱
dllee大大,我現在最要緊的是CSpinEdit如何透過RS232傳送到8051,這是我現在最大的問題所在,希望大大幫幫我吧!!
daniel__lee
高階會員


發表:18
回覆:124
積分:113
註冊:2002-11-10

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-08-06 21:56:26 IP:218.166.xxx.xxx 未訂閱
//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

發送簡訊給我
#11 引用回覆 回覆 發表時間:2003-08-07 22:41:11 IP:61.227.xxx.xxx 未訂閱
請問daniel__lee大大,static void com_isr (void) interrupt 4,是寫在8051還是bcb的程式啊!!
dotdot
版主


發表:29
回覆:142
積分:64
註冊:2002-08-09

發送簡訊給我
#12 引用回覆 回覆 發表時間:2003-08-08 00:01:33 IP:61.70.xxx.xxx 未訂閱
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

發送簡訊給我
#13 引用回覆 回覆 發表時間:2003-08-08 00:19:56 IP:218.167.xxx.xxx 未訂閱
To Kimi static void com_isr (void) interrupt 4 是寫在8051上的,但是並不是這樣就好了,有些前置作業我省掉了沒寫,因為我並不知道你要如何去規劃你的8051,你需要的是補充8051的資訊及了解它的暫存器設定才能寫出8051端的傳送與接收,至於BCB端的處理在這裡的資料非常齊全你可以找到很多方法 真的還是建議你去買本8051吧!! ~ 勿在浮沙上面築高塔 ~
------
~ 勿在浮沙上面築高塔 ~
kimi
一般會員


發表:37
回覆:76
積分:22
註冊:2003-07-17

發送簡訊給我
#14 引用回覆 回覆 發表時間:2003-08-08 08:25:05 IP:61.227.xxx.xxx 未訂閱
dotdot大大PC端的程式收送大致沒問題,再來就是第2點和第3點,而第3點是我最大的問題所在。
dotdot
版主


發表:29
回覆:142
積分:64
註冊:2002-08-09

發送簡訊給我
#15 引用回覆 回覆 發表時間:2003-08-08 10:18:13 IP:211.22.xxx.xxx 未訂閱
給你這兩個連結參考看看 http://www.fwdev.com/vbrs232.htm http://www.fwdev.com/sch/RS232-2051.gif 第1個連結雖然PC端為VB但是主要是可以看他的8051如何寫 第2個連結RS232-2051.gif電路圖的CPU為2051硬體上只是少了些IO基本接法都一樣給你當參考交叉比對檢查看看硬體上是否有問題 ^^加油~
kimi
一般會員


發表:37
回覆:76
積分:22
註冊:2003-07-17

發送簡訊給我
#16 引用回覆 回覆 發表時間:2003-08-08 23:29:00 IP:61.227.xxx.xxx 未訂閱
謝謝dotdot大大的回答,我會好好努力的。希望大大能再提供我多一點的資料 發表人 - kimi 於 2003/08/08 23:31:32
系統時間:2024-04-20 4:28:50
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!