Serial Communication


i need control data logger pc via serial port. have limited programming experience , decided give small basic try automate process. have installed small basic 1.0 , smallbasicserialport, copied smallbasicserialport dll , xml files sub folder named lib. unfortunately not know here, cannot find instructions or settings refer serial communications. don't want spend time trying working , rather move platform if proves big issue. pity find small basic easy work far. appreciate advice this, if use programming platform.

i've been used rs232c communication on dos-basic or decimal basic windows.
year started use smallbasic.
(because simple , interesting.)
 and i'm  remaking programs smallbasic.

i have executed serial communication (rs232c) smallbasic.
goes well.

this written assumption not informed serial communications.

there important points serial communications.
1)first of all,  confirm whether personal computer has 1 or more  serialport(s).
(confirm personal computer of desktop type. )
  there no serialport notebook computer.
  buy usb to  rs232c conversion adapter when there no serialport.
  (maybe costs 30-50 dollars)
  , install software attached.

2)is rs232c cable attached data logger?
  if 'no', buy rs232c cable connects personal computer data logger.
  if 'yes', confirm connector pin number on personal computer side , data logger side.
    if pin number of cable differs of computer or logger , must buy suitable cable.
  again, before buy rs232c cable, confirm connector pin number!
 (there kinds of rs232c cables 9pin-9pin, 8pin-25pin, 9pin-25pin, 14pin-25pin, , 25pin-25pin, etc.)

  moreover, there crossing type , straight type of rs232c cables.
  buy crossing type.

3)before make program, read manual of data logger well.
  confirm followings.
  a)command receive data logger
  b)command sends logger message
  c)command initialize logger.
   etc.
 
4)confirm 'comport number'on computer.
 (start -> control panel -> system -> device manager -> serial port)
 if computer has 1 serialport , comport number '1'.

 refer following program.

 
commport.openport("com1",9600) ' comport number=1  baud rate= 9600
 
comm_enter()

sub comm_enter    
 deli10=text.getcharacter(10) ' line feed
 deli13=text.getcharacter(13) ' carriage return
 deli= deli13+deli10
 
 msg="xxxx"+deli           'xxxx maybe initialize command or other command
 commport.txstring(msg)    'sends message

 msg="yyyy"+deli           'yyyy maybe data receive command
 commport.txstring(msg)
 dat=""
  
   loop:
      dat1=commport.rxchar()     'receives data 1 byte . 1 one.
       if dat1=deli10 then
         goto end1
       endif
      dat=text.append(dat,dat1)  'connects data
   goto loop  
 
   end1:
    dat=math.abs(math.floor(dat)) 'absolute , half-adjusted data
   textwindow.writeline(dat)
   
endsub 

 

 good luck!



Learning  >  Small Basic



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........