led-blinker subproject

Started by Stephane Fonteyne, January 14, 2010, 07:37:22 AM

Previous topic - Next topic

Stephane Fonteyne

hi everyone,

we often program basic and we want to convert all kind off vb6 projects to powerBasic pbwin9.

problem one:

We know every concept about firefly sdk designer such as handles,id's ,...
but we have difficulty's with combining messages to diverse controls
for example:
pushing the button "start" sets a timer on and a scrollbar moves synchronous with the timer. It also changes a variable in an other window.
what we wanted too ask is to post a couple examples of standard-Windows controls which we can use for our project ( education use )

We hope to get a favorable answer to our question

greetings

Stefaan 
Stephane Fonteyne
Ba. Elektronica - ICT
GSM : +32-xxxxxxxxxx
PowerBasic Developer & Hardware Support

Paul Squires

Post the code that you have written already and "we" can offer advice. You have been around PowerBASIC for almost 10 years now... you should be grasping these basic programming concepts by now.

Quote
pushing the button "start" sets a timer on and a scrollbar moves synchronous with the timer. It also changes a variable in an other window.
(1) Pushing the "start" button start.... Respond to the BN_CLICKED message for the specific Command Button.

(2) Starts a timer.... Use the built in FireFly timer control with a global flag to start/stop the timer, or create a timer yourself with the SetTimer api.

(3) scrollbar moves synchronous with the timer... Depends on how you have created the "scrollbar". Is it a standalone HScroll or VScroll control, or is it a scrollbar that is part of another control, like a ListBox.

(4) It also changes a variable in an other window... FF_Control_SetText maybe? Depends on what that other "window" is.



Paul Squires
PlanetSquires Software

Stephane Fonteyne

Hi Paul Squires and everyone,

(2) Starts a timer : I use the build in FF timer control. I don't understand what you main with a global flag to start or stop the timer. Can you explain how you do that.

I have create a timer with the SetTimer API function.

(3) Its an standalone HScroll control, it's not a part of another control.
     Can you explain what you meant "moves synchronous with the timer"

(4) How can I moved the scrollbar but it can't moved but jumps back in
     te beginning

As promised I send my complete worked example. The example can be compiled and executed.

The program is not working properly because I can not move the scrollbar, it remains in its current state or jumps back

Can you look at my program, working with timers

Thank you very much for this

I want FireFly SDK Designer very efficiently used for larger projects

With kind regards
Stephane


I send in attachment my source code en exe file
Stephane Fonteyne
Ba. Elektronica - ICT
GSM : +32-xxxxxxxxxx
PowerBasic Developer & Hardware Support

Paul Squires

I don't really understand what it is you are trying to do, but I modified your program to start and stop the timer by simply setting a global variable (fStopTimer). When the timer fires, I get the value of the scrollbar position, increment it by one, and then set that value to the scroll bar. Therefore, every time the timer fires the scroll increments by one.
Paul Squires
PlanetSquires Software

Rolf Brandt

I think Stephane has connected some hardware which he is controlling by the program via the comport.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Stephane Fonteyne

That's right Rolf
Can you please help me with my problem?
Stephane Fonteyne
Ba. Elektronica - ICT
GSM : +32-xxxxxxxxxx
PowerBasic Developer & Hardware Support

Roger Garstang

All you need to do is change one line in WM_TIMER of this to the code needed to flip your com port LED and delete the sample LED Radio Button. You mess with anything else and make it not work and you are on your own.  If you can't get the COM port to work then you need to tell your "teacher" and make him earn his money since he hasn't for the last 10 years.

Paul,
If App.Comment lines are too long it doesn't wrap correctly at times and gives a compile error in main. What is the max length there anyway? The rc file doesn't seem to care, but bas file does.

Douglas McDonald

#7
To blink an LED from a com port you have to send a serial byte to a logic IC HCT74xxx series IC some have rs232 in's or you need another ic to do that part. One bit of that(0-7) will be High +5VDC or low 0 VDC. place a resistor 290 ohm from the pin(BIT OUT) to the anode and take the cathode to ground. That makes a circuit. There are many many many ways and components that can do this. you can event use a micro controller.

better yet see : http://www.lvr.com/serport.htm for the serial complete book

You can not. CAN NOT just send a value to a com port and blink a LED. The 12VCD (TTL) that you would see is there only a few nano seconds, not enough to see an led blink.

To answer your other question about Tones please see your other post. Its simple to make a tone and I posted sample code. so why ask for more sample code?

Am I missing something here?? Whats he asking?
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

Robert Eaton

Quote from: Douglas McDonald on January 21, 2010, 10:13:53 PM

You can not. CAN NOT just send a value to a com port and blink a LED. The 12VCD (TTL) that you would see is there only a few nano seconds, not enough to see an led blink.

You don't need to send any data to turn an led on and off from the com port. You can simply use the DTR, RTS, or the Transmit pins and you can toggle these high or low as needed. I use this technique to control production test fixtures. You should be able to drive an LED directly (with a current limiting resistor) but it's best to buffer the com port to prevent damage. I just use a transistor and a couple of resistors (such as a 2N3904).

Roger Garstang

Wow, been forever since I've heard Electronics talk.  I had two years of Electronics at the Tech School.  Wish I would have had someone like you guys to confirm resistors with LEDs when I bought my PC case about 5 years ago.  Front has these Bubble Bars with High Voltage LEDs that change colors just wired in series with no resistance that get too hot and keep burning up.  Idiot at the PC shop kept telling me you don't need resistors with LEDs.  I told him about 10 fizzled LEDs in the trash because I forgot resistors in Tech School would disagree with him.  Those little things go quick too...fizzle and a couple blinks if you are lucky. Since he may not know anode and cathode...one side of the LED is flat where other side is round, flat side is negative/ground.

Anyone else miss when Radio Shack sold more than Cell Phones?  I used to go in and buy individual parts, and now you buy 3 packs of limited supply resistors, etc at 10x the price stuff used to be.

Robert Eaton

I hear you Roger ;D

You know the old saying... All of these electronic parts actually work by means of "magic smoke". If you "let out the magic smoke" they stop working ;)




Douglas McDonald

Robert,
Of course your correct, I wasn't thinking of it that way using DTR,RTS I stand corrected.
In his code he was not controlling the RTS,DTR lines. He wasn't even using the serial port although thats what the post states.

he's tring to use direct writes to a port using
Declare Function Inp32 StdCall Lib "Inpout32.dll" Alias "Inp32"(PortAddress As Long) As Word
Declare Sub Out32 StdCall Lib "Inpout32.dll" Alias "Out32"(PortAddress As Long, byteData As Long)



What it looks like he's trying to do is create a tone using the pc speaker at port 0x61. What this has to do with an LED I have no idea.

From Inpout32.dll

QuoteThe DLL Inpout32

The functions in the DLL are implemented in two source files, "inpout32drv.cpp" and "osversion.cpp". osversion.cpp checks the version of operating system. "inpout32drv.cpp" does installing the kernel mode driver, loading it , writing/ reading parallel port etc... The two functions exported from inpout32.dll are

1) Inp32(), reads data from a specified parallel port register.

2) Out32(), writes data to specified parallel port register.

the other functions implemented in Inpout32.dll are

1) DllMain(), called when dll is loaded or unloaded. When the dll is loaded , it checks the OS version and loads hwinterface.sys if needed.

2) Closedriver(), close the opened driver handle. called before unloading the driver.

3) Opendriver(), open a handle to hwinterface driver.

4) inst() , Extract 'hwinterface.sys' from binary resource to 'systemroot\drivers' directory and creates a service. This function is called when 'Opendriver' function fails to open a valid handle to 'hwinterface' service.

5) start() , starts the hwinterface service using Service Control Manager APIs.

6) SystemVersion() Checks the OS version and returns appropriate code.

This states its for the Parallel port which is not &h61 at least the data I have port 0x61 is the speaker. Maybe he's just sending 0x61 to the Parallel port to set bits 0,5,6 and turn on led's

I still can't figure out what he's really looking for but I'm starting to grasp it

Doug
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?