![]() ![]() While (GetTickCount() DATA, TMSB -> DATAĬurrTemp = (( float)DATA (( float)DATA* 256. Procedure for reading temperature from specified device. It also checks if the data received by the PC was not corrupted. The function ReadTemperature modifies two variables, CurrTemp and PrevTemp. That is why I have written the base class COneWire and the CDS18B20, an inferior class. The first one is common for all devices (i.e., devices finding, skip ROM command) and the second is suitable only for one 1-Wire device (i.e., temperature conversion). If(DoCrc(( unsigned char)ROM) != 0)Īll 1-Wire devices provided by the Dallas Semiconductor Corp. Result = TMRom(SHandle,( void far *)StateBuffer,( short far *)ROM) Result = TMNext(SHandle,( void far*)StateBuffer) only get the next rom after setup complete check to see if TMSetup has been done once returns number of all devices that were found. Then, it is possible to start a new session. When 1-Wire devices are no longer necessary, the EndSession function should be called. must be called before any non-session functions can be called ![]() Initializing MicroLan for specified iPort, iPortType. Possible adapter types are listed in the OneWire.h header file. The variables iPortNum and iPortType are the number of the COM-port and the port type which depends on the adapter type. If a 1-Wire device is connected to the COM port by the DS9097E adapter, the function ought to provide a handle to the device. Implementation of the COneWire and CDS18B20 classesĪfter loading the library and setting the initial values in the constructor of COneWire, the StartSesion function should be used. In the TMEX SDK documentation, you could find a table where proper DLL files are assigned for different Operating Systems. In the program's directory, "IBFS32.DLL" as well as "IB97E32.DLL" should be placed. In the COneWire class, I load the " IBFS32.DLL" library and get access points to the functions included in the library. These drivers are included in the TMEX SDK libraries. To use 1-Wire devices, Dallas Semiconductor Corp. The header files gl.h, glut.h, and glu.h are supposed to be in c:\Program Files\Microsoft Visual Studio\Vc98\Include\GL. To use the program presented in the article, you should first install the GLUT library. Installation of OpenGL and TMEX SDK components It will create a virtual COM-port which works as a typical serial port. If you do not have any COM-port, you could use a USB to RS232 converter. The DS9097E adapter which was described in the previous paragraph should be connected to the serial port (COM port). Notice 2: If you solder the adapter wrong, it could damage your motherboard. Notice 1: Plug adapter first, then turn on the computer. 3, the ready circuit board with the soldered elements is shown. In the second one, where the ground is connected with the power supply, the sensor works using "parasite power". In the first "normal mode", all the pins are connected (ground, data in/out, and power supply voltage). 2, you can see that the DS18B20 sensor has three pins whereas we have used only two, why? The DS18B20 sensors could work in two modes. Be careful while connecting diodes, because they have polarity " " and "-". ![]() One or more DS18B20 temperature sensors.But, I think that doing something by your own could be a good experience and costless. If you don't feel up to soldering electronic elements, you could buy the DS9097E adapter. For visualization of temperature measurement, I have used the OpenGL library. In the Internet, you can find many programs to communicate with 1-Wire devices, but my implementation of the COneWire class is more effective, and it could be easily adopted for the specific applications. The concept of the article is to describe how to construct own the DS9097E adapter and communicate with it. Although the 1-Wire technology is old, it is still applied in many branches of the industry. The communication is realized between master devices (PC, microcomputer) and slave devices (memory EPROM, temperature sensor, A/D converter, Real Time clock etc.). It was designed for a device communication bus system that provides data transmission using two wires: the first for ground, and the second for power and data. The 1-Wire technology was invented by Dallas Semiconductor Corp. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |