PDA

View Full Version : Please help me write a Plug in for vixen



yander
06-08-2007, 03:11 PM
I see a similar question has been asked in the past but I didn't see any answers that would help me with this. I have a plug in I wrote for comet in VB for some hardware I made that works correctly. I would like to make my hardware work with vixen. Can someone help me write this plug in, I am not a great programmer and it took me a while to learn the necessary VB to make my comet plug in work. I need to get this working soon as it is for the 4th of July, and I need time to test this and set up the sequence as well. I am providing the dll code that works with comet to control my boxes along with a brief description of my box protocol. Perhaps someone who is familiar with vixen can cut paste and modify my code to make a working vixen plug in.

Thanks in advance

The boxes have 16 outputs, to control the boxes you send the box number and the hex code for the status of lights 1-8 and then 8-16. If you want to turn on light one on box one you send "ONEE(01)(00)" all lights on
box three would be "THRE(FF)(FF)" and so on.


Below is the source code for the plug in for comet that works with my hardware. It was hacked together from a parallel plug in from comet so it looks a little messy but it works.

Private mvarName As String
Private mvarAbout As String
Private mvarMaxChannels As Integer
Private mvarPluginData As String
Private mvarPluginDataHelp As String
Private mvarGridData() ' used by the preCache and
FastRender methods
Private mvarVersion As String
Dim outONEE As String
Dim outTWOO As String
Dim outTHRE As String
Dim outFOUR As String
Dim outFIVE As String
Dim outSIXX As String
Dim outSEVE As String
Dim outEIGH As String
Dim oldONEE As String
Dim oldTWOO As String
Dim oldTHRE As String
Dim oldFOUR As String
Dim oldFIVE As String
Dim oldSIXX As String
Dim oldSEVE As String
Dim oldEIGH As String
'oldONEE = ""
'oldTWOO = ""
'oldTHRE = ""

' plugin specific variables
Private mvarDataPort As Integer
Private mvarControlPort As Integer

' New 0.8.7 plugin property
Public Property Get Version() As String
Version = mvarVersion
End Property

Public Property Get Name() As String
Name = mvarName
End Property

Public Property Get About() As String
About = mvarAbout
End Property

Public Property Get MaxChannels() As Integer
MaxChannels = mvarMaxChannels
End Property

Public Property Get PluginDataHelp() As String
PluginDataHelp = mvarPluginDataHelp
End Property

Public Property Get PluginData() As String
PluginData = mvarPluginData
End Property
Public Property Let PluginData(ByVal vData As String)
' plugin specific implementation
' vData= <data>,<other>
mvarDataPort = mBases.ConvertBase(vData,
ebHexadecimal, ebDecimal)
mvarControlPort = mvarDataPort + 2
mvarPluginData = vData
End Property

Public Sub Class_Initialize()

' init
mvarVersion = "2.0"
mvarName = "PIC Serial Port"
mvarAbout = "DF Basic serial Port controller -
Version " & mvarVersion
mvarMaxChannels = 128

' plugin specific data defaults
Me.PluginData = "378"
mvarPluginDataHelp = "jjhSpecify the LPT Port
address in hexadecimal (ie. 3BC or 378)"

End Sub

Public Sub Class_Terminate()
' terminate

End Sub
' New plugin architecture!
Public Sub preCache(vData As Variant)
mvarGridData = vData
End Sub
' New plugin architecture!
Public Sub fastRender(Interval As Integer)

Dim msComm As Object

Set msComm = CreateObject("MSCOMMLIB.MSCOMM")

' msComm.PortOpen = False
' MsgBox (mvarGridData(1, Interval))
' Use COM1
msComm.CommPort = 1
' 2400 baud, no parity, 8 data bits, 1 stop bit
msComm.Settings = "2400,N,8,1"
' Disable DTR
msComm.DTREnable = False
' Open the port
msComm.PortOpen = True

outONEE = ("ONEE") & Chr$(mvarGridData(1,Interval)) & Chr$(mvarGridData(2, Interval))
outTWOO = ("TWOO") & Chr$(mvarGridData(3,Interval)) & Chr$(mvarGridData(4, Interval))
outTHRE = ("THRE") & Chr$(mvarGridData(5,Interval)) & Chr$(mvarGridData(6, Interval))
outFOUR = ("FOUR") & Chr$(mvarGridData(7,Interval)) & Chr$(mvarGridData(8, Interval))
outFIVE = ("FIVE") & Chr$(mvarGridData(9,Interval)) & Chr$(mvarGridData(10, Interval))
outSIXX = ("SIXX") & Chr$(mvarGridData(11,Interval)) & Chr$(mvarGridData(12, Interval))
outSEVE = ("SEVE") & Chr$(mvarGridData(13,Interval)) & Chr$(mvarGridData(14, Interval))
outEIGH = ("EIGH") & Chr$(mvarGridData(15,Interval)) & Chr$(mvarGridData(16, Interval))
If Not (oldONEE = outONEE) Then msComm.Output =outONEE
If Not (oldTWOO = outTWOO) Then msComm.Output =outTWOO
If Not (oldTHRE = outTHRE) Then msComm.Output =outTHRE
If Not (oldFOUR = outFOUR) Then msComm.Output =outFOUR
If Not (oldFIVE = outFIVE) Then msComm.Output =outFIVE
If Not (oldSIXX = outSIXX) Then msComm.Output =outSIXX
If Not (oldSEVE = outSEVE) Then msComm.Output =outSEVE
If Not (oldEIGH = outEIGH) Then msComm.Output =outEIGH

oldONEE = outONEE
oldTWOO = outTWOO
oldTHRE = outTHRE
oldFOUR = outFOUR
oldFIVE = outFIVE
oldSIXX = outSIXX
oldSEVE = outSEVE
oldEIGH = outEIGH

msComm.PortOpen = False
End Sub
Public Sub clear()

End Sub

teberle
06-09-2007, 10:18 AM
Are you using Serial or Parallel port? It looks to be serial but just want to make sure.

So you have 8 boxes with 16 outputs correct?
These are strictly on/off?

So is this correct for your output on each box?

1 = output 1
3 = output 2
7 = output 3
F = output 4
1F = output 5
3F = output 6
7F = output 7
FF = output 8

So to turn on box 1 output 8 and 9 would be ONEE(FF)(1F)?

It doesn't look to be to hard to write. If it is serial are the parameters below what needs to be configured:
' 2400 baud, no parity, 8 data bits, 1 stop bit

yander
06-10-2007, 06:52 PM
First I want to thank you for taking a look at this.

I am controlling my boxes via serial not parallel, this is being sent at 2400 baud, no parity, 8 data bits, 1 stop bit as this is fast enough for my use. The commands are not quite how you describe however, so let me see if I can clarify.

To turn on just light 8 and 9 you would send (80)(01)
The lights are set up in sets of 4 actually but the parentheses separate the two sets of 8.

This should help if the text lines up correctly

(8765 4321)(16---------9) Light Numbers
(8765 4321) (8765 4321)
(0000 0000) (0000 0000)

(1000 0000) (0000 0001)
( 8 0 ) ( 0 1 )

(80)(01) would be lights 8 and 9
(C0)(90) would be lights 7, 8, 13 and 16

hex binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111

Don't ask me why I did it this way, I did it last year so I forgot excatly why. I remember that it had something to do with the way the pic chip worked and it made for a much shorter program running on the pic.

The code I posted does do this all correctly so hopefully there is a way to use that. If you can get me close then I can probably learn enough to tweak the code to make it work if it doesn't.

teberle
06-10-2007, 11:30 PM
Does the output have the parenthesis around the hex values?

What is the name of your controller?

yander
06-11-2007, 12:26 AM
Yes there are parenthesis around the hex values

I just called them Holiday Control Boxes or HCB.

They are each built into a 3"x2"x1" radio shack project box which is jam packed. They have led's on top so you know which outputs are on. They provide 12V dc outputs with can switch about 5 amps. The boxes are intended to be universal control boxes so you can control dc or add on a box with ssr's for AC.

teberle
06-11-2007, 07:49 AM
I should have something ready for testing by tomorrow.

yander
06-11-2007, 10:03 AM
Awesome, thank you so much for your help, I was really lost as to how to write the plug in.

When I have a little more time I can post the schematic pic code and some pictures of the boxes for this so others can use it.

teberle
06-11-2007, 12:40 PM
send me an email to eberletj at cox dot net so I know where to send the dll.

teberle
06-12-2007, 10:06 AM
I have emailed a dll to you. It has some logging so you can see the outputted values to make sure I am doing it correctly. Test and let me know what needs changed.