Shop OBEX P1 Docs P2 Docs Learn Events
Modem troubles — Parallax Forums

Modem troubles

poguemomhoinpoguemomhoin Posts: 13
edited 2004-09-01 15:00 in BASIC Stamp
Hi all, it's getting late, and I can't figure this out, I'm hoping someone can shed some light on it for me.
I have my stamp 2p connected to a ds1620, and if the temperature goes above a certain value, the fan turns on. When connected to my PC using a VB6 app, I can see the current temperatures, and the limit value for the fan. I can then send a command to the stamp to change the limit value, followed by the new value, and my display on PC is refreshed. No problem yet.
The problem appears when I connect to the stamp by modem. I can connect just fine, and get the temperature information from the stamp as normal. But when I send a new limit value for the fan, a completely different value appears in the stamp (I also have the temperature information displayed on a LCD connected to the stamp).

The vbcode to send the new value is
mscomm1.output=chr$(scrNewTemp.value Mod 256) 'Scroll bar value, from 1 to 50

The stamp uses
serin RX/CTS, Baud, 500, Main, [noparse][[/noparse]inByte]
tempFanOn=inByte

What's the difference with the modem way of connecting?
Please help!

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-30 22:02
    Other than the fact that you need a back-slash between RX and CTS (not a forward slash), it should work. Is inByte getting hammered by something else (i.e., you're using aliases)?· Is your baud constant correct?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • poguemomhoinpoguemomhoin Posts: 13
    edited 2004-08-30 22:48
    I can't find the backslash on this keyboard, but it's not the development PC!
    I don't think I've used aliasing, at least I haven't intentionally.
    Baud rate is fine, because everything else is transferring ok.
    I use the same inByte variable for any byte that is received during communications, which works fine without the modem.
    I have attached the stamp code, a lot of it will be familiar!
  • K de JongK de Jong Posts: 154
    edited 2004-08-30 22:57
    Hi,

    Do you use ASCII or binary format for temperature?

    Not all windows serial routines do exchange binary data !!

    Klaus
  • stamptrolstamptrol Posts: 1,731
    edited 2004-08-30 23:35
    · Hi,

    ·· If your system works when directly connected, but not with the modem, its probably the time taken for handshaking between your VB program and the modem.

    · Your line of stamp code, as written, has to be executed in sync with the VB sending it. If its sitting there either before or after the vb string starts coming through, it will grab the first thing that looks like a byte, regardless of whether that happens to be made up of the overhead surrounding the actual byte you want. ( ie start bit, stop bit, parity bits ).

    · It may be worth your while to use the "WAIT" parameter in the serin command, even if it means adding an extra character from the VB side. For instance, try sending a "{" as a preface to the actual byte. Set the serin to wait until it sees "{" then grab the next byte. Also, defining the·byte with the STR designation has worked better for us coming from VB apps.

    · Regards

    · Tom Sisk·
  • poguemomhoinpoguemomhoin Posts: 13
    edited 2004-08-30 23:50
    Tom,

    Thanks for the suggestion, I'll give it a try tomorrow, I've had enough for one night! (its almost 1am here) The modem at the PC could also be suspect, sometimes it won't respond when expected, a command sometimes need to be sent twice before getting an ok. I plugged in the other modem from the stamp, and it's much better.

    Regards,
    Darren.
  • poguemomhoinpoguemomhoin Posts: 13
    edited 2004-09-01 15:00
    Eureka! Found the problem, as is often the case, some careful reading of the manual (SERIN command) helped.
    I changed the stamp code to

    SERIN RX\CTS, Baud, 500, Main [noparse][[/noparse]DEC inWord]
    tempFanOn=inWord

    and changed the vbcode to

    mscomm1.output= str(scrNewTemp.value) & vbCr 'Scroll bar value, from 1 to 50


    Happy days!!
Sign In or Register to comment.