Hi, I'm quite new to all this so please forgive my lack of technical description.
Project background:
Basically I have had the vision of creating a home lighting control system for the last 3 years. This year I have been trying really hard to get a prototype model working.
I need to work out how to use visual basic to 'fade' to a desired figure in a number of seconds. From there I can convert the figure into an analogue voltage (0 - 10v) using a USB interface card and then control my lighting dimmer.
In simple terms, if I refer to the level of light output in percent, if I want to go from 0% to 100% in 5 seconds it would fade off to fully on in 5 secs. Likewise if I want to go from 70% to 30% in 3 secs it would do so. I did have an example given to me using a timer and a VScroll bar, but somewhere along the lines it gets confused.
Sorry about the long description but I'm really eager to get this thing working!
If anyone can help me in any way I will be very grateful.
Adam
11 3037
I did have an example given to me using a timer and a VScroll bar, but somewhere along the lines it gets confused.
Can you post your codes for the reference of our experts here ^ ^
Rey Sean
What version of VB are you using? Timers and events and things work quite differently depending on the version.
All in all though, it sounds like quite a cool idea, and not too difficult.
Think about it logically......if you need to increase from 0% to 100% in 5 seconds. for each Second you increase by 20%.
So if you set your timer to 1000milliseconds.....Equivalent of 1 second
Set your progress bar to a max value of 100
Just add 20 to the progress bar on each loop
For example: - Timer1_tick
-
'Use an if statement to ensure that the progress bar value is less that 100%
-
If Progressbar.value = Progressbar.max then
-
'Disables the timer
-
Timer1.enabled = False
-
Else
-
'Sets The progress bar equal to its own value plus the additional 20
-
Progressbar.value = Progressbar.value + 20
-
End if
-
End sub
for a smoother increase of the value.
use a time of 500 milliseconds and a increase of 10 per loop
or 250 and 5
I decided this would be a fun project to while away part of the evening. So here's the little sample I threw together. I'll zip up the (VB6) project and EXE, and post the form code here. It's just a single form, pretty simple really.
Hey guys,
Thanks ever so much, alot of positive answers. I will have a go at the examples you have provided when i get chance maybe later tonight! will let you know how i get on!
Many thanks again
Adam
Cool! Let us know how you get on with the project.
Hi, i tried the example given to me by `killer42' and i added in a bit of code so i could use my interface board. I got it all working fine, but the times seems a bit off... eg 5secs seems to be around 8 secs.. has anybody got any clues? Also if i were to replicate the controls frame to control multiple dimmers would i need to use more than 1 timer? Apart from that i'm one big step closer to cracking this project!
Thanks
Adam
Hi, i tried the example given to me by `killer42' and i added in a bit of code so i could use my interface board. I got it all working fine, but the times seems a bit off... eg 5secs seems to be around 8 secs.. has anybody got any clues?
A couple of possibilities come to mind... - My calculations may have been way off. I didn't test the timing at all carefully. The "10 second" setting seemed longer than the "5 second" setting, so I was happy with that. You might want to double-check my logic.
- Perhaps there's some delay in the response. For instance, perhaps you're telling the board to adjust the light 100 times a second, but it takes a tenth of a second for the light to respond. So the light might still take a few seconds to finish changing brightness after the code finishes.
- A lot depends on how the interface works. Is it synchronous? When my code calculates how much to adjust the light on each "tick" of the timer, I suppose it assumes that each tick will finish more or less instantaneously. You might need to adjust either the increment amount, or (more sensibly) the logic.
This sample code is only intended to provide some ideas. Your logic may end up quite different. For instance, rather than adjusting by a fixed amount each tick, you might work out how far along the delay period you have reached, and thus what the current setting should be. Then set it accordingly. This would allow for delays - if something slowed you down, you might just notice a faster jump in brightness when it catches up. - Um...
Also if i were to replicate the controls frame to control multiple dimmers would i need to use more than 1 timer?
I'd say that you can easily drive everything off a single timer. Whether it's appropriate I couldn't say. One thing - I learned early in my VB "career" to avoid creating more timers than necessary, as (A) there was a limit to how many you could use, and (B) they tended to be a bit "expensive". I don't know whether these still apply.
Just try to make it as modular and expandable as possible, so you can easily add more components (lights, or whatever). Before you know it, we'll be seeing your software on the shelves at Woolworths. :)
How u have done this?
How have u controled the bulb using this?
How u make conectivity between PC and bulb?
Can u plz tell me or send me the code.
Thanx
Ali
How u have done this?
How have u controled the bulb using this?
How u make conectivity between PC and bulb?
Can u plz tell me or send me the code.
Thanx
Ali
This maybe something i missed out earlier in the topic list. I'm using a simple usb interface board to prototype with. It allows the control of digital and analogue inputs and outputs. Basically i'm using the analogue outputs to provide the communication with my dimmers. The dimmers use a 0-10v system, 0v = no output, 5V = half output, and 10v = full (approx), or anything in between. The dimmers are then connected to incandescent lighting. The interface board allows control through visual basic coding using DLL(s) (Dynamic Link Library(s)) to control the inputs/outputs. I have used large chunks of the code "Killer42" posted (for which i am extremely gratefull) to create a working prototype.
Thankyou for everybody who has helped to provide answers to my on going 'headache'.
If anybody has any questions about my project so far, i will be more than willing to try and help and to explain it.
Thanks,
Adam
Hm, sounds like a lot of fun. I might have a look at some interface stuff like that some day.
Anyway, when I'm reading about all your awards in a couple of years, I hope I'll have a footnote somewhere. :)
P.S. My people will be in touch to discuss royalties, soon afterward. :D
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tech |
last post by:
In Visual Basic 6.0, the Locked property of a ComboBox control determined
whether the text-box portion of the control could be edited. In Visual Basic
..NET, the Locked property prevents a control...
|
by: Rob R. Ainscough |
last post by:
MS Visual Studio Ad contained in VS Magazine.
Two developers in "hip" clothing diagramming out a huge flow chart on a
beach.
I could NOT stop laughing at the stupidity of the ad -- "Let your...
|
by: typingcat |
last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so
on. I've tried many PHP IDEs today, but almost non of them supported
Unicode (UTF-8) file.
I've found that the only Unicode...
|
by: pmud |
last post by:
Hi,
I need to use an Excel Sheet in ASP.NET application so that the users can
enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever
the USER ENETRS needs to go to the...
|
by: ME |
last post by:
I can't seem to delete records using an objectdatasource. The object is a
Typed Collection built by Visual Studio that access a SQL Database. When I
try to delete using the ObjectDataSource it...
|
by: MikeB |
last post by:
I've been all over the net with this question, I hope I've finally
found a group where I can ask about Visual Basic 2005.
I'm at uni and we're working with Visual Basic 2005. I have some books,
...
|
by: vidhyaprem |
last post by:
i have started a small project in visual basic regarding the stock details in our textile company.It has details like product id,product name,no of items,product picture etc.. so i have created a...
|
by: Hexman |
last post by:
Hello All,
I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm
using some VB6 code, .Net2003 code,...
|
by: Nathan Sokalski |
last post by:
I am attempting to create icons for controls I have created using VB.NET by
using the System.Drawing.ToolboxBitmap attribute. I have managed to do this
in C# by specifying the path to the *.ico...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |