Discussion forum for the BasicX family of microcontroller chips.
|
Has anyone tried this and gotten it to work? basicly it's using com1 of the Bx24 to talk to the siteplayer through the serial line (pin 7 & 8). I can make this work with com3 but i run into a problem with another part of my project. My bx24 seem to like 19200 better than 9600 so i have the siteplayer configure for 65471 in the inc file. even put a link on the SP webpage to set the baudrate to 19200. Thanks for the help! |
|
--- In , "dakota_99_64804" <dakota_99_64804@y...> wrote: > > Has anyone tried this and gotten it to work? basicly it's using com1 > of the Bx24 to talk to the siteplayer through the serial line (pin 7 & > 8). I can make this work with com3 but i run into a problem with > another part of my project. My bx24 seem to like 19200 better than > 9600 so i have the siteplayer configure for 65471 in the inc file. > even put a link on the SP webpage to set the baudrate to 19200. > > Thanks for the help! Hello I am at the time beeing doing som experiments with the BX24/Siteplayer combo. I do not have anything finished yet, but I do have a "DUMMY Project" running just now. The BX generates som LONG values to simulate a Powermeter, and sends these to the Siteplayer. The BX can receive ON/OFF status from the siteplayer to reset and start/stop the counters. As I mentioned, it is not at all a finished program, but it demonstrates the comunication between the Siteplayer and the BX24. You can view the "dummy" siteplayer page at http://tfintlan.homeip.net:1001 Tell me if I can be of further assistance. Regards Tore CODE: Attribute VB_Name = "Wattmeter" Option Explicit 'Com Ques Public Const InputBufferSize As Integer = 20 '30-byte buffer Public Const OutputBufferSize As Integer = 20 '40-byte buffer Public InputBuffer(1 To InputBufferSize) As Byte Public OutputBuffer(1 To OutputBufferSize) As Byte '******************************************************** Public Sub Main() '******************************************************** ' Open COM Queues Call OpenQueue(InputBuffer, InputBufferSize) Call OpenQueue(OutputBuffer, OutputBufferSize) Call OpenCom(1, 9600, InputBuffer, OutputBuffer) Call Sleep(1#) '******************************************************************** *** 'M A I N L O O P '******************************************************************** *** Dim N as long Dim I as Byte Dim kWTot(1 to 8) as long Dim kW(1 to 8) as long Dim kWreset(1 to 8) as long Dim Output(1 to 8 ) as byte Dim OutputOLD(1 to 8 ) as byte Dim CommandByte as Byte Dim AddressByte As Byte N= 0 For I = 1 to 8 kWtot(I) = 100000 kWreset(I) = 0 Output(I) = 0 OutputOLD(I) = 0 Next Do N= N+1 For I = 1 to 8 If Output(I) = 1 Then kWtot(I) = kWtot(I) + 1 kW(I) = kWtot(I) - kWreset(I) End If Next CommandByte = &H83 For I = 1 to 8 AddressByte = (I-1)*4 Call Send_Long(CommandByte, AddressByte,kW(I)) Call sleep(0.1) AddressByte = (I+7)*4 Call Send_Long(CommandByte, AddressByte,kWtot(I)) Call sleep(0.1) Next For I = 1 to 8 AddressByte = (I+63) CommandByte = &HC0 'If not (Read_Bit(CommandByte,AddressByte)= 3) Then ' Output(I) = 1 'End If Output(I)= Read_Bit(CommandByte,AddressByte) If (Output(I) = 1) and (OutputOLD(I) = 1) Then 'nothing End If If (Output(I) = 1) and (OutputOLD(I) = 0) Then OutputOld(I) = 1 kWreset(I) = kWtot(I) kW(I) =0 AddressByte = (I-1)*4 Call Send_Long(CommandByte, AddressByte,kW(I)) Call sleep(0.1) End If If (Output(I) = 0) and (OutputOLD(I) = 1) Then OutputOld(I) = 0 End If If (Output(I) = 0) and (OutputOLD(I) = 0) Then ' nothing End If Next Loop End Sub '********************************************************** 'E N D M A I N L O O P '********************************************************** Private Sub Send_Long(byval CommandByte as byte, ByVal AddressByte As Byte, ByVal ValueLong As Long) call PutQueue(Outputbuffer,Commandbyte,1) call PutQueue(Outputbuffer,AddressByte,1) call PutQueue(Outputbuffer,ValueLong,4) End Sub '******************************************************************** * Private Function Read_Bit(byval CommandByte as byte, ByVal AddressByte As Byte) as Byte Dim TimeOut as single Dim TimedOut as boolean Dim I As Byte Dim B as Byte TimeOut = 1.0 For I = 1 to 15 Call GetQueue(Inputbuffer,B,1,TimeOut, TimedOut) If TimedOut Then Exit For End If Next B = 3 'send read request call PutQueue(Outputbuffer,Commandbyte,1) call PutQueue(Outputbuffer,AddressByte,1) call sleep(0.5) Call GetQueue(Inputbuffer,B,1,TimeOut, TimedOut) If (not TimedOut) and (B = 0) Then Call putpin(26, bxoutputlow) Elseif B=1 Then Call putpin(26, bxoutputhigh) End If Read_Bit = B End Function '******************************************************************** * |
|
See here what i'm working with: Option Explicit Const InBufSize_1 As Integer = 20 Const OutBufSize_1 As Integer = 30 Dim InBuf_1(1 To InBufSize_1) As Byte Dim OutBuf_1(1 To OutBufSize_1) As Byte Dim DataBuf_1(1 To 30) As Byte Dim Data_1 As Byte Const InBufSize_3 As Integer = 20 Const OutBufSize_3 As Integer = 30 Dim InBuf_3(1 To InBufSize_3) As Byte Dim OutBuf_3(1 To OutBufSize_3) As Byte Dim DataBuf_3(1 To 5) As Byte Dim Data_3 As Byte Const BaudRate As Long = 9600 Const GreenLED As Byte = 26 Const RedLED As Byte = 25 Const LEDon As Byte = 0 Const LEDoff As Byte = 1 Public Sub Main() Call Delay(5.0) Call Init Call RedLedOn() Do If StatusQueue(InBuf_1) Then Call GetQueue(InBuf_1, Data_1, 1) If Data_1 = 65 Then Call BetaBright_1() Else Call BetaBright_2() End If End If Loop End Sub Sub Init() Call PutPin(GreenLED, LEDoff) 'turn green LED off Call PutPin(RedLED, LEDoff) 'turn on Red LED Call OpenSerialPort_3 Call OpenSerialPort_1 Call SitePlayer_Init End Sub Sub OpenSerialPort_3() Call defineCom3(11, 12, &H8) Call openQueue(InBuf_3, InBufSize_3) Call openQueue(OutBuf_3, OutBufSize_3) Call openCom(3, 9600, InBuf_3, OutBuf_3) End Sub Sub OpenSerialPort_1() Call openQueue(InBuf_1, InBufSize_1) Call openQueue(OutBuf_1, OutBufSize_1) Call openCom(1, 19200, InBuf_1, OutBuf_1) End Sub Sub SitePlayer_Init() 'tell sp to enable UDP DataBuf_3(1) = &H90 DataBuf_3(2) = &H20 DataBuf_3(3) = &HFF DataBuf_3(4) = &H1 Call putQueue(OutBuf_1, DataBuf_1, 4) End Sub problem is if i change the line in Siteplayer_Init(): Call putQueue(OutBuf_1, DataBuf_1, 4) to read Call putQueue(OutBuf_3, DataBuf_3, 4) it works fine. but if i change it back and connect the SP pin 7 & 8 to the pin 1 & 2 and run it at 9600 or 19200 it dont work? Pin 1 of the Bx24 should go to pin 7 of the SP and pin 2 of Bx24 to pin 8 of the SP. BX24 SP pin1 (TX) <--> Pin 7 (RX) pin2 (RX) <--> Pin 8 (TX) thanks again for the help? sooner or later i figure this out --- Tore Fintland <> wrote: > > --- In , "dakota_99_64804" > <dakota_99_64804@y...> wrote: > > > > Has anyone tried this and gotten it to work? > basicly it's using > com1 > > of the Bx24 to talk to the siteplayer through the > serial line (pin > 7 & > > 8). I can make this work with com3 but i run into > a problem with > > another part of my project. My bx24 seem to like > 19200 better than > > 9600 so i have the siteplayer configure for 65471 > in the inc file. > > even put a link on the SP webpage to set the > baudrate to 19200. > > > > Thanks for the help! > > Hello > > I am at the time beeing doing som experiments with > the > BX24/Siteplayer combo. I do not have anything > finished yet, but I do > have a "DUMMY Project" running just now. The BX > generates som LONG > values to simulate a Powermeter, and sends these to > the Siteplayer. > The BX can receive ON/OFF status from the siteplayer > to reset and > start/stop the counters. As I mentioned, it is not > at all a finished > program, but it demonstrates the comunication > between the Siteplayer > and the BX24. > > You can view the "dummy" siteplayer page at > http://tfintlan.homeip.net:1001 > > Tell me if I can be of further assistance. > > Regards Tore > CODE: > > Attribute VB_Name = "Wattmeter" > Option Explicit > 'Com Ques > Public Const InputBufferSize As Integer = 20 > '30-byte buffer > Public Const OutputBufferSize As Integer = 20 > '40-byte buffer > Public InputBuffer(1 To InputBufferSize) As Byte > Public OutputBuffer(1 To OutputBufferSize) As Byte > '******************************************************** > Public Sub Main() > '******************************************************** > ' Open COM Queues > Call OpenQueue(InputBuffer, InputBufferSize) > Call OpenQueue(OutputBuffer, OutputBufferSize) > > Call OpenCom(1, 9600, InputBuffer, OutputBuffer) > Call Sleep(1#) '******************************************************************** > *** > 'M A I N L O O P > '******************************************************************** > *** > Dim N as long > Dim I as Byte > Dim kWTot(1 to 8) as long > Dim kW(1 to 8) as long > Dim kWreset(1 to 8) as long > Dim Output(1 to 8 ) as byte > Dim OutputOLD(1 to 8 ) as byte > Dim CommandByte as Byte > Dim AddressByte As Byte > N= 0 > > For I = 1 to 8 > kWtot(I) = 100000 > kWreset(I) = 0 > Output(I) = 0 > OutputOLD(I) = 0 > Next > > Do > N= N+1 > > For I = 1 to 8 > If Output(I) = 1 Then > kWtot(I) = kWtot(I) + 1 > kW(I) = kWtot(I) - kWreset(I) > End If > Next > > CommandByte = &H83 > For I = 1 to 8 > AddressByte = (I-1)*4 > Call Send_Long(CommandByte, AddressByte,kW(I)) > Call sleep(0.1) > > AddressByte = (I+7)*4 > Call Send_Long(CommandByte, AddressByte,kWtot(I)) > Call sleep(0.1) > Next > > For I = 1 to 8 > AddressByte = (I+63) > CommandByte = &HC0 > 'If not (Read_Bit(CommandByte,AddressByte)= 3) Then > ' Output(I) = 1 > 'End If > Output(I)= Read_Bit(CommandByte,AddressByte) > > If (Output(I) = 1) and (OutputOLD(I) = 1) Then > 'nothing > End If > > If (Output(I) = 1) and (OutputOLD(I) = 0) Then > OutputOld(I) = 1 > kWreset(I) = kWtot(I) > kW(I) =0 > AddressByte = (I-1)*4 > Call Send_Long(CommandByte, > AddressByte,kW(I)) > Call sleep(0.1) > End If > > If (Output(I) = 0) and (OutputOLD(I) = 1) Then > OutputOld(I) = 0 > End If > > If (Output(I) = 0) and (OutputOLD(I) = 0) Then > ' nothing > End If > > Next > > Loop > End Sub > '********************************************************** > 'E N D M A I N L O O P > '********************************************************** > Private Sub Send_Long(byval CommandByte as byte, > ByVal AddressByte > As Byte, ByVal ValueLong As Long) > > call PutQueue(Outputbuffer,Commandbyte,1) > call PutQueue(Outputbuffer,AddressByte,1) > call PutQueue(Outputbuffer,ValueLong,4) > > End Sub > '******************************************************************** > * > > Private Function Read_Bit(byval CommandByte as byte, > ByVal > AddressByte As Byte) as Byte > Dim TimeOut as single > Dim TimedOut as boolean > Dim I As Byte > Dim B as Byte > TimeOut = 1.0 > > For I = 1 to 15 > Call GetQueue(Inputbuffer,B,1,TimeOut, TimedOut) > If TimedOut Then > Exit For > End If > Next > > B = 3 > > 'send read request > call PutQueue(Outputbuffer,Commandbyte,1) > call PutQueue(Outputbuffer,AddressByte,1) > call sleep(0.5) > Call GetQueue(Inputbuffer,B,1,TimeOut, TimedOut) > If (not TimedOut) and (B = 0) Then > Call putpin(26, bxoutputlow) > Elseif B=1 Then > Call putpin(26, bxoutputhigh) > End If > Read_Bit = B > End Function > '******************************************************************** > * === message truncated === __________________________________ |