control lpt by vb6

control single out of lpt by vb6

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 6500 Views - Last Post: 23 December 2010 - 03:28 PM Rate Topic: -----

#1 zouhair1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 08-November 10

control lpt by vb6

Posted 23 November 2010 - 03:56 AM

dear sir
how are you
please can you help me

now im working to control 8 relays using lpt and vb6
i have one problem
how cani control every single of lpt by a time
for example
pin out1 : start at 8h00min
pin out 2 : start at 9h14min
.... to pin out8 start at 22h min

i used do while but i had a problem ,the out stopped when the second start
please help me
zouhair

Is This A Good Question/Topic? 0
  • +

Replies To: control lpt by vb6

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: control lpt by vb6

Posted 23 November 2010 - 04:03 AM

Please post what code you have then we have a starting point to try and help you.
Was This Post Helpful? 0
  • +
  • -

#3 zouhair1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 08-November 10

Re: control lpt by vb6

Posted 23 November 2010 - 04:09 AM

dir sir
thanks for reply
this is my code about timer

Private Sub Timer1_Timer()
Timer1 = Time
Dim y As Date
y = Format(Now, "hh:mm:ss")
Text9.Text = y
Text10.Text = y
Text11.Text = y
Text12.Text = y
Text13.Text = y
Text14.Text = y
Text15.Text = y
Text16.Text = y
If Check1.Value = 1 Then
Do While Text1.Text = Text9.Text
Out &H378, 1
Exit Do
Loop
end if
if check2.value=1 then
do while text2.text=text10.text
out &h378,2
exit do
loop
end if
if check3.value=1 then
do while text3.text=text11.text
out &h378,4
exit do loop
end if
...
....



End If
Was This Post Helpful? 0
  • +
  • -

#4 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: control lpt by vb6

Posted 23 November 2010 - 04:44 AM

You probably need to look at taking the switching of the outputs into a separate function.

I'm not quite sure why you have the Do While loops??

Call the function on your timer interval (set to 1 minute for example).

In your function, you can then check the times that you have set....I don't think you need the Do While loops.

If you call OUT then does that not latch the output??

Just be aware, that if you want more than one output on at the same time you will need to build up a bitmask for the outputs.
Was This Post Helpful? 0
  • +
  • -

#5 zouhair1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 08-November 10

Re: control lpt by vb6

Posted 23 November 2010 - 04:52 AM

dir sir
i will send to you a graphic program for more understand

becuase i want to bulid a delay by timer
for example
out 1 start at 14h30
out 2 start at 16h44
out 4 start at 20h00
out 8 start at 2158
....
...
...
out 128 start at 23h39

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#6 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: control lpt by vb6

Posted 23 November 2010 - 05:06 AM

I'm sorry, I'm not quite sure what you want to achieve. Even by looking at the display it doesn't help me as you have start and stop buttons for each relay as well as start all and stop all buttons.



So, to simplify things, tell me what you want to do for one relay....

You have a time set in a TextBox (let's say 08:00 HH:MM - Does it need to work in seconds???).

So when the actual time = TextBox Time, you want to switch the relay on...Is that correct??
Was This Post Helpful? 0
  • +
  • -

#7 zouhair1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 08-November 10

Re: control lpt by vb6

Posted 23 November 2010 - 05:16 AM

dir sir
i want to control relay manually or automatic
how
when the checkbox .value=0 now i can start manually also i cant start all at the same time that is not problem for me

now when the checkbox.value =1 now i can start automatic i choose the time from combobox (ex: 12h30min12s) i go to checkbox i make mark now the time is appear on textbox after that all command manually are notactive
i want that WHEN THE TIME ON TEXTBOX1 = TIME NOW THE OUT &H378,1
AND ALSO WHEN THE TEXTBOX2=TIME NOW THE OUT &H378,2

THIS IS MY PROBLEM WHEN THE OUT &H378,2 ON ,THE OUT &H378,1 OFF

WHY THE OUT&378,1OFF
I WANT BOTH OUT KEEP ON
Was This Post Helpful? 0
  • +
  • -

#8 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: control lpt by vb6

Posted 23 November 2010 - 05:49 AM

Ok, there's no need to type in capitals, I can still read it! :)

The problem you have is what I said in my second post about using bit masks.

You OUT the values 1, 2, 4...in binary this is 0001, 0010, 0100. As you can see, when you change from 1 to 2, you are turning off the bit that represents relay one!

You need to OR the bits to keep the other relays on, for example if you OR bits 1 and 2, you would get 3 or in binary 0011, which would turn relay 1 and 2 on.

If you need to switch a particular relay off then you need to AND the negative of that bit, so if you want to turn off relay 1 you would AND the current mask with 0xFE.

Hope that helps.

This post has been edited by maj3091: 23 November 2010 - 05:51 AM

Was This Post Helpful? 0
  • +
  • -

#9 zouhair1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 08-November 10

Re: control lpt by vb6

Posted 23 November 2010 - 05:57 AM

dear sir
thanks
please can you give an example for that
and where i can write a code? is it on timer or on form

can you hlp more
Was This Post Helpful? 0
  • +
  • -

#10 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: control lpt by vb6

Posted 23 November 2010 - 06:21 AM

I'm not going to write the code for you.

I've given you the commands to use to do it (OR and AND) and it really isn't that difficult. If you've managed to figure out how to control hardware via the parallel port, then ANDing and ORing should be straight forward enough for you.

Have a go at it yourself and post your code if you have any problems.
Was This Post Helpful? 0
  • +
  • -

#11 zouhair1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 08-November 10

Re: control lpt by vb6

Posted 23 November 2010 - 06:44 AM

dir sir
thank you so much
i did it
now all its ok , you are right i should make or not and

i have a good feeling now
again i want tell you thanks for all reply
i wish you good life with more success

thanks & best regards
zouhair from morocco
Was This Post Helpful? 0
  • +
  • -

#12 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: control lpt by vb6

Posted 23 November 2010 - 08:17 AM

No problem....hope you get it working....

If you're happy with the assistance, please press the + button to indicate that the posts were helpful to you.
Was This Post Helpful? 1
  • +
  • -

#13 zouhair  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-November 09

Re: control lpt by vb6

Posted 21 December 2010 - 07:04 AM

dear sir
hi again
for switch on i dont have any problem but when i wanted to switch off single out i cant didt it this is my code
out &h378,not 1 and 254
out &h378,not 2 and 254
out &h378,not 4 and 254
out &h378,not 8 and 254
out &h378,not 16 and 254
out &h378,not 32 and 254
out &h378,not 64 and 254
out &h378,not 128 and 254
for example
i want to switch on pin 4 and sitchw off
for switch on its working but when i switch off, all leds they switch on
please help me
Was This Post Helpful? 0
  • +
  • -

#14 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: control lpt by vb6

Posted 21 December 2010 - 02:00 PM

Why don't you create some constants for each bit to turn off then just AND with what's already at the output.

If you keep a variable which holds the current state of your outputs on the port, then you can AND and OR against that and just output the variable.

I already gave you an example in an earlier post.
Was This Post Helpful? 0
  • +
  • -

#15 Guest_zouhair*


Reputation:

Re: control lpt by vb6

Posted 22 December 2010 - 01:52 AM

dear sir
good morning
thanks for reply

but i cant understand what you wanted mean

please can you explain me more

i cant switch off single out

thanks & best regards
Was This Post Helpful? 0

  • (2 Pages)
  • +
  • 1
  • 2