|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (10 bit)
|
VB6, working with a interface board and problems
Another problem i've run into, I got this documentation for a board i'm thinking of getting which is a parallel interface allowing my PC to control several electrical relays and get inputs from a 12V source, the prob is i cant make head nor tail about what instructions do what in VB6. I managed to find some documentation on using the board with VB6 but i didnt understand it, i was hoping someone could make sense of it for me as i'm still totally inexperienced with VB6 at present. Basically this thing is going into a PC im building in my car and i'm gonna use it to monitor certain systems on the car (would look great at the shows
) what i really want is a set of global bool vars. like say input1, input2, etc. and if the input 1 is on then the var input1 becomes true and likewise for the outputs a set of vars so that i can set say a global var called output1 to true and it sorts the instructions to make this happen on the board.Anyways, I know this is probably a lot to ask but it would be greatly appreciated if someone could take the time to have a browse through the attached doc and explain it to me a little that would be immensely appreciated. Many Thanks D
__________________
Intel Core i7 920 2.66GHz | Asus P6T SE| 6GB Corsair ram | XFX Radeon HD 4780 | 2 x 250 Gb Maxtor SATA II (in RAID 0), 1 x 250GB SATA II | Creative XFI soundcard | Coolermaster 650W PSU | ThermalTake Tsunami case My new website -Carp Fishing Forums |
|
|
|
|
|
#2 |
|
Member (10 bit)
Join Date: Jul 2002
Location: University of California, Santa Barbara
Posts: 800
|
That first list of functions in the document is all of the functions you can use to access and control the board. Then it gives specific information on how to use each one.
Near the end of the doc, it has the section on how to use in VB. What their code does, is declare all of the functions so that you can access them as you would any function in VB. So, once you have the line "Private Declare Sub ConfigAllIOasInput Lib "k8d.dll" ()" execute in your program, you can use the ConfigAllIOas Input as it describes in the section about that function anywhere in your VB code. So you put all these declarations so they execute when you start your VB program (it's been a while since I've done VB so I don't know where that is). I didn't read through it in depth, but to accomplish your goal of the global booleans you will need to have something that calls a function to input the data on the inputs, then put this data in your boolean vars. You'll need to set it to run on a regular basis, such as once per second, how often it needs to run probably depends on what data you're reading and what it's for. I seem to recall that a timer would be useful for that sort of function. Remember to use the start and stop functions, which were demonstrated at the end of the VB section. Last edited by mattg2k4; 03-26-2005 at 03:25 AM. |
|
|
|
|
|
#3 |
|
Member (10 bit)
|
Am I right in thinking that I need a module where everything is declared like I declare as public everything in that list of items from the document, then if i got this right, to make it read an input i'd need this in with the declarations (just as an example)
Code:
Public Input1 as Boolean same as that for all inputs and outputs Code:
Private Sub ReadIO_Timer() 'Read status of inputs and update vars ConfigIOChannelAsInput (1) Input1 = ReadIOchannel(1) 'Read Input channel 1 'Read status of vars and update outputs If Output1 = True Then 'If Bool var for OP12 is true set op 12 ConfigIOchannelAsOutput (12) SetIOchannel (12) ' Output channel 12 is on End If If Output1 = False Then ConfigIOchannelAsOutput (12) SetIOchannel (12) ' Output channel 12 is off End If 'Other If....Then's go here for other outputs End Sub |
|
|
|
|
|
#4 |
|
Member (10 bit)
|
Eventually sussed it out:
Bool vars used Input1 for the 1st input and so on.... Output1 for the first output If readIOchannel(1)=1 then Input1=true else input1=false If readIOchannel(2)=1 then Input2=true else input2=false etc etc. And for the outputs If Output1=true then SetIOChannel (11) else ClearIOchannel (11) |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|