Pages:
1
2 |
The Volatile Chemist
International Hazard
Posts: 1981
Registered: 22-3-2014
Location: 'Stil' in the lab...
Member Is Offline
Mood: Copious
|
|
EDIT:
I found this, it may work:
http://www.ascanis.com/Visitor_Downloads/visitor_downloads.h...
OK.... I've been looking into it... I can't seem to find any problems in my code... I apologise, but unless you have any sugestions, I'm gonna have to
quit. If only I could have got something to communicate....
My code is below. You might recognize something:
Imports System.IO.Ports
Public Class Form1
Dim connectto As String = "COM1"
Dim txtmsg As String = ""
Dim zeroset As Boolean = False
Dim valueset As Double = 0
Dim baseline As Boolean = False
Dim baselineval As Boolean = False
Dim cellplus As Boolean = False
Dim cellminus As Boolean = False
Dim cellc As Boolean = False
Private Sub Update_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Update.Tick
connectto = "COM" & NumericUpDown1.Value.ToString
ToolStripStatusLabel1.Text = connectto
Using comPort = My.Computer.Ports.OpenSerialPort(connectto, 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One)
comPort.Handshake = System.IO.Ports.Handshake.None
comPort.DtrEnable = True
If txtmsg <> "" Then
comPort.Write("DISPLAY " & Chr(34) & txtmsg & Chr(34) & vbCr)
txtmsg = ""
End If
If zeroset Then
comPort.Write("AUTOZERO" & vbCr)
zeroset = False
End If
If valueset <> 0 Then
comPort.Write("AUTOZERO " & valueset.ToString & vbCr)
valueset = 0
End If
If baseline Then
comPort.Write("BASELINE" & vbCr)
baseline = False
End If
If baselineval Then
comPort.Write("SCAN " & TextBox1.Text & " " & TextBox2.Text & " " & TextBox3.Text & vbCr)
baselineval = False
End If
If cellplus Then
comPort.Write("CELL +" & vbCr)
cellplus = False
End If
If cellminus Then
comPort.Write("CELL -" & vbCr)
cellminus = False
End If
If cellc Then
comPort.Write("CELL " & NumericUpDown2.Value.ToString & vbCr)
cellc = False
End If
End Using
End Sub
Private Sub ScreenMessageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
ScreenMessageToolStripMenuItem.Click
txtmsg = InputBox("Please type message to be sent to Spectrophotometer visual screen:", "SpecControl", "Text here")
End Sub
Private Sub ExitSpecControlToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
ExitSpecControlToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub SetZeroValueToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
SetZeroValueToolStripMenuItem.Click
zeroset = True
End Sub
Private Sub SetCorrectValueToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
SetCorrectValueToolStripMenuItem.Click
valueset = Val(InputBox("Please input the correct value of the data read by the spectrophotometer. If value is zero, use 'set zero value'
instead"))
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
baseline = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
baselineval = True
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
cellplus = True
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
cellminus = True
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
cellc = True
End Sub
Private Sub WavelengthToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
WavelengthToolStripMenuItem.Click
End Sub
End Class
[Edited on 4-9-2014 by The Volatile Chemist]
|
|
aga
Forum Drunkard
Posts: 7030
Registered: 25-3-2014
Member Is Offline
|
|
Personally i do not recognise the programming language at all.
Probably some Visual Windows stuff.
These bits may be the Sole reason it fails :-
comPort.Handshake = System.IO.Ports.Handshake.None
comPort.DtrEnable = True
DTR will only work if the DTR pin on the machine's RS232 port is actually connected to the PC - need to ask what cable is being used from the machine
to the PC (what it's wiring is).
the Handshake = None is a clue - the PC and the machine are not shaking hands : that means that they both assume that data will flow just as fast as
they can both accept it.
Seems clear that the machine cannot accept data very fast at all.
E.g. you send it a Calibrate command. It could take 30 seconds to do that, so it's Busy.
If you send it anything else while it's busy and it says 'Comms Error' and stops talking.
Side note: Why are ALL Communication Error messages so short and useless when they refer to some sort of COMMUNICATION error ? You could assume that
they would Communicate better, and SAY EXACTLY what the error is.
There is probably a Handshake like XON/XOFF, in which case the DtrEnable will be better turned Off.
Of course, the machine needs to have it's settings made so that It also uses XON/XOFF as well.
Don't give up.
RS232 is a real PITA. Always has been.
You're almost there !
Remember that you almost surely get free access to the machine forever when it works
[Edited on 10-4-2014 by aga]
|
|
The Volatile Chemist
International Hazard
Posts: 1981
Registered: 22-3-2014
Location: 'Stil' in the lab...
Member Is Offline
Mood: Copious
|
|
Quote: Originally posted by aga | Personally i do not recognise the programming language at all.
Probably some Visual Windows stuff.
These bits may be the Sole reason it fails :-
comPort.Handshake = System.IO.Ports.Handshake.None
comPort.DtrEnable = True
DTR will only work if the DTR pin on the machine's RS232 port is actually connected to the PC - need to ask what cable is being used from the machine
to the PC (what it's wiring is).
the Handshake = None is a clue - the PC and the machine are not shaking hands : that means that they both assume that data will flow just as fast as
they can both accept it.
Seems clear that the machine cannot accept data very fast at all.
E.g. you send it a Calibrate command. It could take 30 seconds to do that, so it's Busy.
If you send it anything else while it's busy and it says 'Comms Error' and stops talking.
Side note: Why are ALL Communication Error messages so short and useless when they refer to some sort of COMMUNICATION error ? You could assume that
they would Communicate better, and SAY EXACTLY what the error is.
There is probably a Handshake like XON/XOFF, in which case the DtrEnable will be better turned Off.
Of course, the machine needs to have it's settings made so that It also uses XON/XOFF as well.
Don't give up.
RS232 is a real PITA. Always has been.
You're almost there !
Remember that you almost surely get free access to the machine forever when it works
[Edited on 10-4-2014 by aga] |
Yea, maybe I'll experiment a little longer. I haven't been able to communicate with him....
Quote: Originally posted by aga | Personally i do not recognise the programming language at all.
Probably some Visual Windows stuff.
[Edited on 10-4-2014 by aga] |
LOL, Visual Basic .NET
If you get on, science hideout, I'd like to try a few of the things he suggested, you up for it?
|
|
ScienceHideout
Hazard to Others
Posts: 391
Registered: 12-3-2011
Location: In the Source
Member Is Offline
Mood: High Spin
|
|
I am certainly
aga is also right, if we can get this working, and you ever need something tested, feel free to send it to me and I will pop it in
P.S. The software that you posted a link to above is the light version, which doesn't connect to a spectrophotometer, but rather just gives simulated
data ... I already tried that.
[Edited on 11-4-2014 by ScienceHideout]
hey, if you are reading this, I can't U2U, but you are always welcome to send me an email!
|
|
The Volatile Chemist
International Hazard
Posts: 1981
Registered: 22-3-2014
Location: 'Stil' in the lab...
Member Is Offline
Mood: Copious
|
|
Quote: Originally posted by ScienceHideout | I am certainly
aga is also right, if we can get this working, and you ever need something tested, feel free to send it to me and I will pop it in
P.S. The software that you posted a link to above is the light version, which doesn't connect to a spectrophotometer, but rather just gives simulated
data ... I already tried that.
[Edited on 11-4-2014 by ScienceHideout] |
Alright, I'll get on it tonight. I wonder which handshake it likes. I'll probably make a few test programs tonight.
|
|
aga
Forum Drunkard
Posts: 7030
Registered: 25-3-2014
Member Is Offline
|
|
You should be asking what the configuration options are on the machine !
Find out what RS232 parameters can be set. Usually there are a lot of options.
Then find out what you can do in Visual Basic .NET (yuk) and there should be some handshaking option that both the machine and VB support.
I know it sucks.
RS232 has always been a bitch, but Once you get it working, it'll work forever.
|
|
aga
Forum Drunkard
Posts: 7030
Registered: 25-3-2014
Member Is Offline
|
|
I just googled, and it seems the VB members are :-
None
RequestToSend
RequestToSendXOnXOff
XOnXOff
so change your code to be :-
comPort.Handshake = System.IO.Ports.Handshake.XOnXOff
comPort.DtrEnable = False
set the machine's RS232 config to be xon/xoff as well.
This should work, seeing as the cable must have at least ground, tx and rx connected correctly.
The cable might not be wired correctly for CTS/RTS/DTR to work as expected.
There are many different cables for RS232, which is how Quantum mechanics got started.
Heisenberg was an RS232 specialist.
A working cable configuration can be calculated to work only as a Probability, not a Certainty.
One such working/not working cable killed his cat, probably.
|
|
aga
Forum Drunkard
Posts: 7030
Registered: 25-3-2014
Member Is Offline
|
|
> LOL, Visual Basic .NET
Lol my ass.
;--------------------------------------------------------------
movwf STATUS
swapf wsave,f
swapf wsave,w
;--------------------------------------------------------------
ptr = (uint8_t *) ip_hdr(skb);
exsh = (struct _excession_hdr *) (ptr + sizeof(struct iphdr));
if(exsh->magic != AP_MAGIC) return 0;
; -------------------------------------------------------------
$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username,'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail))
{ echo("<p>" . $mail->getMessage() . "</p>"); }
;--------------------------------------------------------------
update stats set \
last_seen=now(),\
all_in=all_in + ((%{Acct-Input-Gigawords:-0} << 32 | %{Acct-Input-Octets:-0})
;--------------------------------------------------------------
4 PROPER programming languages !
(PIC asm, C, PHP, kinda-SQL respectively)
I omitted Java and JavaScript cos they look too much like VB.
|
|
The Volatile Chemist
International Hazard
Posts: 1981
Registered: 22-3-2014
Location: 'Stil' in the lab...
Member Is Offline
Mood: Copious
|
|
Quote: Originally posted by aga | > LOL, Visual Basic .NET
Lol my ass.
;--------------------------------------------------------------
movwf STATUS
swapf wsave,f
swapf wsave,w
;--------------------------------------------------------------
ptr = (uint8_t *) ip_hdr(skb);
exsh = (struct _excession_hdr *) (ptr + sizeof(struct iphdr));
if(exsh->magic != AP_MAGIC) return 0;
; -------------------------------------------------------------
$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username,'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail))
{ echo("<p>" . $mail->getMessage() . "</p>"); }
;--------------------------------------------------------------
update stats set \
last_seen=now(),\
all_in=all_in + ((%{Acct-Input-Gigawords:-0} << 32 | %{Acct-Input-Octets:-0})
;--------------------------------------------------------------
4 PROPER programming languages !
(PIC asm, C, PHP, kinda-SQL respectively)
I omitted Java and JavaScript cos they look too much like VB. |
Hey, 1st of all, VB.NET was my first language to learn, so thus I'm fastest at developing in it, so it's obvious that I'd use this for a fast to
develop project like this one. (VB.NET compiles WAY easier than the applicable languages above too) 2nd, I know how to program in C# and C++ (And
respective .NET), and have micro-controller languages on my list after Perl, which I'm learning at the moment I have little need for database languages at the moment.
BUT, back on subject. Another test file:
http://ptp.x10.mx/SCT1.exe
And BTW, I read the specs for the serial spectrophotometer, no mention of handshake, so I doubt he'd know.
[Edited on 4-11-2014 by The Volatile Chemist]
[Edited on 4-11-2014 by The Volatile Chemist]
|
|
aga
Forum Drunkard
Posts: 7030
Registered: 25-3-2014
Member Is Offline
|
|
Learn PHP and SQL.
Most of the web uses those, so you can make money doing it.
Add in website design and you have the same as FaceBook !
|
|
mr.crow
National Hazard
Posts: 884
Registered: 9-9-2009
Location: Canada
Member Is Offline
Mood: 0xFF
|
|
Oh gawd, programing language dick waving. I can't get away from it.
Its OK to use VB.NET or heck even VB6. Do whatever you want I would recommend
Python though because its really easy and has a nice serial port module.
PHP is a shit language. Just because people use it doesn't make it good.
Double, double toil and trouble; Fire burn, and caldron bubble
|
|
The Volatile Chemist
International Hazard
Posts: 1981
Registered: 22-3-2014
Location: 'Stil' in the lab...
Member Is Offline
Mood: Copious
|
|
Gosh!!! If you're gonna talk about programming languages, go to http://scratch.mit.edu
I just brought it up b/c it was relevant. Don't talk about them here, 'kay???
This is about spectrophotometers. Did you try the last one Hideout????
|
|
ScienceHideout
Hazard to Others
Posts: 391
Registered: 12-3-2011
Location: In the Source
Member Is Offline
Mood: High Spin
|
|
Okay, sorry about not posting the past few days, I just got back from a short break at the cottage... and then in 3 days I will be in Germany for a
little over a week... Anyways, I will test this new file as soon as possible. I really appreciate you continuing to try and get this to work, even
with all the road bumps! Until I test it,
Dean
hey, if you are reading this, I can't U2U, but you are always welcome to send me an email!
|
|
The Volatile Chemist
International Hazard
Posts: 1981
Registered: 22-3-2014
Location: 'Stil' in the lab...
Member Is Offline
Mood: Copious
|
|
Quote: Originally posted by ScienceHideout |
Okay, sorry about not posting the past few days, I just got back from a short break at the cottage... and then in 3 days I will be in Germany for a
little over a week... Anyways, I will test this new file as soon as possible. I really appreciate you continuing to try and get this to work, even
with all the road bumps! Until I test it,
Dean |
Thanks, enjoy!
I must come off as rather funny, offering to spend time programming something I can't use, but when I saw your request, I wanted to try to help,
because I haven't had a programming priject in a while. I really hope we can get it to communicate, because I'd like to make the program really nice.
It really is fun for me to do this kind of stuff (almost as much as chemistry!), so I just have to get through the hard stuff.
Enjoy your time in foreign lands
Nathan
|
|
ScienceHideout
Hazard to Others
Posts: 391
Registered: 12-3-2011
Location: In the Source
Member Is Offline
Mood: High Spin
|
|
Hi Nathan, a little while ago I got back from Germany. There, I got to meet my friend Felix, Chaoschemiker from Youtube. I have some good and bad
news:
The bad news: When I got back, I tested the spec programs you made again, each with multiple baud rates and termination things. Nothing worked...
The good news: I decided to order an SRAM card from eBay, a little memory card that plugs into the front of the machine... Very handy, it allows me to
save stuff, and even perform operations like scans. This means that I really don't even need computer software anymore, I can just save it all to the
card.
However, all your hard labor creating the software will not go unrewarded! See the email address in my signature? If ever you are thinking "I wish I
could test this with a UV/Vis," just shoot me an email and I will see what I can do to help you. Either you could mail me the samples you want to
test, or perhaps send me the instructions on how you created them, and I can replicate. Seriously, if there is anything I can help you with that
involves the use of this machine, don't hesitate!
You are officially an honorary "Specspert"
Dean
hey, if you are reading this, I can't U2U, but you are always welcome to send me an email!
|
|
The Volatile Chemist
International Hazard
Posts: 1981
Registered: 22-3-2014
Location: 'Stil' in the lab...
Member Is Offline
Mood: Copious
|
|
Quote: Originally posted by ScienceHideout | Hi Nathan, a little while ago I got back from Germany. There, I got to meet my friend Felix, Chaoschemiker from Youtube. I have some good and bad
news:
The bad news: When I got back, I tested the spec programs you made again, each with multiple baud rates and termination things. Nothing worked...
The good news: I decided to order an SRAM card from eBay, a little memory card that plugs into the front of the machine... Very handy, it allows me to
save stuff, and even perform operations like scans. This means that I really don't even need computer software anymore, I can just save it all to the
card.
However, all your hard labor creating the software will not go unrewarded! See the email address in my signature? If ever you are thinking "I wish I
could test this with a UV/Vis," just shoot me an email and I will see what I can do to help you. Either you could mail me the samples you want to
test, or perhaps send me the instructions on how you created them, and I can replicate. Seriously, if there is anything I can help you with that
involves the use of this machine, don't hesitate!
You are officially an honorary "Specspert"
Dean |
Gee, this is awful nice of you! It was fun trying, and I'm glad you have a solution!
I may sometime ask for a graph of some commonly available chemicals, that'd be great!
Good luck to you and your setup!
Nathan
|
|
ScienceHideout
Hazard to Others
Posts: 391
Registered: 12-3-2011
Location: In the Source
Member Is Offline
Mood: High Spin
|
|
Certainly, whatever you want me to graph, I would be happy to.
hey, if you are reading this, I can't U2U, but you are always welcome to send me an email!
|
|
Pages:
1
2 |
|