|
-
Mar 27th, 2000, 05:43 PM
#1
Thread Starter
Junior Member
I'm a geophysicist. The program I am writing will monitor the earths' magnetic field via a G856 proton precession magnetometer and warn us of geomagnetic storms.
The Geometrics G856 (www.geometrics.com) can be made to output readings via RS-232 by a "pulse (pull line low) on
"sync" pin S (or connect pin S to pin D). The data will be sent RS-232 (d = ground, T = transmit (from g-856), G = clear to send,)". This is a quote from the manual.
I have wiring and pin diagrams of the RS-232 interface with the G856. So I need RS-232 pin manipulation controls.
Can this kind of low level comm port manipulation be done in VB5? Maybe certain characters sent to the comm port do this???
Justin.
-
Mar 28th, 2000, 08:46 PM
#2
Addicted Member
Help!
I have a problem. I want to know how i can read in data from a communications port. Thing is, the device attached to the communications port has an RS-232 pin. Can i just read it by doing the following or do i have to change it?
MSCOMM1.SETTINGS = "9600,O,7,2,RS232"
then
MSCOMM1.PORTOPEN = TRUE
or something? PLEASE Help... i need to be able to read in data from this device.... PLEASE HELP!!
-
Mar 28th, 2000, 09:16 PM
#3
Thread Starter
Junior Member
Jason,
You're on the right track. This example from Microsoft:
The following example sets the control's port to communicate at 9600 baud with no parity checking, 8 data bits, and 1 stop bit:
MSComm1.Settings = "9600,N,8,1"
You'll need to find out what parameters your device outputs its data in. Should be in the nuclear weapons manual. Is it a nuclear weapon?
This is Sub Procedure from one of my progs:
Public Sub CommSetup()
' new - could make G856 detection automatic
If DebugMode = True Then
CommPortNumber = 2 ' software debug
MainForm.MSComm1.InputMode = comInputModeText
Else
CommPortNumber = 1 ' G856 control
MainForm.MSComm1.InputMode = comInputModeBinary
End If
' special case for G856 input
MainForm.MSComm1.Settings = "9600,N,7,2"
MainForm.MSComm1.CommPort = CommPortNumber
MainForm.MSComm1.PortOpen = True
' number of chars in G856 input string is 29
' in auto mode I have measured the string as around 19
MainForm.MSComm1.RThreshold = 19
OnError:
'dumInt = MsgBox("RS232 Communications port " & CommPortNumber & " not responding. Check G856 connection, or connect to different port.", vbCritical, "Com Port error")
End Sub
So that's the setup.
After that you'll trap characters/strings with the OnComm event:
Public Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
' Handle each event or error by placing
' code below each case statement
Case comEvReceive ' Received RThreshold # of chars.
DoStuff
End Select
EndSub
Goodluck.
This stuff is pretty easy. you'll get the hang of it quickly.
Anyone up to my original challenge? Now that's hard.
Justin.
-
Mar 28th, 2000, 09:25 PM
#4
Thread Starter
Junior Member
Dunno what happened to my code formatting.
[Edited by Justin Ward on 03-29-2000 at 09:29 AM]
-
Mar 28th, 2000, 09:56 PM
#5
Member
The serial port can not produce a low (0v) on one of its signal pins. The serial uses +12v for HIGH state and -12v for LOW state. These voltages are used because it eliminates transmission errors due to noise or voltage drops accross the serial cable.
-
Mar 29th, 2000, 12:32 AM
#6
Member
I did some thinking, and I came up with a way to convert a serial signal (+12v and -12v) into a active low signal from OPEN to 0 volts. What you need a general purpose NPN transistor. Incase you don't electronic theory I'll explain how this transitor works.
A transistor functions as a electronic switch. It has three pins called Emitter, Base, and Collector. (You should find the pin outs of the transistor) When the transistor is OFF, the collector and emitter is OPEN (no connection). When the transistor is ON then collector and emitter is "shorted". To turn ON the transistor, the Base voltage must be 0.7 volts greater than the Emitter voltage. So lets apply this to your application.
1. Solder the EMITTER pin of the transistor to Pin 5 (Signal Ground)of the serial connector.
2. Solder the BASE pin of the transistor to Pin 4 (DTR) of the serial cable connector.
3. Solder the COLLECTOR to the wire connected to the "sync" pin S.
So when the DTR signal is LOW(-12v), the transistor is OFF, because the base voltage is lower than the Emitter voltage (0v). When the DTR is HIGH(+12v), the transistor ON and will short the "sync" signal to ground (0v). Because the
Base voltage is greater than the (Emitter voltage + 0.7v).
This is the only way to use the serial cable to tigger an active LOW (0 volts) siganl.
Let me know your thoughts.
-
Mar 29th, 2000, 03:11 AM
#7
Hyperactive Member
E-Mail ME ..
Hello Ward ;
If it not too late now , i think i can help you with ur Task , Just Email me The Schematics of the device , or more precisely what signals on which pins do u want to use ... and i ll email u back with a response which i think and hope will Be Adequate ...
E-Mail : [email protected]
-
Mar 29th, 2000, 04:30 AM
#8
Member
Razzaj,
I ask for more info about the device and he gave the following info: (posted from another thread.)
OK - here's the low down from the manual.
We're dealing with RS-232 revision C, and a D9 connector.
The following table lists the functions assigned to each pin of the RS-232 cable from the G-856. Only 3 of 22 standard RS-232C data transmission lines are used in the G-856. The RS-232C interface cable is wired to connect directly to a PC 9-pin serial port.
9-pin RS-232, G-856 Front panel, Function description
2, T, Transmit data from the G856
5, D, Signal ground - zero reference for interface
7, G, Clear to send - When low inhibits G856 output.
Come to think of it this is all irrelevant because I can already accept the output from the device via a MSComm control. There is 1 start bit, 7 data bits, 1 parity bit and 2 stop bits.
The G856 can be set to output data at certain intervals via these lines above. This is fine, I have done this and now need to trigger a reading using the computer.
There is another pin on the front panel of the G856 called the Syncronisation pin (S). I need to connect pin S to pin D in order to trigger a reading. It's low voltage so nothing will get blown up. I can make a cable to connect S to any RS-232 pin I like. Same with G.
So in a nutshell, the problem is:
Can VB be used to switch external devices without using QBasic and relays.
Or alternatively:
Can one serial pin be connected to another using code?
Or alternatively:
Can a serial pin be pulled low using code?
Ideally there would be a function:
Bool SerialPinConnection(Int CommPortID, Int ConnectThisPin, Int 2ThisPin)
The G856 is the older model of the G858.
Justin.
As you can see the serial port as it is, can't produce a Zero volt LOW state. Only 12V HIGH state and -12v LOW state. These voltage states is true for all signals in the serial port. That is why I suggest adding a transistor to the serial cable to switch the "sync" signal to ground. I used the DTR signal as trigger because it is not used by the device.
[Edited by Sacred_knight on 03-29-2000 at 06:25 PM]
-
Mar 29th, 2000, 01:44 PM
#9
Thread Starter
Junior Member
Sacred_knight,
Legend. My electronic skills are good, but I was so focused on finding a code solution, to avoid complex circuitry and Qbasic, that I missed this one. One transister I can deal with. I'll pick one up at lunch time, and by the weekend I should be monitoring magnetic storms.
Well that you chose the DTR line:
This from MS help:
When DTREnable [MSComm property] is set to True, the Data Terminal Ready line is set to high (on) when the port is opened, and low (off) when the port is closed. When DTREnable is set to False, the Data Terminal Ready always remains low.
This seems to be the only MSComm property that can be manipulated for my purpose.
There is the overhead of opening and closing the port each time, but as the program only does simple calculations every 5-30 seconds, and timing of +-1 second is acceptable, this should not be a problem.
Thanks again,
Justin.
-
Mar 29th, 2000, 08:36 PM
#10
Hyperactive Member
MSComm1 don't works in VB5
Dear all,
I used the code of Justin but does not work.
Do I have to set references?
If yes, wich one?
Thanks for reading,
Michelle.
-
Mar 29th, 2000, 08:48 PM
#11
Thread Starter
Junior Member
Michelle,
That code is from one of my apps and the app is working fine. Now that I know how to insert formatted code on this board, I could repost it. But you probably got it nearly - if not entirely right once you transferred it to your compiler and edited it.
Anyway, there are many reasons why this may not work for you. You'll have to supply more info. I'll take a stab in the dark at this stage and suggest that it's the settings.
MSComm1.Settings = "9600,N,7,2" is not common, where as:
MSComm1.Settings = "9600,N,8,1" ie. 8 parity bits and one stop bit is.
Try that for starters.
Oh another idea! Do you know how long the input string is? Mine in this case was 19 chars. If you're not sure best to REM out this line.
MainForm.MSComm1.RThreshold = 19
Justin.
-
Mar 30th, 2000, 12:41 AM
#12
Member
Justin,
Keep me posted on how things work out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|