Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Serial port with Max186
#1
I am using a 8-channel AD-convertor / interface, directly connected to the serial port. Sensitivity is 0 to 8 volts, and it is 12-bits (2mV=1 bit). It is very simple to build. The small program shows reading from one channel, it is possible to use 8 channels! ( http://www.libertybasic.0catch.com/ )
So far I use Liberty Basic, but it is far too slow. How can I get the serial port in action in Freebasic? I use WindowsXP. Here is the LB program (for one channel):

nomainwin

open "com1:9600,n,8,1" for random as #commHandle
Port = hexdec("3FC")

textbox #Meten.a, 5, 5, 200, 30

open "Meten" for Graphics_nsb as #Meten
Print #Meten, "trapclose [quit]"

    while Inkey$<>" "
            scan
            GoSub [readin]
            for slow= 1 to 100000:next slow
            Print #Meten.a, "Output:  "; v1
    wend

goto [quit]

[readin]
    vout = 0: vout1 = 0
        gosub [tel]: vout = vout + 2048 * d
        gosub [tel]: vout = vout + 1024 * d
        gosub [tel]: vout = vout + 512 * d
        gosub [tel]: vout = vout + 256 * d
        gosub [tel]: vout = vout + 128 * d
        gosub [tel]: vout = vout + 64 * d
        gosub [tel]: vout = vout + 32 * d
        gosub [tels]: vout = vout + 16 * d
            gosub [tel]: vout = vout + 8 * d
            gosub [tel]: vout = vout + 4 * d
            gosub [tel]: vout = vout + 2 * d
        gosub [tels]: vout1 = vout + 1 * d
        gosub [highfg]
        v1=int((vout1)-1364)
Return

[tel]
        OUT Port, (254 And INP(Port))
        OUT Port, (253 And INP(Port))
        OUT Port, (1 Or INP(Port))
        If (INP(Port + 2) And 16) = 16 Then d = 1 Else d = 0
return

[tels]
        OUT Port, (254 And INP(Port))
        OUT Port, (2 Or INP(Port))
        OUT Port, (1 Or INP(Port))
        If (INP(Port + 2) And 16) = 16 Then d = 1 Else d = 0
return

[highfg]
        OUT Port, (254 And INP(Port))
        OUT Port, (2 Or INP(Port))
        OUT Port, (1 Or INP(Port))
        OUT Port, (254 And INP(Port))
        OUT Port, (2 Or INP(Port))
        OUT Port, (1 Or INP(Port))
        OUT Port, (254 And INP(Port))
        OUT Port, (253 And INP(Port))
        OUT Port, (1 Or INP(Port))
        OUT Port, (254 And INP(Port))
        OUT Port, (253 And INP(Port))
        OUT Port, (1 Or INP(Port))
return

[quit]
Close #commHandle
Close #Meten
End
Reply


Messages In This Thread
Serial port with Max186 - by ptkindt - 07-08-2008, 11:14 PM
Re: Serial port with Max186 - by ptkindt - 07-12-2008, 03:39 PM
Re: Serial port with Max186 - by roy - 07-12-2008, 09:33 PM
Re: Serial port with Max186 - by ptkindt - 07-12-2008, 10:30 PM
Re: Serial port with Max186 - by roy - 07-12-2008, 11:00 PM
Re: Serial port with Max186 - by ptkindt - 07-12-2008, 11:25 PM
Re: Serial port with Max186 - by ptkindt - 07-21-2008, 02:07 PM
Re: Serial port with Max186 - by Clippy - 09-30-2008, 12:07 AM
Re: Serial port with Max186 - by ptkindt - 11-18-2008, 09:07 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)