TEMPer usb sensor

Thread Starter

lorenzop

Joined Jul 2, 2009
12
I have one of these http://pcsensor.com/index.php?_a=viewProd&productId=15 I'm writing a program in visual basic 6 to control my hydroponic greenhouse. it will be released as open source when it's done, on growcontrol.net . my problem is, the drivers that come on the cd are for .net, I refuse to use .net for software I write. I've found source code to interact with the usb device in c, but that's a language I'm very bad at. the device just creates a virtual serial port for software to connect to.

my question, does anyone know of any source code or an api or something that I could use to get my software working with this device?

I've talked to a sales rep at pcsensors.com and he said to wait a few months, they are working on a dll for the device with support for vb6. 2 days ago I got an email from the guy saying he was leaving the company. I haven't heard back from the company yet, but I don't know if the dll is still being worked on. anyone else mess with one?
 

n9352527

Joined Oct 14, 2005
1,198
If it does create a serial port (confirm this by looking at the Device Manager), then you can use VB to connect to the device through the serial port. As long as you have the specifications for the data protocol used by the device.
 

Thread Starter

lorenzop

Joined Jul 2, 2009
12
If it does create a serial port (confirm this by looking at the Device Manager), then you can use VB to connect to the device through the serial port. As long as you have the specifications for the data protocol used by the device.
yeah, it creates the virtual serial port and I can connect to it, but I don't know the protocol specs for it. a few people have reverse engineered it in c. I've tried manually converting the c code to vb6 a few times, but never any success.
 

n9352527

Joined Oct 14, 2005
1,198
Just follow the C code. There should be data sent for initialisation, reading a value, and other tasks. Then replicate those data exchanges, not the entire C code.

Or ask the vendor for the protocol.
 

Thread Starter

lorenzop

Joined Jul 2, 2009
12
Just follow the C code. There should be data sent for initialisation, reading a value, and other tasks. Then replicate those data exchanges, not the entire C code.

Or ask the vendor for the protocol.

I tried to twice, but the c code I found at the time was confusing. it did some weird rx tx commands or something. I just found nother one, it looks easier to understand. how hard would it be to convert this to vb6 and get it working? http://pc8-termo.fis.ucm.es/~josechu/mitemper.zip

or just as good, does anyone know how to fix this code to be able to use it as a visual basic 6 reference? it compiles
for me but gives an error when I try to add the dll to vb6. Can't add a reference to the specified file.
 
Last edited:

n9352527

Joined Oct 14, 2005
1,198
You need to tackle this in small steps. For example, to establish a communication link with the device, the settings can be extracted from function SetupCommPort in MITEMPer.c, which are:

9600bps, 8 bits, no parity bit and one stop bit with DTR and RTS enabled.

Now, moving on to how to initialise the device, the function is init in functions.c. The sequence is:

- Calling the Start_IIC function, which in turn calls the SetDataLine and SetClockLine passing 1 as parameters for both, and then calling those two fuctions again with 0 as paremeters.
- SetDataLine function sets the RTS line if the passed parameter is 1 or clears the RTS if the passed parameter is 0.
- Similarly, the SetClockLine function sets the DTR line if the passed parameter is 1 or clears the DTR line if the passed parameter is 0.

Now, we can conclude that to initiliase the device, we first have to set the RTS, set the DTR, then clear RTS and clear DTR.

- Next, there are 3 groups of 8 bits (one byte) that need to be transferred. Which are, first group 10011110, second group 00000001, third group 01100000.
- Then stop the IIC (look in the respective function on what have to be done here).
- Start the IIC again.
- Transfer another 3 groups of 8 bits.
- Stop the IIC.

The sequence of transferring the group can be obtained from the function Transmit in functions.c:

- The transmission is done through the DTR and RTS line only. Not through the usual TX data line.
- If the data is 1 set the RTS or if the data is 0 clear the RTS.
- Then the tick (clock), set the DTR followed by clearing the DTR.
- Loop to the next data bit for 8 times.
- After 8 bits, set the RTS line and set the DTR line.
- Then read the CTS line for acknowledgement (inverted).
- Closed by clearing the DTR.

Similarly, you can follow those C code and extracted the necessary sequences and data that you need to talk to the device and obtained a reading.
 

Thread Starter

lorenzop

Joined Jul 2, 2009
12
You need to tackle this in small steps. For example, to establish a communication link with the device, the settings can be extracted from function SetupCommPort in MITEMPer.c, which are:

9600bps, 8 bits, no parity bit and one stop bit with DTR and RTS enabled.

Now, moving on to how to initialise the device, the function is init in functions.c. The sequence is:

- Calling the Start_IIC function, which in turn calls the SetDataLine and SetClockLine passing 1 as parameters for both, and then calling those two fuctions again with 0 as paremeters.
- SetDataLine function sets the RTS line if the passed parameter is 1 or clears the RTS if the passed parameter is 0.
- Similarly, the SetClockLine function sets the DTR line if the passed parameter is 1 or clears the DTR line if the passed parameter is 0.

Now, we can conclude that to initiliase the device, we first have to set the RTS, set the DTR, then clear RTS and clear DTR.

- Next, there are 3 groups of 8 bits (one byte) that need to be transferred. Which are, first group 10011110, second group 00000001, third group 01100000.
- Then stop the IIC (look in the respective function on what have to be done here).
- Start the IIC again.
- Transfer another 3 groups of 8 bits.
- Stop the IIC.

The sequence of transferring the group can be obtained from the function Transmit in functions.c:

- The transmission is done through the DTR and RTS line only. Not through the usual TX data line.
- If the data is 1 set the RTS or if the data is 0 clear the RTS.
- Then the tick (clock), set the DTR followed by clearing the DTR.
- Loop to the next data bit for 8 times.
- After 8 bits, set the RTS line and set the DTR line.
- Then read the CTS line for acknowledgement (inverted).
- Closed by clearing the DTR.

Similarly, you can follow those C code and extracted the necessary sequences and data that you need to talk to the device and obtained a reading.

thank you so much! I've done plenty of reading, but the way you explained it made it all much clearer. 20 minutes to write another test program and I have it working already. sweet. just ordered a bunch more for my project.
 

marcus0815

Joined Aug 24, 2009
6
Hi,
i saw that you are finish to generate the code for vb6 to get values from the temper device.
I´m not so good in programming, so i want to ask you to send me a hole project with all files in vb6.
I Have the device and i have no chance to implemet the dll into my code...
PLease send me a demo...

Thanks a lot
Marcus
 

Thread Starter

lorenzop

Joined Jul 2, 2009
12
I just finished writing a function to scan the com ports to look for new devices. I have a few features to manipulate the values, but it's still missing calibration. (let me know if anyone has an accurate formula for that) I just posted the class source on my blog http://blog.mattsoft.net/
 

marcus0815

Joined Aug 24, 2009
6
Hi,

thanks for your software math...

But now i ordered new temper devices and there is a new version delivered.
It is a usb device not longer a com port...

Has someone an update for this new devices?

Thanks... Marcus
 

Thread Starter

lorenzop

Joined Jul 2, 2009
12
But now i ordered new temper devices and there is a new version delivered.
It is a usb device not longer a com port...

Has someone an update for this new devices?

Thanks... Marcus

crap.. first I've heard of this. that really sucks. now, not only is there a new version of the protocol, but it's not even accessed in the same way. does it look the same, or is there any way to tell it's a new version just by looking at it, not plugging it in? what was that company that makes them, I don't remember.
 

Thread Starter

lorenzop

Joined Jul 2, 2009
12
according to the makers of the device, the new version is called HID TEMPer. it loads as a human interface device. something about.. you turn off your num-lock and caps-lock then use the scroll lock button to set the sample rate for the device. I hope the manual explains it all. it also does logging now without being plugged into the computer, from what I understand. they said the new version of the dll that comes on the cd DOES support vb6. I haven't confirmed any of this information yet, as I don't have any of the new version. anyone who has one, please let me know if it works. mine will be on order soon.
 

marcus0815

Joined Aug 24, 2009
6
.. you are right, the new devices are HID Devices. They are running without installing a driver.
If someone can make a vb6 code for that device, please contact me...

Thanks, Marcus
 

Thread Starter

lorenzop

Joined Jul 2, 2009
12
.. you are right, the new devices are HID Devices. They are running without installing a driver.
If someone can make a vb6 code for that device, please contact me...

Thanks, Marcus
I need more information on how it works. does it just act as a virtual keyboard or how? have you tried the dll? they said it works with vb6
 

marcus0815

Joined Aug 24, 2009
6
when i connect the device to the usb port, automaticaly a new usb device is installed (without a driver).
The old devices generate a com port device in com ports the new devices dont do that, there is no additional com port. They generate a usb-verbundgerät.
on the cd delivered with the device is no *.dll available.
with a hidtest.exe i can connect with the device... it use the hid api functions...

Marcus
 

Thread Starter

lorenzop

Joined Jul 2, 2009
12
when i connect the device to the usb port, automaticaly a new usb device is installed (without a driver).
The old devices generate a com port device in com ports the new devices dont do that, there is no additional com port. They generate a usb-verbundgerät.
on the cd delivered with the device is no *.dll available.
with a hidtest.exe i can connect with the device... it use the hid api functions...
Marcus
that sounds like what I've been reading about it. there's plenty of information about it on google. this shouldn't be to hard to do. I'll write some code once I have one to work with, but that wont be for a couple weeks. unless someone wants to mail me a free one ;-) the older ones did have issues sometimes on xp with the drivers. this should turn out to be a nice new update they made. no drivers needed for anything as old as windows 98 up to windows 7. I didn't notice another problem until just the other day, vista doesn't support mscomm32.ocx so I had to rewrite more code to use api's anyway.

please post if anyone has working code
 
Last edited:
Top