Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
data exchange via rs232
#11
BBQ: This site is called QBasicNews, you know... :roll:
Reply
#12
Dear Plasma
Salaam
Thanks a lot for the big help. I will presently try the code you have sent and try to somehow measure the improvement in the program. In my control systems communication is secondary to the actual control proccess and so I want it to take as short a time as possible.
Reply
#13
Dear BBQ

Quite a long story. In short though.
1- QB is extremely easier to debug which is very important in custom SW meant to use only by one user.
2- Usually the speed is not critical with modern hi MHz motherboards. However less time for comunication means more time to CONTROL
3- AND I am not really a PROGRAMMER (after all I am asking as a newbie). I program my control system because it needs intimate familiarity with the control system design and programmers (at least here) do not seem to like accepting the responsibility of multi thausand dollar loss of productivity a bug can cause and the very limited field testing possibilities (at least not for the kind of money I can offer)
4- My system are almost all one of a kind. No repeats

Would gladly supply more details if you care to email me off list
Reply
#14
Dear Plasma
I have now tried your code but it does not work.
There is a BaudDiv which is not used anywhere and a couple of
BaudNum that is not defined so is ZERO.
If I replace BaudNum s with BaudDiv then it does work but much slower than 9600 baud, may be at 1200 bps rate.
Any sujjestions?
Reply
#15
@Plasma: Even though this is a qb board, it's our duty to inform newbies about using correct s/w for their needs.

@AS: Did you try other modes like 14400, 19200, 38400, 57600?
Reply
#16
Yeah, my bad...it should be BaudDiv instead of BaudNum. I don't have a null modem cable right now so I can't test it out, try switching the open and the ComSpeed:

Code:
DEFINT A-Z
DECLARE SUB ComSpeed (Port, Baud&)

' Set the speed and open the port
OPEN "COM2: ,N,8,1" FOR RANDOM AS #1
ComSpeed 2, 115200

' Now send your data however you normally would, for example:
Rqst.Pkt$ = "440900000000d35e"
PRINT #1, Rqst.Pkt$
SLEEP 1
LINE INPUT #1, Resp.Pkt$

' Close the port when you're done
CLOSE #1

SUB ComSpeed (Port, Baud&)

  ' Based on BaudLatch() sub by Donn Bly
  '
  '  Port = COM Port (1, 2, 3, or 4)
  ' Baud& = Baud setting (9600, 14400, 19200, 38400, 57600, 115200, etc.)

  BaudDiv = 115200 / Baud&
  IF BaudDiv = 0 THEN BaudDiv = 1
  SELECT CASE Port
    CASE 4
      BaseAddr = &H2E8  ' com4
    CASE 3
      BaseAddr = &H3E8  ' com3
    CASE 2
      BaseAddr = &H2F8  ' com2
    CASE ELSE
      BaseAddr = &H3F8  ' com1
  END SELECT

  OldLSR = INP(BaseAddr + 3)
  OUT BaseAddr + 3, OldLSR OR &H80    ' Enable the Divisor Latch
  OUT BaseAddr + 0, BaudDiv MOD &HFF  ' Lo Byte of Baud Rate
  OUT BaseAddr + 1, BaudDiv \ &H100   ' Hi Byte of Baud Rate
  OUT BaseAddr + 3, OldLSR            ' Disable Divisor Latch

END SUB

@BBQ: How do you know what his "needs" are? Maybe he needs to use QB?
Reply
#17
Hey I was just suggesting Big Grin
Reply
#18
THANKS ALL FOR THE REPLIES
the communication via RS232 is working OK (up to 57600 bps NOT at 115200)

But Alas, the Wireless RS232 Cable I purchased proved faulty. It will give me some 3 metres range (instead of at least 50)Manufacturere is supposed to send me a new pair soon.

AND I have managed to land myself in another qb problem, large program to be modolarised. I am asking for help under a new topic.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)