Reading DS2406 And DS2423 using TMEX and VB6
Reading DS2406 And DS2423 using TMEX and VB6
Hi all,
Im writing a litte class lab for students to program 1 Wire devices from Visual Basic 6. We use TMEX API.
I have some problems with the DS2406. What should I send for setting the switch value? flag = TMAccess(SHandle., ??)
The same code I use for DS2405 does not work on DS2406.
I havn't started on the DS2423 counter yet but I can't find anything (examples or so) on how to acces this device from Visual basic 6.
Any other examples for use with 1 wire devices and Visual Basic 6 and TMEX is very, very, very welcome
Best Regards
Maeron
Im writing a litte class lab for students to program 1 Wire devices from Visual Basic 6. We use TMEX API.
I have some problems with the DS2406. What should I send for setting the switch value? flag = TMAccess(SHandle., ??)
The same code I use for DS2405 does not work on DS2406.
I havn't started on the DS2423 counter yet but I can't find anything (examples or so) on how to acces this device from Visual basic 6.
Any other examples for use with 1 wire devices and Visual Basic 6 and TMEX is very, very, very welcome
Best Regards
Maeron
Reading DS2406 And DS2423 using TMEX and VB6
Did you try the Software Search Engine?
http://www.maxim-ic.com/products/ibutton/example/
DS2406 + ALL + TMEX + VB gives a result...
For DS2423 i can provide Delphi source, so you can translate that.
But first try the above search on that one to.
http://www.maxim-ic.com/products/ibutton/example/
DS2406 + ALL + TMEX + VB gives a result...
For DS2423 i can provide Delphi source, so you can translate that.
But first try the above search on that one to.
Reading DS2406 And DS2423 using TMEX and VB6
Yes I've seen that but that code does not set the switch it just check for it and try to acces its filesystem that generates a error.
Reading DS2406 And DS2423 using TMEX and VB6
In that case:
Forum member mhwlng wrote a 1-wire plugin for Girder:
http://www.promixis.com/forums/showthread.php?t=12458
He knows[:)]
Forum member mhwlng wrote a 1-wire plugin for Girder:
http://www.promixis.com/forums/showthread.php?t=12458
He knows[:)]
Reading DS2406 And DS2423 using TMEX and VB6
Thanx
I will contact him
/M
I will contact him
/M
Reading DS2406 And DS2423 using TMEX and VB6
c++ source code is included in above mentioned plugin...
see switch.cpp
I used code from here as an example :
http://sheepdogsoftware.co.uk
Marcel
see switch.cpp
I used code from here as an example :
http://sheepdogsoftware.co.uk
Marcel
Reading DS2406 And DS2423 using TMEX and VB6
That was fast *smile*
Thanx alot I will check that page ...
And thax again
/Maeron
Thanx alot I will check that page ...
And thax again
/Maeron
Reading DS2406 And DS2423 using TMEX and VB6
mhwlng,
I found what I was looking for in you C++ code, thanx for sharing.
I will try this tonight and see if I can get it to work
/Maeron
I found what I was looking for in you C++ code, thanx for sharing.
I will try this tonight and see if I can get it to work
/Maeron
Reading DS2406 And DS2423 using TMEX and VB6
Hmm I tried to send the following command "flag = TMTouchByte(SHandle, &H1F)" HEX 1F = 31 thay SHOULD set channel a AND B to ON but it does not work
the complete code I tried:
What am I doing wrong?
/Maeron
the complete code I tried:
Code: Select all
'// Write STATUS command
flag = TMTouchByte(SHandle, &H55)
CRCByte = &H55
CRC16 = TMCRC(1, CRCByte, CRC16, 1)
flag = TMTouchByte(SHandle, &H7)
CRCByte = &H7
CRC16 = TMCRC(1, CRCByte, CRC16, 1)
flag = TMTouchByte(SHandle, &H0)
CRCByte = &H0
CRC16 = TMCRC(1, CRCByte, CRC16, 1)
' 31 00011111 A on B on = 001F HEX
' 127 01111111 A off B off = 007F HEX
' 63 00111111 A off B on = 003F HEX
' 95 01011111 A on B off = 005F HEX
'// Skicka koder om Av Och P
flag = TMTouchByte(SHandle, &H1F)
CRCByte = &H1F
CRC16 = TMCRC(1, CRCByte, CRC16, 1)
/Maeron
Reading DS2406 And DS2423 using TMEX and VB6
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">What am I doing wrong?
/Maeron
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Sorry, but at the moment, I don't have time to study the 1-wire specifications again and it's too long ago for me to remember exactly how the 1-wire protocol works, from memory...
is it wired correctly ?
your vb example only shows a subset of the complete tmex code (see onewire.cpp, tmex.cpp)
if you perform a device list( see list.cpp) do you see it ?
I know the C++ code works, because I tested it myself with all supported devices. (I used a 6-PIN TSOC 2406 with a led and resistor going from pin 3 to +5V on a breadboard)
I don't remember, if I needed to set output A to 0 or 1 to make the led light up...
/Maeron
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Sorry, but at the moment, I don't have time to study the 1-wire specifications again and it's too long ago for me to remember exactly how the 1-wire protocol works, from memory...
is it wired correctly ?
your vb example only shows a subset of the complete tmex code (see onewire.cpp, tmex.cpp)
if you perform a device list( see list.cpp) do you see it ?
I know the C++ code works, because I tested it myself with all supported devices. (I used a 6-PIN TSOC 2406 with a led and resistor going from pin 3 to +5V on a breadboard)
I don't remember, if I needed to set output A to 0 or 1 to make the led light up...
Reading DS2406 And DS2423 using TMEX and VB6
And i've never done anything with a DS2406...[:I]
So only thing i could do is help you search for possible mistakes in translating to VB. Send me PM if you think that is helpful.
So only thing i could do is help you search for possible mistakes in translating to VB. Send me PM if you think that is helpful.
Reading DS2406 And DS2423 using TMEX and VB6
The device is found by the program and it shows up correctly.
Here is the complete function:
Here is the complete function:
Code: Select all
Function SetFlipFlop(S As Integer, RoMID As String, Fam As Integer) As Boolean
'// Start session
SHandle = -1
Num = 0
While (SHandle <= 0)
SHandle = TMExtendedStartSession(PortNum, PortType, vbNullString)
Num = Num + 1
If Num > 50 Then Exit Function ' This is just to break the function if we cant communicate with the 1 wire bus
Wend
'Soo now we have handle on the 1 Wire bus
'Now we are going to lookup the DS2406 we wanna change
' We are looking for the RomID
If TMFamilySearchSetup(SHandle, state_buffer(0), &H12) = 1 Then
While TMNext(SHandle, state_buffer(0)) = 1
'// Read the ROM number
ROM(0) = 0
flag = TMRom(SHandle, state_buffer(0), ROM(0))
'// Check for the correct type
If ((Fam And &H7F) = (ROM(0) And &H7F)) Then
'// Create a string out of the ROM number
romstr = ""
For i = 7 To 0 Step -1
If (ROM(i) <= &HF) Then romstr = romstr + "0"
romstr = romstr + Hex$(ROM(i))
Next i
If romstr = RoMID Then
'// Write STATUS command
flag = TMTouchByte(SHandle, &H55)
CRCByte = &H55
CRC16 = TMCRC(1, CRCByte, CRC16, 1)
flag = TMTouchByte(SHandle, &H7)
CRCByte = &H7
CRC16 = TMCRC(1, CRCByte, CRC16, 1)
flag = TMTouchByte(SHandle, &H0)
CRCByte = &H0
CRC16 = TMCRC(1, CRCByte, CRC16, 1)
' 31 00011111 A on B on = 001F HEX
' 127 01111111 A off B off = 007F HEX
' 63 00111111 A off B on = 003F HEX
' 95 01011111 A on B off = 005F HEX
'// Send the HARDCODED 00011111 to the Switch
flag = TMTouchByte(SHandle, &H1F)
CRCByte = &H1F
CRC16 = TMCRC(1, CRCByte, CRC16, 1)
End If
End If
Wend
Reading DS2406 And DS2423 using TMEX and VB6
I just tested the plugin in girder with a 6-PIN TSOC 2406 with a led and resistor going from pin 3 to +5V on a breadboard)
and I can confirm :
127 -> led off
31 -> led on
note that you need to apply 5V!
it doesn't work on parasitic power...
(on parasitic power, it still shows up in the device list, though)
Marcel
and I can confirm :
127 -> led off
31 -> led on
note that you need to apply 5V!
it doesn't work on parasitic power...
(on parasitic power, it still shows up in the device list, though)
Marcel
Reading DS2406 And DS2423 using TMEX and VB6
Doesn't it work if powered with the DS94940R (The USB)?
What I understood IT could power the 1 wire network.
/Maeron
What I understood IT could power the 1 wire network.
/Maeron
Reading DS2406 And DS2423 using TMEX and VB6
only simple devices like DS18S20 temperature sensor work on parasitic power.
other devices can be detected on parasitic power, but the rest of the functionality requires 5V to work reliably...
other devices can be detected on parasitic power, but the rest of the functionality requires 5V to work reliably...