🔒 Locked
Very difficult question...
Advertisement
Original Post
Hello everyone.
I am designing a project for school. The project will require data sent through a telephone line through a Denver Instrument SWE scale. The program will recieve this information. I believe it actually sends the data through a DSL cable. I contacted someone at Denver Instruments, but I wasn''t sure if that was the right place to ask. Does anyone have any clue how I can simply get the weight of whatever is on the scale?
Try this google search. I found some sites with related software. Google is your friend 
[edited by - xaxa on April 4, 2003 4:16:37 PM]
[edited by - xaxa on April 4, 2003 4:16:37 PM]
I contacted the people. Here is their email response. Is there anyone that can help me write a driver for this?
The out put connector is a RS - 232 signal level. uses 300 or 2400 baud rate selectable on front panel, see instruction manual, 8 data bits, NO parity and 1 or 2 stop bits. attached is a drawing showing the connection to a 9 pin PC port.
The balance will send by pressing print button when reading is stable or by sending a ?1 for 1 reading or a ?0 for a continuous output. any questions call or write.
The out put connector is a RS - 232 signal level. uses 300 or 2400 baud rate selectable on front panel, see instruction manual, 8 data bits, NO parity and 1 or 2 stop bits. attached is a drawing showing the connection to a 9 pin PC port.
The balance will send by pressing print button when reading is stable or by sending a ?1 for 1 reading or a ?0 for a continuous output. any questions call or write.
There is no need for a driver here.
It is a simple serial interface. In that case... just plug it into your computer using a standard serial RS232 cable and
interface with it by opening "COM1" or "COM2" files.
A quick test would be to try that in hyperterminal. It comes bundled with windows in accessories->communications->hyperterminal. Start it... and create a new connection and specify COM1 or COM2 as the port. Set the baud rate, data bits, parity, stop bits then connect. Just type ?0 and it should work.
If it doesn't try with COM2 and double check the port settings.
---
When programming your own programm, you may need to use SetCommState to set baud rate after opening com1 or com2. It's a standard WIN32API function. Then just write to the file "?0" and then read from the file for the results. As simple as that.
______________________________
Oooh, you found the horadric cube!
[edited by - Coincoin on April 20, 2003 3:46:16 AM]
It is a simple serial interface. In that case... just plug it into your computer using a standard serial RS232 cable and
interface with it by opening "COM1" or "COM2" files.
A quick test would be to try that in hyperterminal. It comes bundled with windows in accessories->communications->hyperterminal. Start it... and create a new connection and specify COM1 or COM2 as the port. Set the baud rate, data bits, parity, stop bits then connect. Just type ?0 and it should work.
If it doesn't try with COM2 and double check the port settings.
---
When programming your own programm, you may need to use SetCommState to set baud rate after opening com1 or com2. It's a standard WIN32API function. Then just write to the file "?0" and then read from the file for the results. As simple as that.
______________________________
Oooh, you found the horadric cube!
[edited by - Coincoin on April 20, 2003 3:46:16 AM]
It is. It''s the ultimate copy protection. When you download the game for free, you also have to purchase one of these scales. When you mail us the $, we''ll send you a cube that weighs exactly 1.04561832 grams. Unless you have the scale and the cube, you can''t play the game!
I''m totally joking, btw.
I''m totally joking, btw.
It doesnt change anything with the logic.
RJ45 is in fact often used for serial cable. Those RJ45 to RS232 cable are also commonly called console cables. They are widely used on Cisco routers and switches. I guess you can find them in any computer shop... or try cisco.com. Try a place where they can refund in case it''s not the right cable.
The program''s logic stays the same... open the COM1 or COM2 files (that is... files litteraly named COM1 and COM2) and write / read from these. But as I said... test with hyperterminal first.
______________________________
Oooh, you found the horadric cube!
RJ45 is in fact often used for serial cable. Those RJ45 to RS232 cable are also commonly called console cables. They are widely used on Cisco routers and switches. I guess you can find them in any computer shop... or try cisco.com. Try a place where they can refund in case it''s not the right cable.
The program''s logic stays the same... open the COM1 or COM2 files (that is... files litteraly named COM1 and COM2) and write / read from these. But as I said... test with hyperterminal first.
______________________________
Oooh, you found the horadric cube!
sorry to bump this thread. I just finished the cable yesterday. Had lots of problems, but my Hyperterminal test started working today! So, to get a recieve information by programming, I'd do something like:
FILE *fp=fopen("COM1", "r");
SetCommState(300);
fprintf(fp,"?0");
fgets(fp);
Something like that? Sorry. This is all indifferent to me. It's good practice for something I haven't done, but I just don' understand I suppose.
[edited by - Muzlack on June 2, 2003 5:52:22 PM]
FILE *fp=fopen("COM1", "r");
SetCommState(300);
fprintf(fp,"?0");
fgets(fp);
Something like that? Sorry. This is all indifferent to me. It's good practice for something I haven't done, but I just don' understand I suppose.
[edited by - Muzlack on June 2, 2003 5:52:22 PM]
Been reading up on-line. Too bad I need the scale (at school) to test this. Here''s my code.
Does it look right? The project is due on friday.
Does it look right? The project is due on friday.
#include <stdio.h>
#include <stdlib.h>
#include <ddraw.h>
#include <dinput.h>
#include <memory.h>
#include <mmsystem.h>
#include <vector>
#include <string>
using namespace std;
int main() {
string portname="//./COM1";
DCB m_dcb; //get current port settings
BOOL b; //bools for checking
//open our port
HANDLE hComm = CreateFile(portname.c_str(), GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,
0,0);
if(hComm==INVALID_HANDLE_VALUE) { //handle errors.
printf("PROBLEM. #1\n");
return (1);
}
b=GetCommState(hComm,&m_dcb);
if(b==0) {
printf("PROBLEM. #2\n");
CloseHandle(hComm);
return(1);
}
//fill in data.
m_dcb.BaudRate=300;
m_dcb.ByteSize=8;
m_dcb.Parity=NOPARITY;
m_dcb.StopBits=ONESTOPBIT;
m_dcb.fBinary=TRUE;
m_dcb.fDsrSensitivity=FALSE;
m_dcb.fParity=FALSE;
m_dcb.fOutX=false;
m_dcb.fInX=false;
m_dcb.fNull=false;
m_dcb.fAbortOnError=TRUE;
m_dcb.fOutxCtsFlow=FALSE;
m_dcb.fOutxDsrFlow=false;
m_dcb.fDtrControl=DTR_CONTROL_DISABLE;
m_dcb.fDsrSensitivity=false;
m_dcb.fRtsControl=RTS_CONTROL_DISABLE;
b=SetCommState(hComm,&m_dcb);
if(b==0) {
printf("PROBLEM. #3\n");
CloseHandle(hComm);
return(1);
}
printf("Succesfully initialized stuff. I hope.\n");
BYTE rx;
BYTE resp=0;
DWORD dwBytesTransferred=0;
int i=0;
char s[50];
while(1) {
for(int z=0;z<500;z++) {
if(ReadFile(hComm,℞,1,&dwBytesTransferred,0)) {
if(dwBytesTransferred==1) {
resp=rx;
s[i]=rx;
} else {
break;
}
}
}
i=0;
printf("TEXT RECIEVED: %s\n",s);
}
CloseHandle(hComm);
return(0);
}
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement