Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 12th May 2008, 07:46 AM   #1
Default spi to rs232 coverter

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
nikolai_dlsu is offline  
Old 12th May 2008, 09:22 AM   #2
Default

Use a small PIC to read the sensor and send the data out via RS232 as ASCII.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 12th May 2008, 03:53 PM   #3
Default

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.
Pommie is offline  
Old 15th May 2008, 03:35 PM   #4
Default vb6 experts

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!!!
nikolai_dlsu is offline  
Old 15th May 2008, 03:50 PM   #5
Default

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.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/
blueroomelectronics is offline  
Old 15th May 2008, 03:53 PM   #6
Default

Quote:
Originally Posted by Pommie
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.
hi Mike,
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/
ericgibbs is offline  
Old 15th May 2008, 04:11 PM   #7
Default

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
EDIT:
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.
ericgibbs is offline  
Old 16th May 2008, 12:59 AM   #8
Default

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
Salgat is offline  
Old 7th February 2009, 09:05 PM   #9
Default SPI to RS232 convertor

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.
ansarirahim is offline  
Reply

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



All times are GMT. The time now is 12:02 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker