![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
hi! we have an ADIS16350 sensor which has a SPI compatible interface. we want to convert the sensor output to rs232 interface because we will be using rs232 in our own GUI in visual basic 6.0. does anybody know how can this be done? thanks | |
| |
| | #2 |
|
Use a small PIC to read the sensor and send the data out via RS232 as ASCII.
| |
| |
| | #3 |
|
You can also use the PC serial port to bit bang SPI in VB by using the handshake lines. As long as your comfortable with the windows API then have a read of these articles. Mike. | |
| |
| | #4 |
|
Is there anyone here, from the philippines who can help us in the visual basic part of our thesis? We really need help!!! Thanks a lot!!!
| |
| |
| | #5 |
|
You could bit bash the SPI device using your PCs parallel port, if you're using XP you need a special DLL to get access to the port though. Else like the other posts said you'll need something to make the SPI data RS232 compatible. Any small microcontroller could do it. | |
| |
| | #6 | |
| Quote:
I use Visual Basic 5 programs to emulate 'SPI' on the PC's parallel port to work with SPI external devices. The MCP3202/04 12bit ADC works OK, with a couple of LM35 makes a nice and simple dual temperature measurement system. Regards
__________________ Eric " Good enough is Perfect " I will NOT answer PM's requesting technical help, please use the Forum PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/ | ||
| |
| | #7 |
|
hi nikolai_dlsu, Extracted from my program, the working parts of the VB5 SPI code. You should be able to paste the routines into VB6 OK. Code: 'PC parallel port working with MCP3302 SPI device
'
option explicit
Dim CmdStr0, CmdStr1 As String
Dim Ary(24) As Long
'port addresses
Const Po378 = &H378, Pi379 = &H379, P37A = &H37A, P37B = &H37B
'command string for MCP3302 SPI
CmdStr0 = Trim("000000011000000000000000") ' chn0
CmdStr1 = Trim("000000011100000000000000") ' chn1
Const EhDhCh = 7 'cs hi, do hi, clk hi'' ready state
Const ElDhCh = 3 'cs lo, do hi, clk hi
Const ElDhCl = 2 'cs lo, do hi, clk lo
Const ElDlCh = 1 'cs lo, do lo, clk hi
Const ElDlCl = 0 'cs lo, do lo, clk lo
Const Dinp = &H80 '' '0000,0001_1000,0000_0000,0000
'-------------------------------------
Private Sub Form_Load()
Form1.Show
MakePwrAry
CmdStr0 = Trim("000000011000000000000000") ' chn0
CmdStr1 = Trim("000000011100000000000000") ' chn1
End Sub
'---------------------------------
Private Sub ReadSPI()
DoEvents
Out Po378, ElDhCh
'send data bits to ADC msb 1st
For p = 1 To 24
If Mid$(CmdStr0, p, 1) = "1" Then
Out Po378, ElDhCh
Out Po378, ElDhCl '''ClDh
Out Po378, ElDhCh ''ChDh
Else ' lo
Out Po378, ElDlCh
Out Po378, ElDlCl ''ClDl
Out Po378, ElDlCh ''''ChDl
End If
V = Inp(Pi379) And Dinp
If V <> Dinp Then
ADCValue1 = ADCValue1 + Ary(p)
End If
Next p
Out Po378, EhDhCh
End Sub
'-----------------------------
Private Sub MakePwrAry()
'precalculate weighting for array when ADC is read,
Dim p As Long
p = 1
For z = 24 To 13 Step -1
Ary(z) = p
p = p * 2
Next z
For z = 12 To 1 Step -1
Ary(z) = 0
Next z
End Sub
Added a zip file, shows port connections. Place the DLL's in the Windows\System folder.
__________________ Eric " Good enough is Perfect " I will NOT answer PM's requesting technical help, please use the Forum PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 7th July 2008 at 12:25 PM. | |
| |
| | #8 |
|
You're best off simply having a microcontroller receive the data and immediately output the same data using the UART peripheral. This will take advantage of hardware peripherals to remove any need for bit banging, which will make the job simpler.
__________________ www.salgat.net | |
| |
| | #9 |
|
Dear ericgibbs The code giving me error "invalid outside procedure" when i m trying ro run the ur code..as i m very new to VB6.0 and very urgent need the SPI to RS232 convector as i have one 24-bit ADC ADS1240E which has SPI interface. Kindly guide me to communicate this ADC..Advance 100000++ thanks..please prove me solution , i will be very thankful to u or anybody can guide me ..please. | |
| |
|
| Tags |
| coverter, rs232, spi |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| PCMCIA to RS232 for ICD2 clone | clockdoctor | Micro Controllers | 6 | 7th April 2008 11:10 PM |
| SPI Testing with ENC28J60 | mikesmixes777 | Micro Controllers | 9 | 17th January 2008 08:41 AM |
| AVR DDS ~ RS232 problem... | krazatchu | AVR | 15 | 13th December 2007 05:44 AM |
| RS232 Converter | e.chain | Micro Controllers | 0 | 6th October 2007 07:19 PM |
| RS232 buffer | TDY | General Electronics Chat | 3 | 18th March 2005 09:36 PM |